Some work on network widgets
authorunc0rr
Thu, 13 Dec 2007 12:39:26 +0000
changeset 646 ed610c2cd0a4
parent 645 c71fe8b942ee
child 647 798c7dbf8bb8
Some work on network widgets
QTfrontend/gameuiconfig.cpp
QTfrontend/hwform.cpp
QTfrontend/hwform.h
QTfrontend/pages.cpp
QTfrontend/pages.h
QTfrontend/ui_hwform.cpp
QTfrontend/ui_hwform.h
--- a/QTfrontend/gameuiconfig.cpp	Wed Dec 12 19:49:13 2007 +0000
+++ b/QTfrontend/gameuiconfig.cpp	Thu Dec 13 12:39:26 2007 +0000
@@ -39,7 +39,7 @@
 	Form->ui.pageOptions->CBEnableSound->setChecked(value("audio/sound", true).toBool());
 
 	Form->ui.pageNet->editNetNick->setText(value("net/nick", QLineEdit::tr("unnamed")).toString());
-	Form->ui.pageNet->editIP->setText(value("net/ip", "").toString());
+//	Form->ui.pageNet->editIP->setText(value("net/ip", "").toString());
 
 	Form->ui.pageOptions->CBShowFPS->setChecked(value("fps/show", false).toBool());
 	Form->ui.pageOptions->fpsedit->setValue(value("fps/interval", 27).toUInt());
@@ -71,7 +71,7 @@
 	setValue("audio/sound", isSoundEnabled());
 
 	setValue("net/nick", Form->ui.pageNet->editNetNick->text());
-	setValue("net/ip", Form->ui.pageNet->editIP->text());
+//	setValue("net/ip", Form->ui.pageNet->editIP->text());
 
 	setValue("fps/show", isShowFPSEnabled());
 	setValue("fps/interval", Form->ui.pageOptions->fpsedit->value());
--- a/QTfrontend/hwform.cpp	Wed Dec 12 19:49:13 2007 +0000
+++ b/QTfrontend/hwform.cpp	Thu Dec 13 12:39:26 2007 +0000
@@ -90,7 +90,11 @@
 
 	connect(ui.pageNet->BtnBack,	SIGNAL(clicked()),	this, SLOT(GoBack()));
 	connect(ui.pageNet->BtnNetConnect,	SIGNAL(clicked()),	this, SLOT(NetConnect()));
-	connect(ui.pageNet->BtnNetSvrStart, SIGNAL(clicked()), this, SLOT(NetStartServer()));
+	connect(ui.pageNet->BtnNetSvrStart,	SIGNAL(clicked()),	this, SLOT(GoToNetServer()));
+	connect(ui.pageNet,	SIGNAL(connectClicked()),	this, SLOT(NetConnectServer()));
+	
+	connect(ui.pageNetServer->BtnBack,	SIGNAL(clicked()),	this, SLOT(GoBack()));
+	connect(ui.pageNetServer->BtnStart,	SIGNAL(clicked()),	this, SLOT(NetStartServer()));
 
 	connect(ui.pageNetGame->BtnBack,	SIGNAL(clicked()),	this, SLOT(GoBack()));
 	connect(ui.pageNetGame->BtnGo,	SIGNAL(clicked()),	this, SLOT(NetStartGame()));
@@ -189,12 +193,17 @@
 
 void HWForm::GoToNet()
 {
-	ui.pageNet->changeServersList();
+	ui.pageNet->updateServersList();
 	connect(ui.pageNet->netServersWidget->serversList,	SIGNAL(doubleClicked (const QModelIndex &)),	this, SLOT(NetConnectServer()));
 
 	GoToPage(ID_PAGE_NET);
 }
 
