From 07778419d9e522085fbaf8da8d13e63717f54d31 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 12 Jul 2018 15:58:29 +0200 Subject: [server] Add button to lock/unlock single client --- gui/server_normal/mainwindow.ui | 16 ++++++++++++++-- pvsmgr.qrc | 1 + src/server/mainwindow/mainwindow.cpp | 37 ++++++++++++++++++++++++++++++++---- src/server/mainwindow/mainwindow.h | 1 + src/server/net/client.cpp | 5 ++++- 5 files changed, 53 insertions(+), 7 deletions(-) diff --git a/gui/server_normal/mainwindow.ui b/gui/server_normal/mainwindow.ui index cb6888a..1f58ec4 100644 --- a/gui/server_normal/mainwindow.ui +++ b/gui/server_normal/mainwindow.ui @@ -142,6 +142,7 @@ QLabel#examModeLabel { + @@ -225,7 +226,7 @@ QLabel#examModeLabel { - + :/reset:/reset @@ -286,10 +287,21 @@ QLabel#examModeLabel { Reload Room Configuration + + + + :/lock-single:/lock-single + + + Lock/Unlock single client + + + Lock or unlock the selected client + + - diff --git a/pvsmgr.qrc b/pvsmgr.qrc index f117322..b6bd891 100644 --- a/pvsmgr.qrc +++ b/pvsmgr.qrc @@ -4,6 +4,7 @@ icons/terminal.svg icons/photo.svg icons/lock.svg + icons/lock-single.svg icons/dozent.svg icons/eye.svg icons/cam32.svg diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp index cb3ef86..8d5bd4a 100644 --- a/src/server/mainwindow/mainwindow.cpp +++ b/src/server/mainwindow/mainwindow.cpp @@ -122,6 +122,7 @@ MainWindow::MainWindow(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))); + connect(ui->action_LockSingle, SIGNAL(triggered()), this, SLOT(onButtonLockSingle())); connect(ui->action_Help, SIGNAL(triggered()), this, SLOT(onButtonHelp())); connect(ui->actionReload_Room_Configuration, SIGNAL(triggered()), this, SLOT(onButtonReloadRoomConfig())); connect(ui->action_DeleteClient, SIGNAL(triggered()), this, SLOT(onDeleteClient())); @@ -132,14 +133,14 @@ MainWindow::MainWindow(QWidget* parent) : // Global::setExam(conf->value("examMode").toBool()); // } - /* disable context-sensitive buttons by default */ _contextButtons << ui->action_DeleteClient << ui->action_StudentToTutor << ui->action_StudentToTutorExclusive << ui->action_SetAsTutor - << ui->action_TutorToStudent; + << ui->action_TutorToStudent + << ui->action_LockSingle; lockContextButtons(); @@ -578,6 +579,7 @@ void MainWindow::unlockContextButtons() ui->action_StudentToTutorExclusive->setEnabled(false); ui->action_StudentToTutor->setEnabled(false); ui->action_TutorToStudent->setEnabled(false); + ui->action_LockSingle->setEnabled(false); } @@ -1035,6 +1037,35 @@ void MainWindow::onButtonLock(bool checked) } } +void MainWindow::onButtonLockSingle() +{ + // If no frame is selected, warning. + if (getSelectedFrame() == NULL) { + QMessageBox::critical(this, tr("Selection"), tr("No client is selected.")); + return; + } + Client *client = getSelectedFrame()->client(); + + // If frame of inactive client has been selected unselect it + if (client == NULL) { + QMessageBox::critical(this, tr("Selection"), tr("The selected client is not connected.")); + return; + } else { // If selected client is locked, first unlock + bool newState = !client->isLocked(); + client->lockScreen(newState); + if (!newState) { + // If no more clients are locked, reset button + for (QList::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) { + if ((*it)->client() == NULL) + continue; + if ((*it)->client()->isLocked()) + return; + } + ui->action_Lock->setChecked(false); + } + } +} + /***************************************************************************//** * On button exit, close application. */ @@ -1049,8 +1080,6 @@ void MainWindow::onButtonExit() */ void MainWindow::onButtonSetAsTutor() { - ui->action_Lock->setChecked(false); - // If no frame is selected, warning. if (getSelectedFrame() == NULL) { QMessageBox::critical(this, tr("Selection"), tr("No client is selected.")); diff --git a/src/server/mainwindow/mainwindow.h b/src/server/mainwindow/mainwindow.h index a07e710..ba24bae 100644 --- a/src/server/mainwindow/mainwindow.h +++ b/src/server/mainwindow/mainwindow.h @@ -114,6 +114,7 @@ protected slots: void onDeleteClient(); void onButtonLock(bool checked); + void onButtonLockSingle(); void onButtonStudentToTutor(); void onButtonStudentToTutorExclusive(); void onButtonTutorToAll(); diff --git a/src/server/net/client.cpp b/src/server/net/client.cpp index 82ebf26..7f94983 100644 --- a/src/server/net/client.cpp +++ b/src/server/net/client.cpp @@ -323,7 +323,10 @@ bool Client::isManagerMachine() /******************************************************************************/ void Client::lockScreen(bool lock) { - if (!_isTutor && _locked != lock && !isManagerMachine()) { + if (_isTutor || isManagerMachine()) { + lock = false; + } + if (_locked != lock) { _locked = lock; NetworkMessage msg; msg.setField(_ID, _LOCK); -- cgit v1.2.3-55-g7522