Add 'Cancel connection' button. Fixes issue #162
authorunc0rr
Fri, 15 Apr 2011 22:38:50 +0400
changeset 5147 a2ae7702bb75
parent 5146 7b65e83e261d
child 5148 73b3b4b8359c
Add 'Cancel connection' button. Fixes issue #162
QTfrontend/hwform.cpp
QTfrontend/netudpwidget.cpp
QTfrontend/pageconnecting.cpp
QTfrontend/pages.h
--- a/QTfrontend/hwform.cpp	Fri Apr 15 21:36:59 2011 +0400
+++ b/QTfrontend/hwform.cpp	Fri Apr 15 22:38:50 2011 +0400
@@ -244,6 +244,8 @@
 
     connect(ui.pageDrawMap->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack()));
 
+    connect(ui.pageConnecting, SIGNAL(cancelConnection()), this, SLOT(GoBack()));
+
 
     ammoSchemeModel = new AmmoSchemeModel(this, cfgdir->absolutePath() + "/schemes.ini");
     ui.pageScheme->setModel(ammoSchemeModel);
@@ -550,7 +552,7 @@
         if (id == ID_PAGE_NETGAME || id == ID_PAGE_NETGAME)
             GoBack();
 
-    if (curid == ID_PAGE_ROOMSLIST) NetDisconnect();
+    if (curid == ID_PAGE_ROOMSLIST || curid == ID_PAGE_CONNECTING) NetDisconnect();
     if (curid == ID_PAGE_NETGAME && hwnet) hwnet->partRoom();
     // need to work on this, can cause invalid state for admin quit trying to prevent bad state message on kick
     //if (curid == ID_PAGE_NETGAME && (!game || game->gameState != gsStarted)) hwnet->partRoom();
--- a/QTfrontend/netudpwidget.cpp	Fri Apr 15 21:36:59 2011 +0400
+++ b/QTfrontend/netudpwidget.cpp	Fri Apr 15 22:38:50 2011 +0400
@@ -37,7 +37,6 @@
     reset();
 
     pUdpSocket->writeDatagram("hedgewars client", QHostAddress::Broadcast, 46631);
-    pUdpSocket->writeDatagram("hedgewars client", QHostAddress("127.0.0.1"), 46631);
 }
 
 void HWNetUdpModel::onClientRead()
--- a/QTfrontend/pageconnecting.cpp	Fri Apr 15 21:36:59 2011 +0400
+++ b/QTfrontend/pageconnecting.cpp	Fri Apr 15 22:38:50 2011 +0400
@@ -29,4 +29,9 @@
     QLabel * lblConnecting = new QLabel(this);
     lblConnecting->setText(tr("Connecting..."));
     pageLayout->addWidget(lblConnecting);
+
+    QPushButton * pbCancel = new QPushButton(this);
+    pbCancel->setText(tr("Cancel"));
+    pageLayout->addWidget(pbCancel);
+    connect(pbCancel, SIGNAL(clicked()), this, SIGNAL(cancelConnection()));
 }
--- a/QTfrontend/pages.h	Fri Apr 15 21:36:59 2011 +0400
+++ b/QTfrontend/pages.h	Fri Apr 15 22:38:50 2011 +0400
@@ -476,6 +476,9 @@
 
 public:
     PageConnecting(QWidget* parent = 0);
+
+signals:
+    void cancelConnection();
 };
 
 class PageScheme : public AbstractPage