summaryrefslogtreecommitdiffstats
path: root/src/client/connectwindow/connectwindow.cpp
diff options
context:
space:
mode:
authorManuel Schneider2014-05-06 15:25:13 +0200
committerManuel Schneider2014-05-06 15:25:13 +0200
commit9d92e6f2202339de585b6bd5c3858e03b89651f0 (patch)
treeacb8e72d3b9f60fcad0ac4fa3af00db20a90133e /src/client/connectwindow/connectwindow.cpp
parentChanges the approach of Qt Gui initialization to the member pointer approach.... (diff)
parentMerge branch 'master' of git.openslx.org:pvs2 (diff)
downloadpvs2-9d92e6f2202339de585b6bd5c3858e03b89651f0.tar.gz
pvs2-9d92e6f2202339de585b6bd5c3858e03b89651f0.tar.xz
pvs2-9d92e6f2202339de585b6bd5c3858e03b89651f0.zip
Merge branch 'master' of git.openslx.org:pvs2
Conflicts: gui/client/toolbar.ui src/client/connectwindow/connectwindow.cpp
Diffstat (limited to 'src/client/connectwindow/connectwindow.cpp')
-rw-r--r--src/client/connectwindow/connectwindow.cpp50
1 files changed, 49 insertions, 1 deletions
diff --git a/src/client/connectwindow/connectwindow.cpp b/src/client/connectwindow/connectwindow.cpp
index 5215a32..61d375d 100644
--- a/src/client/connectwindow/connectwindow.cpp
+++ b/src/client/connectwindow/connectwindow.cpp
@@ -16,6 +16,10 @@
#define UDPBUFSIZ 9000
#define SALT_LEN 18
+/**
+ * Initialize Connection Window.
+ * @param parent
+ */
ConnectWindow::ConnectWindow(QWidget *parent) :
QWidget(parent), _ui(new Ui::ConnectWindow), _connected(false),
_timerDiscover(0), _timerHide(0), _connection(NULL), _state(Idle),
@@ -36,8 +40,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()
@@ -45,6 +50,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;
@@ -57,6 +67,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)
@@ -66,12 +81,16 @@ void ConnectWindow::setState(const ConnectionState state)
}
}
+/**
+ * Handle changes in state and update window.
+ */
void ConnectWindow::updateState()
{
_ui->txtName->setEnabled(_state == Idle && !_connected);
if (_connected)
{
+ _ui->lblCheckmark->setVisible(true);
_ui->cmdOK->setEnabled(true);
_ui->cmdOK->setText(tr("&Disconnect"));
_ui->lblStatus->setText(tr("Connected."));
@@ -177,18 +196,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)
{
_ui->txtName->setFocus();
@@ -198,6 +226,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)
@@ -223,11 +256,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];
@@ -271,6 +311,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);
@@ -289,6 +333,10 @@ void ConnectWindow::onConnectionStateChange(ConnectWindow::ConnectionState state
}
}
+/**
+ * Set _connection = NULL.
+ * @param connection
+ */
void ConnectWindow::onConnectionClosed(QObject* connection)
{
_connection = NULL;