Commit 7e41b40c authored by Tobias Hunger's avatar Tobias Hunger

Wizards: Treat running wizards in the same way as a running NewDialog

That is block the New file or project action.

Change-Id: Ic7bb6013fce02fdcdd5c86b70ba5428218597a40
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent 3ceec865
......@@ -180,7 +180,7 @@ void WizardEventLoop::rejected()
\sa Core::Internal::WizardEventLoop
*/
void BaseFileWizardFactory::runWizard(const QString &path, QWidget *parent, const QString &platform, const QVariantMap &extraValues)
void BaseFileWizardFactory::runWizardImpl(const QString &path, QWidget *parent, const QString &platform, const QVariantMap &extraValues)
{
QTC_ASSERT(!path.isEmpty(), return);
......
......@@ -106,9 +106,6 @@ class CORE_EXPORT BaseFileWizardFactory : public IWizardFactory
Q_OBJECT
public:
// IWizard
void runWizard(const QString &path, QWidget *parent, const QString &platform, const QVariantMap &extraValues);
static QString buildFileName(const QString &path, const QString &baseName, const QString &extension);
protected:
......@@ -129,6 +126,10 @@ protected:
OverwriteResult promptOverwrite(GeneratedFiles *files,
QString *errorMessage) const;
static bool postGenerateOpenEditors(const GeneratedFiles &l, QString *errorMessage = 0);
private:
// IWizard
void runWizardImpl(const QString &path, QWidget *parent, const QString &platform, const QVariantMap &extraValues);
};
} // namespace Core
......
......@@ -286,6 +286,7 @@
*/
#include "dialogs/newdialog.h"
#include "iwizardfactory.h"
#include "mainwindow.h"
#include "documentmanager.h"
......@@ -312,7 +313,7 @@ ICore *ICore::instance()
bool ICore::isNewItemDialogRunning()
{
return NewDialog::isRunning();
return NewDialog::isRunning() || IWizardFactory::isWizardRunning();
}
ICore::ICore(MainWindow *mainwindow)
......
......@@ -59,6 +59,8 @@ class CORE_EXPORT ICore : public QObject
Q_OBJECT
friend class Internal::MainWindow;
friend class IWizardFactory;
explicit ICore(Internal::MainWindow *mw);
~ICore();
......
......@@ -155,6 +155,7 @@ static QList<IFeatureProvider *> s_providerList;
QList<IWizardFactory *> s_allFactories;
QList<IWizardFactory::FactoryCreator> s_factoryCreators;
bool s_areFactoriesLoaded = false;
bool s_isWizardRunning = false;
}
/* A utility to find all wizards supporting a view mode and matching a predicate */
......@@ -242,6 +243,17 @@ QString IWizardFactory::runPath(const QString &defaultPath)
return path;
}
void IWizardFactory::runWizard(const QString &path, QWidget *parent, const QString &platform, const QVariantMap &variables)
{
s_isWizardRunning = true;
ICore::validateNewDialogIsRunning();
runWizardImpl(path, parent, platform, variables);
s_isWizardRunning = false;
ICore::validateNewDialogIsRunning();
}
bool IWizardFactory::isAvailable(const QString &platformName) const
{
if (platformName.isEmpty())
......@@ -293,6 +305,11 @@ void IWizardFactory::registerFeatureProvider(IFeatureProvider *provider)
s_providerList.append(provider);
}
bool IWizardFactory::isWizardRunning()
{
return s_isWizardRunning;
}
void IWizardFactory::destroyFeatureProvider()
{
qDeleteAll(s_providerList);
......
......@@ -88,7 +88,9 @@ public:
QString runPath(const QString &defaultPath);
virtual void runWizard(const QString &path, QWidget *parent, const QString &platform, const QVariantMap &variables) = 0;
// Does bookkeeping and the calls runWizardImpl. Please implement that.
virtual void runWizard(const QString &path, QWidget *parent, const QString &platform,
const QVariantMap &variables);
virtual bool isAvailable(const QString &platformName) const;
QStringList supportedPlatforms() const;
......@@ -105,10 +107,15 @@ public:
static void registerFeatureProvider(IFeatureProvider *provider);
static bool isWizardRunning();
protected:
FeatureSet pluginFeatures() const;
FeatureSet availableFeatures(const QString &platformName) const;
virtual void runWizardImpl(const QString &path, QWidget *parent, const QString &platform,
const QVariantMap &variables) = 0;
private:
static void initialize();
static void destroyFeatureProvider();
......
......@@ -356,7 +356,7 @@ void JsonWizardFactory::registerGeneratorFactory(JsonWizardGeneratorFactory *fac
JsonWizardFactory::~JsonWizardFactory()
{ }
void JsonWizardFactory::runWizard(const QString &path, QWidget *parent, const QString &platform,
void JsonWizardFactory::runWizardImpl(const QString &path, QWidget *parent, const QString &platform,
const QVariantMap &variables)
{
JsonWizard wizard(parent);
......
......@@ -86,15 +86,16 @@ public:
~JsonWizardFactory();
void runWizard(const QString &path, QWidget *parent, const QString &platform,
const QVariantMap &variables);
static QList<QVariant> objectOrList(const QVariant &data, QString *errorMessage);
static QString localizedString(const QVariant &value);
bool isAvailable(const QString &platformName) const override;
private:
void runWizardImpl(const QString &path, QWidget *parent, const QString &platform,
const QVariantMap &variables);
// Create all wizards. As other plugins might register factories for derived
// classes. Called when the new file dialog is shown for the first time.
static QList<IWizardFactory *> createWizardFactories();
......
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