OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / qt4projectmanager / wizards / qtquickappwizard.cpp
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
8 **
9 **
10 ** GNU Lesser General Public License Usage
11 **
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 **
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 **
23 ** Other Usage
24 **
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **************************************************************************/
32
33 #include "mobileappwizardpages.h"
34
35 #include "qtquickapp.h"
36 #include "qtquickappwizard.h"
37 #include "qtquickappwizardpages.h"
38 #include "targetsetuppage.h"
39
40 #include "qt4projectmanagerconstants.h"
41
42 #include <QtCore/QCoreApplication>
43 #include <QtGui/QIcon>
44
45 namespace Qt4ProjectManager {
46 namespace Internal {
47
48 class QtQuickAppWizardDialog : public AbstractMobileAppWizardDialog
49 {
50     Q_OBJECT
51
52 public:
53     explicit QtQuickAppWizardDialog(QWidget *parent = 0);
54
55 private:
56     class QtQuickAppWizardSourcesPage *m_qmlSourcesPage;
57     friend class QtQuickAppWizard;
58 };
59
60 QtQuickAppWizardDialog::QtQuickAppWizardDialog(QWidget *parent)
61     : AbstractMobileAppWizardDialog(parent, QtVersionNumber(4, 7, 0))
62     , m_qmlSourcesPage(0)
63 {
64     setWindowTitle(tr("New Qt Quick Application"));
65     setIntroDescription(tr("This wizard generates a Qt Quick application project."));
66
67     m_qmlSourcesPage = new QtQuickAppWizardSourcesPage;
68     addPageWithTitle(m_qmlSourcesPage, tr("QML Sources"));
69 }
70
71
72 class QtQuickAppWizardPrivate
73 {
74     class QtQuickApp *app;
75     class QtQuickAppWizardDialog *wizardDialog;
76     friend class QtQuickAppWizard;
77 };
78
79 QtQuickAppWizard::QtQuickAppWizard()
80     : AbstractMobileAppWizard(parameters())
81     , m_d(new QtQuickAppWizardPrivate)
82 {
83     m_d->app = new QtQuickApp;
84     m_d->wizardDialog = 0;
85 }
86
87 QtQuickAppWizard::~QtQuickAppWizard()
88 {
89     delete m_d->app;
90     delete m_d;
91 }
92
93 Core::BaseFileWizardParameters QtQuickAppWizard::parameters()
94 {
95     Core::BaseFileWizardParameters parameters(ProjectWizard);
96     parameters.setIcon(QIcon(QLatin1String(Constants::ICON_QTQUICK_APP)));
97     parameters.setDisplayName(tr("Qt Quick Application"));
98     parameters.setId(QLatin1String("QA.QMLA Application"));
99     parameters.setDescription(tr("Creates a Qt Quick application project that can contain "
100                                  "both QML and C++ code and includes a QDeclarativeView.\n\n"
101                                  "You can build the application and deploy it on desktop and "
102                                  "mobile target platforms. For example, you can create signed "
103                                  "Symbian Installation System (SIS) packages for this type of "
104                                  "projects."));
105     parameters.setCategory(QLatin1String(Constants::QML_WIZARD_CATEGORY));
106     parameters.setDisplayCategory(QCoreApplication::translate(Constants::QML_WIZARD_TR_SCOPE,
107                                                               Constants::QML_WIZARD_TR_CATEGORY));
108     return parameters;
109 }
110
111 AbstractMobileAppWizardDialog *QtQuickAppWizard::createWizardDialogInternal(QWidget *parent) const
112 {
113     m_d->wizardDialog = new QtQuickAppWizardDialog(parent);
114     return m_d->wizardDialog;
115 }
116
117 void QtQuickAppWizard::projectPathChanged(const QString &path) const
118 {
119     m_d->wizardDialog->targetsPage()->setProFilePath(path);
120 }
121
122 void QtQuickAppWizard::prepareGenerateFiles(const QWizard *w,
123     QString *errorMessage) const
124 {
125     Q_UNUSED(errorMessage)
126     const QtQuickAppWizardDialog *wizard = qobject_cast<const QtQuickAppWizardDialog*>(w);
127     if (wizard->m_qmlSourcesPage->mainQmlMode() == QtQuickApp::ModeGenerate) {
128         m_d->app->setMainQml(QtQuickApp::ModeGenerate);
129     } else {
130         const QString mainQmlFile = wizard->m_qmlSourcesPage->mainQmlFile();
131         m_d->app->setMainQml(QtQuickApp::ModeImport, mainQmlFile);
132     }
133 }
134
135 QString QtQuickAppWizard::fileToOpenPostGeneration() const
136 {
137     return m_d->app->path(QtQuickApp::MainQml);
138 }
139
140 AbstractMobileApp *QtQuickAppWizard::app() const
141 {
142     return m_d->app;
143 }
144
145 AbstractMobileAppWizardDialog *QtQuickAppWizard::wizardDialog() const
146 {
147     return m_d->wizardDialog;
148 }
149
150 } // namespace Internal
151 } // namespace Qt4ProjectManager
152
153 #include "qtquickappwizard.moc"