QTfrontend/pagenetgame.cpp
changeset 5126 50803f3403a5
parent 5078 3527f0e7bb21
child 5204 e1a5f4d5d86a
equal deleted inserted replaced
5125:715cf3f2b342 5126:50803f3403a5
    18 
    18 
    19 #include <QGridLayout>
    19 #include <QGridLayout>
    20 #include <QPushButton>
    20 #include <QPushButton>
    21 #include <QAction>
    21 #include <QAction>
    22 #include <QMenu>
    22 #include <QMenu>
       
    23 #include <QMessageBox>
    23 
    24 
    24 #include "pages.h"
    25 #include "pages.h"
    25 #include "gamecfgwidget.h"
    26 #include "gamecfgwidget.h"
    26 #include "teamselect.h"
    27 #include "teamselect.h"
    27 #include "chatwidget.h"
    28 #include "chatwidget.h"
    57     QHBoxLayout * bottomLayout = new QHBoxLayout;
    58     QHBoxLayout * bottomLayout = new QHBoxLayout;
    58     pageLayout->addLayout(bottomLayout, 4, 0, 1, 2);
    59     pageLayout->addLayout(bottomLayout, 4, 0, 1, 2);
    59 
    60 
    60     BtnBack = addButton(":/res/Exit.png", bottomLayout, 0, true);
    61     BtnBack = addButton(":/res/Exit.png", bottomLayout, 0, true);
    61 
    62 
       
    63     leRoomName = new QLineEdit(this);
       
    64     leRoomName->setMaxLength(60);
       
    65     leRoomName->setMinimumWidth(200);
       
    66     leRoomName->setMaximumWidth(400);
       
    67     bottomLayout->addWidget(leRoomName, 8,0);
       
    68     BtnUpdate = addButton(QAction::tr("Update"), bottomLayout, 1, false);
       
    69 
    62     BtnGo = new QPushButton(this);
    70     BtnGo = new QPushButton(this);
    63     BtnGo->setToolTip(QPushButton::tr("Ready"));
    71     BtnGo->setToolTip(QPushButton::tr("Ready"));
    64     BtnGo->setIcon(QIcon(":/res/lightbulb_off.png"));
    72     BtnGo->setIcon(QIcon(":/res/lightbulb_off.png"));
    65     BtnGo->setIconSize(QSize(25, 34));
    73     BtnGo->setIconSize(QSize(25, 34));
    66     BtnGo->setMinimumWidth(50);
    74     BtnGo->setMinimumWidth(50);
    80 
    88 
    81     BtnMaster->setMenu(menu);
    89     BtnMaster->setMenu(menu);
    82 
    90 
    83     BtnStart = addButton(QAction::tr("Start"), bottomLayout, 3);
    91     BtnStart = addButton(QAction::tr("Start"), bottomLayout, 3);
    84 
    92 
    85     bottomLayout->insertStretch(1, 100);
    93     bottomLayout->insertStretch(3, 100);
       
    94 
       
    95     connect(BtnUpdate, SIGNAL(clicked()), this, SLOT(onUpdateClick()));
    86 }
    96 }
    87 
    97 
    88 void PageNetGame::setReadyStatus(bool isReady)
    98 void PageNetGame::setReadyStatus(bool isReady)
    89 {
    99 {
    90     if(isReady)
   100     if(isReady)
    91         BtnGo->setIcon(QIcon(":/res/lightbulb_on.png"));
   101         BtnGo->setIcon(QIcon(":/res/lightbulb_on.png"));
    92     else
   102     else
    93         BtnGo->setIcon(QIcon(":/res/lightbulb_off.png"));
   103         BtnGo->setIcon(QIcon(":/res/lightbulb_off.png"));
    94 }
   104 }
    95 
   105 
       
   106 void PageNetGame::onUpdateClick()
       
   107 {
       
   108     if (leRoomName->text().size())
       
   109         emit askForUpdateRoomName(leRoomName->text());
       
   110     else
       
   111         QMessageBox::critical(this,
       
   112                 tr("Error"),
       
   113                 tr("Please enter room name"),
       
   114                 tr("OK"));
       
   115 }
       
   116 
    96 void PageNetGame::setMasterMode(bool isMaster)
   117 void PageNetGame::setMasterMode(bool isMaster)
    97 {
   118 {
    98     BtnMaster->setVisible(isMaster);
   119     BtnMaster->setVisible(isMaster);
    99     BtnStart->setVisible(isMaster);
   120     BtnStart->setVisible(isMaster);
       
   121     BtnUpdate->setVisible(isMaster);
       
   122     leRoomName->setVisible(isMaster);
   100 }
   123 }