summaryrefslogtreecommitdiffstats
path: root/src/server/mainwindow/mainwindow.cpp
diff options
context:
space:
mode:
authorManuel Schneider2014-04-30 14:04:30 +0200
committerManuel Schneider2014-04-30 14:04:30 +0200
commit8568fa8080d5466f271b1c916be0ebb58b0e89ea (patch)
treea045c326fce2beba7752e7e9e4697e348f2d62ef /src/server/mainwindow/mainwindow.cpp
parentDisable all buttons if one is clicked and enable them after a specified time (diff)
downloadpvs2-8568fa8080d5466f271b1c916be0ebb58b0e89ea.tar.gz
pvs2-8568fa8080d5466f271b1c916be0ebb58b0e89ea.tar.xz
pvs2-8568fa8080d5466f271b1c916be0ebb58b0e89ea.zip
cant fire the timer inside the button slots since they are called somewhere wlse too
Diffstat (limited to 'src/server/mainwindow/mainwindow.cpp')
-rw-r--r--src/server/mainwindow/mainwindow.cpp65
1 files changed, 37 insertions, 28 deletions
diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp
index ba5cdbc..29f4bc5 100644
--- a/src/server/mainwindow/mainwindow.cpp
+++ b/src/server/mainwindow/mainwindow.cpp
@@ -80,6 +80,29 @@ MainWindow::MainWindow(QString ipListUrl, QWidget* parent) :
connect(ui->action_SetAsTutor, SIGNAL(triggered()), this, SLOT(onButtonSetAsTutor()));
connect(ui->action_SetAsTutor, SIGNAL(triggered()), this, SLOT(onButtonStopProjection()));
connect(ui->action_Lock, SIGNAL(toggled(bool)), this, SLOT(onButtonLock(bool)));
+
+ /* Stuff for the button lock */
+ _buttonLockTimer = new QTimer(this);
+ _buttonLockTimer->setSingleShot(true);
+ _buttonLockTimer->setInterval(_buttonBlockTime);
+ // Disable the buttons if a button is clicked
+ connect(ui->action_Lock, SIGNAL(triggered()), this, SLOT(DisableButtons()));
+ connect(ui->action_BroadcastScreen, SIGNAL(triggered()), this, SLOT(DisableButtons()));
+ connect(ui->action_TutorToAll, SIGNAL(triggered()), this, SLOT(DisableButtons()));
+ connect(ui->action_StudentToTutor, SIGNAL(triggered()), this, SLOT(DisableButtons()));
+ connect(ui->action_TutorToStudent, SIGNAL(triggered()), this, SLOT(DisableButtons()));
+ connect(ui->action_StopProjection, SIGNAL(triggered()), this, SLOT(DisableButtons()));
+ // Start the timer a button is clicked
+ connect(ui->action_Lock, SIGNAL(triggered()), _buttonLockTimer, SLOT(start()));
+ connect(ui->action_BroadcastScreen, SIGNAL(triggered()), _buttonLockTimer, SLOT(start()));
+ connect(ui->action_TutorToAll, SIGNAL(triggered()), _buttonLockTimer, SLOT(start()));
+ connect(ui->action_StudentToTutor, SIGNAL(triggered()), _buttonLockTimer, SLOT(start()));
+ connect(ui->action_TutorToStudent, SIGNAL(triggered()), _buttonLockTimer, SLOT(start()));
+ connect(ui->action_StopProjection, 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()));
// Listen to updates to the session name through the session name window
@@ -557,9 +580,6 @@ void MainWindow::prepareForProjection(Client * const from, Client * const to)
*/
void MainWindow::onButtonStudentToAll()
{
- DisableButtons();
- QTimer::singleShot(_buttonBlockTime, this, SLOT(EnableButtons()));
-
Client *from = NULL;
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
{
@@ -587,9 +607,6 @@ void MainWindow::onButtonStudentToAll()
*/
void MainWindow::onButtonStudentToTutor()
{
- DisableButtons();
- QTimer::singleShot(_buttonBlockTime, this, SLOT(EnableButtons()));
-
Client *from = NULL;
Client *to = NULL;
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
@@ -629,9 +646,6 @@ void MainWindow::onButtonStudentToTutor()
*/
void MainWindow::onButtonTutorToAll()
{
- DisableButtons();
- QTimer::singleShot(_buttonBlockTime, this, SLOT(EnableButtons()));
-
//
Client *from = NULL;
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
@@ -660,9 +674,6 @@ void MainWindow::onButtonTutorToAll()
*/
void MainWindow::onButtonTutorToStudent()
{
- DisableButtons();
- QTimer::singleShot(_buttonBlockTime, this, SLOT(EnableButtons()));
-
Client *from = NULL;
Client *to = NULL;
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
@@ -701,9 +712,6 @@ void MainWindow::onButtonTutorToStudent()
*/
void MainWindow::onButtonStopProjection()
{
- DisableButtons();
- QTimer::singleShot(_buttonBlockTime, this, SLOT(EnableButtons()));
-
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
{
Client *c = (**it).client();
@@ -734,9 +742,6 @@ void MainWindow::onButtonStopProjection()
*/
void MainWindow::onButtonLock(bool checked)
{
- DisableButtons();
- QTimer::singleShot(_buttonBlockTime, this, SLOT(EnableButtons()));
-
NetworkMessage msg;
msg.setField(_ID, _LOCK);
if (checked)
@@ -1049,18 +1054,22 @@ void MainWindow::onVncClientStateChange(Client* client, int lastProjectionSource
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);
+ ui->action_Lock->setDisabled(true);
+ 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);
+ ui->action_SetAsTutor->setEnabled(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);
+ ui->action_Lock->setEnabled(true);
+ 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);
+ ui->action_SetAsTutor->setEnabled(true);
}