qtquickappwizard.cpp 6.55 KB
Newer Older
1 2 3 4
/**************************************************************************
**
** This file is part of Qt Creator
**
con's avatar
con committed
5
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6
**
hjk's avatar
hjk committed
7
** Contact: Nokia Corporation (info@qt.nokia.com)
8 9 10 11
**
**
** GNU Lesser General Public License Usage
**
hjk's avatar
hjk committed
12 13 14 15 16 17
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18
**
con's avatar
con committed
19
** In addition, as a special exception, Nokia gives you certain additional
hjk's avatar
hjk committed
20
** rights. These rights are described in the Nokia Qt LGPL Exception
con's avatar
con committed
21 22
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
23 24 25 26 27
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
con's avatar
con committed
28
** If you have questions regarding the use of this file, please contact
Tobias Hunger's avatar
Tobias Hunger committed
29
** Nokia at info@qt.nokia.com.
30 31 32
**
**************************************************************************/

33
#include "mobileappwizardpages.h"
34

35 36 37
#include "qtquickapp.h"
#include "qtquickappwizard.h"
#include "qtquickappwizardpages.h"
38
#include "targetsetuppage.h"
39
#include "qt4projectmanagerconstants.h"
40

41 42
#include <qtsupport/qtsupportconstants.h>

43
#include <QtCore/QCoreApplication>
44
#include <QtGui/QIcon>
45

