QTfrontend/pages.cpp
changeset 646 ed610c2cd0a4
parent 638 e1cc516488f2
child 647 798c7dbf8bb8
equal deleted inserted replaced
645:c71fe8b942ee 646:ed610c2cd0a4
   451 
   451 
   452 	ConnGroupBox = new QGroupBox(this);
   452 	ConnGroupBox = new QGroupBox(this);
   453 	ConnGroupBox->setTitle(QGroupBox::tr("Net game"));
   453 	ConnGroupBox->setTitle(QGroupBox::tr("Net game"));
   454 	pageLayout->addWidget(ConnGroupBox, 2, 0, 1, 3);
   454 	pageLayout->addWidget(ConnGroupBox, 2, 0, 1, 3);
   455 	GBClayout = new QGridLayout(ConnGroupBox);
   455 	GBClayout = new QGridLayout(ConnGroupBox);
   456 	GBClayout->setColumnStretch(0, 0);
   456 	GBClayout->setColumnStretch(0, 1);
   457 	GBClayout->setColumnStretch(1, 1);
   457 	GBClayout->setColumnStretch(1, 1);
   458 	GBClayout->setColumnStretch(2, 1);
   458 	GBClayout->setColumnStretch(2, 1);
   459 	GBClayout->setRowStretch(0, 0);
       
   460 	GBClayout->setRowStretch(1, 0);
       
   461 	GBClayout->setRowStretch(2, 1);
       
   462 
       
   463 	labelIP = new QLabel(ConnGroupBox);
       
   464 	labelIP->setText(QLabel::tr("Server address"));
       
   465 	GBClayout->addWidget(labelIP, 0, 0);
       
   466 
       
   467 	editIP = new QLineEdit(ConnGroupBox);
       
   468 	editIP->setMaxLength(50);
       
   469 	GBClayout->addWidget(editIP, 0, 1);
       
   470 
   459 
   471 	BtnNetConnect = new QPushButton(ConnGroupBox);
   460 	BtnNetConnect = new QPushButton(ConnGroupBox);
   472 	BtnNetConnect->setFont(*font14);
   461 	BtnNetConnect->setFont(*font14);
   473 	BtnNetConnect->setText(QPushButton::tr("Connect"));
   462 	BtnNetConnect->setText(QPushButton::tr("Connect"));
   474 	GBClayout->addWidget(BtnNetConnect, 0, 2);
   463 	GBClayout->addWidget(BtnNetConnect, 2, 2);
   475 
   464 
   476 	netServersWidget = 0;
   465 	netServersWidget = 0;
   477 
   466 
   478 	BtnUpdateSList = new QPushButton(ConnGroupBox);
   467 	BtnUpdateSList = new QPushButton(ConnGroupBox);
   479 	BtnUpdateSList->setFont(*font14);
   468 	BtnUpdateSList->setFont(*font14);
   480 	BtnUpdateSList->setText(QPushButton::tr("Update"));
   469 	BtnUpdateSList->setText(QPushButton::tr("Update"));
   481 	GBClayout->addWidget(BtnUpdateSList, 1, 2);
   470 	GBClayout->addWidget(BtnUpdateSList, 2, 0);
   482 
   471 
   483 	BtnBack = new QPushButton(this);
   472 	BtnBack = new QPushButton(this);
   484 	BtnBack->setFont(*font14);
   473 	BtnBack->setFont(*font14);
   485 	BtnBack->setText(QPushButton::tr("Back"));
   474 	BtnBack->setText(QPushButton::tr("Back"));
   486 	pageLayout->addWidget(BtnBack, 3, 0);
   475 	pageLayout->addWidget(BtnBack, 3, 0);
   487 
   476 
   488 	connect(rbLocalGame, SIGNAL(toggled(bool)), this, SLOT(changeServersList()));
   477 	connect(rbLocalGame, SIGNAL(toggled(bool)), this, SLOT(updateServersList()));
   489 }
   478 }
   490 
   479 
   491 void PageNet::changeServersList()
   480 void PageNet::updateServersList()
   492 {
   481 {
   493 	if (netServersWidget) delete netServersWidget;
   482 	if (netServersWidget) delete netServersWidget;
   494 
   483 
   495 	if (rbLocalGame->isChecked())
   484 	if (rbLocalGame->isChecked())
   496 	{
   485 	{
   500 	else
   489 	else
   501 	{
   490 	{
   502 		netServersWidget = new HWNetWwwWidget(ConnGroupBox);
   491 		netServersWidget = new HWNetWwwWidget(ConnGroupBox);
   503 		static_cast<HWNetWwwWidget *>(netServersWidget)->updateList();
   492 		static_cast<HWNetWwwWidget *>(netServersWidget)->updateList();
   504 	}
   493 	}
   505 	GBClayout->addWidget(netServersWidget, 1, 0, 2, 2);
   494 	GBClayout->addWidget(netServersWidget, 1, 0, 1, 3);
   506 
   495 
   507 	connect(BtnUpdateSList, SIGNAL(clicked()), netServersWidget, SLOT(updateList()));
   496 	connect(BtnUpdateSList, SIGNAL(clicked()), netServersWidget, SLOT(updateList()));
       
   497 	connect(netServersWidget->serversList, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(slotConnect()));
       
   498 }
       
   499 
       
   500 void PageNet::slotConnect()
       
   501 {
       
   502 	emit connectClicked();
       
   503 }
       
   504 
       
   505 PageNetServer::PageNetServer(QWidget* parent) : QWidget(parent)
       
   506 {
       
   507 	QFont * font14 = new QFont("MS Shell Dlg", 14);
       
   508 	QGridLayout * pageLayout = new QGridLayout(this);
       
   509 	pageLayout->setColumnStretch(0, 1);
       
   510 	pageLayout->setColumnStretch(1, 1);
       
   511 	pageLayout->setColumnStretch(2, 1);
       
   512 
       
   513 	BtnBack = new QPushButton(this);
       
   514 	BtnBack->setFont(*font14);
       
   515 	BtnBack->setText(QPushButton::tr("Back"));
       
   516 	pageLayout->addWidget(BtnBack, 2, 0);
       
   517 
       
   518 	BtnStart = new QPushButton(this);
       
   519 	BtnStart->setFont(*font14);
       
   520 	BtnStart->setText(QPushButton::tr("Start"));
       
   521 	pageLayout->addWidget(BtnStart, 2, 2);
   508 }
   522 }
   509 
   523 
   510 PageNetGame::PageNetGame(QWidget* parent) : QWidget(parent)
   524 PageNetGame::PageNetGame(QWidget* parent) : QWidget(parent)
   511 {
   525 {
   512 	QFont * font14 = new QFont("MS Shell Dlg", 14);
   526 	QFont * font14 = new QFont("MS Shell Dlg", 14);
   532 	BtnBack = new QPushButton(this);
   546 	BtnBack = new QPushButton(this);
   533 	BtnBack->setFont(*font14);
   547 	BtnBack->setFont(*font14);
   534 	BtnBack->setText(QPushButton::tr("Back"));
   548 	BtnBack->setText(QPushButton::tr("Back"));
   535 	pageLayout->addWidget(BtnBack, 2, 0);
   549 	pageLayout->addWidget(BtnBack, 2, 0);
   536 
   550 
   537 	BtnGo	= new QPushButton(this);
   551 	BtnGo = new QPushButton(this);
   538 	BtnGo->setFont(*font14);
   552 	BtnGo->setFont(*font14);
   539 	BtnGo->setText(QPushButton::tr("Go!"));
   553 	BtnGo->setText(QPushButton::tr("Go!"));
   540 	BtnGo->setEnabled(false);
   554 	BtnGo->setEnabled(false);
   541 	pageLayout->addWidget(BtnGo, 2, 1);
   555 	pageLayout->addWidget(BtnGo, 2, 1);
   542 }
   556 }