summaryrefslogtreecommitdiffstats
path: root/src/client/connectwindow/connectwindow.cpp
diff options
context:
space:
mode:
authorManuel Schneider2014-05-06 14:37:44 +0200
committerManuel Schneider2014-05-06 15:16:20 +0200
commit35c3facc81cf10a2070cc5091e4e447ecc7416e3 (patch)
tree0a29051637a37d419407fa266cb1d8234666f9d6 /src/client/connectwindow/connectwindow.cpp
parentReduces button block time (diff)
downloadpvs2-35c3facc81cf10a2070cc5091e4e447ecc7416e3.tar.gz
pvs2-35c3facc81cf10a2070cc5091e4e447ecc7416e3.tar.xz
pvs2-35c3facc81cf10a2070cc5091e4e447ecc7416e3.zip
Changes the approach of Qt Gui initialization to the member pointer approach. This means multiple inheritance is avoided and the form is now a member pointer of the class. Immlicitely renamed some ui elements for clearification. Again changed unnecessary use of QDialog to QWidget.
Diffstat (limited to 'src/client/connectwindow/connectwindow.cpp')
-rw-r--r--src/client/connectwindow/connectwindow.cpp56
1 files changed, 29 insertions, 27 deletions
diff --git a/src/client/connectwindow/connectwindow.cpp b/src/client/connectwindow/connectwindow.cpp
index ca01404..5215a32 100644
--- a/src/client/connectwindow/connectwindow.cpp
+++ b/src/client/connectwindow/connectwindow.cpp
@@ -5,26 +5,28 @@
* Author: sr
*/
-#include "connectwindow.h"
+#include <QNetworkInterface>
#include "../../shared/settings.h"
#include "../../shared/network.h"
#include "../../shared/util.h"
-
#include "../net/serverconnection.h"
-
-#include <QNetworkInterface>
+#include "connectwindow.h"
+#include "ui_connect.h"
#define UDPBUFSIZ 9000
#define SALT_LEN 18
ConnectWindow::ConnectWindow(QWidget *parent) :
- QDialog(parent), _connected(false), _timerDiscover(0), _timerHide(0), _connection(NULL), _state(Idle),
- _hashErrorCount(0), _hashSslErrorCount(0), _certErrorCount(0), _ipErrorCount(0), _discoveryInterval(800)
+ QWidget(parent), _ui(new Ui::ConnectWindow), _connected(false),
+ _timerDiscover(0), _timerHide(0), _connection(NULL), _state(Idle),
+ _hashErrorCount(0), _hashSslErrorCount(0), _certErrorCount(0),
+ _ipErrorCount(0), _discoveryInterval(800)
{
- setupUi(this);
- //
- connect(cmdOK, SIGNAL(clicked()), this, SLOT(onOkClick()));
- connect(cmdCancel, SIGNAL(clicked()), this, SLOT(onCancelClick()));
+ // Initialize the GUI
+ _ui->setupUi(this);
+
+ connect(_ui->cmdOK, SIGNAL(clicked()), this, SLOT(onOkClick()));
+ connect(_ui->cmdCancel, SIGNAL(clicked()), this, SLOT(onCancelClick()));
int tries = 10;
while (tries-- != 0)
{
@@ -66,51 +68,51 @@ void ConnectWindow::setState(const ConnectionState state)
void ConnectWindow::updateState()
{
- txtName->setEnabled(_state == Idle && !_connected);
+ _ui->txtName->setEnabled(_state == Idle && !_connected);
if (_connected)
{
- cmdOK->setEnabled(true);
- cmdOK->setText(tr("&Disconnect"));
- lblStatus->setText(tr("Connected."));
- txtName->setEnabled(false);
+ _ui->cmdOK->setEnabled(true);
+ _ui->cmdOK->setText(tr("&Disconnect"));
+ _ui->lblStatus->setText(tr("Connected."));
+ _ui->txtName->setEnabled(false);
return;
}
if (_state != Idle)
- cmdOK->setText(tr("&Stop"));
+ _ui->cmdOK->setText(tr("&Stop"));
else
- cmdOK->setText(tr("&Connect"));
+ _ui->cmdOK->setText(tr("&Connect"));
switch (_state)
{
case Idle:
- lblStatus->setText(tr("Ready to connect; please enter session name."));
+ _ui->lblStatus->setText(tr("Ready to connect; please enter session name."));
break;
case Scanning:
- lblStatus->setText(tr("Scanning for session %1.").arg(txtName->text()));
+ _ui->lblStatus->setText(tr("Scanning for session %1.").arg(_ui->txtName->text()));
_timerDiscover = startTimer(_discoveryInterval);
break;
case Connecting:
- lblStatus->setText(tr("Found session, connecting..."));
+ _ui->lblStatus->setText(tr("Found session, connecting..."));
break;
case AwaitingChallenge:
- lblStatus->setText(tr("Waiting for server challenge..."));
+ _ui->lblStatus->setText(tr("Waiting for server challenge..."));
break;
case AwaitingChallengeResponse:
- lblStatus->setText(tr("Replied to challenge, sent own..."));
+ _ui->lblStatus->setText(tr("Replied to challenge, sent own..."));
break;
case LoggingIn:
- lblStatus->setText(tr("Logging in..."));
+ _ui->lblStatus->setText(tr("Logging in..."));
break;
case Connected:
- lblStatus->setText(tr("Connection established!"));
+ _ui->lblStatus->setText(tr("Connection established!"));
break;
case InvalidIpList:
case InvalidHash:
case InvalidCert:
case InvalidSslHash:
- lblError->setText(tr("Invalid hash: %1; invalid cert: %2; invalid iplist: %3; invalid sslhash: %4")
+ _ui->lblError->setText(tr("Invalid hash: %1; invalid cert: %2; invalid iplist: %3; invalid sslhash: %4")
.arg(_hashErrorCount).arg(_certErrorCount).arg(_ipErrorCount).arg(_hashSslErrorCount));
break;
}
@@ -189,7 +191,7 @@ void ConnectWindow::closeEvent(QCloseEvent *e)
void ConnectWindow::showEvent(QShowEvent* event)
{
- txtName->setFocus();
+ _ui->txtName->setFocus();
}
/*
@@ -214,7 +216,7 @@ void ConnectWindow::onOkClick()
{
// Connect (scan for session)
_discoveryInterval = 800;
- _nameBytes = txtName->text().toUtf8();
+ _nameBytes = _ui->txtName->text().toUtf8();
_timerDiscover = startTimer(_discoveryInterval);
_hashErrorCount = _hashSslErrorCount = _certErrorCount = _ipErrorCount = 0;
this->setState(Scanning);