Delay for 250 msec before connect to local server
authorunc0rr
Sun, 26 Oct 2008 14:45:07 +0000
changeset 1418 69df8f2a7cba
parent 1417 210cb6b1b275
child 1419 8650a8f55006
Delay for 250 msec before connect to local server
QTfrontend/hwform.cpp
QTfrontend/hwform.h
QTfrontend/main.cpp
QTfrontend/newnetclient.cpp
--- a/QTfrontend/hwform.cpp	Sun Oct 26 14:37:50 2008 +0000
+++ b/QTfrontend/hwform.cpp	Sun Oct 26 14:45:07 2008 +0000
@@ -30,6 +30,7 @@
 #include <QCheckBox>
 #include <QTextBrowser>
 #include <QAction>
+#include <QTimer>
 
 #include "hwform.h"
 #include "game.h"
@@ -502,7 +503,7 @@
 		delete netHost;
 		netHost = new QString(hpd->leHost->text());
 		netPort = hpd->sbPort->value();
-		_NetConnect(*netHost, netPort, ui.pageOptions->editNetNick->text());
+		NetConnectServer(*netHost, netPort);
 	}
 }
 
@@ -520,9 +521,16 @@
 		return;
 	}
 
-	_NetConnect("localhost", pnetserver->getRunningPort(), ui.pageOptions->editNetNick->text());
+	QTimer::singleShot(250, this, SLOT(AsyncNetServerStart()));
 
-	pRegisterServer = new HWNetUdpServer(0, ui.pageNetServer->leServerDescr->text(), ui.pageNetServer->sbPort->value());
+	pRegisterServer = new HWNetUdpServer(0,
+			ui.pageNetServer->leServerDescr->text(),
+			ui.pageNetServer->sbPort->value());
+}
+
+void HWForm::AsyncNetServerStart()
+{
+	NetConnectServer("localhost", pnetserver->getRunningPort());
 }
 
 void HWForm::NetDisconnect()
@@ -547,14 +555,14 @@
 
 void HWForm::ForcedDisconnect()
 {
-  if(pnetserver) return; // we have server - let it care of all things
-  if (hwnet) {
-    hwnet->deleteLater();
-    hwnet=0;
-    QMessageBox::warning(this, QMessageBox::tr("Network"),
-			 QMessageBox::tr("Connection to server is lost"));
-  }
-  GoBack();
+	if(pnetserver) return; // we have server - let it care of all things
+	if (hwnet) {
+		hwnet->deleteLater();
+		hwnet = 0;
+		QMessageBox::warning(this, QMessageBox::tr("Network"),
+				QMessageBox::tr("Connection to server is lost"));
+	}
+	GoBack();
 }
 
 void HWForm::NetConnected()
@@ -569,7 +577,7 @@
 
 void HWForm::AddNetTeam(const HWTeam& team)
 {
-  ui.pageNetGame->pNetTeamsWidget->addTeam(team);
+	ui.pageNetGame->pNetTeamsWidget->addTeam(team);
 }
 
 void HWForm::StartMPGame()
--- a/QTfrontend/hwform.h	Sun Oct 26 14:37:50 2008 +0000
+++ b/QTfrontend/hwform.h	Sun Oct 26 14:45:07 2008 +0000
@@ -89,6 +89,7 @@
 	void Music(bool checked);
 	void NetGameMaster();
 	void NetGameSlave();
+	void AsyncNetServerStart();
 
 private:
 	void _NetConnect(const QString & hostName, quint16 port, const QString & nick);
--- a/QTfrontend/main.cpp	Sun Oct 26 14:37:50 2008 +0000
+++ b/QTfrontend/main.cpp	Sun Oct 26 14:45:07 2008 +0000
@@ -282,26 +282,6 @@
 			"QMenu::indicator:non-exclusive:unchecked{"
 				"image: url(\":/res/unchecked.png\");"
 				"}"
-
-			"QScrollBar:vertical{"
-				"background-color: #000000;"
-				"border: 2px #ffcc00;"
-				"width: 16px;"
-				"margin: 22px 0 22px 0;"
-				"}"
-			"QScrollBar::handle:vertical{"
-				"border: 1px #ffcc00;"
-				"background-color: #0d0544;"
-				"min-height: 16px;"
-				"}"
-			"QScrollBar::up-arrow:vertical{"
-				"image: url(\":/res/spin_up.png\");"
-				"width: 16px;"
-				"height: 16px;"
-				"}"
-			"QScrollBar::down-arrow:vertical{"
-				"image: url(\":/res/spin_down.png\");"
-				"}"
 			)
 		);
 
--- a/QTfrontend/newnetclient.cpp	Sun Oct 26 14:37:50 2008 +0000
+++ b/QTfrontend/newnetclient.cpp	Sun Oct 26 14:45:07 2008 +0000
@@ -38,17 +38,17 @@
   loginStep(0),
   netClientState(0)
 {
-  connect(&NetSocket, SIGNAL(readyRead()), this, SLOT(ClientRead()));
-  connect(&NetSocket, SIGNAL(connected()), this, SLOT(OnConnect()));
-  connect(&NetSocket, SIGNAL(disconnected()), this, SLOT(OnDisconnect()));
-  connect(&NetSocket, SIGNAL(error(QAbstractSocket::SocketError)), this,
-	  SLOT(displayError(QAbstractSocket::SocketError)));
+	connect(&NetSocket, SIGNAL(readyRead()), this, SLOT(ClientRead()));
+	connect(&NetSocket, SIGNAL(connected()), this, SLOT(OnConnect()));
+	connect(&NetSocket, SIGNAL(disconnected()), this, SLOT(OnDisconnect()));
+	connect(&NetSocket, SIGNAL(error(QAbstractSocket::SocketError)), this,
+			SLOT(displayError(QAbstractSocket::SocketError)));
 }
 
 void HWNewNet::Connect(const QString & hostName, quint16 port, const QString & nick)
 {
-  mynick = nick;
-  NetSocket.connectToHost(hostName, port);
+	mynick = nick;
+	NetSocket.connectToHost(hostName, port);
 }
 
 void HWNewNet::Disconnect()