From 1f493bb8bab4829c6ccecde410a5504f8686b27b Mon Sep 17 00:00:00 2001
From: Björn Hagemeister
Date: Mon, 5 May 2014 18:21:02 +0200
Subject: Adding flashy Symbol for working connection of client to server. And
commenting class ConnectionWindow from client.
---
gui/client/connect.ui | 33 ++++++++++++++++--
gui/client/toolbar.ui | 16 ++++++---
icons/dark-green-check-mark.svg | 10 ++++++
pvsclient.qrc | 2 ++
src/client/connectwindow/connectwindow.cpp | 54 ++++++++++++++++++++++++++++--
5 files changed, 105 insertions(+), 10 deletions(-)
create mode 100644 icons/dark-green-check-mark.svg
diff --git a/gui/client/connect.ui b/gui/client/connect.ui
index c702123..d334924 100644
--- a/gui/client/connect.ui
+++ b/gui/client/connect.ui
@@ -66,8 +66,8 @@
- 10
- 70
+ 20
+ 80
381
21
@@ -108,7 +108,34 @@
false
+
+
+
+ 120
+ 0
+ 221
+ 121
+
+
+
+ false
+
+
+
+
+
+
+
+
+ :/dark-green-check-mark.svg
+
+
+ true
+
+
-
+
+
+
diff --git a/gui/client/toolbar.ui b/gui/client/toolbar.ui
index 8f32658..93d2dc9 100644
--- a/gui/client/toolbar.ui
+++ b/gui/client/toolbar.ui
@@ -67,7 +67,16 @@ QCheckBox::indicator:checked:pressed {
-
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
0
-
@@ -83,7 +92,7 @@ QCheckBox::indicator:checked:pressed {
- 68
+ 84
0
@@ -91,7 +100,7 @@ QCheckBox::indicator:checked:pressed {
Menu
- Menu
+ Menu
@@ -168,7 +177,6 @@ p, li { white-space: pre-wrap; }
-
diff --git a/icons/dark-green-check-mark.svg b/icons/dark-green-check-mark.svg
new file mode 100644
index 0000000..01c2436
--- /dev/null
+++ b/icons/dark-green-check-mark.svg
@@ -0,0 +1,10 @@
+
\ No newline at end of file
diff --git a/pvsclient.qrc b/pvsclient.qrc
index 2979d52..f4cf621 100644
--- a/pvsclient.qrc
+++ b/pvsclient.qrc
@@ -1,5 +1,7 @@
+ icons/dark-green-check-mark.svg
icons/darrow16.svg
icons/ok16.svg
diff --git a/src/client/connectwindow/connectwindow.cpp b/src/client/connectwindow/connectwindow.cpp
index ca01404..07a1a76 100644
--- a/src/client/connectwindow/connectwindow.cpp
+++ b/src/client/connectwindow/connectwindow.cpp
@@ -17,12 +17,16 @@
#define UDPBUFSIZ 9000
#define SALT_LEN 18
+/**
+ * Initialize Connection Window.
+ * @param parent
+ */
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)
{
- setupUi(this);
- //
+ setupUi(this);
+ //
connect(cmdOK, SIGNAL(clicked()), this, SLOT(onOkClick()));
connect(cmdCancel, SIGNAL(clicked()), this, SLOT(onCancelClick()));
int tries = 10;
@@ -34,8 +38,9 @@ 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()
@@ -43,6 +48,11 @@ ConnectWindow::~ConnectWindow()
}
+/**
+ * Set Client as Connected (true) or Disconnected (false).
+ * After settings updateState() is called.
+ * @param connected
+ */
void ConnectWindow::setConnected(const bool connected)
{
_connected = connected;
@@ -55,6 +65,11 @@ void ConnectWindow::setConnected(const bool connected)
}
}
+/**
+ * Set current state of Client.
+ * After setting state updateState() is called.
+ * @param state
+ */
void ConnectWindow::setState(const ConnectionState state)
{
if (_state != state)
@@ -64,12 +79,16 @@ void ConnectWindow::setState(const ConnectionState state)
}
}
+/**
+ * Handle changes in state and update window.
+ */
void ConnectWindow::updateState()
{
txtName->setEnabled(_state == Idle && !_connected);
if (_connected)
{
+ lblCheckmark->setVisible(true);
cmdOK->setEnabled(true);
cmdOK->setText(tr("&Disconnect"));
lblStatus->setText(tr("Connected."));
@@ -175,18 +194,27 @@ void ConnectWindow::timerEvent(QTimerEvent* event)
killTimer(_timerHide);
_timerHide = 0;
this->hide();
+ lblCheckmark->hide();
}
else
// Unknown/Old timer id, kill it
killTimer(event->timerId());
}
+/**
+ * Close Event e and hide window.
+ * @param e
+ */
void ConnectWindow::closeEvent(QCloseEvent *e)
{
e->ignore();
this->hide();
}
+/**
+ * Gives the keyboard input focus to the input line.
+ * @param event
+ */
void ConnectWindow::showEvent(QShowEvent* event)
{
txtName->setFocus();
@@ -196,6 +224,11 @@ void ConnectWindow::showEvent(QShowEvent* event)
* Slots
*/
+/**
+ * Handle click on Connect/Disconnect button.
+ * If already connected --> Stop/disconnect.
+ * Else scanning for given sessionId.
+ */
void ConnectWindow::onOkClick()
{
if (_timerHide)
@@ -221,11 +254,18 @@ void ConnectWindow::onOkClick()
}
}
+/**
+ * Handle click on Cancel/Hide Button.
+ * Just hide the window.
+ */
void ConnectWindow::onCancelClick()
{
this->hide();
}
+/**
+ * Handle incoming service discovery packets.
+ */
void ConnectWindow::onUdpReadyRead()
{
char data[UDPBUFSIZ];
@@ -269,6 +309,10 @@ void ConnectWindow::onUdpReadyRead()
}
}
+/**
+ * Handle connection state changes and update member variables describing state.
+ * @param state
+ */
void ConnectWindow::onConnectionStateChange(ConnectWindow::ConnectionState state)
{
bool reset = (_state == Scanning);
@@ -287,6 +331,10 @@ void ConnectWindow::onConnectionStateChange(ConnectWindow::ConnectionState state
}
}
+/**
+ * Set _connection = NULL.
+ * @param connection
+ */
void ConnectWindow::onConnectionClosed(QObject* connection)
{
_connection = NULL;
--
cgit v1.2.3-55-g7522