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