+void HWForm::GoToNetServer()
+{
+	GoToPage(ID_PAGE_NETSERVER);
+}
+
 void HWForm::OnPageShown(quint8 id, quint8 lastid)
 {
 	if (id == ID_PAGE_MULTIPLAYER || id == ID_PAGE_NETCFG) {
@@ -399,7 +408,7 @@
 
 void HWForm::NetConnect()
 {
-  _NetConnect(ui.pageNet->editIP->text(), 46631, ui.pageNet->editNetNick->text());
+// FIXME:  _NetConnect(ui.pageNet->editIP->text(), 46631, ui.pageNet->editNetNick->text());
 }
 
 void HWForm::NetStartServer()
--- a/QTfrontend/hwform.h	Wed Dec 12 19:49:13 2007 +0000
+++ b/QTfrontend/hwform.h	Thu Dec 13 12:39:26 2007 +0000
@@ -53,6 +53,7 @@
 	void GoToSimpleGame();
 	void GoToTraining();
 	void GoToSelectWeapon();
+	void GoToNetServer();
 	void GoToPage(quint8 id);
 	void GoBack();
 	void btnExitPressed();
@@ -97,7 +98,8 @@
 		ID_PAGE_GAMESTATS       =  9,
 		ID_PAGE_SINGLEPLAYER    = 10,
 		ID_PAGE_TRAINING        = 11,
-		ID_PAGE_SELECTWEAPON    = 12
+		ID_PAGE_SELECTWEAPON    = 12,
+		ID_PAGE_NETSERVER       = 13
 		};
 	HWGame * game;
 	HWTeam * editedTeam;
--- a/QTfrontend/pages.cpp	Wed Dec 12 19:49:13 2007 +0000
+++ b/QTfrontend/pages.cpp	Thu Dec 13 12:39:26 2007 +0000
@@ -453,42 +453,31 @@
 	ConnGroupBox->setTitle(QGroupBox::tr("Net game"));
 	pageLayout->addWidget(ConnGroupBox, 2, 0, 1, 3);
 	GBClayout = new QGridLayout(ConnGroupBox);
-	GBClayout->setColumnStretch(0, 0);
+	GBClayout->setColumnStretch(0, 1);
 	GBClayout->setColumnStretch(1, 1);
 	GBClayout->setColumnStretch(2, 1);
-	GBClayout->setRowStretch(0, 0);
-	GBClayout->setRowStretch(1, 0);
-	GBClayout->setRowStretch(2, 1);
-
-	labelIP = new QLabel(ConnGroupBox);
-	labelIP->setText(QLabel::tr("Server address"));
-	GBClayout->addWidget(labelIP, 0, 0);
-
-	editIP = new QLineEdit(ConnGroupBox);
-	editIP->setMaxLength(50);
-	GBClayout->addWidget(editIP, 0, 1);
 
 	BtnNetConnect = new QPushButton(ConnGroupBox);
 	BtnNetConnect->setFont(*font14);
 	BtnNetConnect->setText(QPushButton::tr("Connect"));
-	GBClayout->addWidget(BtnNetConnect, 0, 2);
+	GBClayout->addWidget(BtnNetConnect, 2, 2);
 
 	netServersWidget = 0;
 
 	BtnUpdateSList = new QPushButton(ConnGroupBox);
 	BtnUpdateSList->setFont(*font14);
 	BtnUpdateSList->setText(QPushButton::tr("Update"));
-	GBClayout->addWidget(BtnUpdateSList, 1, 2);
+	GBClayout->addWidget(BtnUpdateSList, 2, 0);
 
 	BtnBack = new QPushButton(this);
 	BtnBack->setFont(*font14);
 	BtnBack->setText(QPushButton::tr("Back"));
 	pageLayout->addWidget(BtnBack, 3, 0);
 
-	connect(rbLocalGame, SIGNAL(toggled(bool)), this, SLOT(changeServersList()));
+	connect(rbLocalGame, SIGNAL(toggled(bool)), this, SLOT(updateServersList()));
 }
 
-void PageNet::changeServersList()
+void PageNet::updateServersList()
 {
 	if (netServersWidget) delete netServersWidget;
 
@@ -502,9 +491,34 @@
 		netServersWidget = new HWNetWwwWidget(ConnGroupBox);
 		static_cast<HWNetWwwWidget *>(netServersWidget)->updateList();
 	}
