2010-07-15 11:58:37 +02:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
|
|
|
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
|
|
|
**
|
|
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
|
|
|
**
|
|
|
|
|
** Commercial Usage
|
|
|
|
|
**
|
|
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Nokia.
|
|
|
|
|
**
|
|
|
|
|
** 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.
|
|
|
|
|
**
|
|
|
|
|
** If you are unsure which license is appropriate for your use, please
|
|
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
|
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "qmlstandaloneappwizard.h"
|
2010-07-20 17:21:18 +02:00
|
|
|
#include "qmlstandaloneappwizardpages.h"
|
2010-07-15 11:58:37 +02:00
|
|
|
#include "qmlstandaloneapp.h"
|
|
|
|
|
|
|
|
|
|
#include "qmlprojectconstants.h"
|
|
|
|
|
|
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 <QtGui/QIcon>
|
|
|
|
|
|
|
|
|
|
#include <QtGui/QPainter>
|
|
|
|
|
#include <QtGui/QPixmap>
|
|
|
|
|
|
|
|
|
|
#include <QtCore/QTextStream>
|
|
|
|
|
#include <QtCore/QCoreApplication>
|
|
|
|
|
#include <QtCore/QDir>
|
|
|
|
|
#include <QtCore/QFile>
|
|
|
|
|
|
|
|
|
|
namespace QmlProjectManager {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2010-07-20 17:21:18 +02:00
|
|
|
class QmlStandaloneAppWizardDialog : public ProjectExplorer::BaseProjectWizardDialog
|
2010-07-15 11:58:37 +02:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2010-07-20 17:21:18 +02:00
|
|
|
explicit QmlStandaloneAppWizardDialog(QmlStandaloneAppWizard::WizardType type, QWidget *parent = 0);
|
2010-07-15 11:58:37 +02:00
|
|
|
|
|
|
|
|
private:
|
2010-07-20 17:21:18 +02:00
|
|
|
QmlStandaloneAppWizard::WizardType m_type;
|
|
|
|
|
class QmlStandaloneAppWizardSourcesPage *m_qmlSourcesPage;
|
|
|
|
|
class QmlStandaloneAppWizardOptionsPage *m_qmlOptionsPage;
|
|
|
|
|
friend class QmlStandaloneAppWizard;
|
2010-07-15 11:58:37 +02:00
|
|
|
};
|
|
|
|
|
|
2010-07-20 17:21:18 +02:00
|
|
|
QmlStandaloneAppWizardDialog::QmlStandaloneAppWizardDialog(QmlStandaloneAppWizard::WizardType type,
|
|
|
|
|
QWidget *parent)
|
2010-07-15 11:58:37 +02:00
|
|
|
: ProjectExplorer::BaseProjectWizardDialog(parent)
|
2010-07-20 17:21:18 +02:00
|
|
|
, m_type(type)
|
2010-07-15 11:58:37 +02:00
|
|
|
{
|
2010-07-20 17:21:18 +02:00
|
|
|
setWindowTitle(m_type == QmlStandaloneAppWizard::NewQmlFile
|
|
|
|
|
? tr("New Standalone QML Project")
|
|
|
|
|
: tr("Standalone QML Project from existing QML Project"));
|
|
|
|
|
setIntroDescription(m_type == QmlStandaloneAppWizard::NewQmlFile
|
|
|
|
|
? tr("This wizard generates a Standalone QML application project.")
|
|
|
|
|
: tr("This wizard imports an existing QML application and creates a standalone version of it."));
|
|
|
|
|
|
|
|
|
|
m_qmlSourcesPage = new QmlStandaloneAppWizardSourcesPage;
|
|
|
|
|
m_qmlSourcesPage->setMainQmlFileChooserVisible(m_type == QmlStandaloneAppWizard::ImportQmlFile);
|
|
|
|
|
if (m_type == QmlStandaloneAppWizard::ImportQmlFile) {
|
|
|
|
|
const int qmlSourcesPagePageId = addPage(m_qmlSourcesPage);
|
|
|
|
|
wizardProgress()->item(qmlSourcesPagePageId)->setTitle(tr("Qml Sources"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_qmlOptionsPage = new QmlStandaloneAppWizardOptionsPage;
|
2010-07-15 11:58:37 +02:00
|
|
|
const int qmlOptionsPagePageId = addPage(m_qmlOptionsPage);
|
|
|
|
|
wizardProgress()->item(qmlOptionsPagePageId)->setTitle(tr("Qml App options"));
|
2010-08-18 23:22:09 +02:00
|
|
|
if (m_type == QmlStandaloneAppWizard::NewQmlFile) {
|
|
|
|
|
// In case of NewQmlFile, we show that page at the end. Is that useful? Or irritating?
|
|
|
|
|
const int qmlSourcesPagePageId = addPage(m_qmlSourcesPage);
|
|
|
|
|
wizardProgress()->item(qmlSourcesPagePageId)->setTitle(tr("Qml Sources"));
|
|
|
|
|
}
|
2010-07-15 11:58:37 +02:00
|
|
|
}
|
|
|
|
|
|
2010-07-20 17:21:18 +02:00
|
|
|
class QmlStandaloneAppWizardPrivate
|
|
|
|
|
{
|
|
|
|
|
QmlStandaloneAppWizard::WizardType type;
|
|
|
|
|
class QmlStandaloneApp *standaloneApp;
|
|
|
|
|
class QmlStandaloneAppWizardDialog *wizardDialog;
|
|
|
|
|
friend class QmlStandaloneAppWizard;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
QmlStandaloneAppWizard::QmlStandaloneAppWizard(WizardType type)
|
|
|
|
|
: Core::BaseFileWizard(parameters(type))
|
|
|
|
|
, m_d(new QmlStandaloneAppWizardPrivate)
|
2010-07-15 11:58:37 +02:00
|
|
|
{
|
2010-07-20 17:21:18 +02:00
|
|
|
m_d->type = type;
|
|
|
|
|
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-07-15 11:58:37 +02:00
|
|
|
}
|
|
|
|
|
|
2010-07-20 17:21:18 +02:00
|
|
|
Core::BaseFileWizardParameters QmlStandaloneAppWizard::parameters(WizardType type)
|
2010-07-15 11:58:37 +02:00
|
|
|
{
|
|
|
|
|
Core::BaseFileWizardParameters parameters(ProjectWizard);
|
|
|
|
|
parameters.setIcon(QIcon(QLatin1String(Constants::QML_WIZARD_ICON)));
|
2010-07-20 17:21:18 +02:00
|
|
|
parameters.setDisplayName(type == QmlStandaloneAppWizard::NewQmlFile
|
|
|
|
|
? tr("Qt QML New Standalone Application")
|
|
|
|
|
: tr("Qt QML Imported Standalone Application"));
|
|
|
|
|
parameters.setId(QLatin1String(type == QmlStandaloneAppWizard::NewQmlFile
|
|
|
|
|
? "QA.QML New Standalone Application"
|
|
|
|
|
: "QA.QML Imported Standalone Application"));
|
|
|
|
|
parameters.setDescription(type == QmlStandaloneAppWizard::NewQmlFile
|
|
|
|
|
? tr("Creates a standalone, mobile-deployable Qt QML application "
|
|
|
|
|
"project. A lightweight Qt/C++ application with a QDeclarativeView "
|
|
|
|
|
"and a single QML file will be created.")
|
|
|
|
|
: tr("Creates a standalone, mobile-deployable Qt QML application "
|
2010-07-29 14:59:09 +02:00
|
|
|
"project. An existing QML project will be imported and a lightweight "
|
2010-07-20 17:21:18 +02:00
|
|
|
"Qt/C++ application with a QDeclarativeView will be created for it."));
|
2010-07-15 11:58:37 +02:00
|
|
|
parameters.setCategory(QLatin1String(Constants::QML_WIZARD_CATEGORY));
|
|
|
|
|
parameters.setDisplayCategory(QCoreApplication::translate(Constants::QML_WIZARD_TR_SCOPE,
|
|
|
|
|
Constants::QML_WIZARD_TR_CATEGORY));
|
|
|
|
|
return parameters;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-20 17:21:18 +02:00
|
|
|
QWizard *QmlStandaloneAppWizard::createWizardDialog(QWidget *parent,
|
|
|
|
|
const QString &defaultPath,
|
|
|
|
|
const WizardPageList &extensionPages) const
|
2010-07-15 11:58:37 +02:00
|
|
|
{
|
2010-07-20 17:21:18 +02:00
|
|
|
m_d->wizardDialog = new QmlStandaloneAppWizardDialog(m_d->type, parent);
|
2010-07-15 11:58:37 +02:00
|
|
|
|
2010-07-20 17:21:18 +02:00
|
|
|
m_d->wizardDialog->setPath(defaultPath);
|
|
|
|
|
m_d->wizardDialog->setProjectName(QmlStandaloneAppWizardDialog::uniqueProjectName(defaultPath));
|
|
|
|
|
m_d->wizardDialog->m_qmlOptionsPage->setSymbianSvgIcon(m_d->standaloneApp->symbianSvgIcon());
|
|
|
|
|
m_d->wizardDialog->m_qmlOptionsPage->setOrientation(m_d->standaloneApp->orientation());
|
|
|
|
|
m_d->wizardDialog->m_qmlOptionsPage->setNetworkEnabled(m_d->standaloneApp->networkEnabled());
|
|
|
|
|
m_d->wizardDialog->m_qmlOptionsPage->setLoadDummyData(m_d->standaloneApp->loadDummyData());
|
|
|
|
|
connect(m_d->wizardDialog, SIGNAL(introPageLeft(QString, QString)), SLOT(useProjectPath(QString, QString)));
|
2010-08-18 23:22:09 +02:00
|
|
|
connect(m_d->wizardDialog->m_qmlSourcesPage,
|
|
|
|
|
SIGNAL(externalModulesChanged(QStringList, QStringList)), SLOT(handleModulesChange(QStringList, QStringList)));
|
2010-07-15 11:58:37 +02:00
|
|
|
|
|
|
|
|
foreach (QWizardPage *p, extensionPages)
|
2010-07-20 17:21:18 +02:00
|
|
|
BaseFileWizard::applyExtensionPageShortTitle(m_d->wizardDialog, m_d->wizardDialog->addPage(p));
|
2010-07-15 11:58:37 +02:00
|
|
|
|
2010-07-20 17:21:18 +02:00
|
|
|
return m_d->wizardDialog;
|
2010-07-15 11:58:37 +02:00
|
|
|
}
|
|
|
|
|
|
2010-07-20 17:21:18 +02:00
|
|
|
Core::GeneratedFiles QmlStandaloneAppWizard::generateFiles(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-07-15 11:58:37 +02:00
|
|
|
|
2010-07-20 17:21:18 +02:00
|
|
|
m_d->standaloneApp->setProjectName(wizard->projectName());
|
|
|
|
|
m_d->standaloneApp->setProjectPath(wizard->path());
|
|
|
|
|
m_d->standaloneApp->setSymbianTargetUid(wizard->m_qmlOptionsPage->symbianUid());
|
|
|
|
|
m_d->standaloneApp->setSymbianSvgIcon(wizard->m_qmlOptionsPage->symbianSvgIcon());
|
|
|
|
|
m_d->standaloneApp->setOrientation(wizard->m_qmlOptionsPage->orientation());
|
|
|
|
|
m_d->standaloneApp->setNetworkEnabled(wizard->m_qmlOptionsPage->networkEnabled());
|
|
|
|
|
if (m_d->type == QmlStandaloneAppWizard::ImportQmlFile)
|
|
|
|
|
m_d->standaloneApp->setMainQmlFile(wizard->m_qmlSourcesPage->mainQmlFile());
|
2010-08-18 23:22:09 +02:00
|
|
|
m_d->standaloneApp->setExternalModules(
|
|
|
|
|
wizard->m_qmlSourcesPage->moduleUris(), wizard->m_qmlSourcesPage->moduleImportPaths());
|
2010-07-15 11:58:37 +02:00
|
|
|
|
2010-07-20 17:21:18 +02:00
|
|
|
return m_d->standaloneApp->generateFiles(errorMessage);
|
2010-07-15 11:58:37 +02:00
|
|
|
}
|
|
|
|
|
|
2010-07-20 17:21:18 +02:00
|
|
|
bool QmlStandaloneAppWizard::postGenerateFiles(const QWizard *wizard, const Core::GeneratedFiles &l, QString *errorMessage)
|
2010-07-15 11:58:37 +02:00
|
|
|
{
|
|
|
|
|
Q_UNUSED(wizard)
|
2010-07-20 17:21:18 +02:00
|
|
|
const bool success = ProjectExplorer::CustomProjectWizard::postGenerateOpen(l, errorMessage);
|
|
|
|
|
if (success && m_d->type == QmlStandaloneAppWizard::ImportQmlFile) {
|
|
|
|
|
ProjectExplorer::ProjectExplorerPlugin::instance()->setCurrentFile(0, m_d->standaloneApp->mainQmlFile());
|
|
|
|
|
Core::EditorManager::instance()->openEditor(m_d->standaloneApp->mainQmlFile());
|
|
|
|
|
}
|
|
|
|
|
return success;
|
2010-07-15 11:58:37 +02:00
|
|
|
}
|
|
|
|
|
|
2010-07-20 17:21:18 +02:00
|
|
|
void QmlStandaloneAppWizard::useProjectPath(const QString &projectName, const QString &projectPath)
|
2010-07-15 11:58:37 +02:00
|
|
|
{
|
2010-07-20 17:21:18 +02:00
|
|
|
m_d->wizardDialog->m_qmlOptionsPage->setSymbianUid(QmlStandaloneApp::symbianUidForPath(projectPath + projectName));
|
2010-07-15 11:58:37 +02:00
|
|
|
}
|
|
|
|
|
|
2010-08-18 23:22:09 +02:00
|
|
|
void QmlStandaloneAppWizard::handleModulesChange(const QStringList &uris, const QStringList &paths)
|
|
|
|
|
{
|
|
|
|
|
QmlStandaloneApp testApp;
|
|
|
|
|
testApp.setExternalModules(uris, paths);
|
|
|
|
|
m_d->wizardDialog->m_qmlSourcesPage->setModulesError(testApp.error());
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-15 11:58:37 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace QmlProjectManager
|
|
|
|
|
|
|
|
|
|
#include "qmlstandaloneappwizard.moc"
|