1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights. These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
32 **************************************************************************/
37 #include "qtprojectparameters.h"
38 #include <projectexplorer/baseprojectwizarddialog.h>
39 #include <projectexplorer/customwizard/customwizard.h>
41 #include <coreplugin/basefilewizard.h>
43 #include <QtCore/QSet>
45 namespace Qt4ProjectManager {
48 class TargetSetupPage;
54 /* Base class for wizard creating Qt projects using QtProjectParameters.
55 * To implement a project wizard, overwrite:
56 * - createWizardDialog() to create up the dialog
57 * - generateFiles() to set their contents
58 * The base implementation provides the wizard parameters and opens
59 * the finished project in postGenerateFiles().
60 * The pro-file must be the last one of the generated files. */
62 class QtWizard : public Core::BaseFileWizard
65 Q_DISABLE_COPY(QtWizard)
68 QtWizard(const QString &id,
69 const QString &category,
70 const QString &categoryTranslationScope,
71 const QString &displayCategory,
73 const QString &description,
78 static QString templateDir();
80 static QString sourceSuffix();
81 static QString headerSuffix();
82 static QString formSuffix();
83 static QString profileSuffix();
85 // Query CppTools settings for the class wizard settings
86 static bool lowerCaseFiles();
88 static bool qt4ProjectPostGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l, QString *errorMessage);
91 static bool showModulesPageForApplications();
92 static bool showModulesPageForLibraries();
95 bool postGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l, QString *errorMessage);
98 // A custom wizard with an additional Qt 4 target page
99 class CustomQt4ProjectWizard : public ProjectExplorer::CustomProjectWizard {
102 explicit CustomQt4ProjectWizard(const Core::BaseFileWizardParameters& baseFileParameters,
103 QObject *parent = 0);
105 virtual QWizard *createWizardDialog(QWidget *parent,
106 const QString &defaultPath,
107 const WizardPageList &extensionPages) const;
108 static void registerSelf();
111 virtual bool postGenerateFiles(const QWizard *, const Core::GeneratedFiles &l, QString *errorMessage);
114 enum { targetPageId = 2 };
117 /* BaseQt4ProjectWizardDialog: Additionally offers modules page
118 * and getter/setter for blank-delimited modules list, transparently
119 * handling the visibility of the modules page list as well as a page
120 * to select targets and Qt versions.
123 class BaseQt4ProjectWizardDialog : public ProjectExplorer::BaseProjectWizardDialog {
126 explicit BaseQt4ProjectWizardDialog(bool showModulesPage,
127 Utils::ProjectIntroPage *introPage,
129 QWidget *parent = 0);
131 explicit BaseQt4ProjectWizardDialog(bool showModulesPage, QWidget *parent = 0);
132 virtual ~BaseQt4ProjectWizardDialog();
134 int addModulesPage(int id = -1);
135 int addTargetSetupPage(QSet<QString> targets = QSet<QString>(), bool mobile = false, int id = -1);
137 static QSet<QString> desktopTarget();
139 QString selectedModules() const;
140 void setSelectedModules(const QString &, bool lock = false);
142 QString deselectedModules() const;
143 void setDeselectedModules(const QString &);
145 bool writeUserFile(const QString &proFileName) const;
146 bool setupProject(Qt4Project *project) const;
147 bool isTargetSelected(const QString &targetid) const;
150 void generateProfileName(const QString &name, const QString &path);
153 inline void init(bool showModulesPage);
155 ModulesPage *m_modulesPage;
156 TargetSetupPage *m_targetSetupPage;
157 QString m_selectedModules;
158 QString m_deselectedModules;
159 QSet<QString> m_targets;
162 } // namespace Internal
163 } // namespace Qt4ProjectManager