From 1cc0630763431d48f1d70451ac04ab8f2243b36e Mon Sep 17 00:00:00 2001 From: Manuel Schneider Date: Wed, 7 May 2014 16:45:33 +0200 Subject: Comment source file and minor changes. * Change unneccesary slot signature * Reduce hide timer to 500ms --- src/client/toolbar/toolbar.cpp | 70 +++++++++++++++++++++++++++++++++--------- 1 file changed, 56 insertions(+), 14 deletions(-) (limited to 'src/client/toolbar/toolbar.cpp') diff --git a/src/client/toolbar/toolbar.cpp b/src/client/toolbar/toolbar.cpp index b0ded44..5d5b045 100644 --- a/src/client/toolbar/toolbar.cpp +++ b/src/client/toolbar/toolbar.cpp @@ -13,8 +13,15 @@ #include "toolbar.h" #include "ui_toolbar.h" - -//______________________________________________________________________________ +/***************************************************************************//** + * Constructor of the Toolbar. Constructs a widget which is a child of parent. + * Initialize the GUI and sets up the menu, sets window properties, create the + * VNC- and connect-window, connects the necessary signals, sets the UI's + * position and configuires the timer for the UI to be hidden. + * @param parent If parent is 0, the new widget becomes a window. If parent is + * another widget, this widget becomes a child window inside parent. The new + * widget is deleted when its parent is deleted. + */ Toolbar::Toolbar(QWidget *parent) : QWidget(parent), _ui(new Ui::Toolbar), _hideTimer(this), _connection(NULL) { @@ -50,7 +57,7 @@ Toolbar::Toolbar(QWidget *parent) : connect(_acnQuit, SIGNAL(triggered()), qApp, SLOT(quit())); /* Connect the signals from vnc server */ - connect(VncServer::instance(), SIGNAL(started(int, QString&, QString&)), this, SLOT(onVncServerIsRunning(int, QString&, QString&))); + connect(VncServer::instance(), SIGNAL(started(int, QString&, QString&)), this, SLOT(onVncServerIsRunning(int))); /* Set position */ const QDesktopWidget desktop; @@ -59,13 +66,17 @@ Toolbar::Toolbar(QWidget *parent) : qDebug() << primaryScreen.left() << primaryScreen.top() << primaryScreen.right() << primaryScreen.bottom(); /* Setup hide timer */ - _hideTimer.setInterval(600); + _hideTimer.setInterval(500); _hideTimer.setSingleShot(true); connect(&_hideTimer, SIGNAL(timeout()), this, SLOT(hideBar())); _hideTimer.start(); // initially show PVS and hide later } -//______________________________________________________________________________ + +/***************************************************************************//** + * Destructor of the Toolbar. Destroys the widget. All this widget's children + * are deleted first. + */ Toolbar::~Toolbar() { VncServer::instance()->stop(); @@ -74,17 +85,29 @@ Toolbar::~Toolbar() delete _ui; } -//______________________________________________________________________________ /* * Override */ + +/***************************************************************************//** + * This event is reimplemented to receive widget leave events. When the mouse + * cursor leaves the widget, a timer gets started which, when timed out, hides + * the Toolbar. + * @param e The leave event (Mouse leaves widget's boundaries.) + */ void Toolbar::leaveEvent(QEvent* e) { _hideTimer.start(); QWidget::leaveEvent(e); } -//______________________________________________________________________________ + +/***************************************************************************//** + * This event is reimplemented to receive widget enter events. When the mouse + * cursor enters the widget, the timer which, when timed out, hides + * the Toolbar, gets stopped. + * @param e The enter event (Mouse enters widget's boundaries.) + */ void Toolbar::enterEvent(QEvent* e) { _hideTimer.stop(); @@ -92,12 +115,16 @@ void Toolbar::enterEvent(QEvent* e) QWidget::enterEvent(e); } -//______________________________________________________________________________ /* * Slots */ -void Toolbar::onVncServerIsRunning(int port, QString&, QString&) +/***************************************************************************//** + * A slot for the VncServerIsRunning signal. This slot will change the UI + * according to the state fo the VncServer. + * @param[in] port Indicates the state of the VncServer. + */ +void Toolbar::onVncServerIsRunning(int port) { if (port > 0){ _ui->lblStatus->setStyleSheet("color:red"); @@ -110,7 +137,10 @@ void Toolbar::onVncServerIsRunning(int port, QString&, QString&) } } -//______________________________________________________________________________ +/***************************************************************************//** + * A slot for the onDisconnected signal of the ConnectWindow. This slot will + * change the UI according to the state fo the connection. + */ void Toolbar::onDisconnected() { _connectWindow->setConnected(false); @@ -121,7 +151,12 @@ void Toolbar::onDisconnected() _ui->lblStatus->setText(tr("Offline")); } -//______________________________________________________________________________ +/***************************************************************************//** + * A slot for the onConnected signal of the ConnectWindow. This slot will + * change the UI according to the state of the connection and connect the + * relevant signals and slots. + * @param connection Pointer to the ServerConnection + */ void Toolbar::onConnected(ServerConnection* connection) { _ui->lblStatus->setStyleSheet("color:green"); @@ -142,14 +177,19 @@ void Toolbar::onConnected(ServerConnection* connection) _connectWindow->setConnected(true); } -//______________________________________________________________________________ +/***************************************************************************//** + * + */ void Toolbar::onDoDisconnect() { if (_connection != NULL) _connection->disconnectFromServer(); } -//______________________________________________________________________________ +/***************************************************************************//** + * This slot hides the toolbar. Places the toolbar hidden behind the edge of the + * screen just showing 2 pixels. + */ void Toolbar::hideBar() { // // Don't hide window if any menu is open or VNC Server is running from this client. @@ -161,7 +201,9 @@ void Toolbar::hideBar() //move(x(), primaryScreen.bottom() - 2); } -//______________________________________________________________________________ +/***************************************************************************//** + * This slot shows the toolbar. Used after a hideBar(). + */ void Toolbar::showBar() { const QDesktopWidget desktop; -- cgit v1.2.3-55-g7522