From adbc49a0e2ad1b03558c6495cea49307c3db0381 Mon Sep 17 00:00:00 2001 From: Manuel Schneider Date: Wed, 30 Apr 2014 14:50:56 +0200 Subject: KISS'n'DRY for more cohesion --- src/server/mainwindow/mainwindow.cpp | 42 ++++++++++++++---------------------- 1 file changed, 16 insertions(+), 26 deletions(-) (limited to 'src/server/mainwindow/mainwindow.cpp') diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp index 29f4bc5..3d0d167 100644 --- a/src/server/mainwindow/mainwindow.cpp +++ b/src/server/mainwindow/mainwindow.cpp @@ -85,20 +85,20 @@ MainWindow::MainWindow(QString ipListUrl, QWidget* parent) : _buttonLockTimer = new QTimer(this); _buttonLockTimer->setSingleShot(true); _buttonLockTimer->setInterval(_buttonBlockTime); + _lockingButtons + << ui->action_Lock + << ui->action_BroadcastScreen + << ui->action_TutorToAll + << ui->action_StudentToTutor + << ui->action_TutorToStudent + << ui->action_StopProjection + << ui->action_SetAsTutor; // 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())); + foreach (QAction* a, _lockingButtons) + connect(a, 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())); + 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())); @@ -1054,22 +1054,12 @@ void MainWindow::onVncClientStateChange(Client* client, int lastProjectionSource void MainWindow::DisableButtons() { - 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); + foreach (QAction* a, _lockingButtons) + a->setDisabled(true); } void MainWindow::EnableButtons() { - 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); + foreach (QAction* a, _lockingButtons) + a->setEnabled(true); } -- cgit v1.2.3-55-g7522