summaryrefslogtreecommitdiffstats
path: root/src/server/mainwindow/mainwindow.cpp
diff options
context:
space:
mode:
authorChristian Klinger2016-09-29 15:40:18 +0200
committerChristian Klinger2016-09-29 15:40:18 +0200
commit3d82bfc698165bb20f3c38d42f2b77ab855c1edf (patch)
tree2c170bcdd5c89259bb0b530fa11fdfe701c99850 /src/server/mainwindow/mainwindow.cpp
parentadded an information dialog that displays ip and hostname. (diff)
downloadpvs2-3d82bfc698165bb20f3c38d42f2b77ab855c1edf.tar.gz
pvs2-3d82bfc698165bb20f3c38d42f2b77ab855c1edf.tar.xz
pvs2-3d82bfc698165bb20f3c38d42f2b77ab855c1edf.zip
astyle.
Diffstat (limited to 'src/server/mainwindow/mainwindow.cpp')
-rw-r--r--src/server/mainwindow/mainwindow.cpp786
1 files changed, 374 insertions, 412 deletions
diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp
index b29addc..e1d3f1e 100644
--- a/src/server/mainwindow/mainwindow.cpp
+++ b/src/server/mainwindow/mainwindow.cpp
@@ -66,16 +66,16 @@ using std::endl;
MainWindow::MainWindow(QWidget* parent) :
QMainWindow(parent), ui(new Ui::MainWindow), _tbIconSize(24), _tbArea(Qt::LeftToolBarArea)
{
- qDebug() << "MainWindow(parent)";
+ qDebug() << "MainWindow(parent)";
_mode = Mode::Multicast;
_streamingSource = 0;
- /* default value, these will be updated a room is loaded */
- _tilesX = 10;
- _tilesY = 10;
+ /* default value, these will be updated a room is loaded */
+ _tilesX = 10;
+ _tilesY = 10;
- _virtCols = 0;
- _virtRows = 0;
+ _virtCols = 0;
+ _virtRows = 0;
_sessionNameWindow = new SessionNameWindow(this);
_helpWindow = new HelpWindow(this);
@@ -124,24 +124,24 @@ MainWindow::MainWindow(QWidget* parent) :
connect(ui->action_Lock, SIGNAL(toggled(bool)), this, SLOT(onButtonLock(bool)));
connect(ui->action_Help, SIGNAL(triggered()), this, SLOT(onButtonHelp()));
connect(ui->actionReload_Room_Configuration, SIGNAL(triggered()), this, SLOT(onButtonReloadRoomConfig()));
- connect(ui->action_DeleteClient, SIGNAL(triggered()), this, SLOT(onDeleteClient()));
+ connect(ui->action_DeleteClient, SIGNAL(triggered()), this, SLOT(onDeleteClient()));
- // /* In exam-mode: disable most features */
+ // /* In exam-mode: disable most features */
// QSharedPointer<QSettings> conf = Global::getSettings();
- // if (conf->contains("examMode")) {
- // Global::setExam(conf->value("examMode").toBool());
- // }
+ // if (conf->contains("examMode")) {
+ // Global::setExam(conf->value("examMode").toBool());
+ // }
+
+ /* disable context-sensitive buttons by default */
+ _contextButtons
+ << ui->action_DeleteClient
+ << ui->action_StudentToTutor
+ << ui->action_StudentToTutorExclusive
+ << ui->action_SetAsTutor
+ << ui->action_TutorToStudent;
- /* disable context-sensitive buttons by default */
- _contextButtons
- << ui->action_DeleteClient
- << ui->action_StudentToTutor
- << ui->action_StudentToTutorExclusive
- << ui->action_SetAsTutor
- << ui->action_TutorToStudent;
-
- lockContextButtons();
+ lockContextButtons();
/* Stuff for the button lock */
//Setup a timeout
@@ -151,18 +151,18 @@ MainWindow::MainWindow(QWidget* parent) :
connect(_buttonLockTimer, SIGNAL(timeout()), this, SLOT(EnableButtons()));
// Define the locking buttons
_lockingButtons
- << ui->action_Lock
- << ui->action_TutorToAll
- << ui->action_StudentToTutor
- << ui->action_TutorToStudent
- << ui->action_StopProjection
- << ui->action_SetAsTutor;
+ << ui->action_Lock
+ << ui->action_TutorToAll
+ << ui->action_StudentToTutor
+ << ui->action_TutorToStudent
+ << ui->action_StopProjection
+ << ui->action_SetAsTutor;
// 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
connect(_sessionNameWindow, SIGNAL(updateSessionName()), this,
- SLOT(onSessionNameUpdate()));
+ SLOT(onSessionNameUpdate()));
setAttribute(Qt::WA_QuitOnClose);
setUnifiedTitleAndToolBarOnMac(true);
@@ -183,7 +183,8 @@ 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::updateExamMode()
+{
/* TODO */
int numerator = 0;
int denominator = 0;
@@ -229,18 +230,20 @@ MainWindow::~MainWindow()
}
/** Euclidean distance (why is this not implemented in QPoint?) */
-float distance(QPoint a, QPoint b) {
- int dx = a.x() - b.x();
- int dy = a.y() - b.y();
- int sum = dx*dx + dy*dy;
- return sqrt((float) sum);
+float distance(QPoint a, QPoint b)
+{
+ int dx = a.x() - b.x();
+ int dy = a.y() - b.y();
+ int sum = dx * dx + dy * dy;
+ return sqrt((float) sum);
}
-float distance(QPointF a, QPointF b) {
- int dx = a.x() - b.x();
- int dy = a.y() - b.y();
- int sum = dx*dx + dy*dy;
- return sqrt(sum);
+float distance(QPointF a, QPointF b)
+{
+ int dx = a.x() - b.x();
+ int dy = a.y() - b.y();
+ int sum = dx * dx + dy * dy;
+ return sqrt(sum);
}
@@ -253,72 +256,74 @@ float distance(QPointF a, QPointF b) {
* 'Algorithm': ideally, go in circles around the preferred point until you find
* a free spot. Lazy way: store all free positions in an array and find later
* there the closest (<- that's what I do)
- *
- * @param preferred in Pixels!
+ *
+ * @param preferred in Pixels!
* @param toIgnore, ignore this connectionframe when considering free slots
* @return the free slot
*/
-QPoint MainWindow::closestFreeSlot(QPoint preferredPixels, ConnectionFrame* toIgnore) {
- const QSize& clientSize = Global::getCurrentRoom()->clientSize;
+QPoint MainWindow::closestFreeSlot(QPoint preferredPixels, ConnectionFrame* toIgnore)
+{
+ const QSize& clientSize = Global::getCurrentRoom()->clientSize;
bool grid[_tilesX][_tilesY];
memset(grid, 0, sizeof(bool) * _tilesX * _tilesY); /* set everything to false */
- /* fill grid */
+ /* fill grid */
for (auto it = _clientFrames.begin(); it != _clientFrames.end(); ++it) {
- if (*it == toIgnore) { continue; }
-
- const QPoint& p = (*it)->getGridPosition();
-
- for (int x = p.x(); x < p.x() + clientSize.width(); x++) {
- for (int y = p.y(); y < p.y() + clientSize.height(); y++) {
- grid[x][y] = true;
- }
- }
- }
-
- QList<QPoint> freePositions;
- /* check all positions to see if they are available */
- for (int x = 0; x <= _tilesX - clientSize.width(); x++) {
- for ( int y = 0; y <= _tilesY - clientSize.height(); y++) {
- /* check if (x,y) is free */
- bool isFree = true;
- for (int dx = 0; dx < clientSize.width(); dx++) {
- for (int dy = 0; dy < clientSize.height(); dy++) {
- if (grid[x + dx][y + dy]) {
- isFree = false;
- goto endLoop; // double-break
- }
- }
- }
+ if (*it == toIgnore) { continue; }
+
+ const QPoint& p = (*it)->getGridPosition();
+
+ for (int x = p.x(); x < p.x() + clientSize.width(); x++) {
+ for (int y = p.y(); y < p.y() + clientSize.height(); y++) {
+ grid[x][y] = true;
+ }
+ }
+ }
+
+ QList<QPoint> freePositions;
+ /* check all positions to see if they are available */
+ for (int x = 0; x <= _tilesX - clientSize.width(); x++) {
+ for ( int y = 0; y <= _tilesY - clientSize.height(); y++) {
+ /* check if (x,y) is free */
+ bool isFree = true;
+ for (int dx = 0; dx < clientSize.width(); dx++) {
+ for (int dy = 0; dy < clientSize.height(); dy++) {
+ if (grid[x + dx][y + dy]) {
+ isFree = false;
+ goto endLoop; // double-break
+ }
+ }
+ }
endLoop:
- if (isFree) { freePositions << QPoint(x,y); }
- }
- }
- /* among all the free positions, find the closest */
- float min_distance = 10000;
- QPoint bestPosition = QPoint(-1, -1);
-
- for (QPoint freePos : freePositions) {
- QPoint freePosCenter( freePos.x() * getTileWidthPx() + getTileWidthPx() * clientSize.width() / 2,
- freePos.y() * getTileHeightPx() + getTileHeightPx() * clientSize.height() / 2);
- float dist = distance(freePosCenter, preferredPixels);
- if (dist < min_distance) {
- min_distance = dist;
- bestPosition = freePos;
- }
- }
- return bestPosition;
+ if (isFree) { freePositions << QPoint(x, y); }
+ }
+ }
+ /* among all the free positions, find the closest */
+ float min_distance = 10000;
+ QPoint bestPosition = QPoint(-1, -1);
+
+ for (QPoint freePos : freePositions) {
+ QPoint freePosCenter( freePos.x() * getTileWidthPx() + getTileWidthPx() * clientSize.width() / 2,
+ freePos.y() * getTileHeightPx() + getTileHeightPx() * clientSize.height() / 2);
+ float dist = distance(freePosCenter, preferredPixels);
+ if (dist < min_distance) {
+ min_distance = dist;
+ bestPosition = freePos;
+ }
+ }
+ return bestPosition;
}
/* place frame in the cloest available spot */
-void MainWindow::placeFrameInFreeSlot(ConnectionFrame* frame, QPoint preferredPixels) {
+void MainWindow::placeFrameInFreeSlot(ConnectionFrame* frame, QPoint preferredPixels)
+{
- QPoint bestPosition = closestFreeSlot(preferredPixels, frame);
+ QPoint bestPosition = closestFreeSlot(preferredPixels, frame);
- frame->setGridPosition(bestPosition);
- QPoint freePosPx(bestPosition.x() * getTileWidthPx(), bestPosition.y() * getTileHeightPx());
- frame->setCurrentPosition(freePosPx);
+ frame->setGridPosition(bestPosition);
+ QPoint freePosPx(bestPosition.x() * getTileWidthPx(), bestPosition.y() * getTileHeightPx());
+ frame->setCurrentPosition(freePosPx);
}
/***************************************************************************//**
@@ -330,8 +335,8 @@ void MainWindow::placeFrameInFreeSlot(ConnectionFrame* frame, QPoint preferredPi
ConnectionFrame* MainWindow::createFrame()
{
// Allocate and resize
- int width = getTileWidthPx() * Global::getCurrentRoom()->clientSize.width();
- int height= getTileHeightPx() * Global::getCurrentRoom()->clientSize.height();
+ int width = getTileWidthPx() * Global::getCurrentRoom()->clientSize.width();
+ int height = getTileHeightPx() * Global::getCurrentRoom()->clientSize.height();
ConnectionFrame *cf = new ConnectionFrame(ui->frmRoom, width, height);
_clientFrames.append(cf);
@@ -350,14 +355,14 @@ ConnectionFrame* MainWindow::createFrame()
ConnectionFrame* MainWindow::createFrame(QString computerId, QPoint pxCoord, QPoint gridPosition)
{
// Allocate and resize
- const Room* room = Global::getCurrentRoom();
- int width = getTileWidthPx() * (room == NULL ? 1 : room->clientSize.width());
- int height = getTileHeightPx() * (room == NULL ? 1 : room->clientSize.height());
+ const Room* room = Global::getCurrentRoom();
+ int width = getTileWidthPx() * (room == NULL ? 1 : room->clientSize.width());
+ int height = getTileHeightPx() * (room == NULL ? 1 : room->clientSize.height());
- ConnectionFrame *cf = new ConnectionFrame(ui->frmRoom, width, height);
+ ConnectionFrame *cf = new ConnectionFrame(ui->frmRoom, width, height);
cf->setComputerId(computerId);
cf->setCurrentPosition(pxCoord);
- cf->setGridPosition(gridPosition);
+ cf->setGridPosition(gridPosition);
_clientFrames.append(cf);
cf->show();
connect(cf, SIGNAL(frameMoved(bool, ConnectionFrame *)), this, SLOT(onPlaceFrame(bool, ConnectionFrame *)));
@@ -399,7 +404,7 @@ void MainWindow::tellClientCurrentSituation(Client* client)
if (ui->action_Lock->isChecked() || _mode == Mode::LockedUnicast)
client->lockScreen(true);
- if (_mode == Mode::Broadcast){
+ if (_mode == Mode::Broadcast) {
client->setDesiredProjectionSource(_streamingSource);
if (_streamingSource != 0) {
client->startVncClient(getClientFromId(_streamingSource));
@@ -412,20 +417,21 @@ void MainWindow::tellClientCurrentSituation(Client* client)
/**
* returns the minimal grid size such that all clients fit on the grid
**/
-QSize minimalGridSize(const QMap<QString, QPoint>& clientPositions, QSize& clientSize) {
- /* collect the maximum coordinates */
- int x = 0;
- int y= 0;
-
- for (auto it = clientPositions.begin(); it != clientPositions.end(); ++it) {
- QPoint pos = it.value();
- if (pos.x() > x) { x = pos.x(); }
- if (pos.y() > y) { y = pos.y(); }
-
- }
- /* need a little extra space */
- QSize size(x + clientSize.width(), y + clientSize.height());
- return size;
+QSize minimalGridSize(const QMap<QString, QPoint>& clientPositions, QSize& clientSize)
+{
+ /* collect the maximum coordinates */
+ int x = 0;
+ int y = 0;
+
+ for (auto it = clientPositions.begin(); it != clientPositions.end(); ++it) {
+ QPoint pos = it.value();
+ if (pos.x() > x) { x = pos.x(); }
+ if (pos.y() > y) { y = pos.y(); }
+
+ }
+ /* need a little extra space */
+ QSize size(x + clientSize.width(), y + clientSize.height());
+ return size;
}
/***************************************************************************//**
@@ -433,17 +439,16 @@ QSize minimalGridSize(const QMap<QString, QPoint>& clientPositions, QSize& clien
*/
void MainWindow::tryToUseRoomTemplate()
{
- qDebug() << "tryToUseRoomTemplate()";
+ qDebug() << "tryToUseRoomTemplate()";
QMap<QString, Room* > roomsList;
QSharedPointer<QSettings> conf = Global::getSettings();
if (!conf->contains("rooms")) { qDebug() << "Invalid config file (no rooms are set)!"; return; }
QStringList rooms = conf->value("rooms").toStringList();
- QString myRoom = "";
+ QString myRoom = "";
- for (QString roomId : rooms)
- {
+ for (QString roomId : rooms) {
conf->beginGroup(roomId);
QString roomName = conf->value("name").toString();
@@ -455,61 +460,61 @@ void MainWindow::tryToUseRoomTemplate()
qDebug() << "Invalid config file (room " << roomName << " needs a mgrIP)!";
return;
}
- QMap<QString, QPoint> clientPositions;
+ QMap<QString, QPoint> clientPositions;
// First store all room configurations in _rooms.
int size = conf->beginReadArray("client");
for (int j = 0; j < size; j++) {
conf->setArrayIndex(j);
// qDebug() << "ip: " << conf.value("ip").toString() << " pos: " << conf.value("pos").toPoint();
// roomsList[i].insert(conf.value("ip").toString(), conf.value("pos").toPoint());
- clientPositions.insert(conf->value("ip").toString(), conf->value("pos").toPoint());
+ clientPositions.insert(conf->value("ip").toString(), conf->value("pos").toPoint());
}
conf->endArray();
- /* read backgroundImage */
- QString image = conf->contains("backgroundImage") ? conf->value("backgroundImage").toString() : "";
+ /* read backgroundImage */
+ QString image = conf->contains("backgroundImage") ? conf->value("backgroundImage").toString() : "";
QString mgrIP = conf->value("mgrIP").toString();
- QString tutorIP = conf->value("tutorIP").toString();
-
- QSize gridSize;
- QSize clientSize(1,1);
- /* read some other properties of the room */
- if (conf->contains("gridSize")) {
- gridSize = conf->value("gridSize").toSize();
- }
- if (conf->contains("clientSize")) {
- clientSize = conf->value("clientSize").toSize();
- }
-
- foreach (const QHostAddress &address, QNetworkInterface::allAddresses()) {
+ QString tutorIP = conf->value("tutorIP").toString();
+
+ QSize gridSize;
+ QSize clientSize(1, 1);
+ /* read some other properties of the room */
+ if (conf->contains("gridSize")) {
+ gridSize = conf->value("gridSize").toSize();
+ }
+ if (conf->contains("clientSize")) {
+ clientSize = conf->value("clientSize").toSize();
+ }
+
+ foreach (const QHostAddress & address, QNetworkInterface::allAddresses()) {
if (address != QHostAddress(QHostAddress::LocalHost) && mgrIP == address.toString()) {
qDebug("Found this ip in config.");
- myRoom = roomName;
+ myRoom = roomName;
}
}
conf->endGroup();
- if (!gridSize.isValid()) {
- /* ok, let's choose the minimum gridSize to fit all clients */
- gridSize = minimalGridSize(clientPositions, clientSize);
- qDebug() << "had to use minimalGridSize(): = " << gridSize;
+ if (!gridSize.isValid()) {
+ /* ok, let's choose the minimum gridSize to fit all clients */
+ gridSize = minimalGridSize(clientPositions, clientSize);
+ qDebug() << "had to use minimalGridSize(): = " << gridSize;
- }
- Room* r = new Room(clientPositions, gridSize, clientSize, image, tutorIP);
- qDebug() << "read new room: " << roomName << ": " << gridSize << ", " << clientSize;
- roomsList.insert(roomName, r);
+ }
+ Room* r = new Room(clientPositions, gridSize, clientSize, image, tutorIP);
+ qDebug() << "read new room: " << roomName << ": " << gridSize << ", " << clientSize;
+ roomsList.insert(roomName, r);
}
Global::setRooms(roomsList);
- if (myRoom == "") {
- /* so apparently this is not a manager of a room */
- if (Global::manager_only) {
- cout << "exiting because of the argument --manager-only was set and this computer is not a manager" << endl;
- exit(0);
- }
- } else {
- switchRoomTo(myRoom);
- }
-
+ if (myRoom == "") {
+ /* so apparently this is not a manager of a room */
+ if (Global::manager_only) {
+ cout << "exiting because of the argument --manager-only was set and this computer is not a manager" << endl;
+ exit(0);
+ }
+ } else {
+ switchRoomTo(myRoom);
+ }
+
}
/***************************************************************************//**
@@ -520,10 +525,8 @@ void MainWindow::tryToUseRoomTemplate()
*/
Client* MainWindow::getClientFromId(int id)
{
- for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
- {
- if ((*it)->client() != NULL)
- {
+ for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) {
+ if ((*it)->client() != NULL) {
if ((*it)->client()->id() == id)
return (*it)->client();
}
@@ -539,8 +542,7 @@ Client* MainWindow::getClientFromId(int id)
*/
ConnectionFrame* MainWindow::getTutorFrame()
{
- for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
- {
+ for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) {
if (((*it) != NULL) && ((*it)->isTutor()))
return (*it);
}
@@ -555,8 +557,7 @@ ConnectionFrame* MainWindow::getTutorFrame()
*/
ConnectionFrame* MainWindow::getSelectedFrame()
{
- for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
- {
+ for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) {
if (((*it) != NULL) && ((*it)->isSelected()))
return (*it);
}
@@ -597,17 +598,18 @@ enum AspectStatus { GRID_OK, GRID_TOO_WIDE, GRID_TOO_TALL };
* size. The parameters in here are hand-adjusted. Feel free to make it more or
* less sensitive.
* */
-AspectStatus checkAspectRatio(const QSize& frameSize, const QSize& gridSize) {
- float aspectRoom = ((float) gridSize.height()) / ((float) gridSize.width());
- float aspectFrame = ((float) frameSize.height()) / ((float) frameSize.width());
-
- if (aspectRoom / aspectFrame < 0.8) {
- return GRID_TOO_WIDE;
- }
- if ( aspectFrame / aspectRoom < 0.8) {
- return GRID_TOO_TALL;
- }
- return GRID_OK;
+AspectStatus checkAspectRatio(const QSize& frameSize, const QSize& gridSize)
+{
+ float aspectRoom = ((float) gridSize.height()) / ((float) gridSize.width());
+ float aspectFrame = ((float) frameSize.height()) / ((float) frameSize.width());
+
+ if (aspectRoom / aspectFrame < 0.8) {
+ return GRID_TOO_WIDE;
+ }
+ if ( aspectFrame / aspectRoom < 0.8) {
+ return GRID_TOO_TALL;
+ }
+ return GRID_OK;
}
@@ -617,80 +619,81 @@ AspectStatus checkAspectRatio(const QSize& frameSize, const QSize& gridSize) {
*/
void MainWindow::resizeEvent(QResizeEvent* e)
{
- const Room* room = Global::getCurrentRoom();
- const QSize& clientSize = room->clientSize;
+ const Room* room = Global::getCurrentRoom();
+ const QSize& clientSize = room->clientSize;
if (ui->frmRoom->size().width() < 100 || ui->frmRoom->size().height() < 100 || _tilesX <= 0 || _tilesY <= 0) { return; }
- QSize newGridSize = room->gridSize;
-
- /* do we have to add virtual columns? */
- while (checkAspectRatio(ui->frmRoom->size(), newGridSize) == GRID_TOO_WIDE) {
- /* add row */
- newGridSize.setHeight(newGridSize.height() + 1);
- }
- while (checkAspectRatio(ui->frmRoom->size(), newGridSize) == GRID_TOO_TALL) {
- /* add column */
- newGridSize.setWidth(newGridSize.width() + 1);
- }
- this->_tilesX = newGridSize.width();
- this->_tilesY = newGridSize.height();
-
- /* Bring back frame that are now out of the screen */
- for (auto it = _clientFrames.begin(); it != _clientFrames.end(); ++it) {
- const QPoint gp = (*it)->getGridPosition();
- if ( gp.x() >= _tilesX || gp.y() >= _tilesY ) {
- qDebug() << "bring frame back";
- placeFrameInFreeSlot(*it, (*it)->getCurrentPosition());
- }
- }
+ QSize newGridSize = room->gridSize;
+
+ /* do we have to add virtual columns? */
+ while (checkAspectRatio(ui->frmRoom->size(), newGridSize) == GRID_TOO_WIDE) {
+ /* add row */
+ newGridSize.setHeight(newGridSize.height() + 1);
+ }
+ while (checkAspectRatio(ui->frmRoom->size(), newGridSize) == GRID_TOO_TALL) {
+ /* add column */
+ newGridSize.setWidth(newGridSize.width() + 1);
+ }
+ this->_tilesX = newGridSize.width();
+ this->_tilesY = newGridSize.height();
+
+ /* Bring back frame that are now out of the screen */
+ for (auto it = _clientFrames.begin(); it != _clientFrames.end(); ++it) {
+ const QPoint gp = (*it)->getGridPosition();
+ if ( gp.x() >= _tilesX || gp.y() >= _tilesY ) {
+ qDebug() << "bring frame back";
+ placeFrameInFreeSlot(*it, (*it)->getCurrentPosition());
+ }
+ }
/* Resize all connection windows */
- for (QList<ConnectionFrame*>::iterator it = _clientFrames.begin(); it != _clientFrames.end(); ++it)
- {
- int newPosX = (*it)->getGridPosition().x() * getTileWidthPx();
- int newPosY = (*it)->getGridPosition().y() * getTileHeightPx();
- QPoint newPos(newPosX, newPosY);
-
- (*it)->setSize(getTileWidthPx() * clientSize.width(), getTileHeightPx() * clientSize.height());
- (*it)->move(newPos);
+ for (QList<ConnectionFrame*>::iterator it = _clientFrames.begin(); it != _clientFrames.end(); ++it) {
+ int newPosX = (*it)->getGridPosition().x() * getTileWidthPx();
+ int newPosY = (*it)->getGridPosition().y() * getTileHeightPx();
+ QPoint newPos(newPosX, newPosY);
+
+ (*it)->setSize(getTileWidthPx() * clientSize.width(), getTileHeightPx() * clientSize.height());
+ (*it)->move(newPos);
}
- /* update background image label */
- if (_backgroundImage != NULL) {
- int w = ui->frmRoom->width() - 5; /* to make sure that we don't enlarge the window */
- int h = ui->frmRoom->height() - 5;
- ui->imageLabel->hide();
- ui->imageLabel->setScaledContents(true);
- ui->imageLabel->setPixmap(QPixmap::fromImage(*_backgroundImage).scaled(w,h, Qt::IgnoreAspectRatio));
- ui->imageLabel->show();
- } else {
- ui->imageLabel->clear();
- }
+ /* update background image label */
+ if (_backgroundImage != NULL) {
+ int w = ui->frmRoom->width() - 5; /* to make sure that we don't enlarge the window */
+ int h = ui->frmRoom->height() - 5;
+ ui->imageLabel->hide();
+ ui->imageLabel->setScaledContents(true);
+ ui->imageLabel->setPixmap(QPixmap::fromImage(*_backgroundImage).scaled(w, h, Qt::IgnoreAspectRatio));
+ ui->imageLabel->show();
+ } else {
+ ui->imageLabel->clear();
+ }
}
-void MainWindow::lockContextButtons() {
- for (auto it = _contextButtons.begin(); it != _contextButtons.end(); ++it) {
- (*it)->setEnabled(false);
- }
+void MainWindow::lockContextButtons()
+{
+ for (auto it = _contextButtons.begin(); it != _contextButtons.end(); ++it) {
+ (*it)->setEnabled(false);
+ }
}
-void MainWindow::unlockContextButtons() {
- for (auto it = _contextButtons.begin(); it != _contextButtons.end(); ++it) {
- (*it)->setEnabled(true);
- }
- /* and disable some again based on special rules */
- if (getSelectedFrame()->client() != NULL) {
- ui->action_DeleteClient->setEnabled(false);
- }
- if (getSelectedFrame()->client() == NULL) {
- ui->action_SetAsTutor->setEnabled(false);
- ui->action_StudentToTutorExclusive->setEnabled(false);
- ui->action_StudentToTutor->setEnabled(false);
- ui->action_TutorToStudent->setEnabled(false);
- }
+void MainWindow::unlockContextButtons()
+{
+ for (auto it = _contextButtons.begin(); it != _contextButtons.end(); ++it) {
+ (*it)->setEnabled(true);
+ }
+ /* and disable some again based on special rules */
+ if (getSelectedFrame()->client() != NULL) {
+ ui->action_DeleteClient->setEnabled(false);
+ }
+ if (getSelectedFrame()->client() == NULL) {
+ ui->action_SetAsTutor->setEnabled(false);
+ ui->action_StudentToTutorExclusive->setEnabled(false);
+ ui->action_StudentToTutor->setEnabled(false);
+ ui->action_TutorToStudent->setEnabled(false);
+ }
}
@@ -709,11 +712,9 @@ void MainWindow::mouseReleaseEvent(QMouseEvent* e)
if (pos.x() < 0 || pos.y() < 0)
return;
const QSize frame(ui->frmRoom->size());
- if (frame.width() > pos.x() && frame.height() > pos.y())
- {
- lockContextButtons();
- if (getSelectedFrame() != NULL)
- {
+ if (frame.width() > pos.x() && frame.height() > pos.y()) {
+ lockContextButtons();
+ if (getSelectedFrame() != NULL) {
getSelectedFrame()->setSelection(false);
}
}
@@ -749,9 +750,9 @@ void MainWindow::onPlaceFrame(bool activateTrash, ConnectionFrame* connectionFra
{
// if (_tilesX <= 0 || _tilesY <= 0) return;
const QPoint &preferredPixels = connectionFrame->frameGeometry().center();
- placeFrameInFreeSlot(connectionFrame, preferredPixels);
+ placeFrameInFreeSlot(connectionFrame, preferredPixels);
- resizeEvent(NULL);
+ resizeEvent(NULL);
}
/***************************************************************************//**
@@ -762,20 +763,19 @@ void MainWindow::onFrameClicked(ConnectionFrame* frame)
{
// If same frame is clicked again,, do nothing
if (getSelectedFrame() == frame)
- return;
+ return;
// If another frame has been selected, unselect it
// Set the ui selected and set a new reference
- if (getSelectedFrame() != NULL)
- {
+ if (getSelectedFrame() != NULL) {
getSelectedFrame()->setSelection(false);
}
frame->setSelection(true);
qDebug() << "ID of frame: " << frame->computerId();
qDebug() << "ID of selectedFrame: " << getSelectedFrame()->computerId();
- qDebug() << "position of selectedFrame: " << getSelectedFrame()->getGridPosition();
+ qDebug() << "position of selectedFrame: " << getSelectedFrame()->getGridPosition();
- unlockContextButtons();
+ unlockContextButtons();
}
/***************************************************************************//**
@@ -784,16 +784,13 @@ void MainWindow::onFrameClicked(ConnectionFrame* frame)
void MainWindow::onSessionNameClick()
{
_countSessionNameUpdate++;
- if (_countSessionNameUpdate > 1)
- {
+ if (_countSessionNameUpdate > 1) {
int ret = QMessageBox::question(this, "Warning", tr("Sure, You want to change SessionName again?\n"
- "All Clients will be deleted afterwards."), 0, 1, 2);
- if (ret == 1)
- {
+ "All Clients will be deleted afterwards."), 0, 1, 2);
+ if (ret == 1) {
_sessionNameWindow->show(Global::sessionName());
}
- }
- else
+ } else
_sessionNameWindow->show((Global::sessionName()));
}
@@ -804,11 +801,9 @@ void MainWindow::onSessionNameUpdate()
{
// Stop all projections and clear all clients, which where connected to old sessionName.
reset();
- if (_countSessionNameUpdate > 1)
- {
+ if (_countSessionNameUpdate > 1) {
{
- for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
- {
+ for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) {
(*it)->hide();
(*it)->deleteLater();
}
@@ -863,79 +858,78 @@ void MainWindow::onReloadRoomCancel()
_reloadWindow->hide();
}
-void MainWindow::switchRoomTo(QString roomToReload) {
- // qDebug() << roomToReload;
- Global::setCurrentRoom(roomToReload);
- Room *room = Global::getRooms()[roomToReload];
- /* set tiles */
- _tilesX = room->gridSize.width();
- _tilesY = room->gridSize.height();
-
-
- /* place connection frames */
- for (auto it = room->clientPositions.begin(); it != room->clientPositions.end(); ++it) {
- QString computerId = it.key();
- QPoint pos = it.value();
- QPoint pxPos(pos.x() * getTileWidthPx(), pos.y() * getTileHeightPx());
-
- ConnectionFrame *cf = createFrame(computerId, pxPos, pos);
- cf->move(cf->getCurrentPosition());
- onPlaceFrame(false, cf);
- if (computerId == room->tutorIP) {
- qDebug() << "set computer with id " << computerId << " as tutor per configuration";
- if (getTutorFrame() != NULL) {
- getTutorFrame()->setTutor(false);
- }
- cf->setTutor(true);
- } else {
- //qDebug() << "not tutor because id is " << computerId << " and tutorIP is " << room->tutorIP;
- }
- }
-
- /* load background image */
- QString imgPath = Global::getCurrentRoom()->imagePath;
- qDebug() << "imgPath is " << imgPath;
-
- /* delete old image */
- if (_backgroundImage != NULL) {delete _backgroundImage; }
- _backgroundImage = NULL;
-
- if (imgPath != "") {
- qDebug() << "set background image path: " << imgPath;
- if (imgPath.endsWith("svg")) {
- /* render once with maximal screen size */
- const QSize &s = QApplication::desktop()->screenGeometry().size(); // ui->frmRoom->geometry().size();
- QSvgRenderer renderer(imgPath);
- _backgroundImage = new QImage(s, QImage::Format_ARGB32);
- _backgroundImage->fill(Qt::lightGray); /* background color */
- QPainter painter(_backgroundImage);
- renderer.render(&painter);
- } else {
- _backgroundImage = new QImage();
- _backgroundImage->load(imgPath);
- }
- }
-
- /* and force a resize event (this scales the image) */
- resizeEvent(NULL);
+void MainWindow::switchRoomTo(QString roomToReload)
+{
+ // qDebug() << roomToReload;
+ Global::setCurrentRoom(roomToReload);
+ Room *room = Global::getRooms()[roomToReload];
+ /* set tiles */
+ _tilesX = room->gridSize.width();
+ _tilesY = room->gridSize.height();
+
+
+ /* place connection frames */
+ for (auto it = room->clientPositions.begin(); it != room->clientPositions.end(); ++it) {
+ QString computerId = it.key();
+ QPoint pos = it.value();
+ QPoint pxPos(pos.x() * getTileWidthPx(), pos.y() * getTileHeightPx());
+
+ ConnectionFrame *cf = createFrame(computerId, pxPos, pos);
+ cf->move(cf->getCurrentPosition());
+ onPlaceFrame(false, cf);
+ if (computerId == room->tutorIP) {
+ qDebug() << "set computer with id " << computerId << " as tutor per configuration";
+ if (getTutorFrame() != NULL) {
+ getTutorFrame()->setTutor(false);
+ }
+ cf->setTutor(true);
+ } else {
+ //qDebug() << "not tutor because id is " << computerId << " and tutorIP is " << room->tutorIP;
+ }
+ }
+
+ /* load background image */
+ QString imgPath = Global::getCurrentRoom()->imagePath;
+ qDebug() << "imgPath is " << imgPath;
+
+ /* delete old image */
+ if (_backgroundImage != NULL) {delete _backgroundImage; }
+ _backgroundImage = NULL;
+
+ if (imgPath != "") {
+ qDebug() << "set background image path: " << imgPath;
+ if (imgPath.endsWith("svg")) {
+ /* render once with maximal screen size */
+ const QSize &s = QApplication::desktop()->screenGeometry().size(); // ui->frmRoom->geometry().size();
+ QSvgRenderer renderer(imgPath);
+ _backgroundImage = new QImage(s, QImage::Format_ARGB32);
+ _backgroundImage->fill(Qt::lightGray); /* background color */
+ QPainter painter(_backgroundImage);
+ renderer.render(&painter);
+ } else {
+ _backgroundImage = new QImage();
+ _backgroundImage->load(imgPath);
+ }
+ }
+
+ /* and force a resize event (this scales the image) */
+ resizeEvent(NULL);
}
void MainWindow::onReloadRoomOk()
{
- if (_reloadWindow->ui->roomList->currentItem() == NULL)
- {
+ if (_reloadWindow->ui->roomList->currentItem() == NULL) {
QMessageBox::critical(this, "Warning", tr("No item selected, please select room!"), 0, 1);
return;
}
int ret = QMessageBox::QMessageBox::question(this, "Warning", tr("Are you sure you want to reload the room?\n"
- "Note that all clients will be deleted."), 0, 1, 2);
+ "Note that all clients will be deleted."), 0, 1, 2);
if (ret == 1) {
disconnect(_reloadWindow->ui->buttonBox, SIGNAL(accepted()), this, SLOT(onReloadRoomOk()));
disconnect(_reloadWindow->ui->buttonBox, SIGNAL(rejected()), this, SLOT(onReloadRoomCancel()));
// Delete all clients.
- for (QList<ConnectionFrame*>::iterator it = _clientFrames.begin(); it != _clientFrames.end(); it++)
- {
+ for (QList<ConnectionFrame*>::iterator it = _clientFrames.begin(); it != _clientFrames.end(); it++) {
(*it)->hide();
(*it)->deleteLater();
}
@@ -943,19 +937,21 @@ void MainWindow::onReloadRoomOk()
// Load new room configuration.
QString roomToReload = _reloadWindow->ui->roomList->currentItem()->data(0).toString();
- switchRoomTo(roomToReload);
+ switchRoomTo(roomToReload);
_reloadWindow->ui->roomList->clear();
_reloadWindow->hide();
- }
+ }
}
-int MainWindow::getTileWidthPx() const {
- return ui->frmRoom->size().width() / _tilesX;
+int MainWindow::getTileWidthPx() const
+{
+ return ui->frmRoom->size().width() / _tilesX;
}
-int MainWindow::getTileHeightPx() const {
- return ui->frmRoom->size().height() / _tilesY;
+int MainWindow::getTileHeightPx() const
+{
+ return ui->frmRoom->size().height() / _tilesY;
}
/***************************************************************************//**
@@ -981,8 +977,7 @@ void MainWindow::onButtonTutorToAll()
QMessageBox::critical(this, tr("Projection"), sStrTutorOffline);
else if (_clientFrames.size() == 1)
QMessageBox::critical(this, tr("Projection"), sStrNoDestAv);
- else
- {
+ else {
// If this mode is already active, reset everything
if (_mode == Mode::Broadcast) {
reset();
@@ -1018,8 +1013,7 @@ void MainWindow::onButtonTutorToStudent()
QMessageBox::critical(this, tr("Projection"), sStrDestOffline);
else if (getTutorFrame()->client() == NULL)
QMessageBox::critical(this, tr("Projection"), sStrTutorOffline);
- else
- {
+ else {
// If this is the first call in this mode clear the watchers
if (_mode != Mode::Multicast) {
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
@@ -1057,11 +1051,9 @@ void MainWindow::onButtonStudentToTutor()
QMessageBox::critical(this, tr("Projection"), sStrSourceOffline);
else if (getTutorFrame()->client() == NULL)
QMessageBox::critical(this, tr("Projection"), sStrTutorOffline);
- else
- {
+ else {
// If this is not the first run in this mode and the current source is selected, stop the streaming.
- if (_mode == Mode::Unicast && getSelectedFrame()->client()->id() == _streamingSource)
- {
+ if (_mode == Mode::Unicast && getSelectedFrame()->client()->id() == _streamingSource) {
// Stop reset everything
_mode = Mode::None;
reset();
@@ -1071,7 +1063,7 @@ void MainWindow::onButtonStudentToTutor()
// Unset all clients desired sources. Except the tutors desired source, this has to be the selecteds frame
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
if ((*it)->client() != NULL)
- (*it)->client()->setDesiredProjectionSource(getTutorFrame()->client()->id() == (*it)->client()->id() ? getSelectedFrame()->client()->id():NO_SOURCE);
+ (*it)->client()->setDesiredProjectionSource(getTutorFrame()->client()->id() == (*it)->client()->id() ? getSelectedFrame()->client()->id() : NO_SOURCE);
DisableButtons();
_mode = Mode::Unicast;
@@ -1097,11 +1089,9 @@ void MainWindow::onButtonStudentToTutorExclusive()
QMessageBox::critical(this, tr("Projection"), sStrSourceOffline);
else if (getTutorFrame()->client() == NULL)
QMessageBox::critical(this, tr("Projection"), sStrTutorOffline);
- else
- {
+ else {
// If this is not the first run in this mode and the current source is selected, stop the streaming.
- if (_mode == Mode::Unicast && getSelectedFrame()->client()->id() == _streamingSource)
- {
+ if (_mode == Mode::Unicast && getSelectedFrame()->client()->id() == _streamingSource) {
// Stop reset everything
_mode = Mode::None;
reset();
@@ -1111,7 +1101,7 @@ void MainWindow::onButtonStudentToTutorExclusive()
// Unset all clients desired sources. Except the tutors desired source, this has to be the selecteds frame
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
if ((*it)->client() != NULL)
- (*it)->client()->setDesiredProjectionSource(getTutorFrame()->client()->id() == (*it)->client()->id() ? getSelectedFrame()->client()->id():NO_SOURCE);
+ (*it)->client()->setDesiredProjectionSource(getTutorFrame()->client()->id() == (*it)->client()->id() ? getSelectedFrame()->client()->id() : NO_SOURCE);
DisableButtons();
_mode = Mode::LockedUnicast;
@@ -1142,8 +1132,7 @@ void MainWindow::onButtonLock(bool checked)
// Stop all projections
reset();
- for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
- {
+ for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) {
if ((*it)->client() == NULL)
continue;
(*it)->client()->lockScreen(checked);
@@ -1167,20 +1156,16 @@ void MainWindow::onButtonSetAsTutor()
ui->action_Lock->setChecked(false);
// If no frame is selected, warning.
- if (getSelectedFrame() == NULL)
- {
+ if (getSelectedFrame() == NULL) {
QMessageBox::critical(this, tr("Selection"), tr("No client is selected."));
return;
}
// If frame of inactive client has been selected unselect it
- if (getSelectedFrame()->client() == NULL)
- {
+ if (getSelectedFrame()->client() == NULL) {
QMessageBox::critical(this, tr("Selection"), tr("The selected client is not connected."));
return;
- }
- else // If selected client is locked, first unlock
- {
+ } else { // If selected client is locked, first unlock
getSelectedFrame()->client()->lockScreen(false);
}
@@ -1189,8 +1174,7 @@ void MainWindow::onButtonSetAsTutor()
return;
// Else unset the old and set the new tutor
- if (getTutorFrame() != NULL)
- {
+ if (getTutorFrame() != NULL) {
getTutorFrame()->setTutor(false);
}
getSelectedFrame()->setTutor(true);
@@ -1227,23 +1211,19 @@ void MainWindow::onClientAuthenticating(Client* client, ClientLogin* request)
bool inuse;
QString check = request->name;
int addnum = 1;
- do
- {
+ do {
inuse = false;
- for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
- {
+ for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) {
Client *c = (**it).client();
if (c == NULL)
continue;
if (!c->isAuthed())
continue;
- if (c->ip() == request->ip)
- {
+ if (c->ip() == request->ip) {
request->accept = false;
return;
}
- if (c->name() == check)
- {
+ if (c->name() == check) {
inuse = true;
check = request->name + " (" + QString::number(++addnum) + ")";
break;
@@ -1273,17 +1253,14 @@ void MainWindow::onClientAuthenticated(Client* client)
connect(client, SIGNAL(vncClientStateChange(Client*)), this, SLOT(onVncClientStateChange(Client*)));
bool hasActiveTutor = false;
ConnectionFrame *existing = NULL;
- for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
- {
+ for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) {
// qDebug() << "Existing frame ip: " << (*it)->computerId();
// qDebug() << "New Clients ip: " << client->ip();
// qDebug() << ((*it)->computerId() == client->ip());
- if ((*it)->computerId() == client->ip())
- {
+ if ((*it)->computerId() == client->ip()) {
existing = *it;
}
- if ((*it)->isTutor())
- {
+ if ((*it)->isTutor()) {
if ((*it)->client() != NULL)
hasActiveTutor = true;
}
@@ -1291,21 +1268,17 @@ void MainWindow::onClientAuthenticated(Client* client)
bool isTutor = false;
- if (!hasActiveTutor)
- {
- for (int i = 0; i < _tutorList.size(); i++)
- {
+ if (!hasActiveTutor) {
+ for (int i = 0; i < _tutorList.size(); i++) {
// Check if client is possible tutor
- if (client->ip() == _tutorList[i])
- {
+ if (client->ip() == _tutorList[i]) {
isTutor = true;
break;
}
}
}
// Clients ip already exists, but was not active.
- if (existing != NULL)
- {
+ if (existing != NULL) {
// qDebug() << "Should go into this if clause.";
existing->setTutor(isTutor);
existing->assignClient(client);
@@ -1325,8 +1298,7 @@ void MainWindow::onClientAuthenticated(Client* client)
if (x >= _tilesX || y >= _tilesY)
ok = false;
- if (ok)
- {
+ if (ok) {
if (x < 0)
x = 0;
if (y < 0)
@@ -1334,9 +1306,7 @@ void MainWindow::onClientAuthenticated(Client* client)
qDebug("Move E");
cf->move(x * getTileWidthPx(), y * getTileHeightPx());
onPlaceFrame(true, cf);
- }
- else
- {
+ } else {
// Move to any free tile
placeFrameInFreeSlot(cf);
}
@@ -1345,7 +1315,7 @@ void MainWindow::onClientAuthenticated(Client* client)
// Assign client instance
cf->assignClient(client);
- resizeEvent(NULL); // This is where all the positioning should be
+ resizeEvent(NULL); // This is where all the positioning should be
tellClientCurrentSituation(client);
updateExamMode();
@@ -1362,12 +1332,10 @@ void MainWindow::onVncServerStateChange(Client* client)
if (client == getClientFromId(_streamingSource))
EnableButtons();
- if (client->isActiveVncServer())
- {
+ if (client->isActiveVncServer()) {
// apply the desired projection sources
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
- if ( (*it)->client() != NULL) // Ignore offline clients
- {
+ if ( (*it)->client() != NULL) { // Ignore offline clients
if ( (*it)->client()->desiredProjectionSource() == client->id() )
(*it)->client()->startVncClient(client);
else
@@ -1377,14 +1345,10 @@ void MainWindow::onVncServerStateChange(Client* client)
}
// Dont forget to unlock the vnc server
client->lockScreen(false);
- }
- else
- {
+ } else {
// VNC server stopped on some client or failed to start - reset local pending projection information
- for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
- {
- if ((*it)->client() != NULL)
- {
+ for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) {
+ if ((*it)->client() != NULL) {
if ((*it)->client()->desiredProjectionSource() == client->id()) {
(*it)->client()->setDesiredProjectionSource(NO_SOURCE);
(*it)->client()->stopVncClient();
@@ -1397,7 +1361,7 @@ void MainWindow::onVncServerStateChange(Client* client)
client->lockScreen(client->desiredProjectionSource() == NO_SOURCE && _mode == Mode::LockedUnicast);
// If this was the current source remember that there is no source anymore and reset mode
- if (client == getClientFromId(_streamingSource)){
+ if (client == getClientFromId(_streamingSource)) {
_streamingSource = NO_SOURCE;
_mode = Mode::None;
}
@@ -1412,11 +1376,9 @@ void MainWindow::onVncServerStateChange(Client* client)
*/
void MainWindow::onVncClientStateChange(Client* client)
{
- if (client != NULL)
- {
+ if (client != NULL) {
// VNC Client stopped -> remove from watchers
- if (!client->isActiveVncClient())
- {
+ if (!client->isActiveVncClient()) {
// Only unset a desired Projection source if it has not changed meanwhile
if (client->projectionSource() == client->desiredProjectionSource())
client->setDesiredProjectionSource(NO_SOURCE);
@@ -1438,8 +1400,7 @@ void MainWindow::onVncClientStateChange(Client* client)
break;
}
- if ( !(serverHasWatchers || _mode == Mode::Broadcast) )
- {
+ if ( !(serverHasWatchers || _mode == Mode::Broadcast) ) {
Client* c = getClientFromId(client->projectionSource());
if (c != NULL)
c->stopVncServer();
@@ -1453,10 +1414,10 @@ void MainWindow::onVncClientStateChange(Client* client)
*/
void MainWindow::DisableButtons()
{
- qDebug() << "DisableButtons()";
+ qDebug() << "DisableButtons()";
_buttonLockTimer->start();
- foreach (QAction* a, _lockingButtons)
- a->setDisabled(true);
+ foreach (QAction * a, _lockingButtons)
+ a->setDisabled(true);
}
/***************************************************************************//**
@@ -1464,16 +1425,17 @@ void MainWindow::DisableButtons()
*/
void MainWindow::EnableButtons()
{
- qDebug() << "EnableButtons()";
+ qDebug() << "EnableButtons()";
_buttonLockTimer->stop();
- foreach (QAction* a, _lockingButtons)
- a->setEnabled(true);
+ foreach (QAction * a, _lockingButtons)
+ a->setEnabled(true);
}
-void MainWindow::onDeleteClient() {
+void MainWindow::onDeleteClient()
+{
// If no frame is selected, warning.
- ConnectionFrame* frame = getSelectedFrame();
+ ConnectionFrame* frame = getSelectedFrame();
if (frame == NULL) {
QMessageBox::critical(this, tr("Selection"), tr("No client is selected."));
return;
@@ -1482,20 +1444,20 @@ void MainWindow::onDeleteClient() {
QMessageBox::critical(this, tr("Selection"), tr("This client is still connected."));
return;
} else {
- qDebug() << "Now delete the client";
- int ret = QMessageBox::question(this, "Warning", tr("Sure, You want to delete selected client?"), 0, 1, 2);
- if (ret == 1) {
- frame->hide();
- frame->deleteLater();
- _clientFrames.removeOne(frame);
- lockContextButtons();
+ qDebug() << "Now delete the client";
+ int ret = QMessageBox::question(this, "Warning", tr("Sure, You want to delete selected client?"), 0, 1, 2);
+ if (ret == 1) {
+ frame->hide();
+ frame->deleteLater();
+ _clientFrames.removeOne(frame);
+ lockContextButtons();
updateExamMode();
- return;
- } else {
- frame->move(frame->getPreviousPosition());
+ return;
+ } else {
+ frame->move(frame->getPreviousPosition());
updateExamMode();
- return;
- }
+ return;
+ }
}