46
namespace Qt4ProjectManager {
47 48
namespace Internal {

49
class QtQuickAppWizardDialog : public AbstractMobileAppWizardDialog
50 51 52 53
{
    Q_OBJECT

public:
54
    explicit QtQuickAppWizardDialog(QWidget *parent = 0);
55

Feetu Nyrhinen's avatar
Feetu Nyrhinen committed
56 57 58
protected:
    bool validateCurrentPage();

59
private:
60
    class QtQuickAppWizardSourcesPage *m_qmlSourcesPage;
Feetu Nyrhinen's avatar
Feetu Nyrhinen committed
61 62 63 64 65
    class QtQuickComponentSetOptionsPage *m_componentOptionsPage;
    int m_componentOptionsPageId;

    Utils::WizardProgressItem *m_componentItem;

66
    friend class QtQuickAppWizard;
67 68
};

69
QtQuickAppWizardDialog::QtQuickAppWizardDialog(QWidget *parent)
Feetu Nyrhinen's avatar
Feetu Nyrhinen committed
70
    : AbstractMobileAppWizardDialog(parent, QtSupport::QtVersionNumber(4, 7, 1))
71
    , m_qmlSourcesPage(0)
72
{
73 74 75
    setWindowTitle(tr("New Qt Quick Application"));
    setIntroDescription(tr("This wizard generates a Qt Quick application project."));

Feetu Nyrhinen's avatar
Feetu Nyrhinen committed
76 77 78 79 80 81 82 83 84
    m_componentOptionsPage = new Internal::QtQuickComponentSetOptionsPage;
    m_componentOptionsPageId = addPageWithTitle(m_componentOptionsPage, tr("Component Set"));
    m_componentItem = wizardProgress()->item(m_componentOptionsPageId);

    AbstractMobileAppWizardDialog::addMobilePages();

    m_componentItem->setNextItems(QList<Utils::WizardProgressItem *>()
                                  << targetsPageItem());

85
    m_qmlSourcesPage = new QtQuickAppWizardSourcesPage;
86
    addPageWithTitle(m_qmlSourcesPage, tr("QML Sources"));
87 88
}

Feetu Nyrhinen's avatar
Feetu Nyrhinen committed
89 90 91 92 93 94 95 96 97 98
bool QtQuickAppWizardDialog::validateCurrentPage()
{
    if (currentPage() == m_componentOptionsPage) {
        if (m_componentOptionsPage->componentSet() == QtQuickApp::Symbian10Components) {
            setIgnoreGenericOptionsPage(true);
            targetsPage()->setMinimumQtVersion(QtSupport::QtVersionNumber(4, 7, 3));
        }
    }
    return AbstractMobileAppWizardDialog::validateCurrentPage();
}
99

100
class QtQuickAppWizardPrivate
101
{
102
    class QtQuickApp *app;
103
    class QtQuickAppWizardDialog *wizardDialog;
104
    friend class QtQuickAppWizard;
105 106
};

107
QtQuickAppWizard::QtQuickAppWizard()
108
    : AbstractMobileAppWizard(parameters())
109
    , m_d(new QtQuickAppWizardPrivate)
110
{
111
    m_d->app = new QtQuickApp;
112
    m_d->wizardDialog = 0;
113 114
}

115
QtQuickAppWizard::~QtQuickAppWizard()
116
{
117
    delete m_d->app;
118
    delete m_d;
119 120
}

121
Core::BaseFileWizardParameters QtQuickAppWizard::parameters()
122 123
{
    Core::BaseFileWizardParameters parameters(ProjectWizard);
124
    parameters.setIcon(QIcon(QLatin1String(Qt4ProjectManager::Constants::ICON_QTQUICK_APP)));
125 126
    parameters.setDisplayName(tr("Qt Quick Application"));
    parameters.setId(QLatin1String("QA.QMLA Application"));
127 128 129 130 131
    parameters.setDescription(tr("Creates a Qt Quick application project that can contain "
                                 "both QML and C++ code and includes a QDeclarativeView.\n\n"
                                 "You can build the application and deploy it on desktop and "
                                 "mobile target platforms. For example, you can create signed "
                                 "Symbian Installation System (SIS) packages for this type of "
Feetu Nyrhinen's avatar
Feetu Nyrhinen committed
132 133 134
                                 "projects. Moreover, you can select to use a set of premade "
                                 "UI components in your Qt Quick application. "
                                 "To utilize the components, Qt 4.7.3 or newer is required."));
135 136 137
    parameters.setCategory(QLatin1String(QtSupport::Constants::QML_WIZARD_CATEGORY));
    parameters.setDisplayCategory(QCoreApplication::translate(QtSupport::Constants::QML_WIZARD_TR_SCOPE,
                                                              QtSupport::Constants::QML_WIZARD_TR_CATEGORY));
138 139 140
    return parameters;
}

141
AbstractMobileAppWizardDialog *QtQuickAppWizard::createWizardDialogInternal(QWidget *parent) const
142
{
143
    m_d->wizardDialog = new QtQuickAppWizardDialog(parent);
Feetu Nyrhinen's avatar
Feetu Nyrhinen committed
144
    m_d->wizardDialog->m_componentOptionsPage->setComponentSet(m_d->app->componentSet());
145 146 147
    return m_d->wizardDialog;
}

148
void QtQuickAppWizard::projectPathChanged(const QString &path) const
149
{
150
    m_d->wizardDialog->targetsPage()->setProFilePath(path);
151 152
}

153
void QtQuickAppWizard::prepareGenerateFiles(const QWizard *w,
154
    QString *errorMessage) const
155 156
{
    Q_UNUSED(errorMessage)
157
    const QtQuickAppWizardDialog *wizard = qobject_cast<const QtQuickAppWizardDialog*>(w);
158 159 160 161 162 163
    if (wizard->m_qmlSourcesPage->mainQmlMode() == QtQuickApp::ModeGenerate) {
        m_d->app->setMainQml(QtQuickApp::ModeGenerate);
    } else {
        const QString mainQmlFile = wizard->m_qmlSourcesPage->mainQmlFile();
        m_d->app->setMainQml(QtQuickApp::ModeImport, mainQmlFile);
    }
Feetu Nyrhinen's avatar
Feetu Nyrhinen committed
164 165 166
    m_d->app->setComponentSet(wizard->m_componentOptionsPage->componentSet());
    if (m_d->app->componentSet() == QtQuickApp::Symbian10Components)
        m_d->app->setOrientation(AbstractMobileApp::ScreenOrientationImplicit);
167 168
}

169
QString QtQuickAppWizard::fileToOpenPostGeneration() const
170
{
171
    return m_d->app->path(QtQuickApp::MainQml);
172 173
}

174
AbstractMobileApp *QtQuickAppWizard::app() const
175
{
176
    return m_d->app;
177 178
}

179
AbstractMobileAppWizardDialog *QtQuickAppWizard::wizardDialog() const
180 181 182 183
{
    return m_d->wizardDialog;
}

184
} // namespace Internal
185
} // namespace Qt4ProjectManager
186

187
#include "qtquickappwizard.moc"