diff options
author | Simon Rettberg | 2018-07-12 15:58:29 +0200 |
---|---|---|
committer | Simon Rettberg | 2018-07-12 15:58:29 +0200 |
commit | 07778419d9e522085fbaf8da8d13e63717f54d31 (patch) | |
tree | b185ef5ddfccb829725fab8500bc50da4eb82cac | |
parent | [client] top/bottom position detection (diff) | |
download | pvs2-07778419d9e522085fbaf8da8d13e63717f54d31.tar.gz pvs2-07778419d9e522085fbaf8da8d13e63717f54d31.tar.xz pvs2-07778419d9e522085fbaf8da8d13e63717f54d31.zip |
[server] Add button to lock/unlock single client
-rw-r--r-- | gui/server_normal/mainwindow.ui | 16 | ||||
-rw-r--r-- | pvsmgr.qrc | 1 | ||||
-rw-r--r-- | src/server/mainwindow/mainwindow.cpp | 37 | ||||
-rw-r--r-- | src/server/mainwindow/mainwindow.h | 1 | ||||
-rw-r--r-- | 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 { </attribute> <addaction name="actionReload_Room_Configuration"/> <addaction name="action_Lock"/> + <addaction name="action_LockSingle"/> <addaction name="action_TutorToAll"/> <addaction name="action_TutorToStudent"/> <addaction name="action_StudentToTutor"/> @@ -225,7 +226,7 @@ QLabel#examModeLabel { </action> <action name="action_StopProjection"> <property name="icon"> - <iconset resource="../../pvsclient.qrc"> + <iconset resource="../../pvsmgr.qrc"> <normaloff>:/reset</normaloff>:/reset</iconset> </property> <property name="text"> @@ -286,10 +287,21 @@ QLabel#examModeLabel { <string>Reload Room Configuration</string> </property> </action> + <action name="action_LockSingle"> + <property name="icon"> + <iconset resource="../../pvsmgr.qrc"> + <normaloff>:/lock-single</normaloff>:/lock-single</iconset> + </property> + <property name="text"> + <string>Lock/Unlock single client</string> + </property> + <property name="toolTip"> + <string>Lock or unlock the selected client</string> + </property> + </action> </widget> <layoutdefault spacing="6" margin="11"/> <resources> - <include location="../../pvsclient.qrc"/> <include location="../../pvsmgr.qrc"/> </resources> <connections/> @@ -4,6 +4,7 @@ <file alias="terminal">icons/terminal.svg</file> <file alias="photo">icons/photo.svg</file> <file alias="lock">icons/lock.svg</file> + <file alias="lock-single">icons/lock-single.svg</file> <file alias="dozent">icons/dozent.svg</file> <file alias="eye">icons/eye.svg</file> <file alias="cam32">icons/cam32.svg</file> 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<ConnectionFrame*>::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); |