From e5f60a956f8ff8498fe99a29321a47d60e0f3cb2 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@nokia.com> Date: Fri, 27 Aug 2010 09:50:34 +0200 Subject: [PATCH] Wizards: Delay parsing of custom wizards. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ... by introducing signal ICore::showNewItemsDialog(). Reviewed-by: Kai Köhne <kai.koehne@nokia.com> --- src/plugins/coreplugin/icore.h | 1 + src/plugins/coreplugin/mainwindow.cpp | 1 + .../customwizard/customwizard.cpp | 8 ++++---- .../projectexplorer/customwizard/customwizard.h | 13 ++++++++----- src/plugins/projectexplorer/projectexplorer.cpp | 16 ++++++++++++---- src/plugins/projectexplorer/projectexplorer.h | 1 + 6 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/plugins/coreplugin/icore.h b/src/plugins/coreplugin/icore.h index d859e2828f3..d1d4ce1668a 100644 --- a/src/plugins/coreplugin/icore.h +++ b/src/plugins/coreplugin/icore.h @@ -123,6 +123,7 @@ public: signals: void coreAboutToOpen(); void coreOpened(); + void newItemsDialogRequested(); void saveSettingsRequested(); void optionsDialogRequested(); void coreAboutToClose(); diff --git a/src/plugins/coreplugin/mainwindow.cpp b/src/plugins/coreplugin/mainwindow.cpp index c7338cdb1b5..9463c552d12 100644 --- a/src/plugins/coreplugin/mainwindow.cpp +++ b/src/plugins/coreplugin/mainwindow.cpp @@ -885,6 +885,7 @@ QStringList MainWindow::showNewItemDialog(const QString &title, const QList<IWizard *> &wizards, const QString &defaultLocation) { + emit m_coreImpl->newItemsDialogRequested(); // Scan for wizards matching the filter and pick one. Don't show // dialog if there is only one. IWizard *wizard = 0; diff --git a/src/plugins/projectexplorer/customwizard/customwizard.cpp b/src/plugins/projectexplorer/customwizard/customwizard.cpp index 98f2eff9270..03d2aa5f74b 100644 --- a/src/plugins/projectexplorer/customwizard/customwizard.cpp +++ b/src/plugins/projectexplorer/customwizard/customwizard.cpp @@ -327,13 +327,13 @@ QList<CustomWizard*> CustomWizard::createWizards() if (CustomWizardPrivate::verbose) verboseLog = QString::fromLatin1("### CustomWizard: Checking '%1'\n").arg(userTemplateDirName); - QList<QFileInfo> dirs = templateDir.entryInfoList(QDir::Dirs|QDir::Readable|QDir::NoDotAndDotDot, - QDir::Name|QDir::IgnoreCase); + const QDir::Filters filters = QDir::Dirs|QDir::Readable|QDir::NoDotAndDotDot; + const QDir::SortFlags sortflags = QDir::Name|QDir::IgnoreCase; + QList<QFileInfo> dirs = templateDir.entryInfoList(filters, sortflags); if (userTemplateDir.exists()) { if (CustomWizardPrivate::verbose) verboseLog = QString::fromLatin1("### CustomWizard: userTemplateDir '%1' found, adding\n").arg(userTemplateDirName); - dirs += userTemplateDir.entryInfoList(QDir::Dirs|QDir::Readable|QDir::NoDotAndDotDot, - QDir::Name|QDir::IgnoreCase); + dirs += userTemplateDir.entryInfoList(filters, sortflags); } const QString configFile = QLatin1String(configFileC); diff --git a/src/plugins/projectexplorer/customwizard/customwizard.h b/src/plugins/projectexplorer/customwizard/customwizard.h index 2df8bda89e0..5eb6d37e4be 100644 --- a/src/plugins/projectexplorer/customwizard/customwizard.h +++ b/src/plugins/projectexplorer/customwizard/customwizard.h @@ -56,8 +56,11 @@ namespace Internal { struct CustomWizardContext; } -// Factory for creating wizard. Can be registered under a name -// in CustomWizard. +// Factory for creating custom wizards derived from the base classes +// The factory can be registered under a name in CustomWizard. The name can +// be specified in the <wizard class=''...> attribute in the wizard.xml file +// and thus allows for specifying a C++ derived wizard class (see Qt4ProjectManager). + class ICustomWizardFactory { public: virtual CustomWizard *create(const Core::BaseFileWizardParameters& baseFileParameters, @@ -65,7 +68,7 @@ public: virtual ~ICustomWizardFactory() {} }; -// Convenience template to create wizard classes. +// Convenience template to create wizard factory classes. template <class Wizard> class CustomWizardFactory : public ICustomWizardFactory { virtual CustomWizard *create(const Core::BaseFileWizardParameters& baseFileParameters, QObject *parent = 0) const @@ -134,8 +137,8 @@ private: // A custom project wizard presenting CustomProjectWizardDialog // (Project intro page and fields page) for wizards of type "project". -// Overwrites postGenerateFiles() to open the project file which is the -// last one by convention. Also inserts '%ProjectName%' into the base +// Overwrites postGenerateFiles() to open the project files according to the +// file attributes. Also inserts '%ProjectName%' into the base // replacement map once the intro page is left to have it available // for QLineEdit-type fields' default text. diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index b69649ab313..2bc84d6cbbf 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -249,6 +249,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er Core::ICore *core = Core::ICore::instance(); Core::ActionManager *am = core->actionManager(); + connect(core, SIGNAL(newItemsDialogRequested()), this, SLOT(loadCustomWizards())); d->m_welcomePage = new ProjectWelcomePage; connect(d->m_welcomePage, SIGNAL(manageSessions()), this, SLOT(showSessionManager())); @@ -944,12 +945,19 @@ void ProjectExplorerPlugin::extensionsInitialized() d->m_profileMimeTypes += pf->mimeTypes(); addAutoReleasedObject(pf); } + d->m_buildManager->extensionsInitialized(); +} + +void ProjectExplorerPlugin::loadCustomWizards() +{ // Add custom wizards, for which other plugins might have registered // class factories - foreach(Core::IWizard *cpw, ProjectExplorer::CustomWizard::createWizards()) - addAutoReleasedObject(cpw); - - d->m_buildManager->extensionsInitialized(); + static bool firstTime = true; + if (firstTime) { + firstTime = false; + foreach(Core::IWizard *cpw, ProjectExplorer::CustomWizard::createWizards()) + addAutoReleasedObject(cpw); + } } ExtensionSystem::IPlugin::ShutdownFlag ProjectExplorerPlugin::aboutToShutdown() diff --git a/src/plugins/projectexplorer/projectexplorer.h b/src/plugins/projectexplorer/projectexplorer.h index 9ca130fbacc..1770f274401 100644 --- a/src/plugins/projectexplorer/projectexplorer.h +++ b/src/plugins/projectexplorer/projectexplorer.h @@ -194,6 +194,7 @@ private slots: void loadProject(const QString &project) { openProject(project); } void currentModeChanged(Core::IMode *mode, Core::IMode *oldMode); void updateActions(); + void loadCustomWizards(); #ifdef WITH_TESTS void testGccOutputParsers_data(); -- GitLab