|
|
|
|
/* VierGewinnt - A simple 4-in-a-row network game
|
|
|
|
|
*
|
|
|
|
|
* Copyright (c) 2008 by Sebastian Lohff, seba@seba-geek.de
|
|
|
|
|
* http://www.seba-geek.de
|
|
|
|
|
*
|
|
|
|
|
* This file is part of VierGewinnt.
|
|
|
|
|
*
|
|
|
|
|
* VierGewinnt 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, either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* VierGewinnt 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 VierGewinnt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "selectmaster.h"
|
|
|
|
|
|
|
|
|
|
SelectMasterDialog::SelectMasterDialog(QWidget *parent) : QDialog(parent) {
|
|
|
|
|
labelhead = new QLabel(tr("Bitte gib einen anderen Masterserver an"));
|
|
|
|
|
labelmasteraddr = new QLabel(tr("Master-Server:"));
|
|
|
|
|
labelmasterport = new QLabel(tr("Master-Port:"));
|
|
|
|
|
editmasteraddr = new QLineEdit;
|
|
|
|
|
editmasterport = new QLineEdit;
|
|
|
|
|
okcancel = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
|
|
|
|
|
|
|
|
|
connect(okcancel, SIGNAL(accepted()), this, SLOT(checkAndAccept()));
|
|
|
|
|
connect(okcancel, SIGNAL(rejected()), this, SLOT(reject()));
|
|
|
|
|
|
|
|
|
|
layout = new QGridLayout;
|
|
|
|
|
layout->addWidget(labelhead, 0, 0, 1, 2);
|
|
|
|
|
layout->addWidget(labelmasteraddr, 1, 0);
|
|
|
|
|
layout->addWidget(editmasteraddr, 1, 1);
|
|
|
|
|
layout->addWidget(labelmasterport, 2, 0);
|
|
|
|
|
layout->addWidget(editmasterport, 2, 1);
|
|
|
|
|
layout->addWidget(okcancel, 3, 0, 1, 2);
|
|
|
|
|
|
|
|
|
|
setLayout(layout);
|
|
|
|
|
setWindowTitle(tr("Master-Server <20>ndern"));
|
|
|
|
|
setModal(Qt::WindowModal);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SelectMasterDialog::checkAndAccept() {
|
|
|
|
|
if(editmasteraddr->text()=="") {
|
|
|
|
|
QMessageBox msgbox(this);
|
|
|
|
|
msgbox.setText(tr("Der Master-Server ist ung<6E>ltig"));
|
|
|
|
|
msgbox.exec();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int tmpport = editmasterport->text().toInt();
|
|
|
|
|
if(tmpport<1||tmpport>65535) {
|
|
|
|
|
QMessageBox msgbox(this);
|
|
|
|
|
msgbox.setText(tr("Der Master-Port ist ung<6E>ltig"));
|
|
|
|
|
msgbox.exec();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
masterserver = editmasteraddr->text();
|
|
|
|
|
masterport = tmpport;
|
|
|
|
|
accept();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SelectMasterDialog::setData(QString srv, int port) {
|
|
|
|
|
masterserver = srv;
|
|
|
|
|
masterport = port;
|
|
|
|
|
editmasteraddr->setText(masterserver);
|
|
|
|
|
std::stringstream str;
|
|
|
|
|
str << masterport;
|
|
|
|
|
editmasterport->setText(QString(str.str().c_str()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString SelectMasterDialog::getMasterServer() {
|
|
|
|
|
return masterserver;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int SelectMasterDialog::getMasterPort() {
|
|
|
|
|
return masterport;
|
|
|
|
|
}
|