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. --- src/client/connectwindow/connectwindow.cpp | 54 ++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 3 deletions(-) (limited to 'src/client/connectwindow/connectwindow.cpp') 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