From a84954b14912b0bbf23ee78ace1a652974ab007f Mon Sep 17 00:00:00 2001 From: Manuel Schneider Date: Tue, 3 Jun 2014 16:04:58 +0200 Subject: Lock the buttons until the new vnc server sent a reply about its state. If this fails, unlock the buttons after a timeout of 2 seconds --- src/server/mainwindow/mainwindow.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/server/mainwindow/mainwindow.cpp') diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp index 489800f..28177d6 100644 --- a/src/server/mainwindow/mainwindow.cpp +++ b/src/server/mainwindow/mainwindow.cpp @@ -103,9 +103,12 @@ MainWindow::MainWindow(QString ipListUrl, QWidget* parent) : /* Stuff for the button lock */ + //Setup a timeout _buttonLockTimer = new QTimer(this); _buttonLockTimer->setSingleShot(true); _buttonLockTimer->setInterval(_buttonBlockTime); + connect(_buttonLockTimer, SIGNAL(timeout()), this, SLOT(EnableButtons())); + // Define the locking buttons _lockingButtons << ui->action_Lock << ui->action_BroadcastScreen @@ -114,15 +117,6 @@ MainWindow::MainWindow(QString ipListUrl, QWidget* parent) : << ui->action_TutorToStudent << ui->action_StopProjection << ui->action_SetAsTutor; - // Disable the buttons if a button is clicked - foreach (QAction* a, _lockingButtons) - connect(a, SIGNAL(triggered()), this, SLOT(DisableButtons())); - // Start the timer a button is clicked - foreach (QAction* a, _lockingButtons) - connect(a, SIGNAL(triggered()), _buttonLockTimer, SLOT(start())); - // Enable the buttons if the timer fires - connect(_buttonLockTimer, SIGNAL(timeout()), this, SLOT(EnableButtons())); - // Clicking the session name label shows the edit field for it connect(_sessionNameLabel, SIGNAL(clicked()), this, SLOT(onSessionNameClick())); @@ -474,6 +468,8 @@ void MainWindow::onSessionNameUpdate() */ void MainWindow::changeProjection(Client *from, Mode mode, Client *to) { + DisableButtons(); + if (mode == Mode::Broadcast) { // Set all clients as watchers @@ -853,6 +849,9 @@ void MainWindow::onClientAuthenticated(Client* client) */ void MainWindow::onVncServerStateChange(Client* client) { + if (client == _streamingSource) + EnableButtons(); + if (client->isActiveVncServer()) { if (_mode == Mode::Broadcast) @@ -931,6 +930,7 @@ void MainWindow::onVncClientStateChange(Client* client) */ void MainWindow::DisableButtons() { + _buttonLockTimer->start(); foreach (QAction* a, _lockingButtons) a->setDisabled(true); } @@ -940,6 +940,7 @@ void MainWindow::DisableButtons() */ void MainWindow::EnableButtons() { + _buttonLockTimer->stop(); foreach (QAction* a, _lockingButtons) a->setEnabled(true); } -- cgit v1.2.3-55-g7522