# HG changeset patch # User sheepluva # Date 1308526101 -7200 # Node ID 4c8b677503e262b06fdfc5e7d389430d115a6837 # Parent 505a90cfa3774250e0426abbaeb00ed144a48b2d display player count below and with label, just because it's funny to mess with unC0Rr's code and make him cry :P diff -r 505a90cfa377 -r 4c8b677503e2 QTfrontend/chatwidget.cpp --- 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 #include #include -#include #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 it(items); while(it.hasNext()) chatNicks->takeItem(chatNicks->row(it.next())); - lblCount->setText(QString::number(chatNicks->count())); + emit nickCountUpdate(chatNicks->count()); } void HWChatWidget::clear() diff -r 505a90cfa377 -r 4c8b677503e2 QTfrontend/chatwidget.h --- 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; diff -r 505a90cfa377 -r 4c8b677503e2 QTfrontend/pageroomslist.cpp --- 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)); +} + diff -r 505a90cfa377 -r 4c8b677503e2 QTfrontend/pageroomslist.h --- 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();