1
/****************************************************************************
3
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
4
** Contact: http://www.qt-project.org/legal
6
** This file is part of Qt Creator.
8
** Commercial License Usage
9
** Licensees holding valid commercial Qt licenses may use this file in
10
** accordance with the commercial license agreement provided with the
11
** Software or, alternatively, in accordance with the terms contained in
12
** a written agreement between you and Digia. For licensing terms and
13
** conditions see http://qt.digia.com/licensing. For further information
14
** use the contact form at http://qt.digia.com/contact-us.
16
** GNU Lesser General Public License Usage
17
** Alternatively, this file may be used under the terms of the GNU Lesser
18
** General Public License version 2.1 as published by the Free Software
19
** Foundation and appearing in the file LICENSE.LGPL included in the
20
** packaging of this file. Please review the following information to
21
** ensure the GNU Lesser General Public License version 2.1 requirements
22
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24
** In addition, as a special exception, Digia gives you certain additional
25
** rights. These rights are described in the Digia Qt LGPL Exception
26
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28
****************************************************************************/
30
#include "qtquickappwizard.h"
32
#include "qtquickapp.h"
33
#include "qtquickappwizardpages.h"
34
#include "../qmakeprojectmanagerconstants.h"
36
#include <qtsupport/qtsupportconstants.h>
37
#include <qtsupport/baseqtversion.h>
38
#include <projectexplorer/projectexplorerconstants.h>
39
#include <projectexplorer/targetsetuppage.h>
44
namespace QmakeProjectManager {
47
class QtQuickAppWizardDialog : public AbstractMobileAppWizardDialog
52
explicit QtQuickAppWizardDialog(QWidget *parent, const Core::WizardDialogParameters ¶meters,
53
QtQuickAppWizard::Kind kind);
56
bool validateCurrentPage();
59
QtQuickComponentSetOptionsPage *m_componentOptionsPage;
60
int m_componentOptionsPageId;
62
Utils::WizardProgressItem *m_componentItem;
64
friend class QtQuickAppWizard;
67
QtQuickAppWizardDialog::QtQuickAppWizardDialog(QWidget *parent,
68
const Core::WizardDialogParameters ¶meters,
69
QtQuickAppWizard::Kind kind)
70
: AbstractMobileAppWizardDialog(parent,
71
QtSupport::QtVersionNumber(4, 7, 0),
72
QtSupport::QtVersionNumber(5, INT_MAX, INT_MAX), parameters)
74
setWindowTitle(tr("New Qt Quick Application"));
75
setIntroDescription(tr("This wizard generates a Qt Quick application project."));
77
if (kind == QtQuickAppWizard::ImportQml || kind == QtQuickAppWizard::ImportQml2) { //Choose existing qml file
78
m_componentOptionsPage = new Internal::QtQuickComponentSetOptionsPage;
79
m_componentOptionsPageId = addPageWithTitle(m_componentOptionsPage, tr("Select existing QML file"));
80
m_componentItem = wizardProgress()->item(m_componentOptionsPageId);
83
AbstractMobileAppWizardDialog::addMobilePages();
85
if (kind == QtQuickAppWizard::ImportQml || kind == QtQuickAppWizard::ImportQml2) {
86
if (targetsPageItem())
87
m_componentItem->setNextItems(QList<Utils::WizardProgressItem *>()
88
<< targetsPageItem());
92
bool QtQuickAppWizardDialog::validateCurrentPage()
94
if (currentPage() == m_componentOptionsPage)
95
setIgnoreGenericOptionsPage(false);
96
return AbstractMobileAppWizardDialog::validateCurrentPage();
99
class QtQuickAppWizardPrivate
101
class QtQuickApp *app;
102
class QtQuickAppWizardDialog *wizardDialog;
103
QtQuickAppWizard::Kind kind;
104
friend class QtQuickAppWizard;
107
QtQuickAppWizard::QtQuickAppWizard()
108
: d(new QtQuickAppWizardPrivate)
110
setWizardKind(ProjectWizard);
111
setIcon(QIcon(QLatin1String(QmakeProjectManager::Constants::ICON_QTQUICK_APP)));
112
setId(QLatin1String("D.QMLA Application"));
113
setCategory(QLatin1String(ProjectExplorer::Constants::QT_APPLICATION_WIZARD_CATEGORY));
114
setDisplayCategory(QLatin1String(ProjectExplorer::Constants::QT_APPLICATION_WIZARD_CATEGORY_DISPLAY));
116
d->app = new QtQuickApp;
120
QtQuickAppWizard::~QtQuickAppWizard()
126
void QtQuickAppWizard::createInstances(ExtensionSystem::IPlugin *plugin)
128
const QString basicDescription = tr("Creates a Qt Quick 1 application project that can contain "
129
"both QML and C++ code and includes a QDeclarativeView.\n\n");
130
const QString basicDescription2 = tr("Creates a Qt Quick 2 application project that can contain "
131
"both QML and C++ code and includes a QQuickView.\n\n");
133
Core::FeatureSet basicFeatures = Core::Feature(QtSupport::Constants::FEATURE_QT_QUICK_1);
135
QtQuickAppWizard *wizard = new QtQuickAppWizard;
136
wizard->setQtQuickKind(QtQuick1_1);
137
wizard->setDisplayName(tr("Qt Quick 1 Application (Built-in Types)"));
138
wizard->setDescription(basicDescription + tr("The built-in QML types in the QtQuick 1 namespace allow "
139
"you to write cross-platform applications with "
140
"a custom look and feel.\n\nRequires <b>Qt 4.8.0</b> or newer."));
141
wizard->setRequiredFeatures(basicFeatures);
142
plugin->addAutoReleasedObject(wizard);
145
wizard = new QtQuickAppWizard;
146
wizard->setQtQuickKind(QtQuick2_0);
147
wizard->setDisplayName(tr("Qt Quick 2 Application (Built-in Types)"));
148
wizard->setDescription(basicDescription2 + tr("The built-in QML types in the QtQuick 2 namespace allow "
149
"you to write cross-platform applications with "
150
"a custom look and feel.\n\nRequires <b>Qt 5.0</b> or newer."));
151
wizard->setRequiredFeatures(Core::Feature(QtSupport::Constants::FEATURE_QT_QUICK_2));
152
plugin->addAutoReleasedObject(wizard);
155
wizard = new QtQuickAppWizard;
156
wizard->setQtQuickKind(ImportQml);
157
wizard->setDisplayName(tr("Qt Quick 1 Application (from Existing QML File)"));
158
wizard->setDescription(basicDescription + tr("Creates a deployable Qt Quick application from "
159
"existing QML files. All files and directories that "
160
"reside in the same directory as the main .qml file "
161
"are deployed. You can modify the contents of the "
162
"directory any time before deploying.\n\nRequires <b>Qt 4.8.0</b> or newer."));
163
wizard->setRequiredFeatures(basicFeatures);
164
plugin->addAutoReleasedObject(wizard);
167
wizard = new QtQuickAppWizard;
168
wizard->setQtQuickKind(ImportQml2);
169
wizard->setDisplayName(tr("Qt Quick 2 Application (from Existing QML File)"));
170
wizard->setDescription(basicDescription2 + tr("Creates a deployable Qt Quick application from "
171
"existing QML files. All files and directories that "
172
"reside in the same directory as the main .qml file "
173
"are deployed. You can modify the contents of the "
174
"directory any time before deploying.\n\nRequires <b>Qt 5.0</b> or newer."));
176
wizard->setRequiredFeatures(Core::Feature(QtSupport::Constants::FEATURE_QT_QUICK_2));
177
plugin->addAutoReleasedObject(wizard);
179
wizard = new QtQuickAppWizard;
180
wizard->setQtQuickKind(QtQuick_Controls_1_0);
182
wizard->setDisplayName(tr("Qt Quick 2 Application (Qt Quick Controls)"));
183
wizard->setDescription(basicDescription + tr("Creates a deployable Qt Quick application using "
184
"Qt Quick Controls. All files and directories that "
185
"reside in the same directory as the main .qml file "
186
"are deployed. You can modify the contents of the "
187
"directory any time before deploying.\n\nRequires <b>Qt 5.1.0</b> or newer."));
188
wizard->setRequiredFeatures(Core::Feature(QtSupport::Constants::FEATURE_QT_QUICK_2)
189
| Core::Feature(QtSupport::Constants::FEATURE_QT_QUICK_CONTROLS));
190
plugin->addAutoReleasedObject(wizard);
193
AbstractMobileAppWizardDialog *QtQuickAppWizard::createWizardDialogInternal(QWidget *parent,
194
const Core::WizardDialogParameters ¶meters) const
196
d->wizardDialog = new QtQuickAppWizardDialog(parent, parameters, qtQuickKind());
198
switch (qtQuickKind()) {
200
d->app->setComponentSet(QtQuickApp::QtQuick10Components);
201
d->app->setMainQml(QtQuickApp::ModeGenerate);
204
d->app->setComponentSet(QtQuickApp::QtQuick10Components);
205
d->app->setMainQml(QtQuickApp::ModeImport);
208
d->app->setComponentSet(QtQuickApp::QtQuick20Components);
209
d->app->setMainQml(QtQuickApp::ModeImport);
212
d->app->setComponentSet(QtQuickApp::QtQuick20Components);
213
d->app->setMainQml(QtQuickApp::ModeGenerate);
215
case QtQuick_Controls_1_0:
216
d->app->setComponentSet(QtQuickApp::QtQuickControls10);
217
d->app->setMainQml(QtQuickApp::ModeGenerate);
220
qWarning() << "QtQuickAppWizard illegal subOption:" << qtQuickKind();
224
return d->wizardDialog;
227
void QtQuickAppWizard::projectPathChanged(const QString &path) const
229
if (d->wizardDialog->targetsPage())
230
d->wizardDialog->targetsPage()->setProjectPath(path);
233
void QtQuickAppWizard::prepareGenerateFiles(const QWizard *w,
234
QString *errorMessage) const
236
Q_UNUSED(errorMessage)
237
const QtQuickAppWizardDialog *wizard = qobject_cast<const QtQuickAppWizardDialog*>(w);
239
if (d->app->mainQmlMode() == QtQuickApp::ModeGenerate) {
240
d->app->setMainQml(QtQuickApp::ModeGenerate);
242
const QString mainQmlFile = wizard->m_componentOptionsPage->mainQmlFile();
243
d->app->setMainQml(QtQuickApp::ModeImport, mainQmlFile);
247
void QtQuickAppWizard::setQtQuickKind(QtQuickAppWizard::Kind kind)
252
QtQuickAppWizard::Kind QtQuickAppWizard::qtQuickKind() const
257
QString QtQuickAppWizard::fileToOpenPostGeneration() const
259
return d->app->path(QtQuickApp::MainQml);
262
AbstractMobileApp *QtQuickAppWizard::app() const
267
AbstractMobileAppWizardDialog *QtQuickAppWizard::wizardDialog() const
269
return d->wizardDialog;
272
} // namespace Internal
273
} // namespace QmakeProjectManager
275
#include "qtquickappwizard.moc"