summaryrefslogtreecommitdiffstats
path: root/src/server/mainwindow
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
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')
-rw-r--r--src/server/mainwindow/mainwindow.cpp48
-rw-r--r--src/server/mainwindow/mainwindow.h66
2 files changed, 57 insertions, 57 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)
diff --git a/src/server/mainwindow/mainwindow.h b/src/server/mainwindow/mainwindow.h
index 2bba8c3..4b23ae7 100644
--- a/src/server/mainwindow/mainwindow.h
+++ b/src/server/mainwindow/mainwindow.h
@@ -18,46 +18,49 @@ namespace Ui
class MainWindow : public QMainWindow
{
- Q_OBJECT
+ Q_OBJECT
private:
- Ui::MainWindow *ui;
- SessionNameWindow *_sessionNameWindow;
- QLabel *_sessionNameLabel;
- QList<ConnectionFrame*> _clientFrames;
- int _tileWidth, _tileHeight;
- int _tilesX, _tilesY;
- int _tbIconSize;
- Qt::ToolBarArea _tbArea;
- int _timerId, _timerTimeout;
- ListenServer *_listenServer;
- DiscoveryListener *_discoveryListener;
- qint64 _buttonBlockTime;
- FileDownloader _fileDownloader;
- QStringList _tutorList;
+ Ui::MainWindow *ui;
+ SessionNameWindow *_sessionNameWindow;
+ QLabel *_sessionNameLabel;
+ QList<ConnectionFrame*> _clientFrames;
+ int _tbIconSize;
+ Qt::ToolBarArea _tbArea;
+ int _tileWidth, _tileHeight;
+ int _timerId, _timerTimeout;
+ ListenServer *_listenServer;
+ DiscoveryListener *_discoveryListener;
+ FileDownloader _fileDownloader;
+ QStringList _tutorList;
- void placeFrameInFreeSlot(ConnectionFrame* frame);
- ConnectionFrame* createFrame();
- bool loadPosition(QSettings& settings, const QString& id, int& x, int& y);
- void savePosition(ConnectionFrame *cf);
- void prepareForProjection(Client * const from, Client * const to);
- bool isValidClient(Client* client);
+ // Magic numbers
+ static const qint64 _buttonBlockTime = 1000;
+ static const int _tilesX = 9;
+ static const int _tilesY = 7;
+
+ void placeFrameInFreeSlot(ConnectionFrame* frame);
+ ConnectionFrame* createFrame();
+ bool loadPosition(QSettings& settings, const QString& id, int& x, int& y);
+ void savePosition(ConnectionFrame *cf);
+ void prepareForProjection(Client * const from, Client * const to);
+ bool isValidClient(Client* client);
+ bool areButtonsBlocked();
public:
- MainWindow(QString ipListUrl, QWidget *parent = 0);
- ~MainWindow();
+ MainWindow(QString ipListUrl, QWidget *parent = 0);
+ ~MainWindow();
protected:
- void closeEvent(QCloseEvent *e);
- void changeEvent(QEvent *e);
- void resizeEvent(QResizeEvent *e);
- void mouseReleaseEvent(QMouseEvent* e);
- void timerEvent(QTimerEvent* event);
-
+ void closeEvent(QCloseEvent *e);
+ void changeEvent(QEvent *e);
+ void resizeEvent(QResizeEvent *e);
+ void mouseReleaseEvent(QMouseEvent* e);
+ void timerEvent(QTimerEvent* event);
protected slots:
// This
- void onTutorListDownloaded(QByteArray& tutorList);
+ void onTutorListDownloaded(QByteArray& tutorList);
void onSessionNameClick();
void onSessionNameUpdate();
void onButtonSettings();
@@ -79,8 +82,5 @@ protected slots:
void onClientAuthenticated(Client* client);
void onVncServerStateChange(Client* client);
void onVncClientStateChange(Client* client, int lastProjectionSource);
-
};
-
-
#endif