Frontend: room rename
authorclaymore
Fri, 08 Apr 2011 18:50:12 +0200
changeset 5126 50803f3403a5
parent 5125 715cf3f2b342
child 5127 b0b6f17a6a3c
Frontend: room rename
QTfrontend/hwform.cpp
QTfrontend/newnetclient.cpp
QTfrontend/newnetclient.h
QTfrontend/pagenetgame.cpp
QTfrontend/pages.h
--- a/QTfrontend/hwform.cpp	Fri Apr 08 13:42:25 2011 +0200
+++ b/QTfrontend/hwform.cpp	Fri Apr 08 18:50:12 2011 +0200
@@ -1116,9 +1116,13 @@
     {
         // disconnect connections first to ensure their inexistance and not to connect twice
         ui.pageNetGame->BtnStart->disconnect(hwnet);
+        ui.pageNetGame->BtnUpdate->disconnect(hwnet);
+        ui.pageNetGame->leRoomName->setText(hwnet->getRoom());
         ui.pageNetGame->restrictJoins->disconnect(hwnet);
         ui.pageNetGame->restrictTeamAdds->disconnect(hwnet);
         connect(ui.pageNetGame->BtnStart, SIGNAL(clicked()), hwnet, SLOT(startGame()));
+        connect(ui.pageNetGame, SIGNAL(askForUpdateRoomName(const QString &)),
+            hwnet, SLOT(updateRoomName(const QString &)));
         connect(ui.pageNetGame->restrictJoins, SIGNAL(triggered()), hwnet, SLOT(toggleRestrictJoins()));
         connect(ui.pageNetGame->restrictTeamAdds, SIGNAL(triggered()), hwnet, SLOT(toggleRestrictTeamAdds()));
         connect(ui.pageNetGame->pGameCFG->GameSchemes->model(),
--- a/QTfrontend/newnetclient.cpp	Fri Apr 08 13:42:25 2011 +0200
+++ b/QTfrontend/newnetclient.cpp	Fri Apr 08 18:50:12 2011 +0200
@@ -747,6 +747,12 @@
     RawSendNet(QString("START_GAME"));
 }
 
+void HWNewNet::updateRoomName(const QString & name)
+{
+    RawSendNet(QString("ROOM_NAME%1%2").arg(delimeter).arg(name));
+}
+
+
 void HWNewNet::toggleRestrictJoins()
 {
     RawSendNet(QString("TOGGLE_RESTRICT_JOINS"));
--- a/QTfrontend/newnetclient.h	Fri Apr 08 13:42:25 2011 +0200
+++ b/QTfrontend/newnetclient.h	Fri Apr 08 18:50:12 2011 +0200
@@ -148,6 +148,7 @@
 
   void JoinRoom(const QString & room);
   void CreateRoom(const QString & room);
+  void updateRoomName(const QString &);
   void askRoomsList();
   void gameFinished(bool correcly);
   void banPlayer(const QString &);
--- a/QTfrontend/pagenetgame.cpp	Fri Apr 08 13:42:25 2011 +0200
+++ b/QTfrontend/pagenetgame.cpp	Fri Apr 08 18:50:12 2011 +0200
@@ -20,6 +20,7 @@
 #include <QPushButton>
 #include <QAction>
 #include <QMenu>
+#include <QMessageBox>
 
 #include "pages.h"
 #include "gamecfgwidget.h"
@@ -59,6 +60,13 @@
 
     BtnBack = addButton(":/res/Exit.png", bottomLayout, 0, true);
 
+    leRoomName = new QLineEdit(this);
+    leRoomName->setMaxLength(60);
+    leRoomName->setMinimumWidth(200);
+    leRoomName->setMaximumWidth(400);
+    bottomLayout->addWidget(leRoomName, 8,0);
+    BtnUpdate = addButton(QAction::tr("Update"), bottomLayout, 1, false);
+
     BtnGo = new QPushButton(this);
     BtnGo->setToolTip(QPushButton::tr("Ready"));
     BtnGo->setIcon(QIcon(":/res/lightbulb_off.png"));
@@ -82,7 +90,9 @@
 
     BtnStart = addButton(QAction::tr("Start"), bottomLayout, 3);
 
-    bottomLayout->insertStretch(1, 100);
+    bottomLayout->insertStretch(3, 100);
+
+    connect(BtnUpdate, SIGNAL(clicked()), this, SLOT(onUpdateClick()));
 }
 
 void PageNetGame::setReadyStatus(bool isReady)
@@ -93,8 +103,21 @@
         BtnGo->setIcon(QIcon(":/res/lightbulb_off.png"));
 }
 
+void PageNetGame::onUpdateClick()
+{
+    if (leRoomName->text().size())
+        emit askForUpdateRoomName(leRoomName->text());
+    else
+        QMessageBox::critical(this,
+                tr("Error"),
+                tr("Please enter room name"),
+                tr("OK"));
+}
+
 void PageNetGame::setMasterMode(bool isMaster)
 {
     BtnMaster->setVisible(isMaster);
     BtnStart->setVisible(isMaster);
+    BtnUpdate->setVisible(isMaster);
+    leRoomName->setVisible(isMaster);
 }
--- a/QTfrontend/pages.h	Fri Apr 08 13:42:25 2011 +0200
+++ b/QTfrontend/pages.h	Fri Apr 08 18:50:12 2011 +0200
@@ -325,6 +325,9 @@
     QPushButton *BtnGo;
     QPushButton *BtnMaster;
     QPushButton *BtnStart;
+    QPushButton *BtnUpdate;
+
+    QLineEdit * leRoomName;
 
     QAction * restrictJoins;
     QAction * restrictTeamAdds;
@@ -336,10 +339,12 @@
 
 public slots:
     void setReadyStatus(bool isReady);
+    void onUpdateClick();
     void setMasterMode(bool isMaster);
 
 signals:
     void SetupClicked();
+    void askForUpdateRoomName(const QString &);
 };
 
 class PageInfo : public AbstractPage