summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Schneider2014-04-30 15:11:47 +0200
committerManuel Schneider2014-04-30 15:11:47 +0200
commita7aa883f638d5c53d760d14ba2f1e9694197490d (patch)
tree84326477167c3b9b430690d11e7d539388cb0617
parentIncreased the timeout for debugging purposes; Instruct vncserver to trasmit just (diff)
parentKISS'n'DRY for more cohesion (diff)
downloadpvs2-a7aa883f638d5c53d760d14ba2f1e9694197490d.tar.gz
pvs2-a7aa883f638d5c53d760d14ba2f1e9694197490d.tar.xz
pvs2-a7aa883f638d5c53d760d14ba2f1e9694197490d.zip
Merge branch 'bastelstube'
-rw-r--r--src/server/mainwindow/mainwindow.cpp67
-rw-r--r--src/server/mainwindow/mainwindow.h10
2 files changed, 43 insertions, 34 deletions
diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp
index 3ed2b57..3d0d167 100644
--- a/src/server/mainwindow/mainwindow.cpp
+++ b/src/server/mainwindow/mainwindow.cpp
@@ -80,6 +80,29 @@ MainWindow::MainWindow(QString ipListUrl, 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)));
+
+ /* Stuff for the button lock */
+ _buttonLockTimer = new QTimer(this);
+ _buttonLockTimer->setSingleShot(true);
+ _buttonLockTimer->setInterval(_buttonBlockTime);
+ _lockingButtons
+ << ui->action_Lock
+ << ui->action_BroadcastScreen
+ << ui->action_TutorToAll
+ << ui->action_StudentToTutor
+ << ui->action_TutorToStudent
+ << ui->action_StopProjection
+ << ui->action_SetAsTutor;
+ // Disable the buttons if a button is clicked
+ foreach (QAction* a, _lockingButtons)
+ connect(a, SIGNAL(triggered()), this, SLOT(DisableButtons()));
+ // Start the timer a button is clicked
+ foreach (QAction* a, _lockingButtons)
+ connect(a, SIGNAL(triggered()), _buttonLockTimer, SLOT(start()));
+ // Enable the buttons if the timer fires
+ connect(_buttonLockTimer, SIGNAL(timeout()), this, SLOT(EnableButtons()));
+
+
// Clicking the session name label shows the edit field for it
connect(_sessionNameLabel, SIGNAL(clicked()), this, SLOT(onSessionNameClick()));
// Listen to updates to the session name through the session name window
@@ -462,20 +485,6 @@ bool MainWindow::isValidClient(Client* client)
}
/**
- * Check if buttons are blocked.
- * @return If buttons are blocked or not.
- */
-bool MainWindow::areButtonsBlocked()
-{
- bool result;
- static qint64 buttonsBlockedUntil = 0;
- qint64 now = QDateTime::currentMSecsSinceEpoch();
- if (!(result = now < buttonsBlockedUntil))
- buttonsBlockedUntil = now + _buttonBlockTime;
- return result;
-}
-
-/**
* Handle VNC settings for a projection from "from" to "to".
* Check if projection source is active vnc client.
* Check if projection is One --> Many or One --> One.
@@ -571,9 +580,6 @@ void MainWindow::prepareForProjection(Client * const from, Client * const to)
*/
void MainWindow::onButtonStudentToAll()
{
- if (areButtonsBlocked())
- return;
-
Client *from = NULL;
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
{
@@ -601,9 +607,6 @@ void MainWindow::onButtonStudentToAll()
*/
void MainWindow::onButtonStudentToTutor()
{
- if (areButtonsBlocked())
- return;
-
Client *from = NULL;
Client *to = NULL;
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
@@ -643,9 +646,6 @@ void MainWindow::onButtonStudentToTutor()
*/
void MainWindow::onButtonTutorToAll()
{
- if (areButtonsBlocked())
- return;
-
//
Client *from = NULL;
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
@@ -674,9 +674,6 @@ void MainWindow::onButtonTutorToAll()
*/
void MainWindow::onButtonTutorToStudent()
{
- if (areButtonsBlocked())
- return;
-
Client *from = NULL;
Client *to = NULL;
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
@@ -715,9 +712,6 @@ void MainWindow::onButtonTutorToStudent()
*/
void MainWindow::onButtonStopProjection()
{
- if (areButtonsBlocked())
- return;
-
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
{
Client *c = (**it).client();
@@ -748,9 +742,6 @@ void MainWindow::onButtonStopProjection()
*/
void MainWindow::onButtonLock(bool checked)
{
- if (areButtonsBlocked())
- return;
-
NetworkMessage msg;
msg.setField(_ID, _LOCK);
if (checked)
@@ -1060,3 +1051,15 @@ void MainWindow::onVncClientStateChange(Client* client, int lastProjectionSource
if (!inUse && server != NULL)
server->stopVncServer();
}
+
+void MainWindow::DisableButtons()
+{
+ foreach (QAction* a, _lockingButtons)
+ a->setDisabled(true);
+}
+
+void MainWindow::EnableButtons()
+{
+ foreach (QAction* a, _lockingButtons)
+ a->setEnabled(true);
+}
diff --git a/src/server/mainwindow/mainwindow.h b/src/server/mainwindow/mainwindow.h
index e5179ed..153eb5b 100644
--- a/src/server/mainwindow/mainwindow.h
+++ b/src/server/mainwindow/mainwindow.h
@@ -40,6 +40,11 @@ private:
ListenServer *_listenServer;
DiscoveryListener *_discoveryListener;
+ // Button block stuff
+ QTimer * _buttonLockTimer;
+ QList<QAction*> _lockingButtons;
+ static const qint64 _buttonBlockTime = 1000;
+
/**
* Downloader for IP - List of possible tutors.
*/
@@ -51,7 +56,6 @@ private:
QStringList _tutorList;
// Magic numbers
- static const qint64 _buttonBlockTime = 1000;
static const int _tilesX = 9;
static const int _tilesY = 7;
@@ -61,7 +65,6 @@ private:
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);
@@ -98,5 +101,8 @@ protected slots:
void onClientAuthenticated(Client* client);
void onVncServerStateChange(Client* client);
void onVncClientStateChange(Client* client, int lastProjectionSource);
+ //Buttons
+ void DisableButtons();
+ void EnableButtons();
};
#endif