summaryrefslogtreecommitdiffstats
path: root/src/server
diff options
context:
space:
mode:
authorSimon Rettberg2018-07-12 15:58:29 +0200
committerSimon Rettberg2018-07-12 15:58:29 +0200
commit07778419d9e522085fbaf8da8d13e63717f54d31 (patch)
treeb185ef5ddfccb829725fab8500bc50da4eb82cac /src/server
parent[client] top/bottom position detection (diff)
downloadpvs2-07778419d9e522085fbaf8da8d13e63717f54d31.tar.gz
pvs2-07778419d9e522085fbaf8da8d13e63717f54d31.tar.xz
pvs2-07778419d9e522085fbaf8da8d13e63717f54d31.zip
[server] Add button to lock/unlock single client
Diffstat (limited to 'src/server')
-rw-r--r--src/server/mainwindow/mainwindow.cpp37
-rw-r--r--src/server/mainwindow/mainwindow.h1
-rw-r--r--src/server/net/client.cpp5
3 files changed, 38 insertions, 5 deletions
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);