diff --git a/dist/changes-3.1.0 b/dist/changes-3.1.0 index 6ededf8c445..0346ffb142b 100644 --- a/dist/changes-3.1.0 +++ b/dist/changes-3.1.0 @@ -96,6 +96,7 @@ Platform Specific Linux Qt Support + * Custom wizards now use class "qmakeproject" instead of "qt4project" QNX * Added support for Python based pretty printers when debugging on devices diff --git a/doc/src/projects/creator-projects-custom-wizards.qdoc b/doc/src/projects/creator-projects-custom-wizards.qdoc index d4fc42504cb..cc3fd89e742 100644 --- a/doc/src/projects/creator-projects-custom-wizards.qdoc +++ b/doc/src/projects/creator-projects-custom-wizards.qdoc @@ -113,7 +113,7 @@ \code \endcode @@ -127,7 +127,7 @@ \c class. \li \c class specifies the type of the project. This attribute is - optional. Use the value \c qt4project to add Qt 4 specific pages. + optional. Use the value \c qmakeproject to add Qt specific pages. \li \c firstpage specifies the place of the new page in the standard project wizard. The value 10 ensures that the custom page diff --git a/share/qtcreator/templates/wizards/bb-cascades-app/wizard.xml b/share/qtcreator/templates/wizards/bb-cascades-app/wizard.xml index a709153132e..36d1eaaba76 100644 --- a/share/qtcreator/templates/wizards/bb-cascades-app/wizard.xml +++ b/share/qtcreator/templates/wizards/bb-cascades-app/wizard.xml @@ -31,7 +31,7 @@ **************************************************************************/ --> icon.png diff --git a/share/qtcreator/templates/wizards/codesnippet/wizard.xml b/share/qtcreator/templates/wizards/codesnippet/wizard.xml index 6a67b722f9a..8d06f378148 100644 --- a/share/qtcreator/templates/wizards/codesnippet/wizard.xml +++ b/share/qtcreator/templates/wizards/codesnippet/wizard.xml @@ -35,7 +35,7 @@ The "class" and "firstpage" attributes specify that it is a Qt 4 wizard and leave room for the Qt 4 target page. --> Creates a qmake-based test project for which a code snippet can be entered. Code Snippet; diff --git a/share/qtcreator/templates/wizards/helloworld/wizard_sample.xml b/share/qtcreator/templates/wizards/helloworld/wizard_sample.xml index 07a183da2d2..bbac13bfdd3 100644 --- a/share/qtcreator/templates/wizards/helloworld/wizard_sample.xml +++ b/share/qtcreator/templates/wizards/helloworld/wizard_sample.xml @@ -35,7 +35,7 @@ The "class" and "firstpage" attributes specify that it is a Qt 4 wizard and leave room for the Qt 4 target page. --> console.png Creates a hello-world-project with custom message. diff --git a/share/qtcreator/templates/wizards/plaincapp/qmake/wizard.xml b/share/qtcreator/templates/wizards/plaincapp/qmake/wizard.xml index da1c2d3dc77..0f470640c6b 100644 --- a/share/qtcreator/templates/wizards/plaincapp/qmake/wizard.xml +++ b/share/qtcreator/templates/wizards/plaincapp/qmake/wizard.xml @@ -35,7 +35,7 @@ The "class" and "firstpage" attributes specify that it is a Qt 4 wizard and leave room for the Qt 4 target page. --> ../common/console.png diff --git a/share/qtcreator/templates/wizards/plaincppapp/qmake/wizard.xml b/share/qtcreator/templates/wizards/plaincppapp/qmake/wizard.xml index 9399f89f03d..125cfaf1223 100644 --- a/share/qtcreator/templates/wizards/plaincppapp/qmake/wizard.xml +++ b/share/qtcreator/templates/wizards/plaincppapp/qmake/wizard.xml @@ -35,7 +35,7 @@ The "class" and "firstpage" attributes specify that it is a Qt 4 wizard and leave room for the Qt 4 target page. --> ../common/console.png diff --git a/share/qtcreator/templates/wizards/qtcreatorplugin/wizard.xml b/share/qtcreator/templates/wizards/qtcreatorplugin/wizard.xml index 5429154261b..c292e93bd6c 100644 --- a/share/qtcreator/templates/wizards/qtcreatorplugin/wizard.xml +++ b/share/qtcreator/templates/wizards/qtcreatorplugin/wizard.xml @@ -35,7 +35,7 @@ The "class" and "firstpage" attributes specify that it is a Qt 4 wizard and leave room for the Qt 4 target page. --> qtcreator_logo_24.png diff --git a/share/qtcreator/templates/wizards/qtquick1-extension/wizard.xml b/share/qtcreator/templates/wizards/qtquick1-extension/wizard.xml index ceabc683766..2a3d0a44059 100644 --- a/share/qtcreator/templates/wizards/qtquick1-extension/wizard.xml +++ b/share/qtcreator/templates/wizards/qtquick1-extension/wizard.xml @@ -35,7 +35,7 @@ The "class" and "firstpage" attributes specify that it is a Qt 4 wizard and leave room for the Qt 4 target page. --> lib.png diff --git a/share/qtcreator/templates/wizards/qtquick2-extension/wizard.xml b/share/qtcreator/templates/wizards/qtquick2-extension/wizard.xml index 6ee6464b815..d99dc5188e9 100644 --- a/share/qtcreator/templates/wizards/qtquick2-extension/wizard.xml +++ b/share/qtcreator/templates/wizards/qtquick2-extension/wizard.xml @@ -35,7 +35,7 @@ The "class" and "firstpage" attributes specify that it is a Qt 4 wizard and leave room for the Qt 4 target page. --> lib.png diff --git a/src/plugins/projectexplorer/customwizard/customwizard.cpp b/src/plugins/projectexplorer/customwizard/customwizard.cpp index eaccbc186fb..472cc57f22a 100644 --- a/src/plugins/projectexplorer/customwizard/customwizard.cpp +++ b/src/plugins/projectexplorer/customwizard/customwizard.cpp @@ -36,6 +36,8 @@ #include #include + +#include #include #include @@ -330,39 +332,23 @@ CustomWizard::CustomWizardContextPtr CustomWizard::context() const return d->m_context; } -// Static factory map -typedef QMap > CustomWizardFactoryMap; -Q_GLOBAL_STATIC(CustomWizardFactoryMap, customWizardFactoryMap) - -void CustomWizard::registerFactory(const QString &name, const ICustomWizardFactoryPtr &f) +CustomWizard *CustomWizard::createWizard(const CustomProjectWizard::CustomWizardParametersPtr &p, + const Core::IWizard::Data &b) { - customWizardFactoryMap()->insert(name, f); -} - -CustomWizard *CustomWizard::createWizard(const CustomProjectWizard::CustomWizardParametersPtr &p, const Core::IWizard::Data &b) -{ - CustomWizard * rc = 0; - if (p->klass.isEmpty()) { - // Use defaults for empty class names - switch (b.kind) { - case Core::IWizard::ProjectWizard: - rc = new CustomProjectWizard; - break; - case Core::IWizard::FileWizard: - case Core::IWizard::ClassWizard: - rc = new CustomWizard; - break; - } - } else { - // Look up class name in map - const CustomWizardFactoryMap::const_iterator it = customWizardFactoryMap()->constFind(p->klass); - if (it != customWizardFactoryMap()->constEnd()) - rc = it.value()->create(); + CustomWizard *rc = 0; + QList factories = ExtensionSystem::PluginManager::getObjects(); + foreach (ICustomWizardFactory *tmp, factories) { + if ((p->klass.isEmpty() && b.kind == tmp->kind()) + || (!p->klass.isEmpty() && p->klass == tmp->klass())) { + rc = tmp->create(); + break; + } } if (!rc) { qWarning("Unable to create custom wizard for class %s.", qPrintable(p->klass)); return 0; } + rc->setData(b); rc->setParameters(p); return rc; diff --git a/src/plugins/projectexplorer/customwizard/customwizard.h b/src/plugins/projectexplorer/customwizard/customwizard.h index 1541fc0ff91..6153ae4ad72 100644 --- a/src/plugins/projectexplorer/customwizard/customwizard.h +++ b/src/plugins/projectexplorer/customwizard/customwizard.h @@ -55,17 +55,31 @@ namespace Internal { } // Documentation inside. -class ICustomWizardFactory +class ICustomWizardFactory : public QObject { + Q_OBJECT + public: - virtual CustomWizard *create(QObject *parent = 0) const = 0; - virtual ~ICustomWizardFactory() {} + ICustomWizardFactory(const QString &klass, Core::IWizard::WizardKind kind) : + m_klass(klass), m_kind(kind) + { } + + virtual CustomWizard *create() const = 0; + QString klass() const { return m_klass; } + int kind() const { return m_kind; } + +private: + QString m_klass; + Core::IWizard::WizardKind m_kind; }; // Convenience template to create wizard factory classes. template class CustomWizardFactory : public ICustomWizardFactory { - CustomWizard *create(QObject * = 0) const { return new Wizard; } +public: + CustomWizardFactory(const QString &klass, Core::IWizard::WizardKind kind) : ICustomWizardFactory(klass, kind) { } + CustomWizardFactory(Core::IWizard::WizardKind kind) : ICustomWizardFactory(QString(), kind) { } + CustomWizard *create() const { return new Wizard; } }; // Documentation inside. @@ -87,11 +101,6 @@ public: Core::GeneratedFiles generateFiles(const QWizard *w, QString *errorMessage) const; - // Register a factory for a derived custom widget - static void registerFactory(const QString &name, const ICustomWizardFactoryPtr &f); - template static void registerFactory(const QString &name) - { registerFactory(name, ICustomWizardFactoryPtr(new CustomWizardFactory)); } - // Create all wizards. As other plugins might register factories for derived // classes, call it in extensionsInitialized(). static QList createWizards(); diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 6aa93292066..5132776aeb8 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -30,6 +30,7 @@ #include "projectexplorer.h" #include "buildsteplist.h" +#include "customwizard/customwizard.h" #include "deployablefile.h" #include "deployconfiguration.h" #include "gcctoolchainfactories.h" @@ -394,6 +395,10 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er connect(sessionManager, SIGNAL(sessionLoaded(QString)), this, SLOT(updateWelcomePage())); + addAutoReleasedObject(new CustomWizardFactory(Core::IWizard::ProjectWizard)); + addAutoReleasedObject(new CustomWizardFactory(Core::IWizard::FileWizard)); + addAutoReleasedObject(new CustomWizardFactory(Core::IWizard::ClassWizard)); + d->m_proWindow = new ProjectWindow; addAutoReleasedObject(d->m_proWindow); diff --git a/src/plugins/qmakeprojectmanager/qmakeprojectmanagerplugin.cpp b/src/plugins/qmakeprojectmanager/qmakeprojectmanagerplugin.cpp index fd8886f6539..ba4c01e7979 100644 --- a/src/plugins/qmakeprojectmanager/qmakeprojectmanagerplugin.cpp +++ b/src/plugins/qmakeprojectmanager/qmakeprojectmanagerplugin.cpp @@ -127,7 +127,8 @@ bool QmakeProjectManagerPlugin::initialize(const QStringList &arguments, QString addAutoReleasedObject(new TestWizard); addAutoReleasedObject(new CustomWidgetWizard); - CustomQmakeProjectWizard::registerSelf(); + addAutoReleasedObject(new CustomWizardFactory + (QLatin1String("qmakeproject"), Core::IWizard::ProjectWizard)); addAutoReleasedObject(new QMakeStepFactory); addAutoReleasedObject(new MakeStepFactory); diff --git a/src/plugins/qmakeprojectmanager/wizards/qtwizard.cpp b/src/plugins/qmakeprojectmanager/wizards/qtwizard.cpp index 9242263ee81..44fca1cb6c3 100644 --- a/src/plugins/qmakeprojectmanager/wizards/qtwizard.cpp +++ b/src/plugins/qmakeprojectmanager/wizards/qtwizard.cpp @@ -151,11 +151,6 @@ bool CustomQmakeProjectWizard::postGenerateFiles(const QWizard *w, const Core::G return QtWizard::qt4ProjectPostGenerateFiles(w, l, errorMessage); } -void CustomQmakeProjectWizard::registerSelf() -{ - ProjectExplorer::CustomWizard::registerFactory(QLatin1String("qt4project")); -} - // ----------------- BaseQmakeProjectWizardDialog BaseQmakeProjectWizardDialog::BaseQmakeProjectWizardDialog(bool showModulesPage, QWidget *parent, const Core::WizardDialogParameters ¶meters) : diff --git a/src/plugins/qmakeprojectmanager/wizards/qtwizard.h b/src/plugins/qmakeprojectmanager/wizards/qtwizard.h index 53548335c2b..5d08d38da67 100644 --- a/src/plugins/qmakeprojectmanager/wizards/qtwizard.h +++ b/src/plugins/qmakeprojectmanager/wizards/qtwizard.h @@ -91,8 +91,6 @@ class CustomQmakeProjectWizard : public ProjectExplorer::CustomProjectWizard public: CustomQmakeProjectWizard(); - static void registerSelf(); - private: QWizard *createWizardDialog(QWidget *parent, const Core::WizardDialogParameters &wizardDialogParameters) const;