display player count below and with label, just because it's funny to mess with unC0Rr's code and make him cry :P
authorsheepluva
Mon, 20 Jun 2011 01:28:21 +0200
changeset 5263 4c8b677503e2
parent 5262 505a90cfa377
child 5264 5e6f5373f686
display player count below and with label, just because it's funny to mess with unC0Rr's code and make him cry :P
QTfrontend/chatwidget.cpp
QTfrontend/chatwidget.h
QTfrontend/pageroomslist.cpp
QTfrontend/pageroomslist.h
--- a/QTfrontend/chatwidget.cpp	Sun Jun 19 21:03:16 2011 -0400
+++ b/QTfrontend/chatwidget.cpp	Mon Jun 20 01:28:21 2011 +0200
@@ -30,7 +30,6 @@
 #include <QCursor>
 #include <QScrollBar>
 #include <QItemSelectionModel>
-#include <QLabel>
 
 #include "hwconsts.h"
 #include "SDLs.h"
@@ -164,12 +163,7 @@
     connect(chatNicks, SIGNAL(currentRowChanged(int)),
         this, SLOT(chatNickSelected(int)));
 
-    mainLayout.addWidget(chatNicks, 1, 1, 2, 1);
-
-    lblCount = new QLabel(this);
-    mainLayout.addWidget(lblCount, 0, 1);
-    lblCount->setText("0");
-    lblCount->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
+    mainLayout.addWidget(chatNicks, 0, 1, 3, 1);
 
     acInfo = new QAction(QAction::tr("Info"), chatNicks);
     acInfo->setIcon(QIcon(":/res/info.png"));
@@ -397,7 +391,7 @@
     updateNickItem(item);
     chatNicks->addItem(item);
 
-    lblCount->setText(QString::number(chatNicks->count()));
+    emit nickCountUpdate(chatNicks->count());
 
     if(notifyNick && notify && gameSettings->value("frontend/sound", true).toBool()) {
        Mix_PlayChannel(-1, sound[rand()%4], 0);
@@ -410,7 +404,7 @@
     QListIterator<QListWidgetItem *> it(items);
     while(it.hasNext()) chatNicks->takeItem(chatNicks->row(it.next()));
 
-    lblCount->setText(QString::number(chatNicks->count()));
+    emit nickCountUpdate(chatNicks->count());
 }
 
 void HWChatWidget::clear()
--- a/QTfrontend/chatwidget.h	Sun Jun 19 21:03:16 2011 -0400
+++ b/QTfrontend/chatwidget.h	Mon Jun 20 01:28:21 2011 +0200
@@ -34,7 +34,6 @@
 class QListWidget;
 class QSettings;
 class SDLInteraction;
-class QLabel;
 
 // this class is for custom nick sorting
 class ListWidgetNickItem : public QListWidgetItem
@@ -88,6 +87,7 @@
   void ban(const QString & str);
   void info(const QString & str);
   void follow(const QString &);
+  void nickCountUpdate(int cnt);
 
  private:
   QGridLayout mainLayout;
@@ -102,7 +102,6 @@
   QAction * acIgnore;
   QAction * acFriend;
   QSettings * gameSettings;
-  QLabel * lblCount;
   SDLInteraction * sdli;
   Mix_Chunk *sound[4];
   bool notify;
--- a/QTfrontend/pageroomslist.cpp	Sun Jun 19 21:03:16 2011 -0400
+++ b/QTfrontend/pageroomslist.cpp	Mon Jun 20 01:28:21 2011 +0200
@@ -42,7 +42,7 @@
     roomName->setMaxLength(60);
     newRoomLayout->addWidget(roomNameLabel);
     newRoomLayout->addWidget(roomName);
-    pageLayout->addLayout(newRoomLayout, 0, 0);
+    pageLayout->addLayout(newRoomLayout, 0, 0, 1, 2);
 
     roomsList = new QTableWidget(this);
     roomsList->setSelectionBehavior(QAbstractItemView::SelectRows);
@@ -51,7 +51,7 @@
     roomsList->setAlternatingRowColors(true);
     roomsList->setShowGrid(false);
     roomsList->setSelectionMode(QAbstractItemView::SingleSelection);
-    pageLayout->addWidget(roomsList, 1, 0, 3, 1);
+    pageLayout->addWidget(roomsList, 1, 0, 3, 2);
     pageLayout->setRowStretch(2, 100);
     
     QHBoxLayout * filterLayout = new QHBoxLayout();
@@ -97,19 +97,27 @@
     filterLayout->addWidget(searchLabel);
     filterLayout->addWidget(searchText);
 
-    pageLayout->addLayout(filterLayout, 4, 0);
+    pageLayout->addLayout(filterLayout, 4, 0, 1, 2);
 
     chatWidget = new HWChatWidget(this, gameSettings, sdli, false);
-    pageLayout->addWidget(chatWidget, 5, 0, 1, 2);
+    pageLayout->addWidget(chatWidget, 5, 0, 1, 3);
     pageLayout->setRowStretch(5, 350);
 
-    BtnCreate = addButton(tr("Create"), pageLayout, 0, 1);
-    BtnJoin = addButton(tr("Join"), pageLayout, 1, 1);
-    BtnRefresh = addButton(tr("Refresh"), pageLayout, 3, 1);
-    BtnClear = addButton(tr("Clear"), pageLayout, 4, 1);
+    BtnCreate = addButton(tr("Create"), pageLayout, 0, 2);
+    BtnJoin = addButton(tr("Join"), pageLayout, 1, 2);
+    BtnRefresh = addButton(tr("Refresh"), pageLayout, 3, 2);
+    BtnClear = addButton(tr("Clear"), pageLayout, 4, 2);
 
     BtnBack = addButton(":/res/Exit.png", pageLayout, 6, 0, true);
-    BtnAdmin = addButton(tr("Admin features"), pageLayout, 6, 1);
+
+    lblCount = new QLabel(this);
+    pageLayout->addWidget(lblCount, 6, 1, Qt::AlignHCenter);
+    lblCount->setText("?");
+    lblCount->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
+
+    connect(chatWidget, SIGNAL(nickCountUpdate(const int)), this, SLOT(updateNickCounter(const int)));
+
+    BtnAdmin = addButton(tr("Admin features"), pageLayout, 6, 2);
 
     connect(BtnCreate, SIGNAL(clicked()), this, SLOT(onCreateClick()));
     connect(BtnJoin, SIGNAL(clicked()), this, SLOT(onJoinClick()));
@@ -380,3 +388,9 @@
         emit askForJoinRoom(room);
     }
 }
+
+void PageRoomsList::updateNickCounter(int cnt)
+{
+    lblCount->setText(tr("%1 players online").arg(cnt));
+}
+
--- a/QTfrontend/pageroomslist.h	Sun Jun 19 21:03:16 2011 -0400
+++ b/QTfrontend/pageroomslist.h	Mon Jun 20 01:28:21 2011 +0200
@@ -45,6 +45,7 @@
     QComboBox * CBRules;
     QComboBox * CBWeapons;
     HWChatWidget * chatWidget;
+    QLabel * lblCount;
 
 private:
     bool gameInLobby;
@@ -55,6 +56,7 @@
 public slots:
     void setRoomsList(const QStringList & list);
     void setAdmin(bool);
+    void updateNickCounter(int cnt);
 
 private slots:
     void onCreateClick();