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 **************************************************************************/
34 #include "mobileappwizardpages.h"
36 #include "qmlstandaloneapp.h"
37 #include "qmlstandaloneappwizard.h"
38 #include "qmlstandaloneappwizardpages.h"
39 #include "targetsetuppage.h"
41 #include "qt4projectmanagerconstants.h"
43 #include <projectexplorer/baseprojectwizarddialog.h>
44 #include <projectexplorer/customwizard/customwizard.h>
45 #include <projectexplorer/projectexplorer.h>
46 #include <coreplugin/editormanager/editormanager.h>
48 #include <QtCore/QCoreApplication>
49 #include <QtGui/QIcon>
51 namespace Qt4ProjectManager {
54 class QmlStandaloneAppWizardDialog : public AbstractMobileAppWizardDialog
59 explicit QmlStandaloneAppWizardDialog(QWidget *parent = 0);
62 class QmlStandaloneAppWizardSourcesPage *m_qmlSourcesPage;
63 friend class QmlStandaloneAppWizard;
66 QmlStandaloneAppWizardDialog::QmlStandaloneAppWizardDialog(QWidget *parent)
67 : AbstractMobileAppWizardDialog(parent)
70 setWindowTitle(tr("New Qt Quick Application"));
71 setIntroDescription(tr("This wizard generates a Qt Quick application project."));
73 m_qmlSourcesPage = new QmlStandaloneAppWizardSourcesPage;
74 addPageWithTitle(m_qmlSourcesPage, tr("QML Sources"));
78 class QmlStandaloneAppWizardPrivate
80 class QmlStandaloneApp *standaloneApp;
81 class QmlStandaloneAppWizardDialog *wizardDialog;
82 friend class QmlStandaloneAppWizard;
85 QmlStandaloneAppWizard::QmlStandaloneAppWizard()
86 : AbstractMobileAppWizard(parameters())
87 , m_d(new QmlStandaloneAppWizardPrivate)
89 m_d->standaloneApp = new QmlStandaloneApp;
90 m_d->wizardDialog = 0;
93 QmlStandaloneAppWizard::~QmlStandaloneAppWizard()
95 delete m_d->standaloneApp;
99 Core::BaseFileWizardParameters QmlStandaloneAppWizard::parameters()
101 Core::BaseFileWizardParameters parameters(ProjectWizard);
102 parameters.setIcon(QIcon(QLatin1String(Constants::ICON_QML_STANDALONE)));
103 parameters.setDisplayName(tr("Qt Quick Application"));
104 parameters.setId(QLatin1String("QA.QMLA Application"));
105 parameters.setDescription(tr("Creates a Qt Quick application project that can contain "
106 "both QML and C++ code and includes a QDeclarativeView.\n\n"
107 "You can build the application and deploy it on desktop and "
108 "mobile target platforms. For example, you can create signed "
109 "Symbian Installation System (SIS) packages for this type of "
111 parameters.setCategory(QLatin1String(Constants::QML_WIZARD_CATEGORY));
112 parameters.setDisplayCategory(QCoreApplication::translate(Constants::QML_WIZARD_TR_SCOPE,
113 Constants::QML_WIZARD_TR_CATEGORY));
117 AbstractMobileAppWizardDialog *QmlStandaloneAppWizard::createWizardDialogInternal(QWidget *parent) const
119 m_d->wizardDialog = new QmlStandaloneAppWizardDialog(parent);
120 const QList<TargetSetupPage::ImportInfo> &qtVersions
121 = TargetSetupPage::importInfosForKnownQtVersions();
122 QList<TargetSetupPage::ImportInfo> qmlQtVersions;
123 foreach (const TargetSetupPage::ImportInfo &qtVersion, qtVersions) {
124 const QString versionString = qtVersion.version->qtVersionString();
126 const int majorVersion = versionString.mid(0, 1).toInt(&isNumber);
127 if (!isNumber || majorVersion < 4)
129 const int minorVersion = versionString.mid(2, 1).toInt(&isNumber);
130 if (!isNumber || (majorVersion == 4 && minorVersion < 7))
132 qmlQtVersions << qtVersion;
134 m_d->wizardDialog->m_targetsPage->setImportInfos(qmlQtVersions);
136 return m_d->wizardDialog;
139 void QmlStandaloneAppWizard::prepareGenerateFiles(const QWizard *w,
140 QString *errorMessage) const
142 Q_UNUSED(errorMessage)
143 const QmlStandaloneAppWizardDialog *wizard = qobject_cast<const QmlStandaloneAppWizardDialog*>(w);
144 const QString mainQmlFile = wizard->m_qmlSourcesPage->mainQmlFile();
145 if (!mainQmlFile.isEmpty())
146 m_d->standaloneApp->setMainQmlFile(mainQmlFile);
149 bool QmlStandaloneAppWizard::postGenerateFilesInternal(const Core::GeneratedFiles &l,
150 QString *errorMessage)
152 const bool success = ProjectExplorer::CustomProjectWizard::postGenerateOpen(l, errorMessage);
153 if (success && !m_d->standaloneApp->mainQmlFile().isEmpty()) {
154 ProjectExplorer::ProjectExplorerPlugin::instance()->setCurrentFile(0, m_d->standaloneApp->mainQmlFile());
155 Core::EditorManager::instance()->openEditor(m_d->standaloneApp->mainQmlFile(),
156 QString(), Core::EditorManager::ModeSwitch);
161 AbstractMobileApp *QmlStandaloneAppWizard::app() const
163 return m_d->standaloneApp;
166 AbstractMobileAppWizardDialog *QmlStandaloneAppWizard::wizardDialog() const
168 return m_d->wizardDialog;
171 } // namespace Internal
172 } // namespace Qt4ProjectManager
174 #include "qmlstandaloneappwizard.moc"