From 405a5c5d259ae7b2d4cb23c7e3b67929b49f7a7a Mon Sep 17 00:00:00 2001 From: Mat Date: Thu, 18 Aug 2022 21:25:47 -0300 Subject: [PATCH] functor-based Qt signal-slot syntax wizard --- apps/wizard/componentselectionpage.cpp | 4 +-- apps/wizard/existinginstallationpage.cpp | 8 ++--- apps/wizard/installationpage.cpp | 41 +++++++++++------------ apps/wizard/mainwizard.cpp | 8 ++--- apps/wizard/methodselectionpage.cpp | 2 +- apps/wizard/utils/componentlistwidget.cpp | 8 ++--- 6 files changed, 35 insertions(+), 36 deletions(-) diff --git a/apps/wizard/componentselectionpage.cpp b/apps/wizard/componentselectionpage.cpp index b5a9eaab9b..207eb59ce5 100644 --- a/apps/wizard/componentselectionpage.cpp +++ b/apps/wizard/componentselectionpage.cpp @@ -18,8 +18,8 @@ Wizard::ComponentSelectionPage::ComponentSelectionPage(QWidget *parent) : registerField(QLatin1String("installation.components"), componentsList); - connect(componentsList, SIGNAL(itemChanged(QListWidgetItem *)), - this, SLOT(updateButton(QListWidgetItem *))); + connect(componentsList, &ComponentListWidget::itemChanged, + this, &ComponentSelectionPage::updateButton); } diff --git a/apps/wizard/existinginstallationpage.cpp b/apps/wizard/existinginstallationpage.cpp index 35f3c8c257..fde4a4846b 100644 --- a/apps/wizard/existinginstallationpage.cpp +++ b/apps/wizard/existinginstallationpage.cpp @@ -39,11 +39,11 @@ void Wizard::ExistingInstallationPage::initializePage() } } - connect(installationsList, SIGNAL(currentTextChanged(QString)), - this, SLOT(textChanged(QString))); + connect(installationsList, &QListWidget::currentTextChanged, + this, &ExistingInstallationPage::textChanged); - connect(installationsList,SIGNAL(itemSelectionChanged()), - this, SIGNAL(completeChanged())); + connect(installationsList, &QListWidget::itemSelectionChanged, + this, &ExistingInstallationPage::completeChanged); } bool Wizard::ExistingInstallationPage::validatePage() diff --git a/apps/wizard/installationpage.cpp b/apps/wizard/installationpage.cpp index 0df0dbb57a..4d330d4893 100644 --- a/apps/wizard/installationpage.cpp +++ b/apps/wizard/installationpage.cpp @@ -21,36 +21,35 @@ Wizard::InstallationPage::InstallationPage(QWidget *parent, Config::GameSettings mUnshield = std::make_unique(mGameSettings.value("morrowind-bsa-filesize").toLongLong()); mUnshield->moveToThread(mThread.get()); - connect(mThread.get(), SIGNAL(started()), - mUnshield.get(), SLOT(extract())); + connect(mThread.get(), &QThread::started, + mUnshield.get(), &UnshieldWorker::extract); - connect(mUnshield.get(), SIGNAL(finished()), - mThread.get(), SLOT(quit())); + connect(mUnshield.get(), &UnshieldWorker::finished, + mThread.get(), &QThread::quit); - connect(mUnshield.get(), SIGNAL(finished()), - this, SLOT(installationFinished()), Qt::QueuedConnection); + connect(mUnshield.get(), &UnshieldWorker::finished, + this, &InstallationPage::installationFinished, Qt::QueuedConnection); - connect(mUnshield.get(), SIGNAL(error(QString, QString)), - this, SLOT(installationError(QString, QString)), Qt::QueuedConnection); + connect(mUnshield.get(), &UnshieldWorker::error, + this, &InstallationPage::installationError, Qt::QueuedConnection); - connect(mUnshield.get(), SIGNAL(textChanged(QString)), - installProgressLabel, SLOT(setText(QString)), Qt::QueuedConnection); + connect(mUnshield.get(), &UnshieldWorker::textChanged, + installProgressLabel, &QLabel::setText, Qt::QueuedConnection); - connect(mUnshield.get(), SIGNAL(textChanged(QString)), - logTextEdit, SLOT(appendPlainText(QString)), Qt::QueuedConnection); + connect(mUnshield.get(), &UnshieldWorker::textChanged, + logTextEdit, &QPlainTextEdit::appendPlainText, Qt::QueuedConnection); - connect(mUnshield.get(), SIGNAL(textChanged(QString)), - mWizard, SLOT(addLogText(QString)), Qt::QueuedConnection); + connect(mUnshield.get(), &UnshieldWorker::textChanged, + mWizard, &MainWizard::addLogText, Qt::QueuedConnection); - connect(mUnshield.get(), SIGNAL(progressChanged(int)), - installProgressBar, SLOT(setValue(int)), Qt::QueuedConnection); + connect(mUnshield.get(), &UnshieldWorker::progressChanged, + installProgressBar, &QProgressBar::setValue, Qt::QueuedConnection); - connect(mUnshield.get(), SIGNAL(requestFileDialog(Wizard::Component)), - this, SLOT(showFileDialog(Wizard::Component)), Qt::QueuedConnection); + connect(mUnshield.get(), &UnshieldWorker::requestFileDialog, + this, &InstallationPage::showFileDialog, Qt::QueuedConnection); - connect(mUnshield.get(), SIGNAL(requestOldVersionDialog()), - this, SLOT(showOldVersionDialog()) - , Qt::QueuedConnection); + connect(mUnshield.get(), &UnshieldWorker::requestOldVersionDialog, + this, &InstallationPage::showOldVersionDialog, Qt::QueuedConnection); } Wizard::InstallationPage::~InstallationPage() diff --git a/apps/wizard/mainwizard.cpp b/apps/wizard/mainwizard.cpp index 46481753a7..5e3dff5ff5 100644 --- a/apps/wizard/mainwizard.cpp +++ b/apps/wizard/mainwizard.cpp @@ -44,11 +44,11 @@ Wizard::MainWizard::MainWizard(QWidget *parent) : mImporterInvoker = new ProcessInvoker(); - connect(mImporterInvoker->getProcess(), SIGNAL(started()), - this, SLOT(importerStarted())); + connect(mImporterInvoker->getProcess(), &QProcess::started, + this, &MainWizard::importerStarted); - connect(mImporterInvoker->getProcess(), SIGNAL(finished(int,QProcess::ExitStatus)), - this, SLOT(importerFinished(int,QProcess::ExitStatus))); + connect(mImporterInvoker->getProcess(), qOverload(&QProcess::finished), + this, &MainWizard::importerFinished); mLogError = tr("

Could not open %1 for writing

\

Please make sure you have the right permissions \ diff --git a/apps/wizard/methodselectionpage.cpp b/apps/wizard/methodselectionpage.cpp index 37234468b9..e4f8b79f08 100644 --- a/apps/wizard/methodselectionpage.cpp +++ b/apps/wizard/methodselectionpage.cpp @@ -19,7 +19,7 @@ Wizard::MethodSelectionPage::MethodSelectionPage(QWidget *parent) : registerField(QLatin1String("installation.retailDisc"), retailDiscRadioButton); - connect(buyLinkButton, SIGNAL(released()), this, SLOT(handleBuyButton())); + connect(buyLinkButton, &QCommandLinkButton::released, this, &MethodSelectionPage::handleBuyButton); } int Wizard::MethodSelectionPage::nextId() const diff --git a/apps/wizard/utils/componentlistwidget.cpp b/apps/wizard/utils/componentlistwidget.cpp index ff37e5d8ca..7ebc6665b4 100644 --- a/apps/wizard/utils/componentlistwidget.cpp +++ b/apps/wizard/utils/componentlistwidget.cpp @@ -7,11 +7,11 @@ ComponentListWidget::ComponentListWidget(QWidget *parent) : { mCheckedItems = QStringList(); - connect(this, SIGNAL(itemChanged(QListWidgetItem *)), - this, SLOT(updateCheckedItems(QListWidgetItem *))); + connect(this, &ComponentListWidget::itemChanged, + this, qOverload(&ComponentListWidget::updateCheckedItems)); - connect(model(), SIGNAL(rowsInserted(QModelIndex, int, int)), - this, SLOT(updateCheckedItems(QModelIndex, int, int))); + connect(model(), &QAbstractItemModel::rowsInserted, + this, qOverload(&ComponentListWidget::updateCheckedItems)); } QStringList ComponentListWidget::checkedItems()