Refactor codebase to new Qt Slot/Signal syntax - Pt1 (#5202)

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
Co-authored-by: ZeldaZach <zahalpern+github@gmail.com>
This commit is contained in:
BruebachL 2024-12-22 03:01:17 +01:00 committed by GitHub
parent 4823cce622
commit 07ee271478
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 38 additions and 45 deletions

View file

@ -52,7 +52,7 @@ AbstractClient::AbstractClient(QObject *parent)
FeatureSet features; FeatureSet features;
features.initalizeFeatureList(clientFeatures); features.initalizeFeatureList(clientFeatures);
connect(this, SIGNAL(sigQueuePendingCommand(PendingCommand *)), this, SLOT(queuePendingCommand(PendingCommand *))); connect(this, &AbstractClient::sigQueuePendingCommand, this, &AbstractClient::queuePendingCommand);
} }
AbstractClient::~AbstractClient() AbstractClient::~AbstractClient()

View file

@ -38,7 +38,7 @@ void ReleaseChannel::checkForUpdates()
QString releaseChannelUrl = getReleaseChannelUrl(); QString releaseChannelUrl = getReleaseChannelUrl();
qDebug() << "Searching for updates on the channel: " << releaseChannelUrl; qDebug() << "Searching for updates on the channel: " << releaseChannelUrl;
response = netMan->get(QNetworkRequest(releaseChannelUrl)); response = netMan->get(QNetworkRequest(releaseChannelUrl));
connect(response, SIGNAL(finished()), this, SLOT(releaseListFinished())); connect(response, &QNetworkReply::finished, this, &ReleaseChannel::releaseListFinished);
} }
// Different release channel checking functions for different operating systems // Different release channel checking functions for different operating systems
@ -158,7 +158,7 @@ void StableReleaseChannel::releaseListFinished()
QString url = QString(STABLETAG_URL) + tagName; QString url = QString(STABLETAG_URL) + tagName;
qDebug() << "Searching for commit hash corresponding to stable channel tag: " << tagName; qDebug() << "Searching for commit hash corresponding to stable channel tag: " << tagName;
response = netMan->get(QNetworkRequest(url)); response = netMan->get(QNetworkRequest(url));
connect(response, SIGNAL(finished()), this, SLOT(tagListFinished())); connect(response, &QNetworkReply::finished, this, &StableReleaseChannel::tagListFinished);
} }
void StableReleaseChannel::tagListFinished() void StableReleaseChannel::tagListFinished()
@ -260,7 +260,7 @@ void BetaReleaseChannel::releaseListFinished()
qDebug() << "Searching for a corresponding file on the beta channel: " << betaBuildDownloadUrl; qDebug() << "Searching for a corresponding file on the beta channel: " << betaBuildDownloadUrl;
response = netMan->get(QNetworkRequest(betaBuildDownloadUrl)); response = netMan->get(QNetworkRequest(betaBuildDownloadUrl));
connect(response, SIGNAL(finished()), this, SLOT(fileListFinished())); connect(response, &QNetworkReply::finished, this, &BetaReleaseChannel::fileListFinished);
} }
void BetaReleaseChannel::fileListFinished() void BetaReleaseChannel::fileListFinished()

View file

@ -10,7 +10,7 @@ ReplayTimelineWidget::ReplayTimelineWidget(QWidget *parent)
currentEvent(0) currentEvent(0)
{ {
replayTimer = new QTimer(this); replayTimer = new QTimer(this);
connect(replayTimer, SIGNAL(timeout()), this, SLOT(replayTimerTimeout())); connect(replayTimer, &QTimer::timeout, this, &ReplayTimelineWidget::replayTimerTimeout);
rewindBufferingTimer = new QTimer(this); rewindBufferingTimer = new QTimer(this);
rewindBufferingTimer->setSingleShot(true); rewindBufferingTimer->setSingleShot(true);

View file

@ -45,10 +45,10 @@ void SpoilerBackgroundUpdater::downloadFromURL(QUrl url, bool saveResults)
if (saveResults) { if (saveResults) {
// This will write out to the file (used for spoiler.xml) // This will write out to the file (used for spoiler.xml)
connect(reply, SIGNAL(finished()), this, SLOT(actDownloadFinishedSpoilersFile())); connect(reply, &QNetworkReply::finished, this, &SpoilerBackgroundUpdater::actDownloadFinishedSpoilersFile);
} else { } else {
// This will check the status (used to see if we're in spoiler season or not) // This will check the status (used to see if we're in spoiler season or not)
connect(reply, SIGNAL(finished()), this, SLOT(actCheckIfSpoilerSeasonEnabled())); connect(reply, &QNetworkReply::finished, this, &SpoilerBackgroundUpdater::actCheckIfSpoilerSeasonEnabled);
} }
} }

