Commit e7cfdb63 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

SubdirsWizard: Make opening of NewItemDialog work again



The subdirs wizard tries to re-run the NewItemDialog to add
subprojects to the qmake SUBDIRS template it created.

Make this work again.

Task-number: QTCREATORBUG-15057
Change-Id: If5c61970afb3bb4507d4a7de7dde1a6e7078c29a
Reviewed-by: default avatarDaniel Teske <daniel.teske@theqtcompany.com>
parent a7928b4b
......@@ -158,6 +158,49 @@ QList<IWizardFactory::FactoryCreator> s_factoryCreators;
QAction *s_inspectWizardAction = 0;
bool s_areFactoriesLoaded = false;
bool s_isWizardRunning = false;
// NewItemDialog reopening data:
class NewItemDialogData
{
public:
void setData(const QString t, const QList<IWizardFactory *> f,
const QString &dl, const QVariantMap &ev)
{
QTC_ASSERT(!hasData(), return);
QTC_ASSERT(!t.isEmpty(), return);
QTC_ASSERT(!f.isEmpty(), return);
title = t;
factories = f;
defaultLocation = dl;
extraVariables = ev;
}
bool hasData() const { return !factories.isEmpty(); }
void clear() {
title.clear();
factories.clear();
defaultLocation.clear();
extraVariables.clear();
}
void reopen() {
if (!hasData())
return;
ICore::showNewItemDialog(title, factories, defaultLocation, extraVariables);
clear();
}
private:
QString title;
QList<IWizardFactory *> factories;
QString defaultLocation;
QVariantMap extraVariables;
};
NewItemDialogData s_reopenData;
}
/* A utility to find all wizards supporting a view mode and matching a predicate */
......@@ -249,6 +292,8 @@ QString IWizardFactory::runPath(const QString &defaultPath)
Utils::Wizard *IWizardFactory::runWizard(const QString &path, QWidget *parent, const QString &platform, const QVariantMap &variables)
{
QTC_ASSERT(!s_isWizardRunning, return 0);
s_isWizardRunning = true;
ICore::validateNewItemDialogIsRunning();
......@@ -259,11 +304,16 @@ Utils::Wizard *IWizardFactory::runWizard(const QString &path, QWidget *parent, c
connect(m_action, &QAction::triggered, wizard, [wizard]() { ICore::raiseWindow(wizard); });
connect(s_inspectWizardAction, &QAction::triggered,
wizard, [wizard]() { wizard->showVariables(); });
connect(wizard, &Utils::Wizard::finished, [wizard]() {
connect(wizard, &Utils::Wizard::finished, this, [wizard](int result) {
if (result != QDialog::Accepted)
s_reopenData.clear();
wizard->deleteLater();
});
connect(wizard, &QObject::destroyed, this, [wizard]() {
s_isWizardRunning = false;
s_inspectWizardAction->setEnabled(false);
ICore::validateNewItemDialogIsRunning();
wizard->deleteLater();
s_reopenData.reopen();
});
s_inspectWizardAction->setEnabled(true);
wizard->show();
......@@ -271,6 +321,7 @@ Utils::Wizard *IWizardFactory::runWizard(const QString &path, QWidget *parent, c
} else {
s_isWizardRunning = false;
ICore::validateNewItemDialogIsRunning();
s_reopenData.reopen();
}
return wizard;
}
......@@ -331,6 +382,14 @@ bool IWizardFactory::isWizardRunning()
return s_isWizardRunning;
}
void IWizardFactory::requestNewItemDialog(const QString &title,
const QList<IWizardFactory *> &factories,
const QString &defaultLocation,
const QVariantMap &extraVariables)
{
s_reopenData.setData(title, factories, defaultLocation, extraVariables);
}
void IWizardFactory::destroyFeatureProvider()
{
qDeleteAll(s_providerList);
......
......@@ -109,6 +109,11 @@ public:
static bool isWizardRunning();
static void requestNewItemDialog(const QString &title,
const QList<IWizardFactory *> &factories,
const QString &defaultLocation,
const QVariantMap &extraVariables);
protected:
FeatureSet pluginFeatures() const;
FeatureSet availableFeatures(const QString &platformName) const;
......
......@@ -92,10 +92,9 @@ bool SubdirsProjectWizard::postGenerateFiles(const QWizard *w, const Core::Gener
QVariantMap map;
map.insert(QLatin1String(ProjectExplorer::Constants::PREFERRED_PROJECT_NODE), profileName);
map.insert(QLatin1String(ProjectExplorer::Constants::PROJECT_KIT_IDS), QVariant::fromValue(wizard->selectedKits()));
Core::ICore::showNewItemDialog(tr("New Subproject", "Title of dialog"),
Core::IWizardFactory::wizardFactoriesOfKind(Core::IWizardFactory::ProjectWizard),
wizard->parameters().projectPath(),
map);
IWizardFactory::requestNewItemDialog(tr("New Subproject", "Title of dialog"),
Core::IWizardFactory::wizardFactoriesOfKind(Core::IWizardFactory::ProjectWizard),
wizard->parameters().projectPath(), map);
} else {
return false;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment