Refactor window_main to new Qt Slot/Signal syntax (#5423)

This commit is contained in:
RickyRister 2025-01-06 09:38:44 -08:00 committed by GitHub
parent b7f05a12a3
commit 23171f79d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -193,7 +193,7 @@ void MainWindow::activateAccepted()
void MainWindow::actConnect() void MainWindow::actConnect()
{ {
dlgConnect = new DlgConnect(this); dlgConnect = new DlgConnect(this);
connect(dlgConnect, SIGNAL(sigStartForgotPasswordRequest()), this, SLOT(actForgotPasswordRequest())); connect(dlgConnect, &DlgConnect::sigStartForgotPasswordRequest, this, &MainWindow::actForgotPasswordRequest);
if (dlgConnect->exec()) { if (dlgConnect->exec()) {
client->connectToServer(dlgConnect->getHost(), static_cast<unsigned int>(dlgConnect->getPort()), client->connectToServer(dlgConnect->getHost(), static_cast<unsigned int>(dlgConnect->getPort()),
@ -703,58 +703,58 @@ void MainWindow::retranslateUi()
void MainWindow::createActions() void MainWindow::createActions()
{ {
aConnect = new QAction(this); aConnect = new QAction(this);
connect(aConnect, SIGNAL(triggered()), this, SLOT(actConnect())); connect(aConnect, &QAction::triggered, this, &MainWindow::actConnect);
aDisconnect = new QAction(this); aDisconnect = new QAction(this);
aDisconnect->setEnabled(false); aDisconnect->setEnabled(false);
connect(aDisconnect, SIGNAL(triggered()), this, SLOT(actDisconnect())); connect(aDisconnect, &QAction::triggered, this, &MainWindow::actDisconnect);
aSinglePlayer = new QAction(this); aSinglePlayer = new QAction(this);
connect(aSinglePlayer, SIGNAL(triggered()), this, SLOT(actSinglePlayer())); connect(aSinglePlayer, &QAction::triggered, this, &MainWindow::actSinglePlayer);
aWatchReplay = new QAction(this); aWatchReplay = new QAction(this);
connect(aWatchReplay, SIGNAL(triggered()), this, SLOT(actWatchReplay())); connect(aWatchReplay, &QAction::triggered, this, &MainWindow::actWatchReplay);
aDeckEditor = new QAction(this); aDeckEditor = new QAction(this);
connect(aDeckEditor, SIGNAL(triggered()), this, SLOT(actDeckEditor())); connect(aDeckEditor, &QAction::triggered, this, &MainWindow::actDeckEditor);
aVisualDeckStorage = new QAction(this); aVisualDeckStorage = new QAction(this);
connect(aVisualDeckStorage, SIGNAL(triggered()), this, SLOT(actVisualDeckStorage())); connect(aVisualDeckStorage, &QAction::triggered, this, &MainWindow::actVisualDeckStorage);
aFullScreen = new QAction(this); aFullScreen = new QAction(this);
aFullScreen->setCheckable(true); aFullScreen->setCheckable(true);
connect(aFullScreen, SIGNAL(toggled(bool)), this, SLOT(actFullScreen(bool))); connect(aFullScreen, &QAction::toggled, this, &MainWindow::actFullScreen);
aRegister = new QAction(this); aRegister = new QAction(this);
connect(aRegister, SIGNAL(triggered()), this, SLOT(actRegister())); connect(aRegister, &QAction::triggered, this, &MainWindow::actRegister);
aForgotPassword = new QAction(this); aForgotPassword = new QAction(this);
connect(aForgotPassword, SIGNAL(triggered()), this, SLOT(actForgotPasswordRequest())); connect(aForgotPassword, &QAction::triggered, this, &MainWindow::actForgotPasswordRequest);
aSettings = new QAction(this); aSettings = new QAction(this);
connect(aSettings, SIGNAL(triggered()), this, SLOT(actSettings())); connect(aSettings, &QAction::triggered, this, &MainWindow::actSettings);
aExit = new QAction(this); aExit = new QAction(this);
connect(aExit, SIGNAL(triggered()), this, SLOT(actExit())); connect(aExit, &QAction::triggered, this, &MainWindow::actExit);
aManageSets = new QAction(QString(), this); aManageSets = new QAction(QString(), this);
connect(aManageSets, SIGNAL(triggered()), this, SLOT(actManageSets())); connect(aManageSets, &QAction::triggered, this, &MainWindow::actManageSets);
aEditTokens = new QAction(QString(), this); aEditTokens = new QAction(QString(), this);
connect(aEditTokens, SIGNAL(triggered()), this, SLOT(actEditTokens())); connect(aEditTokens, &QAction::triggered, this, &MainWindow::actEditTokens);
aOpenCustomFolder = new QAction(QString(), this); aOpenCustomFolder = new QAction(QString(), this);
connect(aOpenCustomFolder, SIGNAL(triggered()), this, SLOT(actOpenCustomFolder())); connect(aOpenCustomFolder, &QAction::triggered, this, &MainWindow::actOpenCustomFolder);
aOpenCustomsetsFolder = new QAction(QString(), this); aOpenCustomsetsFolder = new QAction(QString(), this);
connect(aOpenCustomsetsFolder, SIGNAL(triggered()), this, SLOT(actOpenCustomsetsFolder())); connect(aOpenCustomsetsFolder, &QAction::triggered, this, &MainWindow::actOpenCustomsetsFolder);
aAddCustomSet = new QAction(QString(), this); aAddCustomSet = new QAction(QString(), this);
connect(aAddCustomSet, SIGNAL(triggered()), this, SLOT(actAddCustomSet())); connect(aAddCustomSet, &QAction::triggered, this, &MainWindow::actAddCustomSet);
aReloadCardDatabase = new QAction(QString(), this); aReloadCardDatabase = new QAction(QString(), this);
connect(aReloadCardDatabase, SIGNAL(triggered()), this, SLOT(actReloadCardDatabase())); connect(aReloadCardDatabase, &QAction::triggered, this, &MainWindow::actReloadCardDatabase);
aAbout = new QAction(this); aAbout = new QAction(this);
connect(aAbout, SIGNAL(triggered()), this, SLOT(actAbout())); connect(aAbout, &QAction::triggered, this, &MainWindow::actAbout);
aTips = new QAction(this); aTips = new QAction(this);
connect(aTips, SIGNAL(triggered()), this, SLOT(actTips())); connect(aTips, &QAction::triggered, this, &MainWindow::actTips);
aUpdate = new QAction(this); aUpdate = new QAction(this);
connect(aUpdate, SIGNAL(triggered()), this, SLOT(actUpdate())); connect(aUpdate, &QAction::triggered, this, &MainWindow::actUpdate);
aCheckCardUpdates = new QAction(this); aCheckCardUpdates = new QAction(this);
connect(aCheckCardUpdates, SIGNAL(triggered()), this, SLOT(actCheckCardUpdates())); connect(aCheckCardUpdates, &QAction::triggered, this, &MainWindow::actCheckCardUpdates);
aViewLog = new QAction(this); aViewLog = new QAction(this);
connect(aViewLog, SIGNAL(triggered()), this, SLOT(actViewLog())); connect(aViewLog, &QAction::triggered, this, &MainWindow::actViewLog);
aOpenSettingsFolder = new QAction(this); aOpenSettingsFolder = new QAction(this);
connect(aOpenSettingsFolder, &QAction::triggered, this, &MainWindow::actOpenSettingsFolder); connect(aOpenSettingsFolder, &QAction::triggered, this, &MainWindow::actOpenSettingsFolder);
aShow = new QAction(this); aShow = new QAction(this);
connect(aShow, SIGNAL(triggered()), this, SLOT(actShow())); connect(aShow, &QAction::triggered, this, &MainWindow::actShow);
#if defined(__APPLE__) /* For OSX */ #if defined(__APPLE__) /* For OSX */
aSettings->setMenuRole(QAction::PreferencesRole); aSettings->setMenuRole(QAction::PreferencesRole);
@ -834,33 +834,30 @@ MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), localServer(nullptr), bHasActivated(false), askedForDbUpdater(false), : QMainWindow(parent), localServer(nullptr), bHasActivated(false), askedForDbUpdater(false),
cardUpdateProcess(nullptr), logviewDialog(nullptr) cardUpdateProcess(nullptr), logviewDialog(nullptr)
{ {
connect(&SettingsCache::instance(), SIGNAL(pixmapCacheSizeChanged(int)), this, SLOT(pixmapCacheSizeChanged(int))); connect(&SettingsCache::instance(), &SettingsCache::pixmapCacheSizeChanged, this,
&MainWindow::pixmapCacheSizeChanged);
pixmapCacheSizeChanged(SettingsCache::instance().getPixmapCacheSize()); pixmapCacheSizeChanged(SettingsCache::instance().getPixmapCacheSize());
client = new RemoteClient; client = new RemoteClient;
connect(client, SIGNAL(connectionClosedEventReceived(const Event_ConnectionClosed &)), this, connect(client, &RemoteClient::connectionClosedEventReceived, this, &MainWindow::processConnectionClosedEvent);
SLOT(processConnectionClosedEvent(const Event_ConnectionClosed &))); connect(client, &RemoteClient::serverShutdownEventReceived, this, &MainWindow::processServerShutdownEvent);
connect(client, SIGNAL(serverShutdownEventReceived(const Event_ServerShutdown &)), this, connect(client, &RemoteClient::loginError, this, &MainWindow::loginError);
SLOT(processServerShutdownEvent(const Event_ServerShutdown &))); connect(client, &RemoteClient::socketError, this, &MainWindow::socketError);
connect(client, SIGNAL(loginError(Response::ResponseCode, QString, quint32, QList<QString>)), this, connect(client, &RemoteClient::serverTimeout, this, &MainWindow::serverTimeout);
SLOT(loginError(Response::ResponseCode, QString, quint32, QList<QString>))); connect(client, &RemoteClient::statusChanged, this, &MainWindow::statusChanged);
connect(client, SIGNAL(socketError(const QString &)), this, SLOT(socketError(const QString &))); connect(client, &RemoteClient::protocolVersionMismatch, this, &MainWindow::protocolVersionMismatch);
connect(client, SIGNAL(serverTimeout()), this, SLOT(serverTimeout())); connect(client, &RemoteClient::userInfoChanged, this, &MainWindow::userInfoReceived, Qt::BlockingQueuedConnection);
connect(client, SIGNAL(statusChanged(ClientStatus)), this, SLOT(statusChanged(ClientStatus))); connect(client, &RemoteClient::notifyUserAboutUpdate, this, &MainWindow::notifyUserAboutUpdate);
connect(client, SIGNAL(protocolVersionMismatch(int, int)), this, SLOT(protocolVersionMismatch(int, int))); connect(client, &RemoteClient::registerAccepted, this, &MainWindow::registerAccepted);
connect(client, SIGNAL(userInfoChanged(const ServerInfo_User &)), this, connect(client, &RemoteClient::registerAcceptedNeedsActivate, this, &MainWindow::registerAcceptedNeedsActivate);
SLOT(userInfoReceived(const ServerInfo_User &)), Qt::BlockingQueuedConnection); connect(client, &RemoteClient::registerError, this, &MainWindow::registerError);
connect(client, SIGNAL(notifyUserAboutUpdate()), this, SLOT(notifyUserAboutUpdate())); connect(client, &RemoteClient::activateAccepted, this, &MainWindow::activateAccepted);
connect(client, SIGNAL(registerAccepted()), this, SLOT(registerAccepted())); connect(client, &RemoteClient::activateError, this, &MainWindow::activateError);
connect(client, SIGNAL(registerAcceptedNeedsActivate()), this, SLOT(registerAcceptedNeedsActivate())); connect(client, &RemoteClient::sigForgotPasswordSuccess, this, &MainWindow::forgotPasswordSuccess);
connect(client, SIGNAL(registerError(Response::ResponseCode, QString, quint32)), this, connect(client, &RemoteClient::sigForgotPasswordError, this, &MainWindow::forgotPasswordError);
SLOT(registerError(Response::ResponseCode, QString, quint32))); connect(client, &RemoteClient::sigPromptForForgotPasswordReset, this, &MainWindow::promptForgotPasswordReset);
connect(client, SIGNAL(activateAccepted()), this, SLOT(activateAccepted())); connect(client, &RemoteClient::sigPromptForForgotPasswordChallenge, this,
connect(client, SIGNAL(activateError()), this, SLOT(activateError())); &MainWindow::promptForgotPasswordChallenge);
connect(client, SIGNAL(sigForgotPasswordSuccess()), this, SLOT(forgotPasswordSuccess()));
connect(client, SIGNAL(sigForgotPasswordError()), this, SLOT(forgotPasswordError()));
connect(client, SIGNAL(sigPromptForForgotPasswordReset()), this, SLOT(promptForgotPasswordReset()));
connect(client, SIGNAL(sigPromptForForgotPasswordChallenge()), this, SLOT(promptForgotPasswordChallenge()));
clientThread = new QThread(this); clientThread = new QThread(this);
client->moveToThread(clientThread); client->moveToThread(clientThread);
@ -870,9 +867,9 @@ MainWindow::MainWindow(QWidget *parent)
createMenus(); createMenus();
tabSupervisor = new TabSupervisor(client); tabSupervisor = new TabSupervisor(client);
connect(tabSupervisor, SIGNAL(setMenu(QList<QMenu *>)), this, SLOT(updateTabMenu(QList<QMenu *>))); connect(tabSupervisor, &TabSupervisor::setMenu, this, &MainWindow::updateTabMenu);
connect(tabSupervisor, SIGNAL(localGameEnded()), this, SLOT(localGameEnded())); connect(tabSupervisor, &TabSupervisor::localGameEnded, this, &MainWindow::localGameEnded);
connect(tabSupervisor, SIGNAL(showWindowIfHidden()), this, SLOT(showWindowIfHidden())); connect(tabSupervisor, &TabSupervisor::showWindowIfHidden, this, &MainWindow::showWindowIfHidden);
tabSupervisor->addDeckEditorTab(nullptr); tabSupervisor->addDeckEditorTab(nullptr);
setCentralWidget(tabSupervisor); setCentralWidget(tabSupervisor);
@ -888,19 +885,20 @@ MainWindow::MainWindow(QWidget *parent)
createTrayIcon(); createTrayIcon();
} }
connect(&SettingsCache::instance().shortcuts(), SIGNAL(shortCutChanged()), this, SLOT(refreshShortcuts())); connect(&SettingsCache::instance().shortcuts(), &ShortcutsSettings::shortCutChanged, this,
&MainWindow::refreshShortcuts);
refreshShortcuts(); refreshShortcuts();
if (SettingsCache::instance().getVisualDeckStorageShowOnLoad()) { if (SettingsCache::instance().getVisualDeckStorageShowOnLoad()) {
connect(CardDatabaseManager::getInstance(), SIGNAL(cardDatabaseLoadingFinished()), tabSupervisor, connect(CardDatabaseManager::getInstance(), &CardDatabase::cardDatabaseLoadingFinished, tabSupervisor,
SLOT(addVisualDeckStorageTab())); &TabSupervisor::addVisualDeckStorageTab);
} }
connect(CardDatabaseManager::getInstance(), SIGNAL(cardDatabaseLoadingFailed()), this, connect(CardDatabaseManager::getInstance(), &CardDatabase::cardDatabaseLoadingFailed, this,
SLOT(cardDatabaseLoadingFailed())); &MainWindow::cardDatabaseLoadingFailed);
connect(CardDatabaseManager::getInstance(), SIGNAL(cardDatabaseNewSetsFound(int, QStringList)), this, connect(CardDatabaseManager::getInstance(), &CardDatabase::cardDatabaseNewSetsFound, this,
SLOT(cardDatabaseNewSetsFound(int, QStringList))); &MainWindow::cardDatabaseNewSetsFound);
connect(CardDatabaseManager::getInstance(), SIGNAL(cardDatabaseAllNewSetsEnabled()), this, connect(CardDatabaseManager::getInstance(), &CardDatabase::cardDatabaseAllNewSetsEnabled, this,
SLOT(cardDatabaseAllNewSetsEnabled())); &MainWindow::cardDatabaseAllNewSetsEnabled);
tip = new DlgTipOfTheDay(); tip = new DlgTipOfTheDay();
@ -1159,8 +1157,8 @@ void MainWindow::actCheckCardUpdates()
connect(cardUpdateProcess, &QProcess::errorOccurred, this, &MainWindow::cardUpdateError); connect(cardUpdateProcess, &QProcess::errorOccurred, this, &MainWindow::cardUpdateError);
connect(cardUpdateProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, connect(cardUpdateProcess, qOverload<int, QProcess::ExitStatus>(&QProcess::finished), this,
SLOT(cardUpdateFinished(int, QProcess::ExitStatus))); &MainWindow::cardUpdateFinished);
// full "run the update" command; leave empty if not present // full "run the update" command; leave empty if not present
QString updaterCmd; QString updaterCmd;