diff options
26 files changed, 144 insertions, 70 deletions
diff --git a/share/qtcreator/templates/wizards/helloworld/wizard_sample.xml b/share/qtcreator/templates/wizards/helloworld/wizard_sample.xml index d216ea6178..7f343b666a 100644 --- a/share/qtcreator/templates/wizards/helloworld/wizard_sample.xml +++ b/share/qtcreator/templates/wizards/helloworld/wizard_sample.xml @@ -42,8 +42,8 @@ leave room for the Qt 4 target page. <displayname>Hello World</displayname>; <displaycategory>Custom Projects</displaycategory> <files> - <file source="main.cpp"/> - <file source="project.pro" target="%ProjectName%.pro"/> + <file source="main.cpp" openeditor="true"/> + <file source="project.pro" target="%ProjectName%.pro" openproject="true"/> </files> <!-- Create a 2nd wizard page with parameters --> <fieldpagetitle>Hello World Parameters</fieldpagetitle> diff --git a/share/qtcreator/templates/wizards/listmodel/wizard_sample.xml b/share/qtcreator/templates/wizards/listmodel/wizard_sample.xml index c81715fc86..910dce154d 100644 --- a/share/qtcreator/templates/wizards/listmodel/wizard_sample.xml +++ b/share/qtcreator/templates/wizards/listmodel/wizard_sample.xml @@ -38,8 +38,8 @@ Custom class wizard example configuration file. --> <displaycategory>Custom Classes</displaycategory> <displaycategory xml:lang="de">Benutzerdefinierte Klassen</displaycategory> <files> - <file source="listmodel.cpp" target="%ClassName:l%.%CppSourceSuffix%"/> - <file source="listmodel.h" target="%ClassName:l%.%CppHeaderSuffix%"/> + <file source="listmodel.cpp" target="%ClassName:l%.%CppSourceSuffix%" openeditor="true"/> + <file source="listmodel.h" target="%ClassName:l%.%CppHeaderSuffix%" openeditor="true"/> </files> <!-- Create parameter wizard page --> <fieldpagetitle>ListModel parameters</fieldpagetitle> diff --git a/share/qtcreator/templates/wizards/qml-runtime/wizard.xml b/share/qtcreator/templates/wizards/qml-runtime/wizard.xml index a7a53a5d90..de785e26f6 100644 --- a/share/qtcreator/templates/wizards/qml-runtime/wizard.xml +++ b/share/qtcreator/templates/wizards/qml-runtime/wizard.xml @@ -45,8 +45,8 @@ leave room for the Qt 4 target page. <file source="plugin.h" target="%ProjectName%.h"/> <file source="plugin.cpp" target="%ProjectName%.cpp"/> <file source="object.h" target="%ObjectName%.h"/> - <file source="object.cpp" target="%ObjectName%.cpp"/> - <file source="project.pro" target="%ProjectName%.pro"/> + <file source="object.cpp" target="%ObjectName%.cpp" openeditor="true"/> + <file source="project.pro" target="%ProjectName%.pro" openproject="true"/> </files> <!-- Create a 2nd wizard page with parameters --> <fieldpagetitle>QML Runtime Plug-in Parameters</fieldpagetitle> diff --git a/src/plugins/coreplugin/basefilewizard.cpp b/src/plugins/coreplugin/basefilewizard.cpp index c136fd7172..4c1309ddfb 100644 --- a/src/plugins/coreplugin/basefilewizard.cpp +++ b/src/plugins/coreplugin/basefilewizard.cpp @@ -66,11 +66,13 @@ public: QByteArray contents; QString editorId; bool binary; + GeneratedFile::Attributes attributes; }; GeneratedFilePrivate::GeneratedFilePrivate(const QString &p) : path(p), - binary(false) + binary(false), + attributes(0) { } @@ -180,6 +182,15 @@ bool GeneratedFile::write(QString *errorMessage) const return true; } +GeneratedFile::Attributes GeneratedFile::attributes() const +{ + return m_d->attributes; +} + +void GeneratedFile::setAttributes(Attributes a) +{ + m_d->attributes = a; +} // ------------ BaseFileWizardParameterData class BaseFileWizardParameterData : public QSharedData @@ -584,16 +595,21 @@ void BaseFileWizard::applyExtensionPageShortTitle(Utils::Wizard *wizard, int pag item->setTitle(shortTitle); } -bool BaseFileWizard::postGenerateFiles(const QWizard *w, const GeneratedFiles &l, QString *errorMessage) +bool BaseFileWizard::postGenerateFiles(const QWizard *, const GeneratedFiles &l, QString *errorMessage) +{ + return BaseFileWizard::postGenerateOpenEditors(l, errorMessage); +} + +bool BaseFileWizard::postGenerateOpenEditors(const GeneratedFiles &l, QString *errorMessage) { - Q_UNUSED(w); - // File mode: open the editors in file mode and ensure editor pane - const Core::GeneratedFiles::const_iterator cend = l.constEnd(); Core::EditorManager *em = Core::EditorManager::instance(); - for (Core::GeneratedFiles::const_iterator it = l.constBegin(); it != cend; ++it) { - if (!em->openEditor(it->path(), it->editorId())) { - *errorMessage = tr("Failed to open an editor for '%1'.").arg(it->path()); - return false; + foreach(const Core::GeneratedFile &file, l) { + if (file.attributes() & Core::GeneratedFile::OpenEditorAttribute) { + if (!em->openEditor(file.path(), file.editorId())) { + if (errorMessage) + *errorMessage = tr("Failed to open an editor for '%1'.").arg(file.path()); + return false; + } } } return true; diff --git a/src/plugins/coreplugin/basefilewizard.h b/src/plugins/coreplugin/basefilewizard.h index 7a8536cea8..9a03410eee 100644 --- a/src/plugins/coreplugin/basefilewizard.h +++ b/src/plugins/coreplugin/basefilewizard.h @@ -65,6 +65,9 @@ class GeneratedFilePrivate; class CORE_EXPORT GeneratedFile { public: + enum Attribute { OpenEditorAttribute = 0x01, OpenProjectAttribute = 0x02 }; + Q_DECLARE_FLAGS(Attributes, Attribute) + GeneratedFile(); explicit GeneratedFile(const QString &path); GeneratedFile(const GeneratedFile &); @@ -92,6 +95,9 @@ public: bool write(QString *errorMessage) const; + Attributes attributes() const; + void setAttributes(Attributes a); + private: QSharedDataPointer<GeneratedFilePrivate> m_d; }; @@ -207,6 +213,10 @@ protected: OverwriteResult promptOverwrite(const QString &location, const QStringList &files, QString *errorMessage) const; + + // Utility to open the editors for the files whose attribute is set accordingly. + static bool postGenerateOpenEditors(const GeneratedFiles &l, QString *errorMessage = 0); + private: BaseFileWizardPrivate *m_d; }; @@ -239,4 +249,6 @@ protected: } // namespace Core +Q_DECLARE_OPERATORS_FOR_FLAGS(Core::GeneratedFile::Attributes) + #endif // BASEFILEWIZARD_H diff --git a/src/plugins/cppeditor/cppclasswizard.cpp b/src/plugins/cppeditor/cppclasswizard.cpp index 4c8caeb8ca..2333cc4daf 100644 --- a/src/plugins/cppeditor/cppclasswizard.cpp +++ b/src/plugins/cppeditor/cppclasswizard.cpp @@ -209,7 +209,10 @@ Core::GeneratedFiles CppClassWizard::generateFiles(const QWizard *w, QString *er return Core::GeneratedFiles(); } headerFile.setContents(header); + headerFile.setAttributes(Core::GeneratedFile::OpenEditorAttribute); + sourceFile.setContents(source); + sourceFile.setAttributes(Core::GeneratedFile::OpenEditorAttribute); return Core::GeneratedFiles() << headerFile << sourceFile; } diff --git a/src/plugins/cppeditor/cppfilewizard.cpp b/src/plugins/cppeditor/cppfilewizard.cpp index 419771f4eb..eff7f24266 100644 --- a/src/plugins/cppeditor/cppfilewizard.cpp +++ b/src/plugins/cppeditor/cppfilewizard.cpp @@ -62,7 +62,7 @@ Core::GeneratedFiles CppFileWizard::generateFilesFromPath(const QString &path, Core::GeneratedFile file(fileName); file.setEditorId(QLatin1String(Constants::CPPEDITOR_ID)); file.setContents(fileContents(m_type, fileName)); - + file.setAttributes(Core::GeneratedFile::OpenEditorAttribute); return Core::GeneratedFiles() << file; } diff --git a/src/plugins/designer/cpp/formclasswizard.cpp b/src/plugins/designer/cpp/formclasswizard.cpp index e8cc25f7fd..7a174ce5bb 100644 --- a/src/plugins/designer/cpp/formclasswizard.cpp +++ b/src/plugins/designer/cpp/formclasswizard.cpp @@ -88,15 +88,18 @@ Core::GeneratedFiles FormClassWizard::generateFiles(const QWizard *w, QString *e Core::GeneratedFile headerFile(headerFileName); headerFile.setEditorId(QLatin1String(CppEditor::Constants::CPPEDITOR_ID)); + headerFile.setAttributes(Core::GeneratedFile::OpenEditorAttribute); // Source Core::GeneratedFile sourceFile(sourceFileName); sourceFile.setEditorId(QLatin1String(CppEditor::Constants::CPPEDITOR_ID)); + sourceFile.setAttributes(Core::GeneratedFile::OpenEditorAttribute); // UI Core::GeneratedFile uiFile(formFileName); uiFile.setContents(params.uiTemplate()); uiFile.setEditorId(QLatin1String(Constants::DESIGNER_XML_EDITOR_ID)); + uiFile.setAttributes(Core::GeneratedFile::OpenEditorAttribute); QString source, header; Designer::FormClassWizardGenerationParameters generationParameters; diff --git a/src/plugins/designer/formwizard.cpp b/src/plugins/designer/formwizard.cpp index 454883b54a..30702087c7 100644 --- a/src/plugins/designer/formwizard.cpp +++ b/src/plugins/designer/formwizard.cpp @@ -67,5 +67,6 @@ Core::GeneratedFiles FormWizard::generateFiles(const QWizard *w, Core::GeneratedFile file(fileName); file.setContents(formTemplate); file.setEditorId(QLatin1String(Constants::DESIGNER_XML_EDITOR_ID)); + file.setAttributes(Core::GeneratedFile::OpenEditorAttribute); return Core::GeneratedFiles() << file; } diff --git a/src/plugins/genericprojectmanager/genericprojectwizard.cpp b/src/plugins/genericprojectmanager/genericprojectwizard.cpp index 3551523e88..4d6b33655f 100644 --- a/src/plugins/genericprojectmanager/genericprojectwizard.cpp +++ b/src/plugins/genericprojectmanager/genericprojectwizard.cpp @@ -31,8 +31,8 @@ #include <coreplugin/icore.h> #include <coreplugin/mimedatabase.h> -#include <projectexplorer/projectexplorer.h> #include <projectexplorer/projectexplorerconstants.h> +#include <projectexplorer/customwizard/customwizard.h> #include <utils/filewizardpage.h> @@ -198,6 +198,7 @@ Core::GeneratedFiles GenericProjectWizard::generateFiles(const QWizard *w, Core::GeneratedFile generatedCreatorFile(creatorFileName); generatedCreatorFile.setContents(QLatin1String("[General]\n")); + generatedCreatorFile.setAttributes(Core::GeneratedFile::OpenProjectAttribute); Core::GeneratedFile generatedFilesFile(filesFileName); generatedFilesFile.setContents(sources.join(QLatin1String("\n"))); @@ -220,12 +221,5 @@ Core::GeneratedFiles GenericProjectWizard::generateFiles(const QWizard *w, bool GenericProjectWizard::postGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l, QString *errorMessage) { Q_UNUSED(w); - // Post-Generate: Open the project - const QString proFileName = l.back().path(); - if (!ProjectExplorer::ProjectExplorerPlugin::instance()->openProject(proFileName)) { - *errorMessage = tr("The project %1 could not be opened.").arg(proFileName); - return false; - } - return true; + return ProjectExplorer::CustomProjectWizard::postGenerateOpen(l, errorMessage); } - diff --git a/src/plugins/projectexplorer/customwizard/customwizard.cpp b/src/plugins/projectexplorer/customwizard/customwizard.cpp index ae40298001..829ed1e028 100644 --- a/src/plugins/projectexplorer/customwizard/customwizard.cpp +++ b/src/plugins/projectexplorer/customwizard/customwizard.cpp @@ -161,6 +161,12 @@ static inline bool createFile(Internal::CustomWizardFile cwFile, Core::GeneratedFile generatedFile; generatedFile.setContents(contents); generatedFile.setPath(targetPath); + Core::GeneratedFile::Attributes attributes = 0; + if (cwFile.openEditor) + attributes |= Core::GeneratedFile::OpenEditorAttribute; + if (cwFile.openProject) + attributes |= Core::GeneratedFile::OpenProjectAttribute; + generatedFile.setAttributes(attributes); files->push_back(generatedFile); return true; } @@ -410,18 +416,26 @@ Core::GeneratedFiles CustomProjectWizard::generateFiles(const QWizard *w, QStrin return generateWizardFiles(targetPath, fieldReplacementMap, errorMessage); } +bool CustomProjectWizard::postGenerateOpen(const Core::GeneratedFiles &l, QString *errorMessage) +{ + // Post-Generate: Open the project and the editors as desired + foreach(const Core::GeneratedFile &file, l) { + if (file.attributes() & Core::GeneratedFile::OpenProjectAttribute) { + if (!ProjectExplorer::ProjectExplorerPlugin::instance()->openProject(file.path())) { + if (errorMessage) + *errorMessage = tr("The project %1 could not be opened.").arg(file.path()); + return false; + } + } + } + return BaseFileWizard::postGenerateOpenEditors(l, errorMessage); +} + bool CustomProjectWizard::postGenerateFiles(const QWizard *, const Core::GeneratedFiles &l, QString *errorMessage) { - // Post-Generate: Open the project - const QString proFileName = l.back().path(); - const bool opened = ProjectExplorer::ProjectExplorerPlugin::instance()->openProject(proFileName); if (CustomWizardPrivate::verbose) - qDebug() << "CustomProjectWizard::postGenerateFiles: opened " << proFileName << opened; - if (opened) { - *errorMessage = tr("The project %1 could not be opened.").arg(proFileName); - return false; - } - return true; + qDebug() << "CustomProjectWizard::postGenerateFiles()"; + return CustomProjectWizard::postGenerateOpen(l, errorMessage); } void CustomProjectWizard::introPageLeft(const QString &project, const QString & /* path */) diff --git a/src/plugins/projectexplorer/customwizard/customwizard.h b/src/plugins/projectexplorer/customwizard/customwizard.h index 522c31d580..7816bf3aef 100644 --- a/src/plugins/projectexplorer/customwizard/customwizard.h +++ b/src/plugins/projectexplorer/customwizard/customwizard.h @@ -154,6 +154,10 @@ public: virtual Core::GeneratedFiles generateFiles(const QWizard *w, QString *errorMessage) const; + // Utility to open the projects and editors for the files that have + // the respective attributes set. + static bool postGenerateOpen(const Core::GeneratedFiles &l, QString *errorMessage = 0); + protected: virtual bool postGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l, QString *errorMessage); diff --git a/src/plugins/projectexplorer/customwizard/customwizardparameters.cpp b/src/plugins/projectexplorer/customwizard/customwizardparameters.cpp index 982668ee68..2f3d902c88 100644 --- a/src/plugins/projectexplorer/customwizard/customwizardparameters.cpp +++ b/src/plugins/projectexplorer/customwizard/customwizardparameters.cpp @@ -68,6 +68,9 @@ static const char filesElementC[] = "files"; static const char fileElementC[] = "file"; static const char fileNameSourceAttributeC[] = "source"; static const char fileNameTargetAttributeC[] = "target"; +static const char fileNameOpenEditorAttributeC[] = "openeditor"; +static const char fileNameOpenProjectAttributeC[] = "openproject"; + enum ParseState { ParseBeginning, @@ -95,6 +98,11 @@ void CustomWizardField::clear() controlAttributes.clear(); } +CustomWizardFile::CustomWizardFile() : + openEditor(false), openProject(false) +{ +} + CustomWizardParameters::CustomWizardParameters() : firstPageId(-1) { @@ -409,6 +417,8 @@ bool CustomWizardParameters::parse(QIODevice &device, CustomWizardFile file; file.source = attributeValue(reader, fileNameSourceAttributeC); file.target = attributeValue(reader, fileNameTargetAttributeC); + file.openEditor = booleanAttributeValue(reader, fileNameOpenEditorAttributeC); + file.openProject = booleanAttributeValue(reader, fileNameOpenProjectAttributeC); if (file.target.isEmpty()) file.target = file.source; if (file.source.isEmpty()) { @@ -460,7 +470,12 @@ QString CustomWizardParameters::toString() const QTextStream str(&rc); str << "Directory: " << directory << " Klass: '" << klass << "'\n"; foreach(const CustomWizardFile &f, files) { - str << " File source: " << f.source << " Target: " << f.target << '\n'; + str << " File source: " << f.source << " Target: " << f.target; + if (f.openEditor) + str << " [editor]"; + if (f.openProject) + str << " [project]"; + str << '\n'; } foreach(const CustomWizardField &f, fields) { str << " Field name: " << f.name; diff --git a/src/plugins/projectexplorer/customwizard/customwizardparameters.h b/src/plugins/projectexplorer/customwizard/customwizardparameters.h index 63c6c0adbc..f71de2b612 100644 --- a/src/plugins/projectexplorer/customwizard/customwizardparameters.h +++ b/src/plugins/projectexplorer/customwizard/customwizardparameters.h @@ -56,8 +56,12 @@ struct CustomWizardField { }; struct CustomWizardFile { + CustomWizardFile(); + QString source; QString target; + bool openEditor; + bool openProject; }; struct CustomWizardParameters diff --git a/src/plugins/qmljseditor/qmlfilewizard.cpp b/src/plugins/qmljseditor/qmlfilewizard.cpp index 8502ad11dc..1d09447b35 100644 --- a/src/plugins/qmljseditor/qmlfilewizard.cpp +++ b/src/plugins/qmljseditor/qmlfilewizard.cpp @@ -52,7 +52,7 @@ Core::GeneratedFiles QmlFileWizard::generateFilesFromPath(const QString &path, Core::GeneratedFile file(fileName); file.setEditorId(QLatin1String(Constants::C_QMLJSEDITOR_ID)); file.setContents(fileContents(fileName)); - + file.setAttributes(Core::GeneratedFile::OpenEditorAttribute); return Core::GeneratedFiles() << file; } diff --git a/src/plugins/qmlprojectmanager/qmlprojectapplicationwizard.cpp b/src/plugins/qmlprojectmanager/qmlprojectapplicationwizard.cpp index 7bf0620a19..d52bec61b3 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectapplicationwizard.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectapplicationwizard.cpp @@ -31,8 +31,7 @@ #include "qmlprojectconstants.h" -#include <projectexplorer/projectexplorer.h> -#include <projectexplorer/projectexplorerconstants.h> +#include <projectexplorer/customwizard/customwizard.h> #include <QtGui/QIcon> @@ -120,6 +119,7 @@ Core::GeneratedFiles QmlProjectApplicationWizard::generateFiles(const QWizard *w } Core::GeneratedFile generatedMainFile(mainFileName); generatedMainFile.setContents(contents); + generatedMainFile.setAttributes(Core::GeneratedFile::OpenEditorAttribute); QString projectContents; { @@ -150,6 +150,7 @@ Core::GeneratedFiles QmlProjectApplicationWizard::generateFiles(const QWizard *w } Core::GeneratedFile generatedCreatorFile(creatorFileName); generatedCreatorFile.setContents(projectContents); + generatedCreatorFile.setAttributes(Core::GeneratedFile::OpenProjectAttribute); Core::GeneratedFiles files; files.append(generatedMainFile); @@ -158,16 +159,10 @@ Core::GeneratedFiles QmlProjectApplicationWizard::generateFiles(const QWizard *w return files; } -bool QmlProjectApplicationWizard::postGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l, QString *errorMessage) +bool QmlProjectApplicationWizard::postGenerateFiles(const QWizard *, const Core::GeneratedFiles &l, QString *errorMessage) { - Q_UNUSED(w); - // Post-Generate: Open the project - const QString proFileName = l.back().path(); - if (!ProjectExplorer::ProjectExplorerPlugin::instance()->openProject(proFileName)) { - *errorMessage = tr("The project %1 could not be opened.").arg(proFileName); - return false; - } - return true; + return ProjectExplorer::CustomProjectWizard::postGenerateOpen(l, errorMessage); + } } // namespace Internal diff --git a/src/plugins/qmlprojectmanager/qmlprojectimportwizard.cpp b/src/plugins/qmlprojectmanager/qmlprojectimportwizard.cpp index e1527b847d..b7165143d0 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectimportwizard.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectimportwizard.cpp @@ -33,8 +33,7 @@ #include <coreplugin/icore.h> #include <coreplugin/mimedatabase.h> -#include <projectexplorer/projectexplorer.h> -#include <projectexplorer/projectexplorerconstants.h> +#include <projectexplorer/customwizard/customwizard.h> #include <utils/filenamevalidatinglineedit.h> #include <utils/filewizardpage.h> @@ -166,6 +165,7 @@ Core::GeneratedFiles QmlProjectImportWizard::generateFiles(const QWizard *w, } Core::GeneratedFile generatedCreatorFile(creatorFileName); generatedCreatorFile.setContents(projectContents); + generatedCreatorFile.setAttributes(Core::GeneratedFile::OpenProjectAttribute); Core::GeneratedFiles files; files.append(generatedCreatorFile); @@ -173,16 +173,9 @@ Core::GeneratedFiles QmlProjectImportWizard::generateFiles(const QWizard *w, return files; } -bool QmlProjectImportWizard::postGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l, QString *errorMessage) +bool QmlProjectImportWizard::postGenerateFiles(const QWizard *, const Core::GeneratedFiles &l, QString *errorMessage) { - Q_UNUSED(w); - // Post-Generate: Open the project - const QString proFileName = l.back().path(); - if (!ProjectExplorer::ProjectExplorerPlugin::instance()->openProject(proFileName)) { - *errorMessage = tr("The project %1 could not be opened.").arg(proFileName); - return false; - } - return true; + return ProjectExplorer::CustomProjectWizard::postGenerateOpen(l ,errorMessage); } } // namespace Internal diff --git a/src/plugins/qt4projectmanager/customwidgetwizard/plugingenerator.cpp b/src/plugins/qt4projectmanager/customwidgetwizard/plugingenerator.cpp index b5f389508c..0da9c70f20 100644 --- a/src/plugins/qt4projectmanager/customwidgetwizard/plugingenerator.cpp +++ b/src/plugins/qt4projectmanager/customwidgetwizard/plugingenerator.cpp @@ -93,7 +93,9 @@ QList<Core::GeneratedFile> PluginGenerator::generatePlugin(const GenerationPara // First create the widget wrappers (plugins) and - if requested - skeletons // for the widgets. - foreach (const PluginOptions::WidgetOptions &wo, options.widgetOptions) { + const int widgetCount = options.widgetOptions.size(); + for (int i = 0; i < widgetCount; i++) { + const PluginOptions::WidgetOptions &wo = options.widgetOptions.at(i); sm.clear(); sm.insert(QLatin1String("SINGLE_INCLUDE_GUARD"), headerGuard(wo.pluginHeaderFile)); sm.insert(QLatin1String("PLUGIN_CLASS"), wo.pluginClassName); @@ -133,6 +135,8 @@ QList<Core::GeneratedFile> PluginGenerator::generatePlugin(const GenerationPara return QList<Core::GeneratedFile>(); Core::GeneratedFile pluginSource(baseDir + wo.pluginSourceFile); pluginSource.setContents(p.license + pluginSourceContents); + if (i == 0 && widgetCount == 1) // Open first widget unless collection + pluginSource.setAttributes(Core::GeneratedFile::OpenEditorAttribute); rc.push_back(pluginSource); if (wo.sourceType == PluginOptions::WidgetOptions::LinkLibrary) @@ -209,7 +213,7 @@ QList<Core::GeneratedFile> PluginGenerator::generatePlugin(const GenerationPara } // Create the sources for the collection if necessary. - if (options.widgetOptions.count() > 1) { + if (widgetCount > 1) { sm.clear(); sm.insert(QLatin1String("COLLECTION_INCLUDE_GUARD"), headerGuard(options.collectionHeaderFile)); sm.insert(QLatin1String("COLLECTION_PLUGIN_CLASS"), options.collectionClassName); @@ -238,6 +242,7 @@ QList<Core::GeneratedFile> PluginGenerator::generatePlugin(const GenerationPara return QList<Core::GeneratedFile>(); Core::GeneratedFile collectionSource(baseDir + options.collectionSourceFile); collectionSource.setContents(p.license + collectionSourceFileContents); + collectionSource.setAttributes(Core::GeneratedFile::OpenEditorAttribute); rc.push_back(collectionSource); pluginHeaders += blank + options.collectionHeaderFile; @@ -282,6 +287,7 @@ QList<Core::GeneratedFile> PluginGenerator::generatePlugin(const GenerationPara return QList<Core::GeneratedFile>(); Core::GeneratedFile proFile(baseDir + p.fileName + QLatin1String(".pro")); proFile.setContents(proFileContents); + proFile.setAttributes(Core::GeneratedFile::OpenProjectAttribute); rc.push_back(proFile); return rc; } diff --git a/src/plugins/qt4projectmanager/wizards/consoleappwizard.cpp b/src/plugins/qt4projectmanager/wizards/consoleappwizard.cpp index 7b79d3c8de..11f313b829 100644 --- a/src/plugins/qt4projectmanager/wizards/consoleappwizard.cpp +++ b/src/plugins/qt4projectmanager/wizards/consoleappwizard.cpp @@ -87,10 +87,12 @@ Core::GeneratedFiles const QString sourceFileName = Core::BaseFileWizard::buildFileName(projectPath, QLatin1String(mainSourceFileC), sourceSuffix()); Core::GeneratedFile source(sourceFileName); source.setContents(license + QLatin1String(mainCppC)); + source.setAttributes(Core::GeneratedFile::OpenEditorAttribute); // Create files: Profile const QString profileName = Core::BaseFileWizard::buildFileName(projectPath, params.fileName, profileSuffix()); Core::GeneratedFile profile(profileName); + profile.setAttributes(Core::GeneratedFile::OpenProjectAttribute); QString contents; { QTextStream proStr(&contents); diff --git a/src/plugins/qt4projectmanager/wizards/emptyprojectwizard.cpp b/src/plugins/qt4projectmanager/wizards/emptyprojectwizard.cpp index 02ad1f3a3b..a8c9c5c533 100644 --- a/src/plugins/qt4projectmanager/wizards/emptyprojectwizard.cpp +++ b/src/plugins/qt4projectmanager/wizards/emptyprojectwizard.cpp @@ -69,6 +69,7 @@ Core::GeneratedFiles const QString profileName = Core::BaseFileWizard::buildFileName(projectPath, params.fileName, profileSuffix()); Core::GeneratedFile profile(profileName); + profile.setAttributes(Core::GeneratedFile::OpenProjectAttribute); return Core::GeneratedFiles() << profile; } diff --git a/src/plugins/qt4projectmanager/wizards/guiappwizard.cpp b/src/plugins/qt4projectmanager/wizards/guiappwizard.cpp index 1ebfc8e17c..92bbb1a338 100644 --- a/src/plugins/qt4projectmanager/wizards/guiappwizard.cpp +++ b/src/plugins/qt4projectmanager/wizards/guiappwizard.cpp @@ -175,6 +175,7 @@ Core::GeneratedFiles GuiAppWizard::generateFiles(const QWizard *w, // Create files: form const QString formName = buildFileName(projectPath, params.formFileName, formSuffix()); form = QSharedPointer<Core::GeneratedFile>(new Core::GeneratedFile(formName)); + form->setAttributes(Core::GeneratedFile::OpenEditorAttribute); if (!parametrizeTemplate(templatePath, QLatin1String("widget.ui"), params, &contents, errorMessage)) return Core::GeneratedFiles(); form->setContents(contents); @@ -185,6 +186,7 @@ Core::GeneratedFiles GuiAppWizard::generateFiles(const QWizard *w, if (!parametrizeTemplate(templatePath, formSourceTemplate, params, &contents, errorMessage)) return Core::GeneratedFiles(); formSource.setContents(license + contents); + formSource.setAttributes(Core::GeneratedFile::OpenEditorAttribute); // Create files: form header const QString formHeaderTemplate = QLatin1String("mywidget.h"); if (!parametrizeTemplate(templatePath, formHeaderTemplate, params, &contents, errorMessage)) @@ -194,6 +196,7 @@ Core::GeneratedFiles GuiAppWizard::generateFiles(const QWizard *w, // Create files: profile const QString profileName = buildFileName(projectPath, projectParams.fileName, profileSuffix()); Core::GeneratedFile profile(profileName); + profile.setAttributes(Core::GeneratedFile::OpenProjectAttribute); contents.clear(); { QTextStream proStr(&contents); diff --git a/src/plugins/qt4projectmanager/wizards/librarywizard.cpp b/src/plugins/qt4projectmanager/wizards/librarywizard.cpp index 343457fc41..65e115c1e1 100644 --- a/src/plugins/qt4projectmanager/wizards/librarywizard.cpp +++ b/src/plugins/qt4projectmanager/wizards/librarywizard.cpp @@ -88,6 +88,7 @@ Core::GeneratedFiles LibraryWizard::generateFiles(const QWizard *w, // Class header + source const QString sourceFileName = buildFileName(projectPath, params.sourceFileName, sourceSuffix()); Core::GeneratedFile source(sourceFileName); + source.setAttributes(Core::GeneratedFile::OpenEditorAttribute); const QString headerFileFullName = buildFileName(projectPath, params.headerFileName, headerSuffix()); const QString headerFileName = QFileInfo(headerFileFullName).fileName(); @@ -116,6 +117,7 @@ Core::GeneratedFiles LibraryWizard::generateFiles(const QWizard *w, // Create files: profile const QString profileName = buildFileName(projectPath, projectParams.fileName, profileSuffix()); Core::GeneratedFile profile(profileName); + profile.setAttributes(Core::GeneratedFile::OpenProjectAttribute); QString profileContents; { QTextStream proStr(&profileContents); diff --git a/src/plugins/qt4projectmanager/wizards/qtwizard.cpp b/src/plugins/qt4projectmanager/wizards/qtwizard.cpp index f292c38fea..1ce7ff9a13 100644 --- a/src/plugins/qt4projectmanager/wizards/qtwizard.cpp +++ b/src/plugins/qt4projectmanager/wizards/qtwizard.cpp @@ -37,6 +37,7 @@ #include "targetsetuppage.h" #include <coreplugin/icore.h> +#include <coreplugin/editormanager/editormanager.h> #include <cpptools/cpptoolsconstants.h> #include <extensionsystem/pluginmanager.h> #include <projectexplorer/projectexplorer.h> @@ -108,20 +109,21 @@ bool QtWizard::postGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l return QtWizard::qt4ProjectPostGenerateFiles(w, l, errorMessage); } -bool QtWizard::qt4ProjectPostGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l, QString *errorMessage) +bool QtWizard::qt4ProjectPostGenerateFiles(const QWizard *w, + const Core::GeneratedFiles &generatedFiles, + QString *errorMessage) { - const QString proFileName = l.back().path(); const BaseQt4ProjectWizardDialog *dialog = qobject_cast<const BaseQt4ProjectWizardDialog *>(w); - // Generate user settings: - dialog->writeUserFile(proFileName); + // Generate user settings + foreach (const Core::GeneratedFile &file, generatedFiles) + if (file.attributes() & Core::GeneratedFile::OpenProjectAttribute) { + dialog->writeUserFile(file.path()); + break; + } - // Post-Generate: Open the project - if (!ProjectExplorer::ProjectExplorerPlugin::instance()->openProject(proFileName)) { - *errorMessage = tr("The project %1 could not be opened.").arg(proFileName); - return false; - } - return true; + // Post-Generate: Open the projects/editors + return ProjectExplorer::CustomProjectWizard::postGenerateOpen(generatedFiles ,errorMessage); } QString QtWizard::templateDir() diff --git a/src/plugins/qt4projectmanager/wizards/testwizard.cpp b/src/plugins/qt4projectmanager/wizards/testwizard.cpp index 5954c820ac..33223db97b 100644 --- a/src/plugins/qt4projectmanager/wizards/testwizard.cpp +++ b/src/plugins/qt4projectmanager/wizards/testwizard.cpp @@ -162,11 +162,13 @@ Core::GeneratedFiles TestWizard::generateFiles(const QWizard *w, QString *errorM const QFileInfo sourceFileInfo(sourceFilePath); Core::GeneratedFile source(sourceFilePath); + source.setAttributes(Core::GeneratedFile::OpenEditorAttribute); source.setContents(generateTestCode(testParams, sourceFileInfo.baseName())); // Create profile with define for base dir to find test data const QString profileName = Core::BaseFileWizard::buildFileName(projectPath, projectParams.fileName, profileSuffix()); Core::GeneratedFile profile(profileName); + profile.setAttributes(Core::GeneratedFile::OpenProjectAttribute); QString contents; { QTextStream proStr(&contents); diff --git a/src/plugins/resourceeditor/resourcewizard.cpp b/src/plugins/resourceeditor/resourcewizard.cpp index ae915c84e4..ce454a36db 100644 --- a/src/plugins/resourceeditor/resourcewizard.cpp +++ b/src/plugins/resourceeditor/resourcewizard.cpp @@ -50,5 +50,6 @@ ResourceWizard::generateFilesFromPath(const QString &path, Core::GeneratedFile file(fileName); file.setContents(QLatin1String("<RCC/>")); file.setEditorId(QLatin1String(Constants::RESOURCEEDITOR_ID)); + file.setAttributes(Core::GeneratedFile::OpenEditorAttribute); return Core::GeneratedFiles() << file; } diff --git a/src/plugins/texteditor/textfilewizard.cpp b/src/plugins/texteditor/textfilewizard.cpp index 5c9c351baf..f7f8875e8b 100644 --- a/src/plugins/texteditor/textfilewizard.cpp +++ b/src/plugins/texteditor/textfilewizard.cpp @@ -54,5 +54,6 @@ Core::GeneratedFiles const QString fileName = Core::BaseFileWizard::buildFileName(path, name, suffix); Core::GeneratedFile file(fileName); file.setEditorId(m_editorId); + file.setAttributes(Core::GeneratedFile::OpenEditorAttribute); return Core::GeneratedFiles() << file; } |