diff options
author | Manuel Schneider | 2014-04-29 19:59:11 +0200 |
---|---|---|
committer | Manuel Schneider | 2014-04-29 19:59:11 +0200 |
commit | e361357e513b8a3ed044dd22c548dae5fefe8ad5 (patch) | |
tree | 86b320bf2396a5da1dfd7effeea95d7af5cbbcf2 /src/server | |
parent | Adding comments for each method in the .cpp files and class definition in the... (diff) | |
download | pvs2-e361357e513b8a3ed044dd22c548dae5fefe8ad5.tar.gz pvs2-e361357e513b8a3ed044dd22c548dae5fefe8ad5.tar.xz pvs2-e361357e513b8a3ed044dd22c548dae5fefe8ad5.zip |
Disable all buttons if one is clicked and enable them after a specified time
Diffstat (limited to 'src/server')
-rw-r--r-- | src/server/mainwindow/mainwindow.cpp | 56 | ||||
-rw-r--r-- | src/server/mainwindow/mainwindow.h | 4 |
2 files changed, 33 insertions, 27 deletions
diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp index 3ed2b57..ba5cdbc 100644 --- a/src/server/mainwindow/mainwindow.cpp +++ b/src/server/mainwindow/mainwindow.cpp @@ -462,20 +462,6 @@ bool MainWindow::isValidClient(Client* client) } /** - * Check if buttons are blocked. - * @return If buttons are blocked or not. - */ -bool MainWindow::areButtonsBlocked() -{ - bool result; - static qint64 buttonsBlockedUntil = 0; - qint64 now = QDateTime::currentMSecsSinceEpoch(); - if (!(result = now < buttonsBlockedUntil)) - buttonsBlockedUntil = now + _buttonBlockTime; - return result; -} - -/** * Handle VNC settings for a projection from "from" to "to". * Check if projection source is active vnc client. * Check if projection is One --> Many or One --> One. @@ -571,8 +557,8 @@ void MainWindow::prepareForProjection(Client * const from, Client * const to) */ void MainWindow::onButtonStudentToAll() { - if (areButtonsBlocked()) - return; + DisableButtons(); + QTimer::singleShot(_buttonBlockTime, this, SLOT(EnableButtons())); Client *from = NULL; for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) @@ -601,8 +587,8 @@ void MainWindow::onButtonStudentToAll() */ void MainWindow::onButtonStudentToTutor() { - if (areButtonsBlocked()) - return; + DisableButtons(); + QTimer::singleShot(_buttonBlockTime, this, SLOT(EnableButtons())); Client *from = NULL; Client *to = NULL; @@ -643,8 +629,8 @@ void MainWindow::onButtonStudentToTutor() */ void MainWindow::onButtonTutorToAll() { - if (areButtonsBlocked()) - return; + DisableButtons(); + QTimer::singleShot(_buttonBlockTime, this, SLOT(EnableButtons())); // Client *from = NULL; @@ -674,8 +660,8 @@ void MainWindow::onButtonTutorToAll() */ void MainWindow::onButtonTutorToStudent() { - if (areButtonsBlocked()) - return; + DisableButtons(); + QTimer::singleShot(_buttonBlockTime, this, SLOT(EnableButtons())); Client *from = NULL; Client *to = NULL; @@ -715,8 +701,8 @@ void MainWindow::onButtonTutorToStudent() */ void MainWindow::onButtonStopProjection() { - if (areButtonsBlocked()) - return; + DisableButtons(); + QTimer::singleShot(_buttonBlockTime, this, SLOT(EnableButtons())); for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) { @@ -748,8 +734,8 @@ void MainWindow::onButtonStopProjection() */ void MainWindow::onButtonLock(bool checked) { - if (areButtonsBlocked()) - return; + DisableButtons(); + QTimer::singleShot(_buttonBlockTime, this, SLOT(EnableButtons())); NetworkMessage msg; msg.setField(_ID, _LOCK); @@ -1060,3 +1046,21 @@ void MainWindow::onVncClientStateChange(Client* client, int lastProjectionSource if (!inUse && server != NULL) server->stopVncServer(); } + +void MainWindow::DisableButtons() +{ + ui->action_BroadcastScreen->setDisabled(true); + ui->action_TutorToAll->setDisabled(true); + ui->action_StudentToTutor->setDisabled(true); + ui->action_TutorToStudent->setDisabled(true); + ui->action_StopProjection->setDisabled(true); +} + +void MainWindow::EnableButtons() +{ + ui->action_BroadcastScreen->setEnabled(true); + ui->action_TutorToAll->setEnabled(true); + ui->action_StudentToTutor->setEnabled(true); + ui->action_TutorToStudent->setEnabled(true); + ui->action_StopProjection->setEnabled(true); +} diff --git a/src/server/mainwindow/mainwindow.h b/src/server/mainwindow/mainwindow.h index e5179ed..38b0f83 100644 --- a/src/server/mainwindow/mainwindow.h +++ b/src/server/mainwindow/mainwindow.h @@ -61,7 +61,6 @@ private: void savePosition(ConnectionFrame *cf); void prepareForProjection(Client * const from, Client * const to); bool isValidClient(Client* client); - bool areButtonsBlocked(); public: MainWindow(QString ipListUrl, QWidget *parent = 0); @@ -98,5 +97,8 @@ protected slots: void onClientAuthenticated(Client* client); void onVncServerStateChange(Client* client); void onVncClientStateChange(Client* client, int lastProjectionSource); + //Buttons + void DisableButtons(); + void EnableButtons(); }; #endif |