# HG changeset patch # User unc0rr # Date 1197581507 0 # Node ID 4f44fc06ca45aa192a08a7c4e802585e98155b71 # Parent 4cca0c7de60980f1ff5f2556b3f81fb5b58595c9 Class to ask host/port to connect to ('Specify' button on PageNet) diff -r 4cca0c7de609 -r 4f44fc06ca45 QTfrontend/CMakeLists.txt --- a/QTfrontend/CMakeLists.txt Thu Dec 13 16:10:58 2007 +0000 +++ b/QTfrontend/CMakeLists.txt Thu Dec 13 21:31:47 2007 +0000 @@ -73,6 +73,7 @@ hwconsts.cpp selectWeapon.cpp itemNum.cpp + input_ip.cpp weaponItem.cpp) if (WIN32) @@ -111,6 +112,7 @@ playrecordpage.h selectWeapon.h itemNum.h + input_ip.h weaponItem.h) set(hwfr_hdrs diff -r 4cca0c7de609 -r 4f44fc06ca45 QTfrontend/hwform.cpp --- a/QTfrontend/hwform.cpp Thu Dec 13 16:10:58 2007 +0000 +++ b/QTfrontend/hwform.cpp Thu Dec 13 21:31:47 2007 +0000 @@ -46,6 +46,7 @@ #include "netwwwserver.h" #include "chatwidget.h" #include "playrecordpage.h" +#include "input_ip.h" HWForm::HWForm(QWidget *parent) : QMainWindow(parent), pnetserver(0), pRegisterServer(0), editedTeam(0), hwnet(0) @@ -89,7 +90,8 @@ connect(ui.pageOptions->WeaponsButt, SIGNAL(clicked()), this, SLOT(GoToSelectWeapon())); connect(ui.pageNet->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); - connect(ui.pageNet->BtnNetConnect, SIGNAL(clicked()), this, SLOT(NetConnect())); + connect(ui.pageNet->BtnNetConnect, SIGNAL(clicked()), this, SLOT(NetConnectServer())); + connect(ui.pageNet->BtnSpecifyServer, SIGNAL(clicked()), this, SLOT(NetConnect())); connect(ui.pageNet->BtnNetSvrStart, SIGNAL(clicked()), this, SLOT(GoToNetServer())); connect(ui.pageNet, SIGNAL(connectClicked()), this, SLOT(NetConnectServer())); @@ -408,6 +410,9 @@ void HWForm::NetConnect() { + HWHostPortDialog * hpd = new HWHostPortDialog(this); + + hpd->exec(); // FIXME: _NetConnect(ui.pageNet->editIP->text(), 46631, ui.pageNet->editNetNick->text()); } diff -r 4cca0c7de609 -r 4f44fc06ca45 QTfrontend/input_ip.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/input_ip.cpp Thu Dec 13 21:31:47 2007 +0000 @@ -0,0 +1,68 @@ +/* + * Hedgewars, a worms-like game + * Copyright (c) 2007 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#include +#include +#include +#include +#include + +#include "input_ip.h" + +HWHostPortDialog::HWHostPortDialog(QWidget* parent) : QDialog(parent) +{ + QGridLayout * layout = new QGridLayout(this); + + QLabel * lbHost = new QLabel(this); + lbHost->setText(tr("Host:")); + layout->addWidget(lbHost, 0, 0); + + QLabel * lbPort = new QLabel(this); + lbPort->setText(tr("Port:")); + layout->addWidget(lbPort, 1, 0); + + leHost = new QLineEdit(this); + layout->addWidget(leHost, 0, 1, 1, 2); + + sbPort = new QSpinBox(this); + sbPort->setMinimum(0); + sbPort->setMaximum(65535); + layout->addWidget(sbPort, 1, 1, 1, 2); + + pbDefault = new QPushButton(this); + pbDefault->setText(tr("default")); + layout->addWidget(pbDefault, 1, 3); + + pbOK = new QPushButton(this); + pbOK->setText(tr("OK")); + pbOK->setDefault(true); + layout->addWidget(pbOK, 3, 1); + + pbCancel = new QPushButton(this); + pbCancel->setText(tr("Cancel")); + layout->addWidget(pbCancel, 3, 2); + + connect(pbOK, SIGNAL(clicked()), this, SLOT(accept())); + connect(pbCancel, SIGNAL(clicked()), this, SLOT(reject())); + connect(pbDefault, SIGNAL(clicked()), this, SLOT(setDefaultPort())); +} + +void HWHostPortDialog::setDefaultPort() +{ + sbPort->setValue(46631); +} diff -r 4cca0c7de609 -r 4f44fc06ca45 QTfrontend/input_ip.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/input_ip.h Thu Dec 13 21:31:47 2007 +0000 @@ -0,0 +1,48 @@ +/* + * Hedgewars, a worms-like game + * Copyright (c) 2007 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + + +#ifndef INPUT_IP_H +#define INPUT_IP_H + +#include +#include + +class QLineEdit; +class QSpinBox; +class QPushButton; + +class HWHostPortDialog : public QDialog +{ + Q_OBJECT +public: + HWHostPortDialog(QWidget* parent = 0); + +private: + QLineEdit* leHost; + QSpinBox* sbPort; + QPushButton* pbOK; + QPushButton* pbCancel; + QPushButton * pbDefault; + +private slots: + void setDefaultPort(); +}; + + +#endif // INPUT_IP_H diff -r 4cca0c7de609 -r 4f44fc06ca45 QTfrontend/pages.cpp --- a/QTfrontend/pages.cpp Thu Dec 13 16:10:58 2007 +0000 +++ b/QTfrontend/pages.cpp Thu Dec 13 21:31:47 2007 +0000 @@ -468,6 +468,11 @@ BtnUpdateSList->setText(QPushButton::tr("Update")); GBClayout->addWidget(BtnUpdateSList, 2, 0); + BtnSpecifyServer = new QPushButton(ConnGroupBox); + BtnSpecifyServer->setFont(*font14); + BtnSpecifyServer->setText(QPushButton::tr("Specify")); + GBClayout->addWidget(BtnSpecifyServer, 2, 1); + BtnBack = new QPushButton(this); BtnBack->setFont(*font14); BtnBack->setText(QPushButton::tr("Back")); diff -r 4cca0c7de609 -r 4f44fc06ca45 QTfrontend/pages.h --- a/QTfrontend/pages.h Thu Dec 13 16:10:58 2007 +0000 +++ b/QTfrontend/pages.h Thu Dec 13 21:31:47 2007 +0000 @@ -161,9 +161,10 @@ QPushButton* BtnUpdateSList; HWNetServersWidget* netServersWidget; - QPushButton *BtnBack; - QPushButton *BtnNetConnect; - QPushButton* BtnNetSvrStart; + QPushButton * BtnBack; + QPushButton * BtnNetConnect; + QPushButton * BtnNetSvrStart; + QPushButton * BtnSpecifyServer; QRadioButton * rbLocalGame; QRadioButton * rbInternetGame;