summaryrefslogtreecommitdiffstats
path: root/src/server/mainwindow/mainwindow.cpp
diff options
context:
space:
mode:
authorManuel Schneider2014-04-24 16:33:26 +0200
committerManuel Schneider2014-04-24 16:33:26 +0200
commitf6b3c21e5a3ea0307a87a9d7a471ae834145151a (patch)
treeaf2c6ece72e68ecdd6bce5bd8bcd66ba1d06c119 /src/server/mainwindow/mainwindow.cpp
parentDoxygen comments, removed incomplete unused event handling for VNC RW access,... (diff)
downloadpvs2-f6b3c21e5a3ea0307a87a9d7a471ae834145151a.tar.gz
pvs2-f6b3c21e5a3ea0307a87a9d7a471ae834145151a.tar.xz
pvs2-f6b3c21e5a3ea0307a87a9d7a471ae834145151a.zip
Reduced button block code. Moved some magic number to header.
Diffstat (limited to 'src/server/mainwindow/mainwindow.cpp')
-rw-r--r--src/server/mainwindow/mainwindow.cpp48
1 files changed, 24 insertions, 24 deletions
diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp
index 4909fb9..6534179 100644
--- a/src/server/mainwindow/mainwindow.cpp
+++ b/src/server/mainwindow/mainwindow.cpp
@@ -36,9 +36,7 @@
#include "ui_mainwindow.h"
MainWindow::MainWindow(QString ipListUrl, QWidget* parent) :
- QMainWindow(parent), ui(new Ui::MainWindow), _tbIconSize(24), _tbArea(Qt::LeftToolBarArea),
- _buttonBlockTime(0)
-
+ QMainWindow(parent), ui(new Ui::MainWindow), _tbIconSize(24), _tbArea(Qt::LeftToolBarArea)
{
_sessionNameWindow = new SessionNameWindow(this);
ui->setupUi(this);
@@ -87,8 +85,6 @@ MainWindow::MainWindow(QString ipListUrl, QWidget* parent) :
setUnifiedTitleAndToolBarOnMac(true);
this->showMaximized(); // show the Mainwindow maximized
- _tilesX = 9;
- _tilesY = 7;
_tileWidth = 10;
_tileHeight = 10;
@@ -382,6 +378,16 @@ bool MainWindow::isValidClient(Client* client)
return false;
}
+bool MainWindow::areButtonsBlocked()
+{
+ bool result;
+ static qint64 buttonsBlockedUntil = 0;
+ qint64 now = QDateTime::currentMSecsSinceEpoch();
+ if (!(result = now < buttonsBlockedUntil))
+ buttonsBlockedUntil = now + _buttonBlockTime;
+ return result;
+}
+
void MainWindow::prepareForProjection(Client * const from, Client * const to)
{
// Projection source is never allowed to be an active VNC viewer
@@ -465,11 +471,9 @@ void MainWindow::prepareForProjection(Client * const from, Client * const to)
void MainWindow::onButtonStudentToAll()
{
- const qint64 now = QDateTime::currentMSecsSinceEpoch();
- if (now < _buttonBlockTime)
+ if (areButtonsBlocked())
return;
- _buttonBlockTime = now + 3000;
- //
+
Client *from = NULL;
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
{
@@ -492,11 +496,9 @@ void MainWindow::onButtonStudentToAll()
void MainWindow::onButtonStudentToTutor()
{
- const qint64 now = QDateTime::currentMSecsSinceEpoch();
- if (now < _buttonBlockTime)
+ if (areButtonsBlocked())
return;
- _buttonBlockTime = now + 3000;
- //
+
Client *from = NULL;
Client *to = NULL;
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
@@ -530,10 +532,9 @@ void MainWindow::onButtonStudentToTutor()
void MainWindow::onButtonTutorToAll()
{
- const qint64 now = QDateTime::currentMSecsSinceEpoch();
- if (now < _buttonBlockTime)
+ if (areButtonsBlocked())
return;
- _buttonBlockTime = now + 3000;
+
//
Client *from = NULL;
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
@@ -557,11 +558,9 @@ void MainWindow::onButtonTutorToAll()
void MainWindow::onButtonTutorToStudent()
{
- const qint64 now = QDateTime::currentMSecsSinceEpoch();
- if (now < _buttonBlockTime)
+ if (areButtonsBlocked())
return;
- _buttonBlockTime = now + 3000;
- //
+
Client *from = NULL;
Client *to = NULL;
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
@@ -595,11 +594,9 @@ void MainWindow::onButtonTutorToStudent()
void MainWindow::onButtonStopProjection()
{
- const qint64 now = QDateTime::currentMSecsSinceEpoch();
- if (now < _buttonBlockTime)
+ if (areButtonsBlocked())
return;
- _buttonBlockTime = now + 3000;
- //
+
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
{
Client *c = (**it).client();
@@ -624,6 +621,9 @@ void MainWindow::onButtonStopProjection()
void MainWindow::onButtonLock(bool checked)
{
+ if (areButtonsBlocked())
+ return;
+
NetworkMessage msg;
msg.setField(_ID, _LOCK);
if (checked)