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 <eike.ziller@qt.io>
This commit is contained in:
hjk
2024-12-04 09:48:00 +01:00
parent 2a990b84fa
commit 23c0ae336f
33 changed files with 88 additions and 118 deletions

View File

@@ -46,8 +46,7 @@ static int indexOfFile(const GeneratedFiles &f, const FilePath &path)
\sa Core::BaseFileWizardFactory \sa Core::BaseFileWizardFactory
*/ */
Utils::Wizard *BaseFileWizardFactory::runWizardImpl(const FilePath &path, QWidget *parent, Wizard *BaseFileWizardFactory::runWizardImpl(const FilePath &path, Id platform,
Id platform,
const QVariantMap &extraValues, const QVariantMap &extraValues,
bool showWizard) bool showWizard)
{ {
@@ -63,7 +62,7 @@ Utils::Wizard *BaseFileWizardFactory::runWizardImpl(const FilePath &path, QWidge
if (flags().testFlag(ForceCapitalLetterForFileName)) if (flags().testFlag(ForceCapitalLetterForFileName))
dialogParameterFlags |= WizardDialogParameters::ForceCapitalLetterForFileName; dialogParameterFlags |= WizardDialogParameters::ForceCapitalLetterForFileName;
Wizard *wizard = create(parent, WizardDialogParameters(path, Wizard *wizard = create(WizardDialogParameters(path,
platform, platform,
requiredFeatures(), requiredFeatures(),
dialogParameterFlags, dialogParameterFlags,

View File

@@ -67,7 +67,7 @@ public:
static Utils::FilePath buildFileName(const Utils::FilePath &path, const QString &baseName, const QString &extension); static Utils::FilePath buildFileName(const Utils::FilePath &path, const QString &baseName, const QString &extension);
protected: protected:
virtual BaseFileWizard *create(QWidget *parent, const WizardDialogParameters &parameters) const = 0; virtual BaseFileWizard *create(const WizardDialogParameters &parameters) const = 0;
virtual GeneratedFiles generateFiles(const QWizard *w, virtual GeneratedFiles generateFiles(const QWizard *w,
QString *errorMessage) const = 0; QString *errorMessage) const = 0;
@@ -84,7 +84,7 @@ protected:
static bool postGenerateOpenEditors(const GeneratedFiles &l, QString *errorMessage = nullptr); static bool postGenerateOpenEditors(const GeneratedFiles &l, QString *errorMessage = nullptr);
private: 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; const QVariantMap &extraValues, bool showWizard = true) final;
}; };

View File

@@ -544,7 +544,7 @@ static void runWizard(IWizardFactory *wizard, const FilePath &defaultLocation, I
const QVariantMap &variables) const QVariantMap &variables)
{ {
const FilePath path = wizard->runPath(defaultLocation); const FilePath path = wizard->runPath(defaultLocation);
wizard->runWizard(path, ICore::dialogParent(), platform, variables); wizard->runWizard(path, platform, variables);
} }
void NewDialogWidget::accept() void NewDialogWidget::accept()

View File

@@ -209,7 +209,7 @@ QList<IWizardFactory*> IWizardFactory::allWizardFactories()
.addOnTriggered(newFactory, [newFactory] { .addOnTriggered(newFactory, [newFactory] {
if (!ICore::isNewItemDialogRunning()) { if (!ICore::isNewItemDialogRunning()) {
FilePath path = newFactory->runPath({}); 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 Creates the wizard that the user selected for execution on the operating
system \a platform with \a variables. 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 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 created. The wizard should fill this in its path selection elements as a
default path. 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 When \a showWizard is \c false, the wizard instance is created and set up
but not actually shown. 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, const QVariantMap &variables,
bool showWizard) bool showWizard)
{ {
@@ -264,7 +263,7 @@ Wizard *IWizardFactory::runWizard(const FilePath &path, QWidget *parent, Id plat
s_isWizardRunning = true; s_isWizardRunning = true;
ICore::updateNewItemDialogState(); ICore::updateNewItemDialogState();
Utils::Wizard *wizard = runWizardImpl(path, parent, platform, variables, showWizard); Wizard *wizard = runWizardImpl(path, platform, variables, showWizard);
if (wizard) { if (wizard) {

View File

@@ -71,7 +71,7 @@ public:
Utils::FilePath runPath(const Utils::FilePath &defaultPath) const; Utils::FilePath runPath(const Utils::FilePath &defaultPath) const;
// Does bookkeeping and the calls runWizardImpl. Please implement that. // 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); const QVariantMap &variables, bool showWizard = true);
virtual bool isAvailable(Utils::Id platformId) const; virtual bool isAvailable(Utils::Id platformId) const;
@@ -103,7 +103,6 @@ protected:
static QSet<Utils::Id> availableFeatures(Utils::Id platformId); static QSet<Utils::Id> availableFeatures(Utils::Id platformId);
virtual Utils::Wizard *runWizardImpl(const Utils::FilePath &path, virtual Utils::Wizard *runWizardImpl(const Utils::FilePath &path,
QWidget *parent,
Utils::Id platform, Utils::Id platform,
const QVariantMap &variables, const QVariantMap &variables,
bool showWizard = true) = 0; bool showWizard = true) = 0;

View File

@@ -42,9 +42,9 @@ QString FormClassWizard::formSuffix() const
return preferredSuffix(Utils::Constants::FORM_MIMETYPE); return preferredSuffix(Utils::Constants::FORM_MIMETYPE);
} }
Core::BaseFileWizard *FormClassWizard::create(QWidget *parent, const Core::WizardDialogParameters &parameters) const Core::BaseFileWizard *FormClassWizard::create(const Core::WizardDialogParameters &parameters) const
{ {
auto wizardDialog = new FormClassWizardDialog(this, parent); auto wizardDialog = new FormClassWizardDialog(this);
wizardDialog->setFilePath(parameters.defaultPath()); wizardDialog->setFilePath(parameters.defaultPath());
return wizardDialog; return wizardDialog;
} }

View File

@@ -22,7 +22,7 @@ public:
QString formSuffix() const; QString formSuffix() const;
private: private:
Core::BaseFileWizard *create(QWidget *parent, const Core::WizardDialogParameters &parameters) const final; Core::BaseFileWizard *create(const Core::WizardDialogParameters &parameters) const final;
Core::GeneratedFiles generateFiles(const QWizard *w, QString *errorMessage) const final; Core::GeneratedFiles generateFiles(const QWizard *w, QString *errorMessage) const final;
}; };

View File

@@ -98,8 +98,8 @@ class GenericProjectWizard final : public BaseFileWizard
Q_OBJECT Q_OBJECT
public: public:
GenericProjectWizard(const BaseFileWizardFactory *factory, QWidget *parent) GenericProjectWizard(const BaseFileWizardFactory *factory)
: BaseFileWizard(factory, QVariantMap(), parent) : BaseFileWizard(factory, QVariantMap(), Core::ICore::dialogParent())
{ {
setWindowTitle(Tr::tr("Import Existing Project")); setWindowTitle(Tr::tr("Import Existing Project"));
@@ -172,9 +172,9 @@ public:
} }
protected: protected:
BaseFileWizard *create(QWidget *parent, const WizardDialogParameters &parameters) const final BaseFileWizard *create(const WizardDialogParameters &parameters) const final
{ {
auto wizard = new GenericProjectWizard(this, parent); auto wizard = new GenericProjectWizard(this);
wizard->setFilePath(parameters.defaultPath()); wizard->setFilePath(parameters.defaultPath());
const QList<QWizardPage *> pages = wizard->extensionPages(); const QList<QWizardPage *> pages = wizard->extensionPages();
for (QWizardPage *p : pages) for (QWizardPage *p : pages)

View File

@@ -39,9 +39,8 @@ struct BaseProjectWizardDialogPrivate
BaseProjectWizardDialog::BaseProjectWizardDialog(const Core::BaseFileWizardFactory *factory, BaseProjectWizardDialog::BaseProjectWizardDialog(const Core::BaseFileWizardFactory *factory,
QWidget *parent,
const Core::WizardDialogParameters &parameters) : const Core::WizardDialogParameters &parameters) :
Core::BaseFileWizard(factory, parameters.extraValues(), parent), Core::BaseFileWizard(factory, parameters.extraValues()),
d(std::make_unique<BaseProjectWizardDialogPrivate>(new ProjectIntroPage)) d(std::make_unique<BaseProjectWizardDialogPrivate>(new ProjectIntroPage))
{ {
setFilePath(parameters.defaultPath()); setFilePath(parameters.defaultPath());
@@ -52,9 +51,8 @@ BaseProjectWizardDialog::BaseProjectWizardDialog(const Core::BaseFileWizardFacto
BaseProjectWizardDialog::BaseProjectWizardDialog(const Core::BaseFileWizardFactory *factory, BaseProjectWizardDialog::BaseProjectWizardDialog(const Core::BaseFileWizardFactory *factory,
ProjectIntroPage *introPage, int introId, ProjectIntroPage *introPage, int introId,
QWidget *parent,
const Core::WizardDialogParameters &parameters) : const Core::WizardDialogParameters &parameters) :
Core::BaseFileWizard(factory, parameters.extraValues(), parent), Core::BaseFileWizard(factory, parameters.extraValues()),
d(std::make_unique<BaseProjectWizardDialogPrivate>(introPage, introId)) d(std::make_unique<BaseProjectWizardDialogPrivate>(introPage, introId))
{ {
setFilePath(parameters.defaultPath()); setFilePath(parameters.defaultPath());

View File

@@ -26,10 +26,10 @@ class PROJECTEXPLORER_EXPORT BaseProjectWizardDialog : public Core::BaseFileWiza
protected: protected:
explicit BaseProjectWizardDialog(const Core::BaseFileWizardFactory *factory, explicit BaseProjectWizardDialog(const Core::BaseFileWizardFactory *factory,
Utils::ProjectIntroPage *introPage, int introId, Utils::ProjectIntroPage *introPage, int introId,
QWidget *parent, const Core::WizardDialogParameters &parameters); const Core::WizardDialogParameters &parameters);
public: public:
explicit BaseProjectWizardDialog(const Core::BaseFileWizardFactory *factory, QWidget *parent, explicit BaseProjectWizardDialog(const Core::BaseFileWizardFactory *factory,
const Core::WizardDialogParameters &parameters); const Core::WizardDialogParameters &parameters);
~BaseProjectWizardDialog() override; ~BaseProjectWizardDialog() override;

View File

@@ -138,10 +138,10 @@ void CustomWizard::setParameters(const CustomWizardParametersPtr &p)
setFlags(p->flags); 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); 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(); d->m_context->reset();
auto customPage = new CustomWizardPage(d->m_context, parameters()); auto customPage = new CustomWizardPage(d->m_context, parameters());
@@ -461,10 +461,9 @@ CustomProjectWizard::CustomProjectWizard() = default;
initProjectWizardDialog() needs to be called. initProjectWizardDialog() needs to be called.
*/ */
BaseFileWizard *CustomProjectWizard::create(QWidget *parent, BaseFileWizard *CustomProjectWizard::create(const WizardDialogParameters &parameters) const
const WizardDialogParameters &parameters) const
{ {
auto projectDialog = new BaseProjectWizardDialog(this, parent, parameters); auto projectDialog = new BaseProjectWizardDialog(this, parameters);
initProjectWizardDialog(projectDialog, initProjectWizardDialog(projectDialog,
parameters.defaultPath(), parameters.defaultPath(),
projectDialog->extensionPages()); projectDialog->extensionPages());

View File

@@ -64,7 +64,7 @@ public:
// Can be reimplemented to create custom wizards. initWizardDialog() needs to be // Can be reimplemented to create custom wizards. initWizardDialog() needs to be
// called. // called.
Core::BaseFileWizard *create(QWidget *parent, const Core::WizardDialogParameters &parameters) const override; Core::BaseFileWizard *create(const Core::WizardDialogParameters &parameters) const override;
Core::GeneratedFiles generateFiles(const QWizard *w, QString *errorMessage) const override; Core::GeneratedFiles generateFiles(const QWizard *w, QString *errorMessage) const override;
@@ -110,7 +110,7 @@ signals:
void projectLocationChanged(const Utils::FilePath &path); void projectLocationChanged(const Utils::FilePath &path);
protected: protected:
Core::BaseFileWizard *create(QWidget *parent, const Core::WizardDialogParameters &parameters) const override; Core::BaseFileWizard *create(const Core::WizardDialogParameters &parameters) const override;
Core::GeneratedFiles generateFiles(const QWizard *w, QString *errorMessage) const override; Core::GeneratedFiles generateFiles(const QWizard *w, QString *errorMessage) const override;

View File

@@ -127,8 +127,8 @@ private:
} // namespace Internal } // namespace Internal
JsonWizard::JsonWizard(QWidget *parent) JsonWizard::JsonWizard()
: Wizard(parent) : Wizard(Core::ICore::dialogParent())
{ {
setMinimumSize(800, 500); setMinimumSize(800, 500);
m_expander.registerExtraResolver([this](const QString &name, QString *ret) -> bool { m_expander.registerExtraResolver([this](const QString &name, QString *ret) -> bool {

View File

@@ -61,7 +61,7 @@ public:
using GeneratorFiles = QList<GeneratorFile>; using GeneratorFiles = QList<GeneratorFile>;
Q_PROPERTY(GeneratorFiles generateFileList READ generateFileList) Q_PROPERTY(GeneratorFiles generateFileList READ generateFileList)
explicit JsonWizard(QWidget *parent = nullptr); JsonWizard();
~JsonWizard() override; ~JsonWizard() override;
void addGenerator(JsonWizardGenerator *gen); void addGenerator(JsonWizardGenerator *gen);

View File

@@ -138,7 +138,6 @@ void ProjectExplorerTest::testJsonWizardsCheckBox()
{ {
QString errorMessage; QString errorMessage;
QWidget parent;
const QJsonArray widgets({ const QJsonArray widgets({
createWidget("CheckBox", "Default", QJsonObject()), createWidget("CheckBox", "Default", QJsonObject()),
createWidget("CheckBox", "Checked", QJsonObject({{"checked", true}})), createWidget("CheckBox", "Checked", QJsonObject({{"checked", true}})),
@@ -155,21 +154,21 @@ void ProjectExplorerTest::testJsonWizardsCheckBox()
const FactoryPtr factory(JsonWizardFactory::createWizardFactory(wizardObject.toVariantMap(), {}, &errorMessage)); const FactoryPtr factory(JsonWizardFactory::createWizardFactory(wizardObject.toVariantMap(), {}, &errorMessage));
QVERIFY2(factory, qPrintable(errorMessage)); QVERIFY2(factory, qPrintable(errorMessage));
Wizard *wizard = factory->runWizard({}, &parent, Id(), QVariantMap()); std::unique_ptr<Wizard> wizard{factory->runWizard({}, Id(), QVariantMap())};
QVERIFY(!findCheckBox(wizard, "Default")->isChecked()); QVERIFY(!findCheckBox(wizard.get(), "Default")->isChecked());
QCOMPARE(wizard->field("DefaultCheckBox"), QVariant(false)); QCOMPARE(wizard->field("DefaultCheckBox"), QVariant(false));
QVERIFY(findCheckBox(wizard, "Checked")->isChecked()); QVERIFY(findCheckBox(wizard.get(), "Checked")->isChecked());
QCOMPARE(wizard->field("CheckedCheckBox"), QVariant(true)); QCOMPARE(wizard->field("CheckedCheckBox"), QVariant(true));
QVERIFY(!findCheckBox(wizard, "UnChecked")->isChecked()); QVERIFY(!findCheckBox(wizard.get(), "UnChecked")->isChecked());
QCOMPARE(wizard->field("UnCheckedCheckBox"), QVariant(false)); QCOMPARE(wizard->field("UnCheckedCheckBox"), QVariant(false));
QVERIFY(!findCheckBox(wizard, "SpecialValueUnChecked")->isChecked()); QVERIFY(!findCheckBox(wizard.get(), "SpecialValueUnChecked")->isChecked());
QCOMPARE(qPrintable(wizard->field("SpecialValueUnCheckedCheckBox").toString()), "SpecialUnCheckedValue"); 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"); QCOMPARE(qPrintable(wizard->field("SpecialValueCheckedCheckBox").toString()), "SpecialCheckedValue");
} }
@@ -177,7 +176,6 @@ void ProjectExplorerTest::testJsonWizardsLineEdit()
{ {
QString errorMessage; QString errorMessage;
QWidget parent;
const QJsonArray widgets({ const QJsonArray widgets({
createWidget("LineEdit", "Default", QJsonObject()), createWidget("LineEdit", "Default", QJsonObject()),
createWidget("LineEdit", "WithText", QJsonObject({{"trText", "some text"}})) createWidget("LineEdit", "WithText", QJsonObject({{"trText", "some text"}}))
@@ -187,20 +185,20 @@ void ProjectExplorerTest::testJsonWizardsLineEdit()
const FactoryPtr factory(JsonWizardFactory::createWizardFactory(wizardObject.toVariantMap(), {}, &errorMessage)); const FactoryPtr factory(JsonWizardFactory::createWizardFactory(wizardObject.toVariantMap(), {}, &errorMessage));
QVERIFY2(factory, qPrintable(errorMessage)); QVERIFY2(factory, qPrintable(errorMessage));
Wizard *wizard = factory->runWizard({}, &parent, Id(), QVariantMap()); std::unique_ptr<Wizard> wizard{factory->runWizard({}, Id(), QVariantMap())};
QVERIFY(findLineEdit(wizard, "Default")); QVERIFY(wizard);
QVERIFY(findLineEdit(wizard, "Default")->text().isEmpty()); QVERIFY(findLineEdit(wizard.get(), "Default"));
QCOMPARE(qPrintable(findLineEdit(wizard, "WithText")->text()), "some text"); QVERIFY(findLineEdit(wizard.get(), "Default")->text().isEmpty());
QCOMPARE(qPrintable(findLineEdit(wizard.get(), "WithText")->text()), "some text");
QVERIFY(!wizard->page(0)->isComplete()); QVERIFY(!wizard->page(0)->isComplete());
findLineEdit(wizard, "Default")->setText("enable isComplete"); findLineEdit(wizard.get(), "Default")->setText("enable isComplete");
QVERIFY(wizard->page(0)->isComplete()); QVERIFY(wizard->page(0)->isComplete());
} }
void ProjectExplorerTest::testJsonWizardsComboBox() void ProjectExplorerTest::testJsonWizardsComboBox()
{ {
QString errorMessage; QString errorMessage;
QWidget parent;
const QJsonArray items({"abc", "cde", "fgh"}); const QJsonArray items({"abc", "cde", "fgh"});
QJsonObject disabledComboBoxObject = createWidget("ComboBox", "Disabled", QJsonObject({ {{"disabledIndex", 2}, {"items", items}} })); QJsonObject disabledComboBoxObject = createWidget("ComboBox", "Disabled", QJsonObject({ {{"disabledIndex", 2}, {"items", items}} }));
@@ -215,9 +213,9 @@ void ProjectExplorerTest::testJsonWizardsComboBox()
const QJsonObject wizardObject = createGeneralWizard(pages); const QJsonObject wizardObject = createGeneralWizard(pages);
const FactoryPtr factory(JsonWizardFactory::createWizardFactory(wizardObject.toVariantMap(), {}, &errorMessage)); const FactoryPtr factory(JsonWizardFactory::createWizardFactory(wizardObject.toVariantMap(), {}, &errorMessage));
QVERIFY2(factory, qPrintable(errorMessage)); QVERIFY2(factory, qPrintable(errorMessage));
Wizard *wizard = factory->runWizard({}, &parent, Id(), QVariantMap()); std::unique_ptr<Wizard> wizard{factory->runWizard({}, Id(), QVariantMap())};
QComboBox *defaultComboBox = findComboBox(wizard, "Default"); QComboBox *defaultComboBox = findComboBox(wizard.get(), "Default");
QVERIFY(defaultComboBox); QVERIFY(defaultComboBox);
QCOMPARE(defaultComboBox->count(), items.count()); QCOMPARE(defaultComboBox->count(), items.count());
QCOMPARE(qPrintable(defaultComboBox->currentText()), "abc"); QCOMPARE(qPrintable(defaultComboBox->currentText()), "abc");
@@ -225,11 +223,11 @@ void ProjectExplorerTest::testJsonWizardsComboBox()
defaultComboBox->setCurrentIndex(2); defaultComboBox->setCurrentIndex(2);
QCOMPARE(qPrintable(defaultComboBox->currentText()), "fgh"); QCOMPARE(qPrintable(defaultComboBox->currentText()), "fgh");
QComboBox *index2ComboBox = findComboBox(wizard, "Index2"); QComboBox *index2ComboBox = findComboBox(wizard.get(), "Index2");
QVERIFY(index2ComboBox); QVERIFY(index2ComboBox);
QCOMPARE(qPrintable(index2ComboBox->currentText()), "fgh"); QCOMPARE(qPrintable(index2ComboBox->currentText()), "fgh");
QComboBox *disabledComboBox = findComboBox(wizard, "Disabled"); QComboBox *disabledComboBox = findComboBox(wizard.get(), "Disabled");
QVERIFY(disabledComboBox); QVERIFY(disabledComboBox);
QCOMPARE(qPrintable(disabledComboBox->currentText()), "fgh"); QCOMPARE(qPrintable(disabledComboBox->currentText()), "fgh");
} }
@@ -242,7 +240,6 @@ static QString iconInsideResource(const QString &relativePathToIcon)
void ProjectExplorerTest::testJsonWizardsIconList() void ProjectExplorerTest::testJsonWizardsIconList()
{ {
QString errorMessage; QString errorMessage;
QWidget parent;
const QJsonArray items({ const QJsonArray items({
QJsonObject{ QJsonObject{
@@ -272,7 +269,7 @@ void ProjectExplorerTest::testJsonWizardsIconList()
const QJsonObject wizardObject = createGeneralWizard(pages); const QJsonObject wizardObject = createGeneralWizard(pages);
const FactoryPtr factory(JsonWizardFactory::createWizardFactory(wizardObject.toVariantMap(), {}, &errorMessage)); const FactoryPtr factory(JsonWizardFactory::createWizardFactory(wizardObject.toVariantMap(), {}, &errorMessage));
QVERIFY2(factory, qPrintable(errorMessage)); QVERIFY2(factory, qPrintable(errorMessage));
Wizard *wizard = factory->runWizard({}, &parent, Id(), QVariantMap()); std::unique_ptr<Wizard> wizard{factory->runWizard({}, Id(), QVariantMap())};
auto view = wizard->findChild<QListView *>("FancyIconList"); auto view = wizard->findChild<QListView *>("FancyIconList");
QCOMPARE(view->model()->rowCount(), 2); QCOMPARE(view->model()->rowCount(), 2);

View File

@@ -653,11 +653,10 @@ static QString qmlProjectName(const FilePath &folder)
return {}; return {};
} }
Wizard *JsonWizardFactory::runWizardImpl(const FilePath &path, QWidget *parent, Wizard *JsonWizardFactory::runWizardImpl(const FilePath &path, Id platform,
Id platform,
const QVariantMap &variables, bool showWizard) const QVariantMap &variables, bool showWizard)
{ {
auto wizard = new JsonWizard(parent); auto wizard = new JsonWizard;
wizard->setWindowIcon(icon()); wizard->setWindowIcon(icon());
wizard->setWindowTitle(displayName()); wizard->setWindowTitle(displayName());

View File

@@ -62,7 +62,7 @@ public:
static void setInstalledWizardsPath(const Utils::FilePath &path); static void setInstalledWizardsPath(const Utils::FilePath &path);
private: 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; const QVariantMap &variables, bool showWizard = true) override;
// Create all wizards. As other plugins might register factories for derived // Create all wizards. As other plugins might register factories for derived

View File

@@ -3621,7 +3621,7 @@ void ProjectExplorerPluginPrivate::addNewHeaderOrSource()
IWizardFactory::allWizardFactories(), IWizardFactory::allWizardFactories(),
[factoryId](const IWizardFactory *f) { return f->id() == factoryId; }); [factoryId](const IWizardFactory *f) { return f->id() == factoryId; });
QTC_ASSERT(factory, return); QTC_ASSERT(factory, return);
factory->runWizard(folderNode->directory(), ICore::dialogParent(), {}, map); factory->runWizard(folderNode->directory(), {}, map);
} }
void ProjectExplorerPluginPrivate::addNewSubproject() void ProjectExplorerPluginPrivate::addNewSubproject()

View File

@@ -110,8 +110,8 @@ class SimpleProjectWizardDialog : public BaseFileWizard
Q_OBJECT Q_OBJECT
public: public:
SimpleProjectWizardDialog(const BaseFileWizardFactory *factory, QWidget *parent) explicit SimpleProjectWizardDialog(const BaseFileWizardFactory *factory)
: BaseFileWizard(factory, QVariantMap(), parent) : BaseFileWizard(factory, QVariantMap())
{ {
setWindowTitle(Tr::tr("Import Existing Project")); setWindowTitle(Tr::tr("Import Existing Project"));
@@ -162,10 +162,9 @@ SimpleProjectWizard::SimpleProjectWizard()
setFlags(IWizardFactory::PlatformIndependent); setFlags(IWizardFactory::PlatformIndependent);
} }
BaseFileWizard *SimpleProjectWizard::create(QWidget *parent, BaseFileWizard *SimpleProjectWizard::create(const WizardDialogParameters &parameters) const
const WizardDialogParameters &parameters) const
{ {
auto wizard = new SimpleProjectWizardDialog(this, parent); auto wizard = new SimpleProjectWizardDialog(this);
wizard->setProjectDir(parameters.defaultPath()); wizard->setProjectDir(parameters.defaultPath());
for (QWizardPage *p : wizard->extensionPages()) for (QWizardPage *p : wizard->extensionPages())

View File

@@ -16,7 +16,7 @@ public:
SimpleProjectWizard(); SimpleProjectWizard();
private: private:
Core::BaseFileWizard *create(QWidget *parent, const Core::WizardDialogParameters &parameters) const override; Core::BaseFileWizard *create(const Core::WizardDialogParameters &parameters) const override;
Core::GeneratedFiles generateFiles(const QWizard *w, QString *errorMessage) const override; Core::GeneratedFiles generateFiles(const QWizard *w, QString *errorMessage) const override;
bool postGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l, bool postGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l,
QString *errorMessage) const override; QString *errorMessage) const override;

View File

@@ -29,10 +29,9 @@ CustomWidgetWizard::CustomWidgetWizard()
setRequiredFeatures({QtSupport::Constants::FEATURE_QWIDGETS}); setRequiredFeatures({QtSupport::Constants::FEATURE_QWIDGETS});
} }
Core::BaseFileWizard *CustomWidgetWizard::create(QWidget *parent, const Core::WizardDialogParameters &parameters) const Core::BaseFileWizard *CustomWidgetWizard::create(const Core::WizardDialogParameters &parameters) const
{ {
CustomWidgetWizardDialog *rc = new CustomWidgetWizardDialog(this, displayName(), auto rc = new CustomWidgetWizardDialog(this, displayName(), icon(), parameters);
icon(), parent, parameters);
rc->setProjectName(CustomWidgetWizardDialog::uniqueProjectName(parameters.defaultPath())); rc->setProjectName(CustomWidgetWizardDialog::uniqueProjectName(parameters.defaultPath()));
rc->setFileNamingParameters(FileNamingParameters(headerSuffix(), sourceSuffix(), QtWizard::lowerCaseFiles())); rc->setFileNamingParameters(FileNamingParameters(headerSuffix(), sourceSuffix(), QtWizard::lowerCaseFiles()));
return rc; return rc;

View File

@@ -16,8 +16,7 @@ public:
CustomWidgetWizard(); CustomWidgetWizard();
protected: protected:
Core::BaseFileWizard *create(QWidget *parent, Core::BaseFileWizard *create(const Core::WizardDialogParameters &parameters) const override;
const Core::WizardDialogParameters &parameters) const override;
Core::GeneratedFiles generateFiles(const QWizard *w, QString *errorMessage) const override; Core::GeneratedFiles generateFiles(const QWizard *w, QString *errorMessage) const override;
}; };

View File

@@ -19,9 +19,8 @@ enum { IntroPageId = 0};
CustomWidgetWizardDialog::CustomWidgetWizardDialog(const Core::BaseFileWizardFactory *factory, CustomWidgetWizardDialog::CustomWidgetWizardDialog(const Core::BaseFileWizardFactory *factory,
const QString &templateName, const QString &templateName,
const QIcon &icon, QWidget *parent, const QIcon &icon, const Core::WizardDialogParameters &parameters) :
const Core::WizardDialogParameters &parameters) : BaseQmakeProjectWizardDialog(factory, parameters),
BaseQmakeProjectWizardDialog(factory, parent, parameters),
m_widgetsPage(new CustomWidgetWidgetsWizardPage), m_widgetsPage(new CustomWidgetWidgetsWizardPage),
m_pluginPage(new CustomWidgetPluginWizardPage) m_pluginPage(new CustomWidgetPluginWizardPage)
{ {

View File

@@ -19,7 +19,6 @@ class CustomWidgetWizardDialog : public BaseQmakeProjectWizardDialog
public: public:
explicit CustomWidgetWizardDialog(const Core::BaseFileWizardFactory *factory, explicit CustomWidgetWizardDialog(const Core::BaseFileWizardFactory *factory,
const QString &templateName, const QIcon &icon, const QString &templateName, const QIcon &icon,
QWidget *parent,
const Core::WizardDialogParameters &parameters); const Core::WizardDialogParameters &parameters);
std::shared_ptr<PluginOptions> pluginOptions() const; std::shared_ptr<PluginOptions> pluginOptions() const;

View File

@@ -97,10 +97,9 @@ bool QtWizard::lowerCaseFiles()
// ------------ CustomQmakeProjectWizard // ------------ CustomQmakeProjectWizard
CustomQmakeProjectWizard::CustomQmakeProjectWizard() = default; CustomQmakeProjectWizard::CustomQmakeProjectWizard() = default;
Core::BaseFileWizard *CustomQmakeProjectWizard::create(QWidget *parent, Core::BaseFileWizard *CustomQmakeProjectWizard::create(const Core::WizardDialogParameters &parameters) const
const Core::WizardDialogParameters &parameters) const
{ {
auto *wizard = new BaseQmakeProjectWizardDialog(this, parent, parameters); auto *wizard = new BaseQmakeProjectWizardDialog(this, parameters);
if (!parameters.extraValues().contains(QLatin1String(ProjectExplorer::Constants::PROJECT_KIT_IDS))) if (!parameters.extraValues().contains(QLatin1String(ProjectExplorer::Constants::PROJECT_KIT_IDS)))
wizard->addTargetSetupPage(targetPageId); wizard->addTargetSetupPage(targetPageId);
@@ -118,9 +117,8 @@ bool CustomQmakeProjectWizard::postGenerateFiles(const QWizard *w, const Core::G
// ----------------- BaseQmakeProjectWizardDialog // ----------------- BaseQmakeProjectWizardDialog
BaseQmakeProjectWizardDialog::BaseQmakeProjectWizardDialog( BaseQmakeProjectWizardDialog::BaseQmakeProjectWizardDialog(
const Core::BaseFileWizardFactory *factory, const Core::BaseFileWizardFactory *factory,
QWidget *parent,
const Core::WizardDialogParameters &parameters) const Core::WizardDialogParameters &parameters)
: ProjectExplorer::BaseProjectWizardDialog(factory, parent, parameters) : ProjectExplorer::BaseProjectWizardDialog(factory, parameters)
{ {
m_profileIds = Utils::transform(parameters.extraValues() m_profileIds = Utils::transform(parameters.extraValues()
.value(ProjectExplorer::Constants::PROJECT_KIT_IDS) .value(ProjectExplorer::Constants::PROJECT_KIT_IDS)
@@ -135,9 +133,8 @@ BaseQmakeProjectWizardDialog::BaseQmakeProjectWizardDialog(
const Core::BaseFileWizardFactory *factory, const Core::BaseFileWizardFactory *factory,
Utils::ProjectIntroPage *introPage, Utils::ProjectIntroPage *introPage,
int introId, int introId,
QWidget *parent,
const Core::WizardDialogParameters &parameters) const Core::WizardDialogParameters &parameters)
: ProjectExplorer::BaseProjectWizardDialog(factory, introPage, introId, parent, parameters) : ProjectExplorer::BaseProjectWizardDialog(factory, introPage, introId, parameters)
{ {
m_profileIds = Utils::transform(parameters.extraValues() m_profileIds = Utils::transform(parameters.extraValues()
.value(ProjectExplorer::Constants::PROJECT_KIT_IDS) .value(ProjectExplorer::Constants::PROJECT_KIT_IDS)

View File

@@ -60,8 +60,7 @@ public:
CustomQmakeProjectWizard(); CustomQmakeProjectWizard();
private: private:
Core::BaseFileWizard *create(QWidget *parent, Core::BaseFileWizard *create(const Core::WizardDialogParameters &parameters) const override;
const Core::WizardDialogParameters &parameters) const override;
bool postGenerateFiles(const QWizard *, const Core::GeneratedFiles &l, bool postGenerateFiles(const QWizard *, const Core::GeneratedFiles &l,
QString *errorMessage) const override; QString *errorMessage) const override;
@@ -81,11 +80,10 @@ class BaseQmakeProjectWizardDialog : public ProjectExplorer::BaseProjectWizardDi
protected: protected:
explicit BaseQmakeProjectWizardDialog(const Core::BaseFileWizardFactory *factory, explicit BaseQmakeProjectWizardDialog(const Core::BaseFileWizardFactory *factory,
Utils::ProjectIntroPage *introPage, Utils::ProjectIntroPage *introPage,
int introId, QWidget *parent, int introId,
const Core::WizardDialogParameters &parameters); const Core::WizardDialogParameters &parameters);
public: public:
explicit BaseQmakeProjectWizardDialog(const Core::BaseFileWizardFactory *factory, explicit BaseQmakeProjectWizardDialog(const Core::BaseFileWizardFactory *factory,
QWidget *parent,
const Core::WizardDialogParameters &parameters); const Core::WizardDialogParameters &parameters);
~BaseQmakeProjectWizardDialog() override; ~BaseQmakeProjectWizardDialog() override;

View File

@@ -33,11 +33,9 @@ SubdirsProjectWizard::SubdirsProjectWizard()
setRequiredFeatures({QtSupport::Constants::FEATURE_QT_PREFIX}); setRequiredFeatures({QtSupport::Constants::FEATURE_QT_PREFIX});
} }
Core::BaseFileWizard *SubdirsProjectWizard::create(QWidget *parent, Core::BaseFileWizard *SubdirsProjectWizard::create(const Core::WizardDialogParameters &parameters) const
const Core::WizardDialogParameters &parameters) const
{ {
SubdirsProjectWizardDialog *dialog = new SubdirsProjectWizardDialog(this, displayName(), icon(), auto dialog = new SubdirsProjectWizardDialog(this, displayName(), icon(), parameters);
parent, parameters);
dialog->setProjectName(SubdirsProjectWizardDialog::uniqueProjectName(parameters.defaultPath())); dialog->setProjectName(SubdirsProjectWizardDialog::uniqueProjectName(parameters.defaultPath()));
const QString buttonText = dialog->wizardStyle() == QWizard::MacStyle const QString buttonText = dialog->wizardStyle() == QWizard::MacStyle

View File

@@ -16,8 +16,7 @@ public:
SubdirsProjectWizard(); SubdirsProjectWizard();
private: private:
Core::BaseFileWizard *create(QWidget *parent, Core::BaseFileWizard *create(const Core::WizardDialogParameters &parameters) const override;
const Core::WizardDialogParameters &parameters) const override;
Core::GeneratedFiles generateFiles(const QWizard *w, QString *errorMessage) const override; Core::GeneratedFiles generateFiles(const QWizard *w, QString *errorMessage) const override;
bool postGenerateFiles(const QWizard *, const Core::GeneratedFiles &l, bool postGenerateFiles(const QWizard *, const Core::GeneratedFiles &l,

View File

@@ -13,9 +13,8 @@ namespace Internal {
SubdirsProjectWizardDialog::SubdirsProjectWizardDialog(const Core::BaseFileWizardFactory *factory, SubdirsProjectWizardDialog::SubdirsProjectWizardDialog(const Core::BaseFileWizardFactory *factory,
const QString &templateName, const QString &templateName,
const QIcon &icon, QWidget *parent, const QIcon &icon, const Core::WizardDialogParameters &parameters) :
const Core::WizardDialogParameters &parameters) : BaseQmakeProjectWizardDialog(factory, parameters)
BaseQmakeProjectWizardDialog(factory, parent, parameters)
{ {
setWindowIcon(icon); setWindowIcon(icon);
setWindowTitle(templateName); setWindowTitle(templateName);

View File

@@ -14,9 +14,8 @@ class SubdirsProjectWizardDialog : public BaseQmakeProjectWizardDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit SubdirsProjectWizardDialog(const Core::BaseFileWizardFactory *factory, const QString &templateName, SubdirsProjectWizardDialog(const Core::BaseFileWizardFactory *factory, const QString &templateName,
const QIcon &icon, const QIcon &icon,
QWidget *parent,
const Core::WizardDialogParameters &parameters); const Core::WizardDialogParameters &parameters);
QtProjectParameters parameters() const; QtProjectParameters parameters() const;

View File

@@ -340,7 +340,7 @@ void QdsNewDialog::setWizardFactories(QList<Core::IWizardFactory *> factories_,
{ {
Utils::Id platform = Utils::Id::fromSetting("Desktop"); Utils::Id platform = Utils::Id::fromSetting("Desktop");
WizardFactories factories{factories_, m_dialog.get(), platform}; WizardFactories factories{factories_, platform};
std::vector<UserPresetData> recents = m_recentsStore.fetchAll(); std::vector<UserPresetData> recents = m_recentsStore.fetchAll();
std::vector<UserPresetData> userPresets = m_userPresetsStore.fetchAll(); std::vector<UserPresetData> userPresets = m_userPresetsStore.fetchAll();

View File

@@ -17,10 +17,8 @@ using namespace StudioWelcome;
WizardFactories::GetIconUnicodeFunc WizardFactories::m_getIconUnicode = &QmlDesigner::Theme::getIconUnicode; WizardFactories::GetIconUnicodeFunc WizardFactories::m_getIconUnicode = &QmlDesigner::Theme::getIconUnicode;
WizardFactories::WizardFactories(const QList<Core::IWizardFactory *> &factories, WizardFactories::WizardFactories(const QList<Core::IWizardFactory *> &factories,
QWidget *wizardParent,
const Utils::Id &platform) const Utils::Id &platform)
: m_wizardParent{wizardParent} : m_platform{platform}
, m_platform{platform}
{ {
m_factories = Utils::filtered(Utils::transform(factories, [](Core::IWizardFactory *f) { m_factories = Utils::filtered(Utils::transform(factories, [](Core::IWizardFactory *f) {
return qobject_cast<JsonWizardFactory *>(f); return qobject_cast<JsonWizardFactory *>(f);
@@ -56,8 +54,7 @@ void WizardFactories::filter()
m_factories = acceptedFactories; m_factories = acceptedFactories;
} }
std::shared_ptr<PresetItem> WizardFactories::makePresetItem(JsonWizardFactory *f, QWidget *parent, std::shared_ptr<PresetItem> WizardFactories::makePresetItem(JsonWizardFactory *f, const Utils::Id &platform)
const Utils::Id &platform)
{ {
using namespace std::placeholders; using namespace std::placeholders;
@@ -77,7 +74,7 @@ std::shared_ptr<PresetItem> WizardFactories::makePresetItem(JsonWizardFactory *f
result->qmlPath = f->detailsPageQmlPath(); result->qmlPath = f->detailsPageQmlPath();
result->fontIconCode = m_getIconUnicode(f->fontIconName()); result->fontIconCode = m_getIconUnicode(f->fontIconName());
result->create result->create
= std::bind(&JsonWizardFactory::runWizard, f, _1, parent, platform, QVariantMap(), false); = std::bind(&JsonWizardFactory::runWizard, f, _1, platform, QVariantMap(), false);
return result; return result;
} }
@@ -93,11 +90,11 @@ std::map<QString, WizardCategory> WizardFactories::makePresetItemsGroupedByCateg
/*.name =*/ f->displayCategory(), /*.name =*/ f->displayCategory(),
/*.items = */ /*.items = */
{ {
makePresetItem(f, m_wizardParent, m_platform), makePresetItem(f, m_platform),
}, },
}; };
} else { } else {
auto presetItem = makePresetItem(f, m_wizardParent, m_platform); auto presetItem = makePresetItem(f, m_platform);
categories[f->category()].items.push_back(presetItem); categories[f->category()].items.push_back(presetItem);
} }
} }

View File

@@ -25,8 +25,7 @@ public:
using GetIconUnicodeFunc = QString (*)(const QString &); using GetIconUnicodeFunc = QString (*)(const QString &);
public: public:
WizardFactories(const QList<Core::IWizardFactory *> &factories, QWidget *wizardParent, WizardFactories(const QList<Core::IWizardFactory *> &factories, const Utils::Id &platform);
const Utils::Id &platform);
const Core::IWizardFactory *front() const; const Core::IWizardFactory *front() const;
const std::map<QString, WizardCategory> &presetsGroupedByCategory() const const std::map<QString, WizardCategory> &presetsGroupedByCategory() const
@@ -42,11 +41,10 @@ private:
void sortByCategoryAndId(); void sortByCategoryAndId();
void filter(); void filter();
std::shared_ptr<PresetItem> makePresetItem(JsonWizardFactory *f, QWidget *parent, const Utils::Id &platform); std::shared_ptr<PresetItem> makePresetItem(JsonWizardFactory *f, const Utils::Id &platform);
std::map<QString, WizardCategory> makePresetItemsGroupedByCategory(); std::map<QString, WizardCategory> makePresetItemsGroupedByCategory();
private: private:
QWidget *m_wizardParent;
Utils::Id m_platform; // filter wizards to only those supported by this platform. Utils::Id m_platform; // filter wizards to only those supported by this platform.
QList<JsonWizardFactory *> m_factories; QList<JsonWizardFactory *> m_factories;