summaryrefslogtreecommitdiffstats
path: root/src/client/connectwindow/connectwindow.cpp
diff options
context:
space:
mode:
authorManuel Schneider2014-05-06 18:45:03 +0200
committerManuel Schneider2014-05-06 18:45:03 +0200
commit03bb2a73d30e9d138d85dafe5b0c37296feb5e9c (patch)
treea8abe332c737bc6d7cf4fa11b614dcdeca53eaba /src/client/connectwindow/connectwindow.cpp
parentClipped the green checkmark's white space. (diff)
downloadpvs2-03bb2a73d30e9d138d85dafe5b0c37296feb5e9c.tar.gz
pvs2-03bb2a73d30e9d138d85dafe5b0c37296feb5e9c.tar.xz
pvs2-03bb2a73d30e9d138d85dafe5b0c37296feb5e9c.zip
Changes the ConnectionWidows gui to a relative layout. Added a stacked widget to
change between checkmark and the rest. Changed the non expressive names of ui elements.
Diffstat (limited to 'src/client/connectwindow/connectwindow.cpp')
-rw-r--r--src/client/connectwindow/connectwindow.cpp48
1 files changed, 24 insertions, 24 deletions
diff --git a/src/client/connectwindow/connectwindow.cpp b/src/client/connectwindow/connectwindow.cpp
index 61d375d..9736dc7 100644
--- a/src/client/connectwindow/connectwindow.cpp
+++ b/src/client/connectwindow/connectwindow.cpp
@@ -29,9 +29,11 @@ ConnectWindow::ConnectWindow(QWidget *parent) :
// 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;
+ // Set actions of buttons
+ connect(_ui->btn_connection, SIGNAL(clicked()), this, SLOT(onBtnConnection()));
+ connect(_ui->btn_hide, SIGNAL(clicked()), this, SLOT(onBtnHide()));
+
+ int tries = 10;
while (tries-- != 0)
{
const quint16 port = (quint16)(qrand() % 10000) + 10000;
@@ -40,15 +42,11 @@ ConnectWindow::ConnectWindow(QWidget *parent) :
if (tries == 0)
qFatal("Could not bind to any UDP port for server discovery.");
}
- connect(&_discoverySocket, SIGNAL(readyRead()), this, SLOT(onUdpReadyRead()));
+ connect(&_discoverySocket, SIGNAL(readyRead()), this, SLOT(onUdpReadyRead()));
this->setState(Idle);
- lblCheckmark->hide();
}
-ConnectWindow::~ConnectWindow()
-{
-
-}
+ConnectWindow::~ConnectWindow(){}
/**
* Set Client as Connected (true) or Disconnected (false).
@@ -86,22 +84,22 @@ void ConnectWindow::setState(const ConnectionState state)
*/
void ConnectWindow::updateState()
{
- _ui->txtName->setEnabled(_state == Idle && !_connected);
+ _ui->lineEditName->setEnabled(_state == Idle && !_connected);
if (_connected)
{
- _ui->lblCheckmark->setVisible(true);
- _ui->cmdOK->setEnabled(true);
- _ui->cmdOK->setText(tr("&Disconnect"));
+ _ui->btn_connection->setEnabled(true);
+ _ui->btn_connection->setText(tr("&Disconnect"));
_ui->lblStatus->setText(tr("Connected."));
- _ui->txtName->setEnabled(false);
+ _ui->lineEditName->setEnabled(false);
+ _ui->stackedWidget->setCurrentIndex(1);
return;
}
if (_state != Idle)
- _ui->cmdOK->setText(tr("&Stop"));
+ _ui->btn_connection->setText(tr("&Stop"));
else
- _ui->cmdOK->setText(tr("&Connect"));
+ _ui->btn_connection->setText(tr("&Connect"));
switch (_state)
{
@@ -109,7 +107,7 @@ void ConnectWindow::updateState()
_ui->lblStatus->setText(tr("Ready to connect; please enter session name."));
break;
case Scanning:
- _ui->lblStatus->setText(tr("Scanning for session %1.").arg(_ui->txtName->text()));
+ _ui->lblStatus->setText(tr("Scanning for session %1.").arg(_ui->lineEditName->text()));
_timerDiscover = startTimer(_discoveryInterval);
break;
case Connecting:
@@ -131,7 +129,7 @@ void ConnectWindow::updateState()
case InvalidHash:
case InvalidCert:
case InvalidSslHash:
- _ui->lblError->setText(tr("Invalid hash: %1; invalid cert: %2; invalid iplist: %3; invalid sslhash: %4")
+ _ui->lblStatus->setText(tr("Invalid hash: %1; invalid cert: %2; invalid iplist: %3; invalid sslhash: %4")
.arg(_hashErrorCount).arg(_certErrorCount).arg(_ipErrorCount).arg(_hashSslErrorCount));
break;
}
@@ -196,7 +194,7 @@ void ConnectWindow::timerEvent(QTimerEvent* event)
killTimer(_timerHide);
_timerHide = 0;
this->hide();
- lblCheckmark->hide();
+ _ui->stackedWidget->setCurrentIndex(0);
}
else
// Unknown/Old timer id, kill it
@@ -219,7 +217,7 @@ void ConnectWindow::closeEvent(QCloseEvent *e)
*/
void ConnectWindow::showEvent(QShowEvent* event)
{
- _ui->txtName->setFocus();
+ _ui->lineEditName->setFocus();
}
/*
@@ -231,10 +229,12 @@ void ConnectWindow::showEvent(QShowEvent* event)
* If already connected --> Stop/disconnect.
* Else scanning for given sessionId.
*/
-void ConnectWindow::onOkClick()
+void ConnectWindow::onBtnConnection()
{
- if (_timerHide)
+ if (_timerHide){
killTimer(_timerHide);
+ _ui->stackedWidget->setCurrentIndex(0);
+ }
_timerHide = 0;
if (_timerDiscover)
killTimer(_timerDiscover);
@@ -249,7 +249,7 @@ void ConnectWindow::onOkClick()
{
// Connect (scan for session)
_discoveryInterval = 800;
- _nameBytes = _ui->txtName->text().toUtf8();
+ _nameBytes = _ui->lineEditName->text().toUtf8();
_timerDiscover = startTimer(_discoveryInterval);
_hashErrorCount = _hashSslErrorCount = _certErrorCount = _ipErrorCount = 0;
this->setState(Scanning);
@@ -260,7 +260,7 @@ void ConnectWindow::onOkClick()
* Handle click on Cancel/Hide Button.
* Just hide the window.
*/
-void ConnectWindow::onCancelClick()
+void ConnectWindow::onBtnHide()
{
this->hide();
}