summaryrefslogtreecommitdiffstats
path: root/src/server/mainwindow/mainwindow.cpp
diff options
context:
space:
mode:
authorSimon Rettberg2017-03-06 16:01:30 +0100
committerSimon Rettberg2017-03-06 16:01:30 +0100
commit35c7c33c23685e00bc981a3809a3f3a3597c2f9a (patch)
treede55d0e2e81eb1842709028319237266f277c7e9 /src/server/mainwindow/mainwindow.cpp
parentUpdate translations (diff)
downloadpvs2-35c7c33c23685e00bc981a3809a3f3a3597c2f9a.tar.gz
pvs2-35c7c33c23685e00bc981a3809a3f3a3597c2f9a.tar.xz
pvs2-35c7c33c23685e00bc981a3809a3f3a3597c2f9a.zip
[server] Prevent screen standby while clients are connected
Diffstat (limited to 'src/server/mainwindow/mainwindow.cpp')
-rw-r--r--src/server/mainwindow/mainwindow.cpp35
1 files changed, 22 insertions, 13 deletions
diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp
index 0a77240..a984173 100644
--- a/src/server/mainwindow/mainwindow.cpp
+++ b/src/server/mainwindow/mainwindow.cpp
@@ -35,6 +35,7 @@
#include "../net/filedownloader.h"
// Others
#include "../../shared/settings.h"
+#include "../util/platform/screensaver.h"
// Auto-generated ui class
#include "ui_mainwindow.h"
#include "ui_reloadroom.h"
@@ -62,7 +63,8 @@ using std::endl;
* @param parent
*/
MainWindow::MainWindow(QWidget* parent) :
- QMainWindow(parent), ui(new Ui::MainWindow), _tbIconSize(24), _tbArea(Qt::LeftToolBarArea)
+ QMainWindow(parent), ui(new Ui::MainWindow), _tbIconSize(24), _tbArea(Qt::LeftToolBarArea),
+ _lastClientCount(0)
{
qDebug() << "MainWindow(parent)";
_mode = Mode::Multicast;
@@ -108,7 +110,7 @@ MainWindow::MainWindow(QWidget* parent) :
ui->toolBar->insertWidget(ui->action_TutorToStudent, _examModeLabel);
serverApp->setExam(false);
- updateExamMode();
+ clientCountChanged();
// Close button in tool bar
connect(ui->action_Exit, SIGNAL(triggered()), this, SLOT(onButtonExit()));
@@ -181,22 +183,22 @@ MainWindow::MainWindow(QWidget* parent) :
/** this function determines if the number of clients in exam mode comprise
* more than 50%. In that case the whole manager switches to exam mode,
* disabling many features in the toolbar **/
-void MainWindow::updateExamMode()
+void MainWindow::clientCountChanged()
{
- int numerator = 0;
- int denominator = 0;
+ int examClientCount = 0;
+ int clientCount = 0;
for (auto it = _clientFrames.begin(); it != _clientFrames.end(); ++it) {
Client* c = (*it)->client();
if (c != NULL) {
bool b = c->isExamMode();
- numerator += b ? 1 : 0;
- denominator++;
+ examClientCount += b ? 1 : 0;
+ clientCount++;
}
}
- serverApp->setExam(numerator * 2 >= denominator && denominator > 0);
+ serverApp->setExam(examClientCount * 2 >= clientCount && clientCount > 0);
bool e = serverApp->isExam();
qDebug() << "isExam is " << e;
ui->action_TutorToAll->setVisible(!e);
@@ -207,8 +209,15 @@ void MainWindow::updateExamMode()
_examModeLabel->setVisible(e);
_examModeLabel->setFixedHeight(e ? 400 : 0);
-
-
+ if (_lastClientCount != clientCount) {
+ if (clientCount == 0) {
+ ScreenSaver::allowSaverAndStandby(true);
+ } else {
+ ScreenSaver::forceUnlockAndScreenOn();
+ ScreenSaver::allowSaverAndStandby(false);
+ }
+ _lastClientCount = clientCount;
+ }
}
MainWindow::~MainWindow()
@@ -1149,7 +1158,7 @@ void MainWindow::onClientAuthenticated(Client* client)
// qDebug() << "Should go into this if clause.";
existing->assignClient(client);
tellClientCurrentSituation(client);
- updateExamMode();
+ clientCountChanged();
return;
}
@@ -1160,7 +1169,7 @@ void MainWindow::onClientAuthenticated(Client* client)
//resizeEvent(NULL); // This is where all the positioning should be
tellClientCurrentSituation(client);
- updateExamMode();
+ clientCountChanged();
}
@@ -1294,7 +1303,7 @@ void MainWindow::onDeleteClient()
frame->deleteLater();
_clientFrames.removeOne(frame);
lockContextButtons();
- updateExamMode();
+ clientCountChanged();
return;
}
}