--- a/QTfrontend/hwform.cpp Sun Feb 15 17:48:05 2009 +0000
+++ b/QTfrontend/hwform.cpp Sun Feb 15 20:29:52 2009 +0000
@@ -329,7 +329,7 @@
if (id == ID_PAGE_NETGAME || id == ID_PAGE_NETGAME)
GoBack();
- if (id == ID_PAGE_NET) {
+ if ((id == ID_PAGE_NET) && (curid != ID_PAGE_CONNECTING)) {
if(hwnet || pnetserver) NetDisconnect();
}
}
@@ -449,6 +449,12 @@
hwnet = new HWNewNet(config, ui.pageNetGame->pGameCFG, ui.pageNetGame->pNetTeamsWidget);
+ {
+ GoToPage(ID_PAGE_CONNECTING);
+ connect(hwnet, SIGNAL(Connected()), this, SLOT(GoBack()));
+ connect(hwnet, SIGNAL(Disconnected()), this, SLOT(GoBack()));
+ }
+
connect(hwnet, SIGNAL(showMessage(const QString &)), this, SLOT(ShowErrorMessage(const QString &)), Qt::QueuedConnection);
connect(hwnet, SIGNAL(AskForRunGame()), this, SLOT(CreateNetGame()));
@@ -533,7 +539,7 @@
hwnet, SLOT(onWeaponsNameChanged(const QString &, const QString &)));
connect(ui.pageNetGame->pGameCFG, SIGNAL(newTemplateFilter(int)), hwnet, SLOT(onTemplateFilterChanged(int)));
- connect(hwnet, SIGNAL(Disconnected()), this, SLOT(ForcedDisconnect()));
+ connect(hwnet, SIGNAL(Disconnected()), this, SLOT(ForcedDisconnect()), Qt::QueuedConnection);
connect(hwnet, SIGNAL(seedChanged(const QString &)), ui.pageNetGame->pGameCFG, SLOT(setSeed(const QString &)));
connect(hwnet, SIGNAL(mapChanged(const QString &)), ui.pageNetGame->pGameCFG, SLOT(setMap(const QString &)));
connect(hwnet, SIGNAL(themeChanged(const QString &)), ui.pageNetGame->pGameCFG, SLOT(setTheme(const QString &)));
@@ -599,6 +605,7 @@
void HWForm::NetDisconnect()
{
+ qDebug("NetDisconnect");
if(hwnet) {
hwnet->Disconnect();
delete hwnet;
@@ -625,8 +632,9 @@
hwnet = 0;
QMessageBox::warning(this, QMessageBox::tr("Network"),
QMessageBox::tr("Connection to server is lost"));
+
}
- GoBack();
+ if (ui.Pages->currentIndex() != ID_PAGE_NET) GoBack();
}
void HWForm::NetConnected()
--- a/QTfrontend/hwform.h Sun Feb 15 17:48:05 2009 +0000
+++ b/QTfrontend/hwform.h Sun Feb 15 20:29:52 2009 +0000
@@ -112,7 +112,8 @@
ID_PAGE_SELECTWEAPON = 11,
ID_PAGE_NETSERVER = 12,
ID_PAGE_INGAME = 13,
- ID_PAGE_ROOMSLIST = 14
+ ID_PAGE_ROOMSLIST = 14,
+ ID_PAGE_CONNECTING = 15
};
HWGame * game;
HWTeam * editedTeam;
--- a/QTfrontend/newnetclient.cpp Sun Feb 15 17:48:05 2009 +0000
+++ b/QTfrontend/newnetclient.cpp Sun Feb 15 20:29:52 2009 +0000
@@ -17,7 +17,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
-#include <QMessageBox>
#include <QDebug>
#include "hwconsts.h"
@@ -49,7 +48,10 @@
HWNewNet::~HWNewNet()
{
if (m_game_connected)
+ {
RawSendNet(QString("QUIT%1%2").arg(delimeter).arg("User quit"));
+ emit Disconnected();
+ }
NetSocket.flush();
}
@@ -64,6 +66,7 @@
if (m_game_connected)
RawSendNet(QString("QUIT%1%2").arg(delimeter).arg("User quit"));
m_game_connected = false;
+
NetSocket.disconnectFromHost();
}
@@ -172,20 +175,19 @@
void HWNewNet::displayError(QAbstractSocket::SocketError socketError)
{
+ emit Disconnected();
+
switch (socketError) {
case QAbstractSocket::RemoteHostClosedError:
break;
case QAbstractSocket::HostNotFoundError:
- QMessageBox::information(0, tr("Error"),
- tr("The host was not found. Please check the host name and port settings."));
+ emit showMessage(tr("The host was not found. Please check the host name and port settings."));
break;
case QAbstractSocket::ConnectionRefusedError:
- QMessageBox::information(0, tr("Error"),
- tr("Connection refused"));
+ emit showMessage(tr("Connection refused"));
break;
default:
- QMessageBox::information(0, tr("Error"),
- NetSocket.errorString());
+ emit showMessage(NetSocket.errorString());
}
}
--- a/QTfrontend/pages.cpp Sun Feb 15 17:48:05 2009 +0000
+++ b/QTfrontend/pages.cpp Sun Feb 15 20:29:52 2009 +0000
@@ -815,3 +815,9 @@
emit askForRoomList();
}
+
+PageConnecting::PageConnecting(QWidget* parent) :
+ AbstractPage(parent)
+{
+ QGridLayout * pageLayout = new QGridLayout(this);
+}
--- a/QTfrontend/pages.h Sun Feb 15 17:48:05 2009 +0000
+++ b/QTfrontend/pages.h Sun Feb 15 20:29:52 2009 +0000
@@ -380,4 +380,12 @@
void askForRoomList();
};
+class PageConnecting : public AbstractPage
+{
+ Q_OBJECT
+
+public:
+ PageConnecting(QWidget* parent = 0);
+};
+
#endif // PAGES_H
--- a/QTfrontend/ui_hwform.cpp Sun Feb 15 17:48:05 2009 +0000
+++ b/QTfrontend/ui_hwform.cpp Sun Feb 15 20:29:52 2009 +0000
@@ -100,4 +100,7 @@
pageRoomsList = new PageRoomsList();
Pages->addWidget(pageRoomsList);
+
+ pageConnecting = new PageConnecting();
+ Pages->addWidget(pageConnecting);
}
--- a/QTfrontend/ui_hwform.h Sun Feb 15 17:48:05 2009 +0000
+++ b/QTfrontend/ui_hwform.h Sun Feb 15 20:29:52 2009 +0000
@@ -35,6 +35,7 @@
class PageSelectWeapon;
class PageInGame;
class PageRoomsList;
+class PageConnecting;
class QStackedLayout;
class QFont;
class QWidget;
@@ -61,6 +62,7 @@
PageSelectWeapon *pageSelectWeapon;
PageInGame *pageInGame;
PageRoomsList *pageRoomsList;
+ PageConnecting *pageConnecting;
QStackedLayout *Pages;
QFont *font14;