From bcaa6c6b8a8f5bd54647bd462e045ba90a3ca9b0 Mon Sep 17 00:00:00 2001 From: RickyRister <42636155+RickyRister@users.noreply.github.com> Date: Mon, 21 Apr 2025 13:30:40 -0700 Subject: [PATCH] Refactor files in common to new Qt Slot/Signal syntax (#5872) --- common/server.cpp | 10 +++++----- common/server_game.cpp | 2 +- common/server_protocolhandler.cpp | 2 +- common/server_room.cpp | 7 ++++--- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/common/server.cpp b/common/server.cpp index a8223c599..4b0120ea1 100644 --- a/common/server.cpp +++ b/common/server.cpp @@ -51,8 +51,7 @@ Server::Server(QObject *parent) : QObject(parent), nextLocalGameId(0), tcpUserCo qRegisterMetaType("IslMessage"); qRegisterMetaType("Command_JoinGame"); - connect(this, SIGNAL(sigSendIslMessage(IslMessage, int)), this, SLOT(doSendIslMessage(IslMessage, int)), - Qt::QueuedConnection); + connect(this, &Server::sigSendIslMessage, this, &Server::doSendIslMessage, Qt::QueuedConnection); } void Server::prepareDestroy() @@ -67,7 +66,7 @@ void Server::prepareDestroy() void Server::setDatabaseInterface(Server_DatabaseInterface *_databaseInterface) { - connect(this, SIGNAL(endSession(qint64)), _databaseInterface, SLOT(endSession(qint64))); + connect(this, &Server::endSession, _databaseInterface, &Server_DatabaseInterface::endSession); databaseInterfaces.insert(QThread::currentThread(), _databaseInterface); } @@ -568,8 +567,9 @@ void Server::addRoom(Server_Room *newRoom) QWriteLocker locker(&roomsLock); qDebug() << "Adding room: ID=" << newRoom->getId() << "name=" << newRoom->getName(); rooms.insert(newRoom->getId(), newRoom); - connect(newRoom, SIGNAL(roomInfoChanged(ServerInfo_Room)), this, SLOT(broadcastRoomUpdate(const ServerInfo_Room &)), - Qt::QueuedConnection); + connect( + newRoom, &Server_Room::roomInfoChanged, this, [this](auto roomInfo) { broadcastRoomUpdate(roomInfo); }, + Qt::QueuedConnection); } int Server::getUsersCount() const diff --git a/common/server_game.cpp b/common/server_game.cpp index 17ab01dda..9387ccd37 100644 --- a/common/server_game.cpp +++ b/common/server_game.cpp @@ -87,7 +87,7 @@ Server_Game::Server_Game(const ServerInfo_User &_creatorInfo, if (room->getServer()->getGameShouldPing()) { pingClock = new QTimer(this); - connect(pingClock, SIGNAL(timeout()), this, SLOT(pingClockTimeout())); + connect(pingClock, &QTimer::timeout, this, &Server_Game::pingClockTimeout); pingClock->start(1000); } } diff --git a/common/server_protocolhandler.cpp b/common/server_protocolhandler.cpp index 045b84487..075b3901e 100644 --- a/common/server_protocolhandler.cpp +++ b/common/server_protocolhandler.cpp @@ -36,7 +36,7 @@ Server_ProtocolHandler::Server_ProtocolHandler(Server *_server, idleClientWarningSent(false), timeRunning(0), lastDataReceived(0), lastActionReceived(0) { - connect(server, SIGNAL(pingClockTimeout()), this, SLOT(pingClockTimeout())); + connect(server, &Server::pingClockTimeout, this, &Server_ProtocolHandler::pingClockTimeout); } Server_ProtocolHandler::~Server_ProtocolHandler() diff --git a/common/server_room.cpp b/common/server_room.cpp index 77f720cb5..654666edf 100644 --- a/common/server_room.cpp +++ b/common/server_room.cpp @@ -31,8 +31,9 @@ Server_Room::Server_Room(int _id, permissionLevel(_permissionLevel), privilegeLevel(_privilegeLevel), autoJoin(_autoJoin), joinMessage(_joinMessage), gameTypes(_gameTypes), gamesLock(QReadWriteLock::Recursive) { - connect(this, SIGNAL(gameListChanged(ServerInfo_Game)), this, SLOT(broadcastGameListUpdate(ServerInfo_Game)), - Qt::QueuedConnection); + connect( + this, &Server_Room::gameListChanged, this, [this](auto gameInfo) { broadcastGameListUpdate(gameInfo); }, + Qt::QueuedConnection); } Server_Room::~Server_Room() @@ -352,7 +353,7 @@ void Server_Room::addGame(Server_Game *game) roomInfo.set_room_id(id); gamesLock.lockForWrite(); - connect(game, SIGNAL(gameInfoChanged(ServerInfo_Game)), this, SLOT(broadcastGameListUpdate(ServerInfo_Game))); + connect(game, &Server_Game::gameInfoChanged, this, [this](auto gameInfo) { broadcastGameListUpdate(gameInfo); }); game->gameMutex.lock(); games.insert(game->getGameId(), game);