-	GBClayout->addWidget(netServersWidget, 1, 0, 2, 2);
+	GBClayout->addWidget(netServersWidget, 1, 0, 1, 3);
 
 	connect(BtnUpdateSList, SIGNAL(clicked()), netServersWidget, SLOT(updateList()));
+	connect(netServersWidget->serversList, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(slotConnect()));
+}
+
+void PageNet::slotConnect()
+{
+	emit connectClicked();
+}
+
+PageNetServer::PageNetServer(QWidget* parent) : QWidget(parent)
+{
+	QFont * font14 = new QFont("MS Shell Dlg", 14);
+	QGridLayout * pageLayout = new QGridLayout(this);
+	pageLayout->setColumnStretch(0, 1);
+	pageLayout->setColumnStretch(1, 1);
+	pageLayout->setColumnStretch(2, 1);
+
+	BtnBack = new QPushButton(this);
+	BtnBack->setFont(*font14);
+	BtnBack->setText(QPushButton::tr("Back"));
+	pageLayout->addWidget(BtnBack, 2, 0);
+
+	BtnStart = new QPushButton(this);
+	BtnStart->setFont(*font14);
+	BtnStart->setText(QPushButton::tr("Start"));
+	pageLayout->addWidget(BtnStart, 2, 2);
 }
 
 PageNetGame::PageNetGame(QWidget* parent) : QWidget(parent)
@@ -534,7 +548,7 @@
 	BtnBack->setText(QPushButton::tr("Back"));
 	pageLayout->addWidget(BtnBack, 2, 0);
 
-	BtnGo	= new QPushButton(this);
+	BtnGo = new QPushButton(this);
 	BtnGo->setFont(*font14);
 	BtnGo->setText(QPushButton::tr("Go!"));
 	BtnGo->setEnabled(false);
--- a/QTfrontend/pages.h	Wed Dec 12 19:49:13 2007 +0000
+++ b/QTfrontend/pages.h	Thu Dec 13 12:39:26 2007 +0000
@@ -164,8 +164,6 @@
 	QGroupBox *NNGroupBox;
 	QLabel *labelNN;
 	QLineEdit *editNetNick;
-	QLabel *labelIP;
-	QLineEdit * editIP;
 	QRadioButton * rbLocalGame;
 	QRadioButton * rbInternetGame;
 
@@ -173,8 +171,25 @@
 	QGroupBox * ConnGroupBox;
 	QGridLayout * GBClayout;
 
+private slots:
+	void slotConnect();
+
 public slots:
-	void changeServersList();
+	void updateServersList();
+
+signals:
+	void connectClicked();
+};
+
+class PageNetServer : public QWidget
+{
+	Q_OBJECT
+
+public:
+	PageNetServer(QWidget* parent = 0);
+
+	QPushButton *BtnBack;
+	QPushButton *BtnStart;
 };
 
 class PageNetGame : public QWidget
--- a/QTfrontend/ui_hwform.cpp	Wed Dec 12 19:49:13 2007 +0000
+++ b/QTfrontend/ui_hwform.cpp	Thu Dec 13 12:39:26 2007 +0000
@@ -92,4 +92,7 @@
 
 	pageSelectWeapon = new PageSelectWeapon();
 	Pages->addWidget(pageSelectWeapon);
+
+	pageNetServer = new PageNetServer();
+	Pages->addWidget(pageNetServer);
 }
--- a/QTfrontend/ui_hwform.h	Wed Dec 12 19:49:13 2007 +0000
+++ b/QTfrontend/ui_hwform.h	Thu Dec 13 12:39:26 2007 +0000
@@ -26,6 +26,7 @@
 class PagePlayDemo;
 class PageOptions;
 class PageNet;
+class PageNetServer;
 class PageNetChat;
 class PageNetGame;
 class PageInfo;
@@ -50,6 +51,7 @@
 	PagePlayDemo *pagePlayDemo;
 	PageOptions *pageOptions;
 	PageNet *pageNet;
+	PageNetServer * pageNetServer;
 	PageNetChat *pageNetChat;
 	PageNetGame *pageNetGame;
 	PageInfo *pageInfo;