View file

@ -15,8 +15,8 @@
SoundEngine::SoundEngine(QObject *parent) : QObject(parent), player(nullptr) SoundEngine::SoundEngine(QObject *parent) : QObject(parent), player(nullptr)
{ {
ensureThemeDirectoryExists(); ensureThemeDirectoryExists();
connect(&SettingsCache::instance(), SIGNAL(soundThemeChanged()), this, SLOT(themeChangedSlot())); connect(&SettingsCache::instance(), &SettingsCache::soundThemeChanged, this, &SoundEngine::themeChangedSlot);
connect(&SettingsCache::instance(), SIGNAL(soundEnabledChanged()), this, SLOT(soundEnabledChanged())); connect(&SettingsCache::instance(), &SettingsCache::soundEnabledChanged, this, &SoundEngine::soundEnabledChanged);
soundEnabledChanged(); soundEnabledChanged();
themeChangedSlot(); themeChangedSlot();

View file

@ -30,29 +30,22 @@ TabUserLists::TabUserLists(TabSupervisor *_tabSupervisor,
userInfoBox = new UserInfoBox(client, true); userInfoBox = new UserInfoBox(client, true);
userInfoBox->updateInfo(userInfo); userInfoBox->updateInfo(userInfo);
connect(allUsersList, SIGNAL(openMessageDialog(const QString &, bool)), this, connect(allUsersList, &UserList::openMessageDialog, this, &TabUserLists::openMessageDialog);
SIGNAL(openMessageDialog(const QString &, bool))); connect(buddyList, &UserList::openMessageDialog, this, &TabUserLists::openMessageDialog);
connect(buddyList, SIGNAL(openMessageDialog(const QString &, bool)), this, connect(ignoreList, &UserList::openMessageDialog, this, &TabUserLists::openMessageDialog);
SIGNAL(openMessageDialog(const QString &, bool)));
connect(ignoreList, SIGNAL(openMessageDialog(const QString &, bool)), this,
SIGNAL(openMessageDialog(const QString &, bool)));
connect(client, SIGNAL(userJoinedEventReceived(const Event_UserJoined &)), this, connect(client, &AbstractClient::userJoinedEventReceived, this, &TabUserLists::processUserJoinedEvent);
SLOT(processUserJoinedEvent(const Event_UserJoined &))); connect(client, &AbstractClient::userLeftEventReceived, this, &TabUserLists::processUserLeftEvent);
connect(client, SIGNAL(userLeftEventReceived(const Event_UserLeft &)), this, connect(client, &AbstractClient::buddyListReceived, this, &TabUserLists::buddyListReceived);
SLOT(processUserLeftEvent(const Event_UserLeft &))); connect(client, &AbstractClient::ignoreListReceived, this, &TabUserLists::ignoreListReceived);
connect(client, SIGNAL(buddyListReceived(const QList<ServerInfo_User> &)), this, connect(client, &AbstractClient::addToListEventReceived, this, &TabUserLists::processAddToListEvent);
SLOT(buddyListReceived(const QList<ServerInfo_User> &))); connect(client, &AbstractClient::removeFromListEventReceived, this, &TabUserLists::processRemoveFromListEvent);
connect(client, SIGNAL(ignoreListReceived(const QList<ServerInfo_User> &)), this,
SLOT(ignoreListReceived(const QList<ServerInfo_User> &)));
connect(client, SIGNAL(addToListEventReceived(const Event_AddToList &)), this,
SLOT(processAddToListEvent(const Event_AddToList &)));
connect(client, SIGNAL(removeFromListEventReceived(const Event_RemoveFromList &)), this,
SLOT(processRemoveFromListEvent(const Event_RemoveFromList &)));
PendingCommand *pend = client->prepareSessionCommand(Command_ListUsers()); PendingCommand *pend = client->prepareSessionCommand(Command_ListUsers());
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, connect(pend,
SLOT(processListUsersResponse(const Response &))); static_cast<void (PendingCommand::*)(const Response &, const CommandContainer &, const QVariant &)>(
&PendingCommand::finished),
this, &TabUserLists::processListUsersResponse);
client->sendCommand(pend); client->sendCommand(pend);
QVBoxLayout *vbox = new QVBoxLayout; QVBoxLayout *vbox = new QVBoxLayout;
@ -63,9 +56,9 @@ TabUserLists::TabUserLists(TabSupervisor *_tabSupervisor,
addBuddyEdit = new LineEditUnfocusable; addBuddyEdit = new LineEditUnfocusable;
addBuddyEdit->setMaxLength(MAX_NAME_LENGTH); addBuddyEdit->setMaxLength(MAX_NAME_LENGTH);
addBuddyEdit->setPlaceholderText(tr("Add to Buddy List")); addBuddyEdit->setPlaceholderText(tr("Add to Buddy List"));
connect(addBuddyEdit, SIGNAL(returnPressed()), this, SLOT(addToBuddyList())); connect(addBuddyEdit, &LineEditUnfocusable::returnPressed, this, &TabUserLists::addToBuddyList);
QPushButton *addBuddyButton = new QPushButton("Add"); QPushButton *addBuddyButton = new QPushButton("Add");
connect(addBuddyButton, SIGNAL(clicked()), this, SLOT(addToBuddyList())); connect(addBuddyButton, &QPushButton::clicked, this, &TabUserLists::addToBuddyList);
addToBuddyList->addWidget(addBuddyEdit); addToBuddyList->addWidget(addBuddyEdit);
addToBuddyList->addWidget(addBuddyButton); addToBuddyList->addWidget(addBuddyButton);
@ -73,9 +66,9 @@ TabUserLists::TabUserLists(TabSupervisor *_tabSupervisor,
addIgnoreEdit = new LineEditUnfocusable; addIgnoreEdit = new LineEditUnfocusable;
addIgnoreEdit->setMaxLength(MAX_NAME_LENGTH); addIgnoreEdit->setMaxLength(MAX_NAME_LENGTH);
addIgnoreEdit->setPlaceholderText(tr("Add to Ignore List")); addIgnoreEdit->setPlaceholderText(tr("Add to Ignore List"));
connect(addIgnoreEdit, SIGNAL(returnPressed()), this, SLOT(addToIgnoreList())); connect(addIgnoreEdit, &LineEditUnfocusable::returnPressed, this, &TabUserLists::addToIgnoreList);
QPushButton *addIgnoreButton = new QPushButton("Add"); QPushButton *addIgnoreButton = new QPushButton("Add");
connect(addIgnoreButton, SIGNAL(clicked()), this, SLOT(addToIgnoreList())); connect(addIgnoreButton, &QPushButton::clicked, this, &TabUserLists::addToIgnoreList);
addToIgnoreList->addWidget(addIgnoreEdit); addToIgnoreList->addWidget(addIgnoreEdit);
addToIgnoreList->addWidget(addIgnoreButton); addToIgnoreList->addWidget(addIgnoreButton);

View file

@ -29,8 +29,8 @@ ShutdownDialog::ShutdownDialog(QWidget *parent) : QDialog(parent)
minutesEdit->setMaximum(999); minutesEdit->setMaximum(999);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); connect(buttonBox, &QDialogButtonBox::accepted, this, &ShutdownDialog::accept);
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); connect(buttonBox, &QDialogButtonBox::accepted, this, &ShutdownDialog::reject);
QGridLayout *mainLayout = new QGridLayout; QGridLayout *mainLayout = new QGridLayout;
mainLayout->addWidget(reasonLabel, 0, 0); mainLayout->addWidget(reasonLabel, 0, 0);
@ -57,11 +57,11 @@ TabAdmin::TabAdmin(TabSupervisor *_tabSupervisor, AbstractClient *_client, bool
: Tab(_tabSupervisor, parent), locked(true), client(_client), fullAdmin(_fullAdmin) : Tab(_tabSupervisor, parent), locked(true), client(_client), fullAdmin(_fullAdmin)
{ {
updateServerMessageButton = new QPushButton; updateServerMessageButton = new QPushButton;
connect(updateServerMessageButton, SIGNAL(clicked()), this, SLOT(actUpdateServerMessage())); connect(updateServerMessageButton, &QPushButton::clicked, this, &TabAdmin::actUpdateServerMessage);
shutdownServerButton = new QPushButton; shutdownServerButton = new QPushButton;
connect(shutdownServerButton, SIGNAL(clicked()), this, SLOT(actShutdownServer())); connect(shutdownServerButton, &QPushButton::clicked, this, &TabAdmin::actShutdownServer);
reloadConfigButton = new QPushButton; reloadConfigButton = new QPushButton;
connect(reloadConfigButton, SIGNAL(clicked()), this, SLOT(actReloadConfig())); connect(reloadConfigButton, &QPushButton::clicked, this, &TabAdmin::actReloadConfig);
QVBoxLayout *vbox = new QVBoxLayout; QVBoxLayout *vbox = new QVBoxLayout;
vbox->addWidget(updateServerMessageButton); vbox->addWidget(updateServerMessageButton);
@ -74,10 +74,10 @@ TabAdmin::TabAdmin(TabSupervisor *_tabSupervisor, AbstractClient *_client, bool
adminGroupBox->setEnabled(false); adminGroupBox->setEnabled(false);
unlockButton = new QPushButton; unlockButton = new QPushButton;
connect(unlockButton, SIGNAL(clicked()), this, SLOT(actUnlock())); connect(unlockButton, &QPushButton::clicked, this, &TabAdmin::actUnlock);
lockButton = new QPushButton; lockButton = new QPushButton;
lockButton->setEnabled(false); lockButton->setEnabled(false);
connect(lockButton, SIGNAL(clicked()), this, SLOT(actLock())); connect(lockButton, &QPushButton::clicked, this, &TabAdmin::actLock);
QVBoxLayout *mainLayout = new QVBoxLayout; QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(adminGroupBox); mainLayout->addWidget(adminGroupBox);

View file

@ -14,7 +14,7 @@ TappedOutInterface::TappedOutInterface(CardDatabase &_cardDatabase, QObject *par
: QObject(parent), cardDatabase(_cardDatabase) : QObject(parent), cardDatabase(_cardDatabase)
{ {
manager = new QNetworkAccessManager(this); manager = new QNetworkAccessManager(this);
connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(queryFinished(QNetworkReply *))); connect(manager, &QNetworkAccessManager::finished, this, &TappedOutInterface::queryFinished);
} }
void TappedOutInterface::queryFinished(QNetworkReply *reply) void TappedOutInterface::queryFinished(QNetworkReply *reply)

View file

@ -15,9 +15,9 @@ void UpdateDownloader::beginDownload(QUrl downloadUrl)
originalUrl = downloadUrl; originalUrl = downloadUrl;
response = netMan->get(QNetworkRequest(downloadUrl)); response = netMan->get(QNetworkRequest(downloadUrl));
connect(response, SIGNAL(finished()), this, SLOT(fileFinished())); connect(response, &QNetworkReply::finished, this, &UpdateDownloader::fileFinished);
connect(response, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(downloadProgress(qint64, qint64))); connect(response, &QNetworkReply::downloadProgress, this, &UpdateDownloader::downloadProgress);
connect(this, SIGNAL(stopDownload()), response, SLOT(abort())); connect(this, &UpdateDownloader::stopDownload, response, &QNetworkReply::abort);
} }
void UpdateDownloader::downloadError(QNetworkReply::NetworkError) void UpdateDownloader::downloadError(QNetworkReply::NetworkError)

View file

@ -138,7 +138,7 @@ int main(int argc, char *argv[])
QApplication app(argc, argv); QApplication app(argc, argv);
QObject::connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit())); QObject::connect(&app, &QApplication::lastWindowClosed, &app, &QApplication::quit);
qInstallMessageHandler(CockatriceLogger); qInstallMessageHandler(CockatriceLogger);
#ifdef Q_OS_WIN #ifdef Q_OS_WIN