2010-07-15 11:58:37 +02:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2011-01-11 16:28:15 +01:00
|
|
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
2010-07-15 11:58:37 +02:00
|
|
|
**
|
|
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** No Commercial Usage
|
2010-07-15 11:58:37 +02:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** This file contains pre-release code and may not be distributed.
|
|
|
|
|
** You may use this file in accordance with the terms and conditions
|
|
|
|
|
** contained in the Technology Preview License Agreement accompanying
|
|
|
|
|
** this package.
|
2010-07-15 11:58:37 +02:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, 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-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
|
|
|
|
** If you have questions regarding the use of this file, please contact
|
|
|
|
|
** 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
|
|
|
|
2010-09-17 12:58:19 +02:00
|
|
|
#include "qmlstandaloneapp.h"
|
2010-07-15 11:58:37 +02:00
|
|
|
#include "qmlstandaloneappwizard.h"
|
2010-07-20 17:21:18 +02:00
|
|
|
#include "qmlstandaloneappwizardpages.h"
|
2010-09-21 08:51:52 +02:00
|
|
|
#include "targetsetuppage.h"
|
2010-07-15 11:58:37 +02:00
|
|
|
|
2010-08-25 14:25:18 +02:00
|
|
|
#include "qt4projectmanagerconstants.h"
|
2010-07-15 11:58:37 +02:00
|
|
|
|
2010-07-20 17:21:18 +02:00
|
|
|
#include <projectexplorer/baseprojectwizarddialog.h>
|
2010-07-15 11:58:37 +02:00
|
|
|
#include <projectexplorer/customwizard/customwizard.h>
|
2010-07-20 17:21:18 +02:00
|
|
|
#include <projectexplorer/projectexplorer.h>
|
|
|
|
|
#include <coreplugin/editormanager/editormanager.h>
|
2010-07-15 11:58:37 +02:00
|
|
|
|
|
|
|
|
#include <QtCore/QCoreApplication>
|
2010-09-17 12:58:19 +02:00
|
|
|
#include <QtGui/QIcon>
|
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 {
|
|
|
|
|
|
2010-09-17 12:58:19 +02:00
|
|
|
class QmlStandaloneAppWizardDialog : public AbstractMobileAppWizardDialog
|
2010-07-15 11:58:37 +02:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2010-10-02 17:51:36 +02:00
|
|
|
explicit QmlStandaloneAppWizardDialog(QWidget *parent = 0);
|
2010-07-15 11:58:37 +02:00
|
|
|
|
|
|
|
|
private:
|
2010-07-20 17:21:18 +02:00
|
|
|
class QmlStandaloneAppWizardSourcesPage *m_qmlSourcesPage;
|
|
|
|
|
friend class QmlStandaloneAppWizard;
|
2010-07-15 11:58:37 +02:00
|
|
|
};
|
|
|
|
|
|
2010-10-02 17:51:36 +02:00
|
|
|
QmlStandaloneAppWizardDialog::QmlStandaloneAppWizardDialog(QWidget *parent)
|
2010-09-17 12:58:19 +02:00
|
|
|
: AbstractMobileAppWizardDialog(parent)
|
2010-09-22 14:22:57 +02:00
|
|
|
, m_qmlSourcesPage(0)
|
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."));
|
|
|
|
|
|
|
|
|
|
m_qmlSourcesPage = new QmlStandaloneAppWizardSourcesPage;
|
2010-12-01 16:55:42 +01:00
|
|
|
addPageWithTitle(m_qmlSourcesPage, tr("QML Sources"));
|
2010-07-15 11:58:37 +02:00
|
|
|
}
|
|
|
|
|
|
2010-12-01 16:55:42 +01:00
|
|
|
|
2010-07-20 17:21:18 +02:00
|
|
|
class QmlStandaloneAppWizardPrivate
|
|
|
|
|
{
|
|
|
|
|
class QmlStandaloneApp *standaloneApp;
|
|
|
|
|
class QmlStandaloneAppWizardDialog *wizardDialog;
|
|
|
|
|
friend class QmlStandaloneAppWizard;
|
|
|
|
|
};
|
|
|
|
|
|
2010-10-02 17:51:36 +02:00
|
|
|
QmlStandaloneAppWizard::QmlStandaloneAppWizard()
|
|
|
|
|
: AbstractMobileAppWizard(parameters())
|
2010-07-20 17:21:18 +02:00
|
|
|
, m_d(new QmlStandaloneAppWizardPrivate)
|
2010-07-15 11:58:37 +02:00
|
|
|
{
|
2010-07-20 17:21:18 +02:00
|
|
|
m_d->standaloneApp = new QmlStandaloneApp;
|
|
|
|
|
m_d->wizardDialog = 0;
|
2010-07-15 11:58:37 +02:00
|
|
|
}
|
|
|
|
|
|
2010-07-20 17:21:18 +02:00
|
|
|
QmlStandaloneAppWizard::~QmlStandaloneAppWizard()
|
2010-07-15 11:58:37 +02:00
|
|
|
{
|
2010-07-20 17:21:18 +02:00
|
|
|
delete m_d->standaloneApp;
|
2010-09-17 12:58:19 +02:00
|
|
|
delete m_d;
|
2010-07-15 11:58:37 +02:00
|
|
|
}
|
|
|
|
|
|
2010-10-02 17:51:36 +02:00
|
|
|
Core::BaseFileWizardParameters QmlStandaloneAppWizard::parameters()
|
2010-07-15 11:58:37 +02:00
|
|
|
{
|
|
|
|
|
Core::BaseFileWizardParameters parameters(ProjectWizard);
|
2010-08-25 14:25:18 +02:00
|
|
|
parameters.setIcon(QIcon(QLatin1String(Constants::ICON_QML_STANDALONE)));
|
2010-10-02 17:51:36 +02:00
|
|
|
parameters.setDisplayName(tr("Qt Quick Application"));
|
|
|
|
|
parameters.setId(QLatin1String("QA.QMLA Application"));
|
2010-10-07 17:02:20 +02:00
|
|
|
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 "
|
|
|
|
|
"projects."));
|
2010-10-04 14:50:58 +02:00
|
|
|
parameters.setCategory(QLatin1String(Constants::QML_WIZARD_CATEGORY));
|
|
|
|
|
parameters.setDisplayCategory(QCoreApplication::translate(Constants::QML_WIZARD_TR_SCOPE,
|
|
|
|
|
Constants::QML_WIZARD_TR_CATEGORY));
|
2010-07-15 11:58:37 +02:00
|
|
|
return parameters;
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-17 12:58:19 +02:00
|
|
|
AbstractMobileAppWizardDialog *QmlStandaloneAppWizard::createWizardDialogInternal(QWidget *parent) const
|
2010-07-15 11:58:37 +02:00
|
|
|
{
|
2010-10-02 17:51:36 +02:00
|
|
|
m_d->wizardDialog = new QmlStandaloneAppWizardDialog(parent);
|
2010-09-21 08:51:52 +02:00
|
|
|
const QList<TargetSetupPage::ImportInfo> &qtVersions
|
|
|
|
|
= TargetSetupPage::importInfosForKnownQtVersions();
|
|
|
|
|
QList<TargetSetupPage::ImportInfo> qmlQtVersions;
|
|
|
|
|
foreach (const TargetSetupPage::ImportInfo &qtVersion, qtVersions) {
|
|
|
|
|
const QString versionString = qtVersion.version->qtVersionString();
|
|
|
|
|
bool isNumber;
|
|
|
|
|
const int majorVersion = versionString.mid(0, 1).toInt(&isNumber);
|
|
|
|
|
if (!isNumber || majorVersion < 4)
|
|
|
|
|
continue;
|
|
|
|
|
const int minorVersion = versionString.mid(2, 1).toInt(&isNumber);
|
2010-09-28 11:21:30 +02:00
|
|
|
if (!isNumber || (majorVersion == 4 && minorVersion < 7))
|
2010-09-21 08:51:52 +02:00
|
|
|
continue;
|
|
|
|
|
qmlQtVersions << qtVersion;
|
|
|
|
|
}
|
|
|
|
|
m_d->wizardDialog->m_targetsPage->setImportInfos(qmlQtVersions);
|
|
|
|
|
|
2010-07-20 17:21:18 +02:00
|
|
|
return m_d->wizardDialog;
|
2010-07-15 11:58:37 +02:00
|
|
|
}
|
|
|
|
|
|
2010-09-17 12:58:19 +02:00
|
|
|
void QmlStandaloneAppWizard::prepareGenerateFiles(const QWizard *w,
|
|
|
|
|
QString *errorMessage) const
|
2010-07-15 11:58:37 +02:00
|
|
|
{
|
|
|
|
|
Q_UNUSED(errorMessage)
|
2010-07-20 17:21:18 +02:00
|
|
|
const QmlStandaloneAppWizardDialog *wizard = qobject_cast<const QmlStandaloneAppWizardDialog*>(w);
|
2010-10-02 17:51:36 +02:00
|
|
|
const QString mainQmlFile = wizard->m_qmlSourcesPage->mainQmlFile();
|
|
|
|
|
if (!mainQmlFile.isEmpty())
|
|
|
|
|
m_d->standaloneApp->setMainQmlFile(mainQmlFile);
|
2010-07-15 11:58:37 +02:00
|
|
|
}
|
|
|
|
|
|
2010-09-21 08:51:52 +02:00
|
|
|
bool QmlStandaloneAppWizard::postGenerateFilesInternal(const Core::GeneratedFiles &l,
|
|
|
|
|
QString *errorMessage)
|
2010-07-15 11:58:37 +02:00
|
|
|
{
|
2010-07-20 17:21:18 +02:00
|
|
|
const bool success = ProjectExplorer::CustomProjectWizard::postGenerateOpen(l, errorMessage);
|
2010-10-02 17:51:36 +02:00
|
|
|
if (success && !m_d->standaloneApp->mainQmlFile().isEmpty()) {
|
2010-07-20 17:21:18 +02:00
|
|
|
ProjectExplorer::ProjectExplorerPlugin::instance()->setCurrentFile(0, m_d->standaloneApp->mainQmlFile());
|
2010-09-14 15:15:57 +02:00
|
|
|
Core::EditorManager::instance()->openEditor(m_d->standaloneApp->mainQmlFile(),
|
|
|
|
|
QString(), Core::EditorManager::ModeSwitch);
|
2010-07-20 17:21:18 +02:00
|
|
|
}
|
|
|
|
|
return success;
|
2010-07-15 11:58:37 +02:00
|
|
|
}
|
|
|
|
|
|
2010-09-17 12:58:19 +02:00
|
|
|
AbstractMobileApp *QmlStandaloneAppWizard::app() const
|
|
|
|
|
{
|
|
|
|
|
return m_d->standaloneApp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AbstractMobileAppWizardDialog *QmlStandaloneAppWizard::wizardDialog() const
|
|
|
|
|
{
|
|
|
|
|
return m_d->wizardDialog;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
#include "qmlstandaloneappwizard.moc"
|