From 23c0ae336f1a8bbeb5a2db6edf85e1d736247040 Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 4 Dec 2024 09:48:00 +0100 Subject: [PATCH] Core etc: Use dialogParent() for several wizards This was de-facto the case almost always, only the tests used a local dummy and StudioWelcome::WizardFactories. Change-Id: I20191d050d14664c95d9676098f90db76b25d57f Reviewed-by: Eike Ziller --- .../coreplugin/basefilewizardfactory.cpp | 17 ++++----- .../coreplugin/basefilewizardfactory.h | 4 +- src/plugins/coreplugin/dialogs/newdialog.cpp | 2 +- src/plugins/coreplugin/iwizardfactory.cpp | 7 ++-- src/plugins/coreplugin/iwizardfactory.h | 3 +- src/plugins/designer/cpp/formclasswizard.cpp | 4 +- src/plugins/designer/cpp/formclasswizard.h | 2 +- .../genericprojectwizard.cpp | 8 ++-- .../baseprojectwizarddialog.cpp | 6 +-- .../projectexplorer/baseprojectwizarddialog.h | 4 +- .../customwizard/customwizard.cpp | 9 ++--- .../customwizard/customwizard.h | 4 +- .../projectexplorer/jsonwizard/jsonwizard.cpp | 4 +- .../projectexplorer/jsonwizard/jsonwizard.h | 2 +- .../jsonwizard/jsonwizard_test.cpp | 37 +++++++++---------- .../jsonwizard/jsonwizardfactory.cpp | 5 +-- .../jsonwizard/jsonwizardfactory.h | 2 +- .../projectexplorer/projectexplorer.cpp | 2 +- .../projectexplorer/simpleprojectwizard.cpp | 9 ++--- .../projectexplorer/simpleprojectwizard.h | 2 +- .../customwidgetwizard/customwidgetwizard.cpp | 5 +-- .../customwidgetwizard/customwidgetwizard.h | 3 +- .../customwidgetwizarddialog.cpp | 5 +-- .../customwidgetwizarddialog.h | 1 - .../qmakeprojectmanager/wizards/qtwizard.cpp | 11 ++---- .../qmakeprojectmanager/wizards/qtwizard.h | 6 +-- .../wizards/subdirsprojectwizard.cpp | 6 +-- .../wizards/subdirsprojectwizard.h | 3 +- .../wizards/subdirsprojectwizarddialog.cpp | 5 +-- .../wizards/subdirsprojectwizarddialog.h | 7 ++-- src/plugins/studiowelcome/qdsnewdialog.cpp | 2 +- src/plugins/studiowelcome/wizardfactories.cpp | 13 +++---- src/plugins/studiowelcome/wizardfactories.h | 6 +-- 33 files changed, 88 insertions(+), 118 deletions(-) diff --git a/src/plugins/coreplugin/basefilewizardfactory.cpp b/src/plugins/coreplugin/basefilewizardfactory.cpp index 60000388ad6..9ffa51ff0a2 100644 --- a/src/plugins/coreplugin/basefilewizardfactory.cpp +++ b/src/plugins/coreplugin/basefilewizardfactory.cpp @@ -46,10 +46,9 @@ static int indexOfFile(const GeneratedFiles &f, const FilePath &path) \sa Core::BaseFileWizardFactory */ -Utils::Wizard *BaseFileWizardFactory::runWizardImpl(const FilePath &path, QWidget *parent, - Id platform, - const QVariantMap &extraValues, - bool showWizard) +Wizard *BaseFileWizardFactory::runWizardImpl(const FilePath &path, Id platform, + const QVariantMap &extraValues, + bool showWizard) { Q_UNUSED(showWizard); QTC_ASSERT(!path.isEmpty(), return nullptr); @@ -63,11 +62,11 @@ Utils::Wizard *BaseFileWizardFactory::runWizardImpl(const FilePath &path, QWidge if (flags().testFlag(ForceCapitalLetterForFileName)) dialogParameterFlags |= WizardDialogParameters::ForceCapitalLetterForFileName; - Wizard *wizard = create(parent, WizardDialogParameters(path, - platform, - requiredFeatures(), - dialogParameterFlags, - extraValues)); + Wizard *wizard = create(WizardDialogParameters(path, + platform, + requiredFeatures(), + dialogParameterFlags, + extraValues)); QTC_CHECK(wizard); return wizard; } diff --git a/src/plugins/coreplugin/basefilewizardfactory.h b/src/plugins/coreplugin/basefilewizardfactory.h index 0d9033d6d59..a2f25945aa4 100644 --- a/src/plugins/coreplugin/basefilewizardfactory.h +++ b/src/plugins/coreplugin/basefilewizardfactory.h @@ -67,7 +67,7 @@ public: static Utils::FilePath buildFileName(const Utils::FilePath &path, const QString &baseName, const QString &extension); protected: - virtual BaseFileWizard *create(QWidget *parent, const WizardDialogParameters ¶meters) const = 0; + virtual BaseFileWizard *create(const WizardDialogParameters ¶meters) const = 0; virtual GeneratedFiles generateFiles(const QWizard *w, QString *errorMessage) const = 0; @@ -84,7 +84,7 @@ protected: static bool postGenerateOpenEditors(const GeneratedFiles &l, QString *errorMessage = nullptr); private: - Utils::Wizard *runWizardImpl(const Utils::FilePath &path, QWidget *parent, Utils::Id platform, + Utils::Wizard *runWizardImpl(const Utils::FilePath &path, Utils::Id platform, const QVariantMap &extraValues, bool showWizard = true) final; }; diff --git a/src/plugins/coreplugin/dialogs/newdialog.cpp b/src/plugins/coreplugin/dialogs/newdialog.cpp index f6be40905b9..4efd33cc010 100644 --- a/src/plugins/coreplugin/dialogs/newdialog.cpp +++ b/src/plugins/coreplugin/dialogs/newdialog.cpp @@ -544,7 +544,7 @@ static void runWizard(IWizardFactory *wizard, const FilePath &defaultLocation, I const QVariantMap &variables) { const FilePath path = wizard->runPath(defaultLocation); - wizard->runWizard(path, ICore::dialogParent(), platform, variables); + wizard->runWizard(path, platform, variables); } void NewDialogWidget::accept() diff --git a/src/plugins/coreplugin/iwizardfactory.cpp b/src/plugins/coreplugin/iwizardfactory.cpp index d5f85acc84f..4299ad888f4 100644 --- a/src/plugins/coreplugin/iwizardfactory.cpp +++ b/src/plugins/coreplugin/iwizardfactory.cpp @@ -209,7 +209,7 @@ QList IWizardFactory::allWizardFactories() .addOnTriggered(newFactory, [newFactory] { if (!ICore::isNewItemDialogRunning()) { FilePath path = newFactory->runPath({}); - newFactory->runWizard(path, ICore::dialogParent(), Id(), QVariantMap()); + newFactory->runWizard(path, Id(), QVariantMap()); } }); @@ -247,7 +247,6 @@ FilePath IWizardFactory::runPath(const FilePath &defaultPath) const Creates the wizard that the user selected for execution on the operating system \a platform with \a variables. - Any dialogs the wizard opens should use the given \a parent. The \a path argument is a suggestion for the location where files should be created. The wizard should fill this in its path selection elements as a default path. @@ -255,7 +254,7 @@ FilePath IWizardFactory::runPath(const FilePath &defaultPath) const When \a showWizard is \c false, the wizard instance is created and set up but not actually shown. */ -Wizard *IWizardFactory::runWizard(const FilePath &path, QWidget *parent, Id platform, +Wizard *IWizardFactory::runWizard(const FilePath &path, Id platform, const QVariantMap &variables, bool showWizard) { @@ -264,7 +263,7 @@ Wizard *IWizardFactory::runWizard(const FilePath &path, QWidget *parent, Id plat s_isWizardRunning = true; ICore::updateNewItemDialogState(); - Utils::Wizard *wizard = runWizardImpl(path, parent, platform, variables, showWizard); + Wizard *wizard = runWizardImpl(path, platform, variables, showWizard); if (wizard) { diff --git a/src/plugins/coreplugin/iwizardfactory.h b/src/plugins/coreplugin/iwizardfactory.h index 97b47ac3d3a..e7794907ce3 100644 --- a/src/plugins/coreplugin/iwizardfactory.h +++ b/src/plugins/coreplugin/iwizardfactory.h @@ -71,7 +71,7 @@ public: Utils::FilePath runPath(const Utils::FilePath &defaultPath) const; // Does bookkeeping and the calls runWizardImpl. Please implement that. - Utils::Wizard *runWizard(const Utils::FilePath &path, QWidget *parent, Utils::Id platform, + Utils::Wizard *runWizard(const Utils::FilePath &path, Utils::Id platform, const QVariantMap &variables, bool showWizard = true); virtual bool isAvailable(Utils::Id platformId) const; @@ -103,7 +103,6 @@ protected: static QSet availableFeatures(Utils::Id platformId); virtual Utils::Wizard *runWizardImpl(const Utils::FilePath &path, - QWidget *parent, Utils::Id platform, const QVariantMap &variables, bool showWizard = true) = 0; diff --git a/src/plugins/designer/cpp/formclasswizard.cpp b/src/plugins/designer/cpp/formclasswizard.cpp index 0290259527c..037f3456727 100644 --- a/src/plugins/designer/cpp/formclasswizard.cpp +++ b/src/plugins/designer/cpp/formclasswizard.cpp @@ -42,9 +42,9 @@ QString FormClassWizard::formSuffix() const return preferredSuffix(Utils::Constants::FORM_MIMETYPE); } -Core::BaseFileWizard *FormClassWizard::create(QWidget *parent, const Core::WizardDialogParameters ¶meters) const +Core::BaseFileWizard *FormClassWizard::create(const Core::WizardDialogParameters ¶meters) const { - auto wizardDialog = new FormClassWizardDialog(this, parent); + auto wizardDialog = new FormClassWizardDialog(this); wizardDialog->setFilePath(parameters.defaultPath()); return wizardDialog; } diff --git a/src/plugins/designer/cpp/formclasswizard.h b/src/plugins/designer/cpp/formclasswizard.h index 90238410738..bf4ade24a37 100644 --- a/src/plugins/designer/cpp/formclasswizard.h +++ b/src/plugins/designer/cpp/formclasswizard.h @@ -22,7 +22,7 @@ public: QString formSuffix() const; private: - Core::BaseFileWizard *create(QWidget *parent, const Core::WizardDialogParameters ¶meters) const final; + Core::BaseFileWizard *create(const Core::WizardDialogParameters ¶meters) const final; Core::GeneratedFiles generateFiles(const QWizard *w, QString *errorMessage) const final; }; diff --git a/src/plugins/genericprojectmanager/genericprojectwizard.cpp b/src/plugins/genericprojectmanager/genericprojectwizard.cpp index a6e12cd029b..096a39e0b20 100644 --- a/src/plugins/genericprojectmanager/genericprojectwizard.cpp +++ b/src/plugins/genericprojectmanager/genericprojectwizard.cpp @@ -98,8 +98,8 @@ class GenericProjectWizard final : public BaseFileWizard Q_OBJECT public: - GenericProjectWizard(const BaseFileWizardFactory *factory, QWidget *parent) - : BaseFileWizard(factory, QVariantMap(), parent) + GenericProjectWizard(const BaseFileWizardFactory *factory) + : BaseFileWizard(factory, QVariantMap(), Core::ICore::dialogParent()) { setWindowTitle(Tr::tr("Import Existing Project")); @@ -172,9 +172,9 @@ public: } protected: - BaseFileWizard *create(QWidget *parent, const WizardDialogParameters ¶meters) const final + BaseFileWizard *create(const WizardDialogParameters ¶meters) const final { - auto wizard = new GenericProjectWizard(this, parent); + auto wizard = new GenericProjectWizard(this); wizard->setFilePath(parameters.defaultPath()); const QList pages = wizard->extensionPages(); for (QWizardPage *p : pages) diff --git a/src/plugins/projectexplorer/baseprojectwizarddialog.cpp b/src/plugins/projectexplorer/baseprojectwizarddialog.cpp index 733034b28c9..bb8af3e00ee 100644 --- a/src/plugins/projectexplorer/baseprojectwizarddialog.cpp +++ b/src/plugins/projectexplorer/baseprojectwizarddialog.cpp @@ -39,9 +39,8 @@ struct BaseProjectWizardDialogPrivate BaseProjectWizardDialog::BaseProjectWizardDialog(const Core::BaseFileWizardFactory *factory, - QWidget *parent, const Core::WizardDialogParameters ¶meters) : - Core::BaseFileWizard(factory, parameters.extraValues(), parent), + Core::BaseFileWizard(factory, parameters.extraValues()), d(std::make_unique(new ProjectIntroPage)) { setFilePath(parameters.defaultPath()); @@ -52,9 +51,8 @@ BaseProjectWizardDialog::BaseProjectWizardDialog(const Core::BaseFileWizardFacto BaseProjectWizardDialog::BaseProjectWizardDialog(const Core::BaseFileWizardFactory *factory, ProjectIntroPage *introPage, int introId, - QWidget *parent, const Core::WizardDialogParameters ¶meters) : - Core::BaseFileWizard(factory, parameters.extraValues(), parent), + Core::BaseFileWizard(factory, parameters.extraValues()), d(std::make_unique(introPage, introId)) { setFilePath(parameters.defaultPath()); diff --git a/src/plugins/projectexplorer/baseprojectwizarddialog.h b/src/plugins/projectexplorer/baseprojectwizarddialog.h index 8cee34db556..6cd2ba29160 100644 --- a/src/plugins/projectexplorer/baseprojectwizarddialog.h +++ b/src/plugins/projectexplorer/baseprojectwizarddialog.h @@ -26,10 +26,10 @@ class PROJECTEXPLORER_EXPORT BaseProjectWizardDialog : public Core::BaseFileWiza protected: explicit BaseProjectWizardDialog(const Core::BaseFileWizardFactory *factory, Utils::ProjectIntroPage *introPage, int introId, - QWidget *parent, const Core::WizardDialogParameters ¶meters); + const Core::WizardDialogParameters ¶meters); public: - explicit BaseProjectWizardDialog(const Core::BaseFileWizardFactory *factory, QWidget *parent, + explicit BaseProjectWizardDialog(const Core::BaseFileWizardFactory *factory, const Core::WizardDialogParameters ¶meters); ~BaseProjectWizardDialog() override; diff --git a/src/plugins/projectexplorer/customwizard/customwizard.cpp b/src/plugins/projectexplorer/customwizard/customwizard.cpp index c2ff5082bbb..fe81b3ba7e7 100644 --- a/src/plugins/projectexplorer/customwizard/customwizard.cpp +++ b/src/plugins/projectexplorer/customwizard/customwizard.cpp @@ -138,10 +138,10 @@ void CustomWizard::setParameters(const CustomWizardParametersPtr &p) setFlags(p->flags); } -BaseFileWizard *CustomWizard::create(QWidget *parent, const WizardDialogParameters &p) const +BaseFileWizard *CustomWizard::create(const WizardDialogParameters &p) const { QTC_ASSERT(d->m_parameters, return nullptr); - auto wizard = new BaseFileWizard(this, p.extraValues(), parent); + auto wizard = new BaseFileWizard(this, p.extraValues()); d->m_context->reset(); auto customPage = new CustomWizardPage(d->m_context, parameters()); @@ -461,10 +461,9 @@ CustomProjectWizard::CustomProjectWizard() = default; initProjectWizardDialog() needs to be called. */ -BaseFileWizard *CustomProjectWizard::create(QWidget *parent, - const WizardDialogParameters ¶meters) const +BaseFileWizard *CustomProjectWizard::create(const WizardDialogParameters ¶meters) const { - auto projectDialog = new BaseProjectWizardDialog(this, parent, parameters); + auto projectDialog = new BaseProjectWizardDialog(this, parameters); initProjectWizardDialog(projectDialog, parameters.defaultPath(), projectDialog->extensionPages()); diff --git a/src/plugins/projectexplorer/customwizard/customwizard.h b/src/plugins/projectexplorer/customwizard/customwizard.h index e1c1813f31c..f3421a04496 100644 --- a/src/plugins/projectexplorer/customwizard/customwizard.h +++ b/src/plugins/projectexplorer/customwizard/customwizard.h @@ -64,7 +64,7 @@ public: // Can be reimplemented to create custom wizards. initWizardDialog() needs to be // called. - Core::BaseFileWizard *create(QWidget *parent, const Core::WizardDialogParameters ¶meters) const override; + Core::BaseFileWizard *create(const Core::WizardDialogParameters ¶meters) const override; Core::GeneratedFiles generateFiles(const QWizard *w, QString *errorMessage) const override; @@ -110,7 +110,7 @@ signals: void projectLocationChanged(const Utils::FilePath &path); protected: - Core::BaseFileWizard *create(QWidget *parent, const Core::WizardDialogParameters ¶meters) const override; + Core::BaseFileWizard *create(const Core::WizardDialogParameters ¶meters) const override; Core::GeneratedFiles generateFiles(const QWizard *w, QString *errorMessage) const override; diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp b/src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp index 5ee0965e9ec..eb05160570c 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp @@ -127,8 +127,8 @@ private: } // namespace Internal -JsonWizard::JsonWizard(QWidget *parent) - : Wizard(parent) +JsonWizard::JsonWizard() + : Wizard(Core::ICore::dialogParent()) { setMinimumSize(800, 500); m_expander.registerExtraResolver([this](const QString &name, QString *ret) -> bool { diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizard.h b/src/plugins/projectexplorer/jsonwizard/jsonwizard.h index 90dc4c5d74d..648f95b3cfd 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonwizard.h +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizard.h @@ -61,7 +61,7 @@ public: using GeneratorFiles = QList; Q_PROPERTY(GeneratorFiles generateFileList READ generateFileList) - explicit JsonWizard(QWidget *parent = nullptr); + JsonWizard(); ~JsonWizard() override; void addGenerator(JsonWizardGenerator *gen); diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizard_test.cpp b/src/plugins/projectexplorer/jsonwizard/jsonwizard_test.cpp index 100be4c6cf0..2553c23c949 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonwizard_test.cpp +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizard_test.cpp @@ -138,7 +138,6 @@ void ProjectExplorerTest::testJsonWizardsCheckBox() { QString errorMessage; - QWidget parent; const QJsonArray widgets({ createWidget("CheckBox", "Default", QJsonObject()), createWidget("CheckBox", "Checked", QJsonObject({{"checked", true}})), @@ -155,21 +154,21 @@ void ProjectExplorerTest::testJsonWizardsCheckBox() const FactoryPtr factory(JsonWizardFactory::createWizardFactory(wizardObject.toVariantMap(), {}, &errorMessage)); QVERIFY2(factory, qPrintable(errorMessage)); - Wizard *wizard = factory->runWizard({}, &parent, Id(), QVariantMap()); + std::unique_ptr wizard{factory->runWizard({}, Id(), QVariantMap())}; - QVERIFY(!findCheckBox(wizard, "Default")->isChecked()); + QVERIFY(!findCheckBox(wizard.get(), "Default")->isChecked()); QCOMPARE(wizard->field("DefaultCheckBox"), QVariant(false)); - QVERIFY(findCheckBox(wizard, "Checked")->isChecked()); + QVERIFY(findCheckBox(wizard.get(), "Checked")->isChecked()); QCOMPARE(wizard->field("CheckedCheckBox"), QVariant(true)); - QVERIFY(!findCheckBox(wizard, "UnChecked")->isChecked()); + QVERIFY(!findCheckBox(wizard.get(), "UnChecked")->isChecked()); QCOMPARE(wizard->field("UnCheckedCheckBox"), QVariant(false)); - QVERIFY(!findCheckBox(wizard, "SpecialValueUnChecked")->isChecked()); + QVERIFY(!findCheckBox(wizard.get(), "SpecialValueUnChecked")->isChecked()); QCOMPARE(qPrintable(wizard->field("SpecialValueUnCheckedCheckBox").toString()), "SpecialUnCheckedValue"); - QVERIFY(findCheckBox(wizard, "SpecialValueChecked")->isChecked()); + QVERIFY(findCheckBox(wizard.get(), "SpecialValueChecked")->isChecked()); QCOMPARE(qPrintable(wizard->field("SpecialValueCheckedCheckBox").toString()), "SpecialCheckedValue"); } @@ -177,7 +176,6 @@ void ProjectExplorerTest::testJsonWizardsLineEdit() { QString errorMessage; - QWidget parent; const QJsonArray widgets({ createWidget("LineEdit", "Default", QJsonObject()), createWidget("LineEdit", "WithText", QJsonObject({{"trText", "some text"}})) @@ -187,20 +185,20 @@ void ProjectExplorerTest::testJsonWizardsLineEdit() const FactoryPtr factory(JsonWizardFactory::createWizardFactory(wizardObject.toVariantMap(), {}, &errorMessage)); QVERIFY2(factory, qPrintable(errorMessage)); - Wizard *wizard = factory->runWizard({}, &parent, Id(), QVariantMap()); - QVERIFY(findLineEdit(wizard, "Default")); - QVERIFY(findLineEdit(wizard, "Default")->text().isEmpty()); - QCOMPARE(qPrintable(findLineEdit(wizard, "WithText")->text()), "some text"); + std::unique_ptr wizard{factory->runWizard({}, Id(), QVariantMap())}; + QVERIFY(wizard); + QVERIFY(findLineEdit(wizard.get(), "Default")); + QVERIFY(findLineEdit(wizard.get(), "Default")->text().isEmpty()); + QCOMPARE(qPrintable(findLineEdit(wizard.get(), "WithText")->text()), "some text"); QVERIFY(!wizard->page(0)->isComplete()); - findLineEdit(wizard, "Default")->setText("enable isComplete"); + findLineEdit(wizard.get(), "Default")->setText("enable isComplete"); QVERIFY(wizard->page(0)->isComplete()); } void ProjectExplorerTest::testJsonWizardsComboBox() { QString errorMessage; - QWidget parent; const QJsonArray items({"abc", "cde", "fgh"}); QJsonObject disabledComboBoxObject = createWidget("ComboBox", "Disabled", QJsonObject({ {{"disabledIndex", 2}, {"items", items}} })); @@ -215,9 +213,9 @@ void ProjectExplorerTest::testJsonWizardsComboBox() const QJsonObject wizardObject = createGeneralWizard(pages); const FactoryPtr factory(JsonWizardFactory::createWizardFactory(wizardObject.toVariantMap(), {}, &errorMessage)); QVERIFY2(factory, qPrintable(errorMessage)); - Wizard *wizard = factory->runWizard({}, &parent, Id(), QVariantMap()); + std::unique_ptr wizard{factory->runWizard({}, Id(), QVariantMap())}; - QComboBox *defaultComboBox = findComboBox(wizard, "Default"); + QComboBox *defaultComboBox = findComboBox(wizard.get(), "Default"); QVERIFY(defaultComboBox); QCOMPARE(defaultComboBox->count(), items.count()); QCOMPARE(qPrintable(defaultComboBox->currentText()), "abc"); @@ -225,11 +223,11 @@ void ProjectExplorerTest::testJsonWizardsComboBox() defaultComboBox->setCurrentIndex(2); QCOMPARE(qPrintable(defaultComboBox->currentText()), "fgh"); - QComboBox *index2ComboBox = findComboBox(wizard, "Index2"); + QComboBox *index2ComboBox = findComboBox(wizard.get(), "Index2"); QVERIFY(index2ComboBox); QCOMPARE(qPrintable(index2ComboBox->currentText()), "fgh"); - QComboBox *disabledComboBox = findComboBox(wizard, "Disabled"); + QComboBox *disabledComboBox = findComboBox(wizard.get(), "Disabled"); QVERIFY(disabledComboBox); QCOMPARE(qPrintable(disabledComboBox->currentText()), "fgh"); } @@ -242,7 +240,6 @@ static QString iconInsideResource(const QString &relativePathToIcon) void ProjectExplorerTest::testJsonWizardsIconList() { QString errorMessage; - QWidget parent; const QJsonArray items({ QJsonObject{ @@ -272,7 +269,7 @@ void ProjectExplorerTest::testJsonWizardsIconList() const QJsonObject wizardObject = createGeneralWizard(pages); const FactoryPtr factory(JsonWizardFactory::createWizardFactory(wizardObject.toVariantMap(), {}, &errorMessage)); QVERIFY2(factory, qPrintable(errorMessage)); - Wizard *wizard = factory->runWizard({}, &parent, Id(), QVariantMap()); + std::unique_ptr wizard{factory->runWizard({}, Id(), QVariantMap())}; auto view = wizard->findChild("FancyIconList"); QCOMPARE(view->model()->rowCount(), 2); diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp b/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp index 6cb79cef777..fbf7534ee6e 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp @@ -653,11 +653,10 @@ static QString qmlProjectName(const FilePath &folder) return {}; } -Wizard *JsonWizardFactory::runWizardImpl(const FilePath &path, QWidget *parent, - Id platform, +Wizard *JsonWizardFactory::runWizardImpl(const FilePath &path, Id platform, const QVariantMap &variables, bool showWizard) { - auto wizard = new JsonWizard(parent); + auto wizard = new JsonWizard; wizard->setWindowIcon(icon()); wizard->setWindowTitle(displayName()); diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.h b/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.h index 5e7fba1f1de..2e18346b29f 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.h +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.h @@ -62,7 +62,7 @@ public: static void setInstalledWizardsPath(const Utils::FilePath &path); private: - Utils::Wizard *runWizardImpl(const Utils::FilePath &path, QWidget *parent, Utils::Id platform, + Utils::Wizard *runWizardImpl(const Utils::FilePath &path, Utils::Id platform, const QVariantMap &variables, bool showWizard = true) override; // Create all wizards. As other plugins might register factories for derived diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index f3451b92ca3..c1cba541107 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -3621,7 +3621,7 @@ void ProjectExplorerPluginPrivate::addNewHeaderOrSource() IWizardFactory::allWizardFactories(), [factoryId](const IWizardFactory *f) { return f->id() == factoryId; }); QTC_ASSERT(factory, return); - factory->runWizard(folderNode->directory(), ICore::dialogParent(), {}, map); + factory->runWizard(folderNode->directory(), {}, map); } void ProjectExplorerPluginPrivate::addNewSubproject() diff --git a/src/plugins/projectexplorer/simpleprojectwizard.cpp b/src/plugins/projectexplorer/simpleprojectwizard.cpp index ad6e05fbe3b..68ea0f998fa 100644 --- a/src/plugins/projectexplorer/simpleprojectwizard.cpp +++ b/src/plugins/projectexplorer/simpleprojectwizard.cpp @@ -110,8 +110,8 @@ class SimpleProjectWizardDialog : public BaseFileWizard Q_OBJECT public: - SimpleProjectWizardDialog(const BaseFileWizardFactory *factory, QWidget *parent) - : BaseFileWizard(factory, QVariantMap(), parent) + explicit SimpleProjectWizardDialog(const BaseFileWizardFactory *factory) + : BaseFileWizard(factory, QVariantMap()) { setWindowTitle(Tr::tr("Import Existing Project")); @@ -162,10 +162,9 @@ SimpleProjectWizard::SimpleProjectWizard() setFlags(IWizardFactory::PlatformIndependent); } -BaseFileWizard *SimpleProjectWizard::create(QWidget *parent, - const WizardDialogParameters ¶meters) const +BaseFileWizard *SimpleProjectWizard::create(const WizardDialogParameters ¶meters) const { - auto wizard = new SimpleProjectWizardDialog(this, parent); + auto wizard = new SimpleProjectWizardDialog(this); wizard->setProjectDir(parameters.defaultPath()); for (QWizardPage *p : wizard->extensionPages()) diff --git a/src/plugins/projectexplorer/simpleprojectwizard.h b/src/plugins/projectexplorer/simpleprojectwizard.h index 2f5ffcc4d33..6400670f6e8 100644 --- a/src/plugins/projectexplorer/simpleprojectwizard.h +++ b/src/plugins/projectexplorer/simpleprojectwizard.h @@ -16,7 +16,7 @@ public: SimpleProjectWizard(); private: - Core::BaseFileWizard *create(QWidget *parent, const Core::WizardDialogParameters ¶meters) const override; + Core::BaseFileWizard *create(const Core::WizardDialogParameters ¶meters) const override; Core::GeneratedFiles generateFiles(const QWizard *w, QString *errorMessage) const override; bool postGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l, QString *errorMessage) const override; diff --git a/src/plugins/qmakeprojectmanager/customwidgetwizard/customwidgetwizard.cpp b/src/plugins/qmakeprojectmanager/customwidgetwizard/customwidgetwizard.cpp index b5322031bf1..03936a66a38 100644 --- a/src/plugins/qmakeprojectmanager/customwidgetwizard/customwidgetwizard.cpp +++ b/src/plugins/qmakeprojectmanager/customwidgetwizard/customwidgetwizard.cpp @@ -29,10 +29,9 @@ CustomWidgetWizard::CustomWidgetWizard() setRequiredFeatures({QtSupport::Constants::FEATURE_QWIDGETS}); } -Core::BaseFileWizard *CustomWidgetWizard::create(QWidget *parent, const Core::WizardDialogParameters ¶meters) const +Core::BaseFileWizard *CustomWidgetWizard::create(const Core::WizardDialogParameters ¶meters) const { - CustomWidgetWizardDialog *rc = new CustomWidgetWizardDialog(this, displayName(), - icon(), parent, parameters); + auto rc = new CustomWidgetWizardDialog(this, displayName(), icon(), parameters); rc->setProjectName(CustomWidgetWizardDialog::uniqueProjectName(parameters.defaultPath())); rc->setFileNamingParameters(FileNamingParameters(headerSuffix(), sourceSuffix(), QtWizard::lowerCaseFiles())); return rc; diff --git a/src/plugins/qmakeprojectmanager/customwidgetwizard/customwidgetwizard.h b/src/plugins/qmakeprojectmanager/customwidgetwizard/customwidgetwizard.h index 456c3c8071e..b7c96102852 100644 --- a/src/plugins/qmakeprojectmanager/customwidgetwizard/customwidgetwizard.h +++ b/src/plugins/qmakeprojectmanager/customwidgetwizard/customwidgetwizard.h @@ -16,8 +16,7 @@ public: CustomWidgetWizard(); protected: - Core::BaseFileWizard *create(QWidget *parent, - const Core::WizardDialogParameters ¶meters) const override; + Core::BaseFileWizard *create(const Core::WizardDialogParameters ¶meters) const override; Core::GeneratedFiles generateFiles(const QWizard *w, QString *errorMessage) const override; }; diff --git a/src/plugins/qmakeprojectmanager/customwidgetwizard/customwidgetwizarddialog.cpp b/src/plugins/qmakeprojectmanager/customwidgetwizard/customwidgetwizarddialog.cpp index 49ff339f45a..4b160f39eed 100644 --- a/src/plugins/qmakeprojectmanager/customwidgetwizard/customwidgetwizarddialog.cpp +++ b/src/plugins/qmakeprojectmanager/customwidgetwizard/customwidgetwizarddialog.cpp @@ -19,9 +19,8 @@ enum { IntroPageId = 0}; CustomWidgetWizardDialog::CustomWidgetWizardDialog(const Core::BaseFileWizardFactory *factory, const QString &templateName, - const QIcon &icon, QWidget *parent, - const Core::WizardDialogParameters ¶meters) : - BaseQmakeProjectWizardDialog(factory, parent, parameters), + const QIcon &icon, const Core::WizardDialogParameters ¶meters) : + BaseQmakeProjectWizardDialog(factory, parameters), m_widgetsPage(new CustomWidgetWidgetsWizardPage), m_pluginPage(new CustomWidgetPluginWizardPage) { diff --git a/src/plugins/qmakeprojectmanager/customwidgetwizard/customwidgetwizarddialog.h b/src/plugins/qmakeprojectmanager/customwidgetwizard/customwidgetwizarddialog.h index 6fcf38cba78..a20602bcf21 100644 --- a/src/plugins/qmakeprojectmanager/customwidgetwizard/customwidgetwizarddialog.h +++ b/src/plugins/qmakeprojectmanager/customwidgetwizard/customwidgetwizarddialog.h @@ -19,7 +19,6 @@ class CustomWidgetWizardDialog : public BaseQmakeProjectWizardDialog public: explicit CustomWidgetWizardDialog(const Core::BaseFileWizardFactory *factory, const QString &templateName, const QIcon &icon, - QWidget *parent, const Core::WizardDialogParameters ¶meters); std::shared_ptr pluginOptions() const; diff --git a/src/plugins/qmakeprojectmanager/wizards/qtwizard.cpp b/src/plugins/qmakeprojectmanager/wizards/qtwizard.cpp index a4493d6361d..840a3f849a6 100644 --- a/src/plugins/qmakeprojectmanager/wizards/qtwizard.cpp +++ b/src/plugins/qmakeprojectmanager/wizards/qtwizard.cpp @@ -97,10 +97,9 @@ bool QtWizard::lowerCaseFiles() // ------------ CustomQmakeProjectWizard CustomQmakeProjectWizard::CustomQmakeProjectWizard() = default; -Core::BaseFileWizard *CustomQmakeProjectWizard::create(QWidget *parent, - const Core::WizardDialogParameters ¶meters) const +Core::BaseFileWizard *CustomQmakeProjectWizard::create(const Core::WizardDialogParameters ¶meters) const { - auto *wizard = new BaseQmakeProjectWizardDialog(this, parent, parameters); + auto *wizard = new BaseQmakeProjectWizardDialog(this, parameters); if (!parameters.extraValues().contains(QLatin1String(ProjectExplorer::Constants::PROJECT_KIT_IDS))) wizard->addTargetSetupPage(targetPageId); @@ -118,9 +117,8 @@ bool CustomQmakeProjectWizard::postGenerateFiles(const QWizard *w, const Core::G // ----------------- BaseQmakeProjectWizardDialog BaseQmakeProjectWizardDialog::BaseQmakeProjectWizardDialog( const Core::BaseFileWizardFactory *factory, - QWidget *parent, const Core::WizardDialogParameters ¶meters) - : ProjectExplorer::BaseProjectWizardDialog(factory, parent, parameters) + : ProjectExplorer::BaseProjectWizardDialog(factory, parameters) { m_profileIds = Utils::transform(parameters.extraValues() .value(ProjectExplorer::Constants::PROJECT_KIT_IDS) @@ -135,9 +133,8 @@ BaseQmakeProjectWizardDialog::BaseQmakeProjectWizardDialog( const Core::BaseFileWizardFactory *factory, Utils::ProjectIntroPage *introPage, int introId, - QWidget *parent, const Core::WizardDialogParameters ¶meters) - : ProjectExplorer::BaseProjectWizardDialog(factory, introPage, introId, parent, parameters) + : ProjectExplorer::BaseProjectWizardDialog(factory, introPage, introId, parameters) { m_profileIds = Utils::transform(parameters.extraValues() .value(ProjectExplorer::Constants::PROJECT_KIT_IDS) diff --git a/src/plugins/qmakeprojectmanager/wizards/qtwizard.h b/src/plugins/qmakeprojectmanager/wizards/qtwizard.h index ba6b7ce6339..a6913d1e58e 100644 --- a/src/plugins/qmakeprojectmanager/wizards/qtwizard.h +++ b/src/plugins/qmakeprojectmanager/wizards/qtwizard.h @@ -60,8 +60,7 @@ public: CustomQmakeProjectWizard(); private: - Core::BaseFileWizard *create(QWidget *parent, - const Core::WizardDialogParameters ¶meters) const override; + Core::BaseFileWizard *create(const Core::WizardDialogParameters ¶meters) const override; bool postGenerateFiles(const QWizard *, const Core::GeneratedFiles &l, QString *errorMessage) const override; @@ -81,11 +80,10 @@ class BaseQmakeProjectWizardDialog : public ProjectExplorer::BaseProjectWizardDi protected: explicit BaseQmakeProjectWizardDialog(const Core::BaseFileWizardFactory *factory, Utils::ProjectIntroPage *introPage, - int introId, QWidget *parent, + int introId, const Core::WizardDialogParameters ¶meters); public: explicit BaseQmakeProjectWizardDialog(const Core::BaseFileWizardFactory *factory, - QWidget *parent, const Core::WizardDialogParameters ¶meters); ~BaseQmakeProjectWizardDialog() override; diff --git a/src/plugins/qmakeprojectmanager/wizards/subdirsprojectwizard.cpp b/src/plugins/qmakeprojectmanager/wizards/subdirsprojectwizard.cpp index bba91520493..1e5e932efee 100644 --- a/src/plugins/qmakeprojectmanager/wizards/subdirsprojectwizard.cpp +++ b/src/plugins/qmakeprojectmanager/wizards/subdirsprojectwizard.cpp @@ -33,11 +33,9 @@ SubdirsProjectWizard::SubdirsProjectWizard() setRequiredFeatures({QtSupport::Constants::FEATURE_QT_PREFIX}); } -Core::BaseFileWizard *SubdirsProjectWizard::create(QWidget *parent, - const Core::WizardDialogParameters ¶meters) const +Core::BaseFileWizard *SubdirsProjectWizard::create(const Core::WizardDialogParameters ¶meters) const { - SubdirsProjectWizardDialog *dialog = new SubdirsProjectWizardDialog(this, displayName(), icon(), - parent, parameters); + auto dialog = new SubdirsProjectWizardDialog(this, displayName(), icon(), parameters); dialog->setProjectName(SubdirsProjectWizardDialog::uniqueProjectName(parameters.defaultPath())); const QString buttonText = dialog->wizardStyle() == QWizard::MacStyle diff --git a/src/plugins/qmakeprojectmanager/wizards/subdirsprojectwizard.h b/src/plugins/qmakeprojectmanager/wizards/subdirsprojectwizard.h index 449c3a7e6d5..379c3456e0e 100644 --- a/src/plugins/qmakeprojectmanager/wizards/subdirsprojectwizard.h +++ b/src/plugins/qmakeprojectmanager/wizards/subdirsprojectwizard.h @@ -16,8 +16,7 @@ public: SubdirsProjectWizard(); private: - Core::BaseFileWizard *create(QWidget *parent, - const Core::WizardDialogParameters ¶meters) const override; + Core::BaseFileWizard *create(const Core::WizardDialogParameters ¶meters) const override; Core::GeneratedFiles generateFiles(const QWizard *w, QString *errorMessage) const override; bool postGenerateFiles(const QWizard *, const Core::GeneratedFiles &l, diff --git a/src/plugins/qmakeprojectmanager/wizards/subdirsprojectwizarddialog.cpp b/src/plugins/qmakeprojectmanager/wizards/subdirsprojectwizarddialog.cpp index 86b9f940f28..8a9dada3b99 100644 --- a/src/plugins/qmakeprojectmanager/wizards/subdirsprojectwizarddialog.cpp +++ b/src/plugins/qmakeprojectmanager/wizards/subdirsprojectwizarddialog.cpp @@ -13,9 +13,8 @@ namespace Internal { SubdirsProjectWizardDialog::SubdirsProjectWizardDialog(const Core::BaseFileWizardFactory *factory, const QString &templateName, - const QIcon &icon, QWidget *parent, - const Core::WizardDialogParameters ¶meters) : - BaseQmakeProjectWizardDialog(factory, parent, parameters) + const QIcon &icon, const Core::WizardDialogParameters ¶meters) : + BaseQmakeProjectWizardDialog(factory, parameters) { setWindowIcon(icon); setWindowTitle(templateName); diff --git a/src/plugins/qmakeprojectmanager/wizards/subdirsprojectwizarddialog.h b/src/plugins/qmakeprojectmanager/wizards/subdirsprojectwizarddialog.h index 4080e29ce94..3af2906e920 100644 --- a/src/plugins/qmakeprojectmanager/wizards/subdirsprojectwizarddialog.h +++ b/src/plugins/qmakeprojectmanager/wizards/subdirsprojectwizarddialog.h @@ -14,10 +14,9 @@ class SubdirsProjectWizardDialog : public BaseQmakeProjectWizardDialog { Q_OBJECT public: - explicit SubdirsProjectWizardDialog(const Core::BaseFileWizardFactory *factory, const QString &templateName, - const QIcon &icon, - QWidget *parent, - const Core::WizardDialogParameters ¶meters); + SubdirsProjectWizardDialog(const Core::BaseFileWizardFactory *factory, const QString &templateName, + const QIcon &icon, + const Core::WizardDialogParameters ¶meters); QtProjectParameters parameters() const; }; diff --git a/src/plugins/studiowelcome/qdsnewdialog.cpp b/src/plugins/studiowelcome/qdsnewdialog.cpp index 1032e7fceea..e483effd8ae 100644 --- a/src/plugins/studiowelcome/qdsnewdialog.cpp +++ b/src/plugins/studiowelcome/qdsnewdialog.cpp @@ -340,7 +340,7 @@ void QdsNewDialog::setWizardFactories(QList factories_, { Utils::Id platform = Utils::Id::fromSetting("Desktop"); - WizardFactories factories{factories_, m_dialog.get(), platform}; + WizardFactories factories{factories_, platform}; std::vector recents = m_recentsStore.fetchAll(); std::vector userPresets = m_userPresetsStore.fetchAll(); diff --git a/src/plugins/studiowelcome/wizardfactories.cpp b/src/plugins/studiowelcome/wizardfactories.cpp index 0b285d1c493..248b41b5e25 100644 --- a/src/plugins/studiowelcome/wizardfactories.cpp +++ b/src/plugins/studiowelcome/wizardfactories.cpp @@ -17,10 +17,8 @@ using namespace StudioWelcome; WizardFactories::GetIconUnicodeFunc WizardFactories::m_getIconUnicode = &QmlDesigner::Theme::getIconUnicode; WizardFactories::WizardFactories(const QList &factories, - QWidget *wizardParent, const Utils::Id &platform) - : m_wizardParent{wizardParent} - , m_platform{platform} + : m_platform{platform} { m_factories = Utils::filtered(Utils::transform(factories, [](Core::IWizardFactory *f) { return qobject_cast(f); @@ -56,8 +54,7 @@ void WizardFactories::filter() m_factories = acceptedFactories; } -std::shared_ptr WizardFactories::makePresetItem(JsonWizardFactory *f, QWidget *parent, - const Utils::Id &platform) +std::shared_ptr WizardFactories::makePresetItem(JsonWizardFactory *f, const Utils::Id &platform) { using namespace std::placeholders; @@ -77,7 +74,7 @@ std::shared_ptr WizardFactories::makePresetItem(JsonWizardFactory *f result->qmlPath = f->detailsPageQmlPath(); result->fontIconCode = m_getIconUnicode(f->fontIconName()); result->create - = std::bind(&JsonWizardFactory::runWizard, f, _1, parent, platform, QVariantMap(), false); + = std::bind(&JsonWizardFactory::runWizard, f, _1, platform, QVariantMap(), false); return result; } @@ -93,11 +90,11 @@ std::map WizardFactories::makePresetItemsGroupedByCateg /*.name =*/ f->displayCategory(), /*.items = */ { - makePresetItem(f, m_wizardParent, m_platform), + makePresetItem(f, m_platform), }, }; } else { - auto presetItem = makePresetItem(f, m_wizardParent, m_platform); + auto presetItem = makePresetItem(f, m_platform); categories[f->category()].items.push_back(presetItem); } } diff --git a/src/plugins/studiowelcome/wizardfactories.h b/src/plugins/studiowelcome/wizardfactories.h index 1a5640af629..dc9606fab09 100644 --- a/src/plugins/studiowelcome/wizardfactories.h +++ b/src/plugins/studiowelcome/wizardfactories.h @@ -25,8 +25,7 @@ public: using GetIconUnicodeFunc = QString (*)(const QString &); public: - WizardFactories(const QList &factories, QWidget *wizardParent, - const Utils::Id &platform); + WizardFactories(const QList &factories, const Utils::Id &platform); const Core::IWizardFactory *front() const; const std::map &presetsGroupedByCategory() const @@ -42,11 +41,10 @@ private: void sortByCategoryAndId(); void filter(); - std::shared_ptr makePresetItem(JsonWizardFactory *f, QWidget *parent, const Utils::Id &platform); + std::shared_ptr makePresetItem(JsonWizardFactory *f, const Utils::Id &platform); std::map makePresetItemsGroupedByCategory(); private: - QWidget *m_wizardParent; Utils::Id m_platform; // filter wizards to only those supported by this platform. QList m_factories;