summaryrefslogtreecommitdiffstats
path: root/src/server/mainwindow/mainwindow.cpp
diff options
context:
space:
mode:
authorBjörn Hagemeister2014-05-12 18:04:17 +0200
committerBjörn Hagemeister2014-05-12 18:04:17 +0200
commit838e5ac0f437649f4afbb27de68e4dcfaf84c6da (patch)
treec4e94e6edf1177e47804559554bba156542cc5ef /src/server/mainwindow/mainwindow.cpp
parentSinec c++11 is enabled by default, set flag to stop annoying warnings. (diff)
downloadpvs2-838e5ac0f437649f4afbb27de68e4dcfaf84c6da.tar.gz
pvs2-838e5ac0f437649f4afbb27de68e4dcfaf84c6da.tar.xz
pvs2-838e5ac0f437649f4afbb27de68e4dcfaf84c6da.zip
Configured not locking the screen, if manager and client working on same machine.
Plus changing symbol for tutor2all button.
Diffstat (limited to 'src/server/mainwindow/mainwindow.cpp')
-rw-r--r--src/server/mainwindow/mainwindow.cpp106
1 files changed, 51 insertions, 55 deletions
diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp
index 1844458..00e4eb0 100644
--- a/src/server/mainwindow/mainwindow.cpp
+++ b/src/server/mainwindow/mainwindow.cpp
@@ -18,6 +18,7 @@
// QT stuff
#include <QtGui>
#include <QFileDialog>
+#include <QNetworkInterface>
// Other custom UI elements
#include "../clicklabel/clicklabel.h"
#include "../sessionnamewindow/sessionnamewindow.h"
@@ -35,7 +36,7 @@
// Auto-generated ui class
#include "ui_mainwindow.h"
-/**
+/***************************************************************************//**
* Initialize MainWindow and ListenServer.
* @param ipListUrl
* @param parent
@@ -135,7 +136,7 @@ MainWindow::~MainWindow()
delete ui;
}
-/**
+/***************************************************************************//**
* Place the frames at possible Position.
* If current position out of range, place frame into next free cell.
* @param frame
@@ -188,7 +189,7 @@ void MainWindow::placeFrameInFreeSlot(ConnectionFrame* frame)
}
}
-/**
+/***************************************************************************//**
* Create new Frame.
* Create new frame and add to current available frame list.
* Also connect signals frameMoved() and clicked() with slots.
@@ -205,7 +206,7 @@ ConnectionFrame* MainWindow::createFrame()
return cf;
}
-/**
+/***************************************************************************//**
* Load position.
* @param settings
* @param id
@@ -226,7 +227,7 @@ bool MainWindow::loadPosition(QSettings& settings, const QString& id, int& x, in
return true;
}
-/**
+/***************************************************************************//**
* Save position of given connectionFrame.
* @param cf
*/
@@ -246,7 +247,7 @@ void MainWindow::savePosition(ConnectionFrame *cf)
* Overridden methods
*/
-/**
+/***************************************************************************//**
* Handle closeEvent.
* If user calls closing MainWindow, close, else ignore.
* @param e
@@ -260,7 +261,7 @@ void MainWindow::closeEvent(QCloseEvent* e)
e->ignore();
}
-/**
+/***************************************************************************//**
* Change Event.
* @param e
*/
@@ -269,7 +270,7 @@ void MainWindow::changeEvent(QEvent* e)
QMainWindow::changeEvent(e);
}
-/**
+/***************************************************************************//**
* Resize event.
* @param e
*/
@@ -283,7 +284,7 @@ void MainWindow::resizeEvent(QResizeEvent* e)
_timerTimeout = 8;
}
-/**
+/***************************************************************************//**
* Handle Mouse Release Event.
* Check if click was inside the frame and if that is the case, set the selection of each connected
* client to false.
@@ -307,8 +308,10 @@ void MainWindow::mouseReleaseEvent(QMouseEvent* e)
}
}
-/**
- * Handle Timer EventtimerEvent.
+/***************************************************************************//**
+ * Handle TimerEvent.
+ * If timerId of event equals _timerId reduce _timerTimeout by 1.
+ * If _timerTimeout equals 1 move toolbar if necessary, otherwise kill timer.
* @param event
*/
void MainWindow::timerEvent(QTimerEvent* event)
@@ -367,9 +370,9 @@ void MainWindow::timerEvent(QTimerEvent* event)
* Slots
*/
-/**
+/***************************************************************************//**
* Extract information from downloaded tutorList.
- * Split downloaded file by new line and store ips in _tutorList.
+ * Split downloaded file by new line and store IPs in _tutorList.
* @param tutorList
*/
void MainWindow::onTutorListDownloaded(QByteArray& tutorList)
@@ -380,7 +383,7 @@ void MainWindow::onTutorListDownloaded(QByteArray& tutorList)
qDebug() << _tutorList;
}
-/**
+/***************************************************************************//**
* Place Frame to from user specified position.
* @param frame
*/
@@ -415,7 +418,7 @@ void MainWindow::onPlaceFrame(ConnectionFrame* frame)
}
}
-/**
+/***************************************************************************//**
* Mark given frame after it was clicked on.
* @param frame
*/
@@ -430,7 +433,7 @@ void MainWindow::onFrameClicked(ConnectionFrame* frame)
}
}
-/**
+/***************************************************************************//**
* Show session name, after it was clicked on.
*/
void MainWindow::onSessionNameClick()
@@ -438,7 +441,7 @@ void MainWindow::onSessionNameClick()
_sessionNameWindow->show(Global::sessionName());
}
-/**
+/***************************************************************************//**
* Update session name.
*/
void MainWindow::onSessionNameUpdate()
@@ -446,28 +449,7 @@ void MainWindow::onSessionNameUpdate()
_sessionNameLabel->setText(tr("Session Name: %1 [click to edit]").arg(Global::sessionName()));
}
-/**
- * OnButtonSettings.
- */
-void MainWindow::onButtonSettings()
-{
- // Move to any free tile
- placeFrameInFreeSlot(createFrame());
-}
-
-/**
- * OnButtonChat.
- */
-void MainWindow::onButtonChat()
-{
- /*
- for (QList<ConnectionFrame*>::iterator it = _clientFrames.begin(); it != _clientFrames.end(); ++it) {
- (*it)->setSize(100 + qrand() % 200);
- }
- */
-}
-
-/**
+/***************************************************************************//**
* Check if given client is valid.
* And if that is the case return true.
* @param client
@@ -484,7 +466,7 @@ bool MainWindow::isValidClient(Client* client)
return false;
}
-/**
+/***************************************************************************//**
* 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.
@@ -572,7 +554,7 @@ void MainWindow::prepareForProjection(Client * const from, Client * const to)
from->startVncServer();
}
-/**
+/***************************************************************************//**
* Button projection from one student to all the others.
* First get which client is projectionSource and set this one as from.
* Set projection source for all clients,except the selected one, to false.
@@ -600,7 +582,7 @@ void MainWindow::onButtonStudentToAll()
prepareForProjection(from, NULL);
}
-/**
+/***************************************************************************//**
* Handle projection from one student to tutor.
* Get the client to project from and get client, who is tutor, as to.
* Call prepareForProjection(from, to).
@@ -638,7 +620,7 @@ void MainWindow::onButtonStudentToTutor()
prepareForProjection(from, to);
}
-/**
+/***************************************************************************//**
* Handle projection from tutor to all.
* Get the client who is tutor and set the projectionSource of all
* clients, except the tutor ones, to false.
@@ -667,7 +649,7 @@ void MainWindow::onButtonTutorToAll()
prepareForProjection(from, NULL);
}
-/**
+/***************************************************************************//**
* Handle the projection from Tutor to specific student.
* Set the client who is tutor as from and the selected client as to.
* Call prepareForProjection(from, to).
@@ -705,7 +687,7 @@ void MainWindow::onButtonTutorToStudent()
prepareForProjection(from, to);
}
-/**
+/***************************************************************************//**
* Handle Button StopProjection.
* Set ProjectionSource of each client to false and create a NetworkMessage to
* stop the active VNC Server and the active VNC Client(s).
@@ -734,7 +716,7 @@ void MainWindow::onButtonStopProjection()
}
}
-/**
+/***************************************************************************//**
* Handle button to lock or unlock screens of client(s).
* If already locked, do nothing, else create a NetworkMessage to lock (checked) or
* unlock (!checked) the client(s), except the tutor.
@@ -751,13 +733,21 @@ void MainWindow::onButtonLock(bool checked)
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
{
Client *c = (**it).client();
- if (c == NULL || (**it).isTutor())
- continue; // Don't lock the tutor
+
+ // Check if client is Tutor or the manager is also running on this machine.
+ bool isManagerMachine = false;
+ foreach (const QHostAddress &address, QNetworkInterface::allAddresses()) {
+ if (address != QHostAddress(QHostAddress::LocalHost) && c->ip() == address.toString())
+ isManagerMachine = true;
+ }
+
+ if (c == NULL || (**it).isTutor() || isManagerMachine)
+ continue; // Don't lock the tutor or the manager running machine.
c->sendMessage(msg);
}
}
-/**
+/***************************************************************************//**
* On button exit, close application.
*/
void MainWindow::onButtonExit()
@@ -765,7 +755,7 @@ void MainWindow::onButtonExit()
this->close();
}
-/**
+/***************************************************************************//**
* Handle button to set specific client as tutor.
* Unset active tutor and set selected client, if not inactive, as new tutor.
*/
@@ -794,7 +784,7 @@ void MainWindow::onButtonSetAsTutor()
}
}
-/**
+/***************************************************************************//**
* Handle from ListenServer signaled new client connection.
* @param client
*/
@@ -805,7 +795,7 @@ void MainWindow::onClientConnected(Client* client)
connect(client, SIGNAL(authenticated(Client*)), this, SLOT(onClientAuthenticated(Client*)));
}
-/**
+/***************************************************************************//**
* Authenticate new Client client.
* @param client
* @param request
@@ -847,7 +837,7 @@ void MainWindow::onClientAuthenticating(Client* client, ClientLogin* request)
request->name = check;
}
-/**
+/***************************************************************************//**
* After authenticating new client, check if that's the first one and set tutor if necessary.
* Also check the current VNC status and take these setting also for the new client.
* @param client
@@ -953,7 +943,7 @@ void MainWindow::onClientAuthenticated(Client* client)
}
}
-/**
+/***************************************************************************//**
* Handle if VNC Server State has changed.
* Check if VNC server has been started/stopped on some client and start VNC server/reset pending
* VNC projection information.
@@ -1014,7 +1004,7 @@ void MainWindow::onVncServerStateChange(Client* client)
}
}
-/**
+/***************************************************************************//**
* Handle VNC client state change.
* Check if any vnc client is in use, and if that is not the case, stop VNC Server.
* @param client
@@ -1052,12 +1042,18 @@ void MainWindow::onVncClientStateChange(Client* client, int lastProjectionSource
server->stopVncServer();
}
+/***************************************************************************//**
+ * DisableButtons.
+ */
void MainWindow::DisableButtons()
{
foreach (QAction* a, _lockingButtons)
a->setDisabled(true);
}
+/***************************************************************************//**
+ * EnableButtons.
+ */
void MainWindow::EnableButtons()
{
foreach (QAction* a, _lockingButtons)