summaryrefslogtreecommitdiffstats
path: root/src/server/mainwindow/mainwindow.cpp
diff options
context:
space:
mode:
authorSimon Rettberg2022-10-30 20:34:23 +0100
committerSimon Rettberg2022-10-30 20:34:23 +0100
commit9f479b8f76238a03bce5d13aee14efd34e659c6e (patch)
treee320d32838202ac4604032da7a4bc3702cc304da /src/server/mainwindow/mainwindow.cpp
parentUpdate translation files (diff)
downloadpvs2-9f479b8f76238a03bce5d13aee14efd34e659c6e.tar.gz
pvs2-9f479b8f76238a03bce5d13aee14efd34e659c6e.tar.xz
pvs2-9f479b8f76238a03bce5d13aee14efd34e659c6e.zip
Clean up and modernize code
- static "new-style" signal->slot connections - Fix a lot of things Clang-Tidy complained about - Move includes to .cpp files and use forward decls in .h - Don't use <QtWidgets> and <QtCore>, but specific includes instead
Diffstat (limited to 'src/server/mainwindow/mainwindow.cpp')
-rw-r--r--src/server/mainwindow/mainwindow.cpp228
1 files changed, 108 insertions, 120 deletions
diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp
index b63545f..e8247d0 100644
--- a/src/server/mainwindow/mainwindow.cpp
+++ b/src/server/mainwindow/mainwindow.cpp
@@ -16,11 +16,13 @@
// Self
#include "mainwindow.h"
// QT stuff
-#include <QtWidgets>
-#include <QFileDialog>
#include <QSvgRenderer>
#include <QPainter>
#include <QImage>
+#include <QMessageBox>
+#include <QCloseEvent>
+#include <QDialogButtonBox>
+#include <QScreen>
// Other custom UI elements
#include "../serverapp/serverapp.h"
#include "../clicklabel/clicklabel.h"
@@ -32,16 +34,12 @@
#include "../net/listenserver.h"
#include "../net/client.h"
#include "../net/discoverylistener.h"
-#include "../net/filedownloader.h"
// Others
#include "../../shared/settings.h"
#include "../util/platform/screensaver.h"
// Auto-generated ui class
#include "ui_mainwindow.h"
-#include <iostream>
-#include <vector>
-
#define sStrTutorNdef MainWindow::tr("No tutor defined.")
#define sStrTutorOffline MainWindow::tr("Tutor is offline.")
#define sStrSourceNdef MainWindow::tr("Please select a projection source.")
@@ -49,33 +47,24 @@
#define sStrDestNdef MainWindow::tr("Please select a projection destination.")
#define sStrDestOffline MainWindow::tr("The projection destination is offline.")
#define sStrSourceDestSame MainWindow::tr("Selected projection target is tutor.")
-#define sStrClientOnline MainWindow::tr("Selected client is currently online.")
#define sStrNoDestAv MainWindow::tr("No projection destination available.")
-using std::vector;
-using std::cout;
-using std::endl;
-
/**
* Initialize MainWindow and ListenServer.
* @param ipListUrl
* @param parent
*/
-MainWindow::MainWindow(QWidget* parent) :
- QMainWindow(parent), ui(new Ui::MainWindow), _tbIconSize(24), _tbArea(Qt::LeftToolBarArea),
- _lastClientCount(0)
+MainWindow::MainWindow(QWidget* parent)
+ : QMainWindow(parent)
+ , ui(new Ui::MainWindow)
+ , _mode(Mode::Multicast)
{
qDebug() << "MainWindow(parent)";
- _mode = Mode::Multicast;
- _streamingSource = 0;
/* default value, these will be updated a room is loaded */
_tilesX = 10;
_tilesY = 10;
- _virtCols = 0;
- _virtRows = 0;
-
_sessionNameWindow = new SessionNameWindow(this);
_reloadWindow = new ReloadRoomWindow(this);
_reloadWindow->setWindowTitle(tr("Reload Room"));
@@ -113,26 +102,26 @@ MainWindow::MainWindow(QWidget* parent) :
serverApp->setExam(false);
// Close button in tool bar
- connect(ui->action_Exit, SIGNAL(triggered()), this, SLOT(onButtonExit()));
- connect(ui->action_TutorToAll, SIGNAL(triggered()), this, SLOT(onButtonTutorToAll()));
- connect(ui->action_StudentToTutor, SIGNAL(triggered()), this, SLOT(onButtonStudentToTutor()));
- connect(ui->action_StudentToTutorExclusive, SIGNAL(triggered()), this, SLOT(onButtonStudentToTutorExclusive()));
- connect(ui->action_TutorToStudent, SIGNAL(triggered()), this, SLOT(onButtonTutorToStudent()));
- connect(ui->action_StopProjection, SIGNAL(triggered()), this, SLOT(onButtonStopProjection()));
- 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)));
- connect(ui->action_LockSingle, SIGNAL(triggered()), this, SLOT(onButtonLockSingle()));
- 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_Exit, &QAction::triggered, this, &MainWindow::onButtonExit);
+ connect(ui->action_TutorToAll, &QAction::triggered, this, &MainWindow::onButtonTutorToAll);
+ connect(ui->action_StudentToTutor, &QAction::triggered, this, &MainWindow::onButtonStudentToTutor);
+ connect(ui->action_StudentToTutorExclusive, &QAction::triggered, this, &MainWindow::onButtonStudentToTutorExclusive);
+ connect(ui->action_TutorToStudent, &QAction::triggered, this, &MainWindow::onButtonTutorToStudent);
+ connect(ui->action_StopProjection, &QAction::triggered, this, &MainWindow::onButtonStopProjection);
+ connect(ui->action_SetAsTutor, &QAction::triggered, this, &MainWindow::onButtonSetAsTutor);
+ connect(ui->action_SetAsTutor, &QAction::triggered, this, &MainWindow::onButtonStopProjection);
+ connect(ui->action_Lock, &QAction::toggled, this, &MainWindow::onButtonLock);
+ connect(ui->action_LockSingle, &QAction::triggered, this, &MainWindow::onButtonLockSingle);
+ connect(ui->action_Help, &QAction::triggered, this, &MainWindow::onButtonHelp);
+ connect(ui->actionReload_Room_Configuration, &QAction::triggered, this, &MainWindow::onButtonReloadRoomConfig);
+ connect(ui->action_DeleteClient, &QAction::triggered, this, &MainWindow::onDeleteClient);
/* Stuff for the button lock */
//Setup a timeout
_buttonLockTimer = new QTimer(this);
_buttonLockTimer->setSingleShot(true);
_buttonLockTimer->setInterval(BUTTON_BLOCK_TIME);
- connect(_buttonLockTimer, SIGNAL(timeout()), this, SLOT(enableButtons()));
+ connect(_buttonLockTimer, &QTimer::timeout, this, &MainWindow::enableButtons);
// Define the locking buttons
_lockingButtons
<< ui->action_DeleteClient
@@ -146,18 +135,18 @@ MainWindow::MainWindow(QWidget* parent) :
<< ui->action_StopProjection;
// Clicking the session name label shows the edit field for it
- connect(_sessionNameLabel, SIGNAL(clicked()), this, SLOT(onSessionNameClick()));
+ connect(_sessionNameLabel, &ClickLabel::clicked, this, &MainWindow::onSessionNameClick);
// Listen to updates to the session name through the session name window
- connect(_sessionNameWindow, SIGNAL(updateSessionName()), this,
- SLOT(onSessionNameUpdate()));
+ connect(_sessionNameWindow, &SessionNameWindow::updateSessionName,
+ this, &MainWindow::onSessionNameUpdate);
setAttribute(Qt::WA_QuitOnClose);
setUnifiedTitleAndToolBarOnMac(true);
this->showMaximized(); // show the Mainwindow maximized
- _listenServer = new ListenServer(CLIENT_PORT);
- connect(_listenServer, SIGNAL(newClient(Client*)), this, SLOT(onClientConnected(Client*)));
- _discoveryListener = new DiscoveryListener();
+ auto *ls = new ListenServer(CLIENT_PORT, this);
+ connect(ls, &ListenServer::newClient, this, &MainWindow::onClientConnected);
+ new DiscoveryListener(this);
// Finally
this->onSessionNameUpdate(); // Just make lable visible.
@@ -174,8 +163,8 @@ void MainWindow::clientCountChanged()
int clientCount = 0;
- for (auto it = _clientFrames.begin(); it != _clientFrames.end(); ++it) {
- Client* c = (*it)->client();
+ for (auto * frame : _clientFrames) {
+ Client* c = frame->client();
if (c != nullptr) {
bool b = c->isExamMode();
examClientCount += b ? 1 : 0;
@@ -240,7 +229,7 @@ static int distance(QPoint a, QPoint b)
* @param toIgnore, ignore this connectionframe when considering free slots
* @return the free slot
*/
-QPoint MainWindow::closestFreeSlot(const QPoint preferredPixels, const ConnectionFrame* toIgnore)
+QPoint MainWindow::closestFreeSlot(const QPoint &preferredPixels, const ConnectionFrame* toIgnore)
{
const bool pickFirstOne = ( preferredPixels == QPoint(-1, -1) );
const QSize& clientSize = serverApp->getCurrentRoom()->clientSize;
@@ -249,11 +238,11 @@ QPoint MainWindow::closestFreeSlot(const QPoint preferredPixels, const Connectio
memset(grid, 0, sizeof(bool) * size_t(_tilesX * _tilesY)); /* set everything to false */
/* fill grid */
- for (auto it = _clientFrames.begin(); it != _clientFrames.end(); ++it) {
+ for (auto * frame : _clientFrames) {
- if (*it == toIgnore) { continue; }
+ if (frame == toIgnore) { continue; }
- const QPoint p = (*it)->getGridPosition();
+ const QPoint p = frame->getGridPosition();
for (int x = p.x(); x < p.x() + clientSize.width(); x++) {
for (int y = p.y(); y < p.y() + clientSize.height(); y++) {
@@ -322,7 +311,7 @@ void MainWindow::placeFrameInFreeSlot(ConnectionFrame* frame, QPoint preferredPi
*/
ConnectionFrame* MainWindow::createFrame(const QString &computerId, const QPoint* gridPosition, bool fromRoomplan)
{
- ConnectionFrame *cf = new ConnectionFrame(this, ui->frmRoom, fromRoomplan);
+ auto *cf = new ConnectionFrame(this, ui->frmRoom, fromRoomplan);
if (gridPosition == nullptr) {
placeFrameInFreeSlot(cf);
} else {
@@ -331,9 +320,9 @@ ConnectionFrame* MainWindow::createFrame(const QString &computerId, const QPoint
cf->setComputerId(computerId);
_clientFrames.append(cf);
cf->show();
- connect(cf, SIGNAL(frameMoved(ConnectionFrame *)), this, SLOT(onFrameDropped(ConnectionFrame *)));
- connect(cf, SIGNAL(clicked(ConnectionFrame *)), this, SLOT(onFrameClicked(ConnectionFrame *)));
- connect(cf, SIGNAL(frameMoving(ConnectionFrame *)), this, SLOT(onFrameMoving(ConnectionFrame *)));
+ connect(cf, &ConnectionFrame::frameMoved, this, &MainWindow::onFrameDropped);
+ connect(cf, &ConnectionFrame::clicked, this, &MainWindow::onFrameClicked);
+ connect(cf, &ConnectionFrame::frameMoving, this, &MainWindow::onFrameMoving);
return cf;
}
@@ -364,10 +353,10 @@ void MainWindow::tellClientCurrentSituation(Client* client)
*/
Client* MainWindow::getClientFromId(int id)
{
- for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) {
- if ((*it)->client() != nullptr) {
- if ((*it)->client()->id() == id)
- return (*it)->client();
+ for (auto * frame : _clientFrames) {
+ if (frame->client() != nullptr) {
+ if (frame->client()->id() == id)
+ return frame->client();
}
}
return nullptr;
@@ -381,9 +370,9 @@ Client* MainWindow::getClientFromId(int id)
*/
ConnectionFrame* MainWindow::getTutorFrame()
{
- for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) {
- if (((*it) != nullptr) && ((*it)->isTutor()))
- return (*it);
+ for (auto * frame : _clientFrames) {
+ if ((frame != nullptr) && (frame->isTutor()))
+ return frame;
}
return nullptr;
}
@@ -396,9 +385,9 @@ ConnectionFrame* MainWindow::getTutorFrame()
*/
ConnectionFrame* MainWindow::getSelectedFrame()
{
- for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) {
- if (((*it) != nullptr) && ((*it)->isSelected()))
- return (*it);
+ for (auto * frame : _clientFrames) {
+ if ((frame != nullptr) && (frame->isSelected()))
+ return frame;
}
return nullptr;
}
@@ -469,8 +458,8 @@ void MainWindow::resizeEvent(QResizeEvent* /* e */ )
const QSize& clientSize = room->clientSize;
// Check if any frames have been moved beyond the room dimensions
- for (auto it = _clientFrames.begin(); it != _clientFrames.end(); ++it) {
- QPoint bounds = (*it)->getGridPosition();
+ for (auto * frame : _clientFrames) {
+ QPoint bounds = frame->getGridPosition();
while (bounds.x() + clientSize.width() > newGridSize.width()) {
newGridSize += QSize(1, 0);
}
@@ -498,16 +487,16 @@ void MainWindow::resizeEvent(QResizeEvent* /* e */ )
const int maxY = _tilesY - clientSize.height();
/* Bring back frames which are now out of the screen */
- for (auto it = _clientFrames.begin(); it != _clientFrames.end(); ++it) {
- const QPoint gp = (*it)->getGridPosition();
+ for (auto * frame : _clientFrames) {
+ const QPoint gp = frame->getGridPosition();
if ( gp.x() > maxX || gp.y() > maxY ) {
- placeFrameInFreeSlot(*it, (*it)->pos());
+ placeFrameInFreeSlot(frame, frame->pos());
}
}
/* Resize all connection windows */
- for (auto it = _clientFrames.begin(); it != _clientFrames.end(); ++it) {
- (*it)->updateGeometry();
+ for (auto * frame : _clientFrames) {
+ frame->updateGeometry();
}
/* update background image label */
@@ -580,10 +569,10 @@ void MainWindow::reset(bool lock)
}
// Unlock all clients
- for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) {
- if ((*it)->client() != nullptr) {
- (*it)->client()->lockScreen(lock);
- (*it)->client()->removeAttention();
+ for (auto * frame : _clientFrames) {
+ if (frame->client() != nullptr) {
+ frame->client()->lockScreen(lock);
+ frame->client()->removeAttention();
}
}
@@ -595,6 +584,7 @@ void MainWindow::reset(bool lock)
void MainWindow::onFrameMoving(ConnectionFrame* connectionFrame)
{
+ // Get where the frame would be placed, and show a blue shadow in that spot
QPoint slot = closestFreeSlot(connectionFrame->pos(), connectionFrame);
_dropMarker->setGeometry(slot.x() * getTileWidthPx(), slot.y() * getTileHeightPx(), connectionFrame->width(), connectionFrame->height());
if (!_dropMarker->isVisible()) {
@@ -611,11 +601,8 @@ void MainWindow::onFrameMoving(ConnectionFrame* connectionFrame)
void MainWindow::onFrameDropped(ConnectionFrame* connectionFrame)
{
_dropMarker->hide();
- // if (_tilesX <= 0 || _tilesY <= 0) return;
const QPoint preferredPixels = connectionFrame->pos();
placeFrameInFreeSlot(connectionFrame, preferredPixels);
-
- //resizeEvent(nullptr);
}
/**
@@ -626,7 +613,7 @@ void MainWindow::onFrameClicked(ConnectionFrame* frame)
{
_dropMarker->hide();
ConnectionFrame *current = getSelectedFrame();
- // If same frame is clicked again,, do nothing
+ // If same frame is clicked again, do nothing
if (current == frame)
return;
@@ -710,19 +697,19 @@ void MainWindow::startVncServerIfNecessary(int from)
void MainWindow::onButtonReloadRoomConfig()
{
- connect(_reloadWindow->buttonBox(), SIGNAL(accepted()), this, SLOT(onReloadRoomOk()));
- connect(_reloadWindow->buttonBox(), SIGNAL(rejected()), this, SLOT(onReloadRoomCancel()));
+ connect(_reloadWindow->buttonBox(), &QDialogButtonBox::accepted, this, &MainWindow::onReloadRoomOk);
+ connect(_reloadWindow->buttonBox(), &QDialogButtonBox::rejected, this, &MainWindow::onReloadRoomCancel);
QList<QString> keyList = serverApp->getRooms().keys();
- for (QList<QString>::iterator it = keyList.begin(); it != keyList.end() ; it++) {
- _reloadWindow->addRoom(*it);
+ for (const auto & it : keyList) {
+ _reloadWindow->addRoom(it);
}
_reloadWindow->show();
}
void MainWindow::onReloadRoomCancel()
{
- disconnect(_reloadWindow->buttonBox(), SIGNAL(accepted()), this, SLOT(onReloadRoomOk()));
- disconnect(_reloadWindow->buttonBox(), SIGNAL(rejected()), this, SLOT(onReloadRoomCancel()));
+ disconnect(_reloadWindow->buttonBox(), &QDialogButtonBox::accepted, this, &MainWindow::onReloadRoomOk);
+ disconnect(_reloadWindow->buttonBox(), &QDialogButtonBox::rejected, this, &MainWindow::onReloadRoomCancel);
_reloadWindow->clearRoomList();
_reloadWindow->hide();
}
@@ -730,7 +717,7 @@ void MainWindow::onReloadRoomCancel()
void MainWindow::reloadCurrentRoom()
{
/* delete old image */
- if (_backgroundImage != nullptr) {delete _backgroundImage; }
+ delete _backgroundImage;
_backgroundImage = nullptr;
const Room *room = serverApp->getCurrentRoom();
@@ -742,8 +729,8 @@ void MainWindow::reloadCurrentRoom()
/* place connection frames */
for (auto it = room->clientPositions.begin(); it != room->clientPositions.end(); ++it) {
- QString computerId = it.key();
- QPoint pos = it.value();
+ const QString& computerId = it.key();
+ const QPoint& pos = it.value();
ConnectionFrame *cf = createFrame(computerId, &pos, true);
onFrameDropped(cf);
@@ -764,7 +751,7 @@ void MainWindow::reloadCurrentRoom()
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();
+ QSize s = QGuiApplication::screenAt(geometry().center())->size();
QSvgRenderer renderer(imgPath);
_backgroundImage = new QImage(s, QImage::Format_ARGB32);
_backgroundImage->fill(Qt::lightGray); /* background color */
@@ -794,12 +781,12 @@ void MainWindow::onReloadRoomOk()
"Note that all clients will be deleted."),
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
if (ret == QMessageBox::Yes) {
- disconnect(_reloadWindow->buttonBox(), SIGNAL(accepted()), this, SLOT(onReloadRoomOk()));
- disconnect(_reloadWindow->buttonBox(), SIGNAL(rejected()), this, SLOT(onReloadRoomCancel()));
+ disconnect(_reloadWindow->buttonBox(), &QDialogButtonBox::accepted, this, &MainWindow::onReloadRoomOk);
+ disconnect(_reloadWindow->buttonBox(), &QDialogButtonBox::rejected, this, &MainWindow::onReloadRoomCancel);
// Delete all clients.
- for (QList<ConnectionFrame*>::iterator it = _clientFrames.begin(); it != _clientFrames.end(); it++) {
- (*it)->hide();
- (*it)->deleteLater();
+ for (auto * frame : _clientFrames) {
+ frame->hide();
+ frame->deleteLater();
}
_clientFrames.clear();
@@ -864,9 +851,9 @@ void MainWindow::onButtonTutorToAll()
}
// Set all clients as watchers of tutor. Except for the tutors desired source, which hase to be none
- for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
- if ((*it)->client() != nullptr)
- (*it)->client()->setDesiredProjectionSource((*it)->client() == getTutorFrame()->client() ? NO_SOURCE : getTutorFrame()->client()->id());
+ for (auto * frame : _clientFrames)
+ if (frame->client() != nullptr)
+ frame->client()->setDesiredProjectionSource(frame->client() == getTutorFrame()->client() ? NO_SOURCE : getTutorFrame()->client()->id());
disableButtons();
_mode = Mode::Broadcast;
@@ -913,7 +900,7 @@ void MainWindow::onButtonTutorToStudent()
disableButtons();
int numClients = 0;
- for (auto c : _clientFrames) {
+ for (auto * c : _clientFrames) {
if (c->client() != nullptr && c->client()->desiredProjectionSource() == sourceClient->id()) {
numClients++;
}
@@ -1035,10 +1022,10 @@ void MainWindow::onButtonLockSingle()
client->lockScreen(newState);
if (!newState) {
// If no more clients are locked, reset button
- for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) {
- if ((*it)->client() == nullptr)
+ for (auto * frame : _clientFrames) {
+ if (frame->client() == nullptr)
continue;
- if ((*it)->client()->isLocked())
+ if (frame->client()->isLocked())
return;
}
ui->action_Lock->setChecked(false);
@@ -1089,8 +1076,8 @@ void MainWindow::onButtonSetAsTutor()
*/
void MainWindow::onClientConnected(Client* client)
{
- connect(client, SIGNAL(authenticating(Client*, ClientLogin*)), this, SLOT(onClientAuthenticating(Client*, ClientLogin*)));
- connect(client, SIGNAL(authenticated(Client*)), this, SLOT(onClientAuthenticated(Client*)));
+ connect(client, &Client::authenticating, this, &MainWindow::onClientAuthenticating);
+ connect(client, &Client::authenticated, this, &MainWindow::onClientAuthenticated);
}
/**
@@ -1105,7 +1092,7 @@ void MainWindow::onClientConnected(Client* client)
*/
void MainWindow::onClientAuthenticating(Client* client, ClientLogin* request)
{
- disconnect(client, SIGNAL(authenticating(Client*, ClientLogin*)), this, SLOT(onClientAuthenticating(Client*, ClientLogin*)));
+ disconnect(client, &Client::authenticating, this, &MainWindow::onClientAuthenticating);
/* copy examMode */
client->setExamMode(request->examMode);
@@ -1116,8 +1103,8 @@ void MainWindow::onClientAuthenticating(Client* client, ClientLogin* request)
int addnum = 1;
do {
inuse = false;
- for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) {
- Client *c = (**it).client();
+ for (auto * frame : _clientFrames) {
+ Client *c = frame->client();
if (c == nullptr)
continue;
if (!c->isAuthed())
@@ -1133,10 +1120,11 @@ void MainWindow::onClientAuthenticating(Client* client, ClientLogin* request)
}
}
} while (inuse && addnum < 100);
- if (inuse)
+ if (inuse) {
request->accept = false;
- else
+ } else {
request->name = check;
+ }
}
/**
@@ -1151,14 +1139,14 @@ void MainWindow::onClientAuthenticating(Client* client, ClientLogin* request)
*/
void MainWindow::onClientAuthenticated(Client* client)
{
- disconnect(client, SIGNAL(authenticated(Client*)), this, SLOT(onClientAuthenticated(Client*)));
- connect(client, SIGNAL(vncServerStateChange(Client*)), this, SLOT(onVncServerStateChange(Client*)));
- connect(client, SIGNAL(vncClientStateChange(Client*)), this, SLOT(onVncClientStateChange(Client*)));
+ disconnect(client, &Client::authenticated, this, &MainWindow::onClientAuthenticated);
+ connect(client, &Client::vncServerStateChange, this, &MainWindow::onVncServerStateChange);
+ connect(client, &Client::vncClientStateChange, this, &MainWindow::onVncClientStateChange);
ConnectionFrame *existing = nullptr;
ConnectionFrame *cf = nullptr;
- for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) {
- if ((*it)->computerId() == client->ip()) {
- existing = *it;
+ for (auto * frame : _clientFrames) {
+ if (frame->computerId() == client->ip()) {
+ existing = frame;
}
}
@@ -1170,7 +1158,7 @@ void MainWindow::onClientAuthenticated(Client* client)
}
cf->assignClient(client);
- connect(client, SIGNAL(disconnected()), this, SLOT(clientCountChanged()));
+ connect(client, &Client::disconnected, this, &MainWindow::clientCountChanged);
tellClientCurrentSituation(client);
clientCountChanged();
}
@@ -1203,13 +1191,13 @@ void MainWindow::onVncServerStateChange(Client* client)
client->lockScreen(false);
} 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() != nullptr) {
- if ((*it)->client()->desiredProjectionSource() == client->id()) {
- (*it)->client()->setDesiredProjectionSource(NO_SOURCE);
- (*it)->client()->stopVncClient();
+ for (auto * frame : _clientFrames) {
+ if (frame->client() != nullptr) {
+ if (frame->client()->desiredProjectionSource() == client->id()) {
+ frame->client()->setDesiredProjectionSource(NO_SOURCE);
+ frame->client()->stopVncClient();
if (_mode == Mode::LockedUnicast)
- (*it)->client()->lockScreen(true);
+ frame->client()->lockScreen(true);
}
}
}
@@ -1250,14 +1238,14 @@ void MainWindow::onVncClientStateChange(Client* client)
* the new connect.
*/
bool serverHasWatchers = false;
- for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
- if ((*it)->client() != nullptr)
- if ((*it)->client()->desiredProjectionSource() == client->projectionSource()) {
+ for (auto * frame : _clientFrames)
+ if (frame->client() != nullptr)
+ if (frame->client()->desiredProjectionSource() == client->projectionSource()) {
serverHasWatchers = true;
break;
}
- if ( !serverHasWatchers ) {
+ if (!serverHasWatchers) {
Client* c = getClientFromId(client->projectionSource());
if (c != nullptr)
c->stopVncServer();