summaryrefslogtreecommitdiffstats
path: root/src
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
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')
-rw-r--r--src/client/connectwindow/connectwindow.cpp48
-rw-r--r--src/client/connectwindow/connectwindow.h4
-rw-r--r--src/client/toolbar/toolbar.cpp15
-rw-r--r--src/server/sessionnamewindow/sessionnamewindow.cpp8
4 files changed, 45 insertions, 30 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();
}
diff --git a/src/client/connectwindow/connectwindow.h b/src/client/connectwindow/connectwindow.h
index 8d4a436..299a339 100644
--- a/src/client/connectwindow/connectwindow.h
+++ b/src/client/connectwindow/connectwindow.h
@@ -90,8 +90,8 @@ protected:
void showEvent(QShowEvent* event);
protected slots:
- void onOkClick();
- void onCancelClick();
+ void onBtnConnection();
+ void onBtnHide();
void onUdpReadyRead();
void onConnectionStateChange(ConnectWindow::ConnectionState state);
void onConnectionClosed(QObject* connection);
diff --git a/src/client/toolbar/toolbar.cpp b/src/client/toolbar/toolbar.cpp
index f45d63a..816d5f4 100644
--- a/src/client/toolbar/toolbar.cpp
+++ b/src/client/toolbar/toolbar.cpp
@@ -20,6 +20,21 @@ Toolbar::Toolbar(QWidget *parent) :
// Initialize the GUI
_ui->setupUi(this);
+// QWidget *firstPageWidget = new QWidget;
+// QWidget *secondPageWidget = new QWidget;
+
+// QStackedLayout *stackedLayout = new QStackedLayout;
+// stackedLayout->addWidget(firstPageWidget);
+// stackedLayout->addWidget(secondPageWidget);
+
+// QVBoxLayout *mainLayout = new QVBoxLayout;
+// mainLayout->addLayout(stackedLayout);
+// setLayout(mainLayout);
+
+
+
+
+
setWindowFlags(Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint | Qt::FramelessWindowHint);
setAttribute(Qt::WA_AlwaysShowToolTips);
setAttribute(Qt::WA_QuitOnClose);
diff --git a/src/server/sessionnamewindow/sessionnamewindow.cpp b/src/server/sessionnamewindow/sessionnamewindow.cpp
index 01ac910..f0ca532 100644
--- a/src/server/sessionnamewindow/sessionnamewindow.cpp
+++ b/src/server/sessionnamewindow/sessionnamewindow.cpp
@@ -28,7 +28,7 @@ SessionNameWindow::SessionNameWindow(QWidget *parent) :
connect(ui->bboxOkCancel, SIGNAL(accepted()), this, SLOT(onOkClicked()));
connect(ui->bboxOkCancel, SIGNAL(rejected()), this, SLOT(close()));
connect(ui->cmdRandom, SIGNAL(clicked(bool)), this, SLOT(onGenerateRandomName()));
- ui->txtName->setFocus();
+ ui->lineEditName->setFocus();
}
SessionNameWindow::~SessionNameWindow()
@@ -38,7 +38,7 @@ SessionNameWindow::~SessionNameWindow()
void SessionNameWindow::show(const QString& name)
{
- ui->txtName->setText(name);
+ ui->lineEditName->setText(name);
this->showNormal();
}
@@ -58,12 +58,12 @@ void SessionNameWindow::closeEvent(QCloseEvent *e)
void SessionNameWindow::onOkClicked()
{
- Global::setSessionName(ui->txtName->text());
+ Global::setSessionName(ui->lineEditName->text());
emit updateSessionName();
this->hide();
}
void SessionNameWindow::onGenerateRandomName()
{
- ui->txtName->setText(QString::number(qrand() % 9000 + 1000));
+ ui->lineEditName->setText(QString::number(qrand() % 9000 + 1000));
}