2010-07-15 11:58:37 +02:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2012-01-26 18:33:46 +01:00
|
|
|
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2010-07-15 11:58:37 +02:00
|
|
|
**
|
2011-11-02 15:59:12 +01:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2010-07-15 11:58:37 +02:00
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** 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.
|
2010-07-15 11:58:37 +02:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** 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.
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-11-02 15:59:12 +01:00
|
|
|
** Nokia at qt-info@nokia.com.
|
2010-07-15 11:58:37 +02:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
2010-09-16 16:53:59 +02:00
|
|
|
#include "mobileappwizardpages.h"
|
2010-09-21 08:51:52 +02:00
|
|
|
|
2011-02-06 16:23:02 +01:00
|
|
|
#include "qtquickapp.h"
|
|
|
|
|
#include "qtquickappwizard.h"
|
|
|
|
|
#include "qtquickappwizardpages.h"
|
2010-09-21 08:51:52 +02:00
|
|
|
#include "targetsetuppage.h"
|
2010-08-25 14:25:18 +02:00
|
|
|
#include "qt4projectmanagerconstants.h"
|
2010-07-15 11:58:37 +02:00
|
|
|
|
2011-05-20 21:40:53 +02:00
|
|
|
#include <qtsupport/qtsupportconstants.h>
|
2012-02-08 17:25:35 +01:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2012-01-18 13:50:14 +01:00
|
|
|
#include <coreplugin/dialogs/iwizard.h>
|
2011-05-20 21:40:53 +02:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QCoreApplication>
|
|
|
|
|
#include <QIcon>
|
|
|
|
|
#include <QDebug>
|
2010-07-15 11:58:37 +02:00
|
|
|
|
2010-08-25 14:25:18 +02:00
|
|
|
namespace Qt4ProjectManager {
|
2010-07-15 11:58:37 +02:00
|
|
|
namespace Internal {
|
|
|
|
|
|
2011-02-07 12:47:07 +01:00
|
|
|
class QtQuickAppWizardDialog : public AbstractMobileAppWizardDialog
|
2010-07-15 11:58:37 +02:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2012-02-14 14:02:47 +01:00
|
|
|
explicit QtQuickAppWizardDialog(QWidget *parent, const Core::WizardDialogParameters ¶meters,
|
|
|
|
|
QtQuickAppWizard::Kind kind);
|
2010-07-15 11:58:37 +02:00
|
|
|
|
2011-06-10 15:40:57 +03:00
|
|
|
protected:
|
|
|
|
|
bool validateCurrentPage();
|
|
|
|
|
|
2010-07-15 11:58:37 +02:00
|
|
|
private:
|
2012-02-14 14:02:47 +01:00
|
|
|
QtQuickComponentSetOptionsPage *m_componentOptionsPage;
|
2011-06-10 15:40:57 +03:00
|
|
|
int m_componentOptionsPageId;
|
|
|
|
|
|
|
|
|
|
Utils::WizardProgressItem *m_componentItem;
|
|
|
|
|
|
2011-02-06 16:23:02 +01:00
|
|
|
friend class QtQuickAppWizard;
|
2010-07-15 11:58:37 +02:00
|
|
|
};
|
|
|
|
|
|
2012-02-03 18:00:08 +01:00
|
|
|
QtQuickAppWizardDialog::QtQuickAppWizardDialog(QWidget *parent,
|
2012-02-14 14:02:47 +01:00
|
|
|
const Core::WizardDialogParameters ¶meters,
|
|
|
|
|
QtQuickAppWizard::Kind kind)
|
2012-02-03 18:00:08 +01:00
|
|
|
: AbstractMobileAppWizardDialog(parent,
|
|
|
|
|
QtSupport::QtVersionNumber(4, 7, 0),
|
|
|
|
|
QtSupport::QtVersionNumber(4, INT_MAX, INT_MAX), parameters)
|
2010-07-15 11:58:37 +02:00
|
|
|
{
|
2010-10-02 17:51:36 +02:00
|
|
|
setWindowTitle(tr("New Qt Quick Application"));
|
|
|
|
|
setIntroDescription(tr("This wizard generates a Qt Quick application project."));
|
|
|
|
|
|
2012-02-14 14:02:47 +01:00
|
|
|
if (kind == QtQuickAppWizard::ImportQml) { //Choose existing qml file
|
|
|
|
|
m_componentOptionsPage = new Internal::QtQuickComponentSetOptionsPage;
|
|
|
|
|
m_componentOptionsPageId = addPageWithTitle(m_componentOptionsPage, tr("Select existing QML file"));
|
|
|
|
|
m_componentItem = wizardProgress()->item(m_componentOptionsPageId);
|
|
|
|
|
}
|
2011-06-10 15:40:57 +03:00
|
|
|
|
|
|
|
|
AbstractMobileAppWizardDialog::addMobilePages();
|
|
|
|
|
|
2012-02-14 14:02:47 +01:00
|
|
|
if (kind == QtQuickAppWizard::ImportQml) {
|
|
|
|
|
m_componentItem->setNextItems(QList<Utils::WizardProgressItem *>()
|
|
|
|
|
<< targetsPageItem());
|
|
|
|
|
}
|
2010-07-15 11:58:37 +02:00
|
|
|
}
|
|
|
|
|
|
2011-06-10 15:40:57 +03:00
|
|
|
bool QtQuickAppWizardDialog::validateCurrentPage()
|
|
|
|
|
{
|
|
|
|
|
if (currentPage() == m_componentOptionsPage) {
|
2011-07-07 17:25:52 +02:00
|
|
|
setIgnoreGenericOptionsPage(false);
|
2011-06-10 15:40:57 +03:00
|
|
|
}
|
|
|
|
|
return AbstractMobileAppWizardDialog::validateCurrentPage();
|
|
|
|
|
}
|
2010-12-01 16:55:42 +01:00
|
|
|
|
2011-02-06 16:23:02 +01:00
|
|
|
class QtQuickAppWizardPrivate
|
2010-07-20 17:21:18 +02:00
|
|
|
{
|
2011-02-06 16:23:02 +01:00
|
|
|
class QtQuickApp *app;
|
2011-02-07 12:47:07 +01:00
|
|
|
class QtQuickAppWizardDialog *wizardDialog;
|
2012-02-14 14:02:47 +01:00
|
|
|
QtQuickAppWizard::Kind kind;
|
2011-02-06 16:23:02 +01:00
|
|
|
friend class QtQuickAppWizard;
|
2010-07-20 17:21:18 +02:00
|
|
|
};
|
|
|
|
|
|
2011-02-06 16:23:02 +01:00
|
|
|
QtQuickAppWizard::QtQuickAppWizard()
|
2012-02-14 14:02:47 +01:00
|
|
|
: AbstractMobileAppWizard(baseParameters())
|
2011-09-15 13:42:38 +02:00
|
|
|
, d(new QtQuickAppWizardPrivate)
|
2010-07-15 11:58:37 +02:00
|
|
|
{
|
2011-09-15 13:42:38 +02:00
|
|
|
d->app = new QtQuickApp;
|
|
|
|
|
d->wizardDialog = 0;
|
2010-07-15 11:58:37 +02:00
|
|
|
}
|
|
|
|
|
|
2012-02-14 14:02:47 +01:00
|
|
|
QtQuickAppWizard::QtQuickAppWizard(const Core::BaseFileWizardParameters ¶ms, QObject *parent)
|
|
|
|
|
: AbstractMobileAppWizard(params, parent)
|
|
|
|
|
, d(new QtQuickAppWizardPrivate)
|
|
|
|
|
{
|
|
|
|
|
d->app = new QtQuickApp;
|
|
|
|
|
d->wizardDialog = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-06 16:23:02 +01:00
|
|
|
QtQuickAppWizard::~QtQuickAppWizard()
|
2010-07-15 11:58:37 +02:00
|
|
|
{
|
2011-09-15 13:42:38 +02:00
|
|
|
delete d->app;
|
|
|
|
|
delete d;
|
2010-07-15 11:58:37 +02:00
|
|
|
}
|
|
|
|
|
|
2012-02-14 14:02:47 +01:00
|
|
|
void QtQuickAppWizard::createInstances(ExtensionSystem::IPlugin *plugin)
|
2012-01-18 13:50:14 +01:00
|
|
|
{
|
2012-02-14 14:02:47 +01:00
|
|
|
Core::BaseFileWizardParameters base = baseParameters();
|
|
|
|
|
QList<Core::BaseFileWizardParameters> list;
|
|
|
|
|
Core::BaseFileWizardParameters parameter;
|
|
|
|
|
|
|
|
|
|
const QString basicDescription = tr("Creates a Qt Quick application project that can contain "
|
|
|
|
|
"both QML and C++ code and includes a QDeclarativeView.\n\n");
|
|
|
|
|
|
|
|
|
|
Core::FeatureSet basicFeatures;
|
|
|
|
|
basicFeatures = Core::Feature(QtSupport::Constants::FEATURE_QT_QUICK_1_1);
|
|
|
|
|
|
|
|
|
|
parameter = base;
|
|
|
|
|
parameter.setDisplayName(tr("Qt Quick Application (Built-in elements)"));
|
|
|
|
|
parameter.setDescription(basicDescription + tr("The built-in elements in the QtQuick namespace allow "
|
|
|
|
|
"you to write cross-platform applications with "
|
|
|
|
|
"a custom look and feel.\n\nRequires Qt 4.7.1 or newer."));
|
|
|
|
|
parameter.setRequiredFeatures(basicFeatures);
|
|
|
|
|
list << parameter;
|
|
|
|
|
|
|
|
|
|
parameter = base;
|
|
|
|
|
parameter.setDisplayName(tr("Qt Quick Application for Symbian"));
|
|
|
|
|
parameter.setDescription(basicDescription + tr("The Qt Quick Components for Symbian are a set of "
|
|
|
|
|
"ready-made components that are designed with specific "
|
|
|
|
|
"native appearance for the Symbian platform.\n\nRequires "
|
|
|
|
|
"Qt 4.7.4 or newer, and the component set installed for "
|
|
|
|
|
"your Qt version."));
|
|
|
|
|
parameter.setRequiredFeatures(basicFeatures | Core::Feature(QtSupport::Constants::FEATURE_QTQUICK_COMPONENTS_SYMBIAN));
|
|
|
|
|
list << parameter;
|
|
|
|
|
|
|
|
|
|
parameter = base;
|
|
|
|
|
parameter.setDisplayName(tr("Qt Quick Application for MeeGo/Harmattan"));
|
|
|
|
|
parameter.setDescription(basicDescription + tr("The Qt Quick Components for MeeGo/Harmattan are "
|
|
|
|
|
"a set of ready-made components that are designed "
|
|
|
|
|
"with specific native appearance for the MeeGo/Harmattan "
|
|
|
|
|
"platform.\n\nRequires Qt 4.7.4 or newer, and the "
|
|
|
|
|
"component set installed for your Qt version."));
|
|
|
|
|
parameter.setRequiredFeatures(basicFeatures | Core::Feature(QtSupport::Constants::FEATURE_QTQUICK_COMPONENTS_MEEGO));
|
|
|
|
|
list << parameter;
|
|
|
|
|
|
|
|
|
|
parameter = base;
|
|
|
|
|
parameter.setDisplayName(tr("Qt Quick Application (from existing .qml file)"));
|
|
|
|
|
parameter.setDescription(basicDescription + tr("Creates a deployable Qt Quick application from "
|
|
|
|
|
"existing QML files. All files and directories that "
|
|
|
|
|
"reside in the same directory as the main QML file "
|
|
|
|
|
"are deployed. You can modify the contents of the "
|
|
|
|
|
"directory any time before deploying."));
|
|
|
|
|
parameter.setRequiredFeatures(basicFeatures);
|
|
|
|
|
list << parameter;
|
|
|
|
|
|
|
|
|
|
QList<QtQuickAppWizard*> wizardList = Core::createMultipleBaseFileWizardInstances<QtQuickAppWizard>(list, plugin);
|
|
|
|
|
|
|
|
|
|
Q_ASSERT(wizardList.count() == 4);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < wizardList.count(); i++) {
|
|
|
|
|
wizardList.at(i)->setQtQuickKind(Kind(i));
|
|
|
|
|
}
|
2012-01-18 13:50:14 +01:00
|
|
|
}
|
|
|
|
|
|
2012-02-14 14:02:47 +01:00
|
|
|
Core::BaseFileWizardParameters QtQuickAppWizard::baseParameters()
|
2010-07-15 11:58:37 +02:00
|
|
|
{
|
|
|
|
|
Core::BaseFileWizardParameters parameters(ProjectWizard);
|
2011-05-20 21:40:53 +02:00
|
|
|
parameters.setIcon(QIcon(QLatin1String(Qt4ProjectManager::Constants::ICON_QTQUICK_APP)));
|
2012-02-22 11:53:58 +01:00
|
|
|
parameters.setId(QLatin1String("D.QMLA Application"));
|
2012-02-08 17:25:35 +01:00
|
|
|
parameters.setCategory(QLatin1String(ProjectExplorer::Constants::QT_APPLICATION_WIZARD_CATEGORY));
|
|
|
|
|
parameters.setDisplayCategory(ProjectExplorer::Constants::QT_APPLICATION_WIZARD_CATEGORY_DISPLAY);
|
2012-02-14 14:02:47 +01:00
|
|
|
|
2010-07-15 11:58:37 +02:00
|
|
|
return parameters;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-03 18:00:08 +01:00
|
|
|
AbstractMobileAppWizardDialog *QtQuickAppWizard::createWizardDialogInternal(QWidget *parent,
|
|
|
|
|
const Core::WizardDialogParameters ¶meters) const
|
2010-07-15 11:58:37 +02:00
|
|
|
{
|
2012-02-14 14:02:47 +01:00
|
|
|
d->wizardDialog = new QtQuickAppWizardDialog(parent, parameters, qtQuickKind());
|
|
|
|
|
|
|
|
|
|
switch (qtQuickKind()) {
|
|
|
|
|
case QtQuick1_1:
|
|
|
|
|
d->app->setComponentSet(QtQuickApp::QtQuick10Components);
|
|
|
|
|
d->app->setMainQml(QtQuickApp::ModeGenerate);
|
|
|
|
|
break;
|
|
|
|
|
case SymbianComponents:
|
|
|
|
|
d->app->setComponentSet(QtQuickApp::Symbian11Components);
|
|
|
|
|
d->app->setMainQml(QtQuickApp::ModeGenerate);
|
|
|
|
|
break;
|
|
|
|
|
case MeegoComponents:
|
|
|
|
|
d->app->setComponentSet(QtQuickApp::Meego10Components);
|
|
|
|
|
d->app->setMainQml(QtQuickApp::ModeGenerate);
|
|
|
|
|
break;
|
|
|
|
|
case ImportQml:
|
|
|
|
|
d->app->setComponentSet(QtQuickApp::QtQuick10Components);
|
|
|
|
|
d->app->setMainQml(QtQuickApp::ModeImport);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
qWarning() << "QtQuickAppWizard illegal subOption:" << qtQuickKind();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-15 13:42:38 +02:00
|
|
|
return d->wizardDialog;
|
2010-12-10 19:02:19 +01:00
|
|
|
}
|
|
|
|
|
|
2011-02-06 16:23:02 +01:00
|
|
|
void QtQuickAppWizard::projectPathChanged(const QString &path) const
|
2010-12-10 19:02:19 +01:00
|
|
|
{
|
2011-09-15 13:42:38 +02:00
|
|
|
d->wizardDialog->targetsPage()->setProFilePath(path);
|
2010-07-15 11:58:37 +02:00
|
|
|
}
|
|
|
|
|
|
2011-02-06 16:23:02 +01:00
|
|
|
void QtQuickAppWizard::prepareGenerateFiles(const QWizard *w,
|
2010-09-17 12:58:19 +02:00
|
|
|
QString *errorMessage) const
|
2010-07-15 11:58:37 +02:00
|
|
|
{
|
|
|
|
|
Q_UNUSED(errorMessage)
|
2011-02-07 12:47:07 +01:00
|
|
|
const QtQuickAppWizardDialog *wizard = qobject_cast<const QtQuickAppWizardDialog*>(w);
|
2012-02-14 14:02:47 +01:00
|
|
|
|
|
|
|
|
if (d->app->mainQmlMode() == QtQuickApp::ModeGenerate) {
|
2011-09-15 13:42:38 +02:00
|
|
|
d->app->setMainQml(QtQuickApp::ModeGenerate);
|
2011-02-09 21:39:46 +01:00
|
|
|
} else {
|
2011-06-29 16:43:22 +02:00
|
|
|
const QString mainQmlFile = wizard->m_componentOptionsPage->mainQmlFile();
|
2011-09-15 13:42:38 +02:00
|
|
|
d->app->setMainQml(QtQuickApp::ModeImport, mainQmlFile);
|
2011-02-09 21:39:46 +01:00
|
|
|
}
|
2012-02-14 14:02:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QtQuickAppWizard::setQtQuickKind(QtQuickAppWizard::Kind kind)
|
|
|
|
|
{
|
|
|
|
|
d->kind = kind;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QtQuickAppWizard::Kind QtQuickAppWizard::qtQuickKind() const
|
|
|
|
|
{
|
|
|
|
|
return d->kind;
|
2010-07-15 11:58:37 +02:00
|
|
|
}
|
|
|
|
|
|
2011-02-10 22:44:01 +01:00
|
|
|
QString QtQuickAppWizard::fileToOpenPostGeneration() const
|
2010-07-15 11:58:37 +02:00
|
|
|
{
|
2011-09-15 13:42:38 +02:00
|
|
|
return d->app->path(QtQuickApp::MainQml);
|
2010-07-15 11:58:37 +02:00
|
|
|
}
|
|
|
|
|
|
2011-02-06 16:23:02 +01:00
|
|
|
AbstractMobileApp *QtQuickAppWizard::app() const
|
2010-09-17 12:58:19 +02:00
|
|
|
{
|
2011-09-15 13:42:38 +02:00
|
|
|
return d->app;
|
2010-09-17 12:58:19 +02:00
|
|
|
}
|
|
|
|
|
|
2011-02-06 16:23:02 +01:00
|
|
|
AbstractMobileAppWizardDialog *QtQuickAppWizard::wizardDialog() const
|
2010-09-17 12:58:19 +02:00
|
|
|
{
|
2011-09-15 13:42:38 +02:00
|
|
|
return d->wizardDialog;
|
2010-09-17 12:58:19 +02:00
|
|
|
}
|
|
|
|
|
|
2010-07-15 11:58:37 +02:00
|
|
|
} // namespace Internal
|
2010-08-25 14:25:18 +02:00
|
|
|
} // namespace Qt4ProjectManager
|
2010-07-15 11:58:37 +02:00
|
|
|
|
2011-02-06 16:23:02 +01:00
|
|
|
#include "qtquickappwizard.moc"
|