diff options
14 files changed, 420 insertions, 239 deletions
diff --git a/src/plugins/qmlprojectmanager/qmlproject.qrc b/src/plugins/qmlprojectmanager/qmlproject.qrc index c50f05276e..6b77059358 100644 --- a/src/plugins/qmlprojectmanager/qmlproject.qrc +++ b/src/plugins/qmlprojectmanager/qmlproject.qrc @@ -5,7 +5,7 @@ <file>images/qmlproject.png</file> <file>images/qml_wizard.png</file> <file>wizards/templates/app.pro</file> - <file>wizards/templates/qml/app.qml</file> + <file>wizards/templates/qml/app/app.qml</file> <file>wizards/templates/cpp/qmlapplicationview.h</file> <file>wizards/templates/cpp/symbianicon.svg</file> <file>wizards/templates/cpp/main.cpp</file> diff --git a/src/plugins/qmlprojectmanager/qmlprojectmanager.pro b/src/plugins/qmlprojectmanager/qmlprojectmanager.pro index 97158b12ca..87c286ce4a 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectmanager.pro +++ b/src/plugins/qmlprojectmanager/qmlprojectmanager.pro @@ -23,7 +23,7 @@ HEADERS += qmlproject.h \ qmlprojectmanagerconstants.h \ qmlprojecttarget.h \ wizards/qmlstandaloneappwizard.h \ - wizards/qmlstandaloneappwizardoptionspage.h \ + wizards/qmlstandaloneappwizardpages.h \ wizards/qmlstandaloneapp.h SOURCES += qmlproject.cpp \ @@ -38,7 +38,7 @@ SOURCES += qmlproject.cpp \ qmlprojectapplicationwizard.cpp \ qmlprojecttarget.cpp \ wizards/qmlstandaloneappwizard.cpp \ - wizards/qmlstandaloneappwizardoptionspage.cpp \ + wizards/qmlstandaloneappwizardpages.cpp \ wizards/qmlstandaloneapp.cpp RESOURCES += qmlproject.qrc @@ -48,7 +48,8 @@ INCLUDEPATH += \ wizards FORMS += \ - wizards/qmlstandaloneappwizardoptionspage.ui + wizards/qmlstandaloneappwizardoptionspage.ui \ + wizards/qmlstandaloneappwizardsourcespage.ui OTHER_FILES += QmlProjectManager.pluginspec \ QmlProject.mimetypes.xml diff --git a/src/plugins/qmlprojectmanager/qmlprojectplugin.cpp b/src/plugins/qmlprojectmanager/qmlprojectplugin.cpp index 2bbacd7d26..4ee1344425 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectplugin.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectplugin.cpp @@ -77,7 +77,8 @@ bool QmlProjectPlugin::initialize(const QStringList &, QString *errorMessage) addAutoReleasedObject(manager); addAutoReleasedObject(new Internal::QmlProjectRunConfigurationFactory); addAutoReleasedObject(new Internal::QmlRunControlFactory); - addAutoReleasedObject(new QmlNewStandaloneAppWizard); + addAutoReleasedObject(new QmlStandaloneAppWizard(QmlStandaloneAppWizard::NewQmlFile)); + addAutoReleasedObject(new QmlStandaloneAppWizard(QmlStandaloneAppWizard::ImportQmlFile)); addAutoReleasedObject(new QmlProjectApplicationWizard); addAutoReleasedObject(new QmlProjectImportWizard); diff --git a/src/plugins/qmlprojectmanager/wizards/qmlstandaloneapp.cpp b/src/plugins/qmlprojectmanager/wizards/qmlstandaloneapp.cpp index 1ec01439ab..f45d30977c 100644 --- a/src/plugins/qmlprojectmanager/wizards/qmlstandaloneapp.cpp +++ b/src/plugins/qmlprojectmanager/wizards/qmlstandaloneapp.cpp @@ -55,6 +55,16 @@ QString QmlStandaloneApp::symbianUidForPath(const QString &path) + QString::fromLatin1("%1").arg(hash, 7, 16, QLatin1Char('0')).right(7); } +void QmlStandaloneApp::setMainQmlFile(const QString &qmlFile) +{ + m_mainQmlFile.setFile(qmlFile); +} + +QString QmlStandaloneApp::mainQmlFile() const +{ + return path(MainQml, Target); +} + void QmlStandaloneApp::setOrientation(Orientation orientation) { m_orientation = orientation; @@ -77,10 +87,7 @@ QString QmlStandaloneApp::projectName() const void QmlStandaloneApp::setProjectPath(const QString &path) { - m_projectPath = path; - if (!(m_projectPath.endsWith(QLatin1Char('\\')) - || m_projectPath.endsWith(QLatin1Char('/')))) - m_projectPath.append(QDir::separator()); + m_projectPath.setFile(path); } void QmlStandaloneApp::setSymbianSvgIcon(const QString &icon) @@ -101,7 +108,7 @@ void QmlStandaloneApp::setSymbianTargetUid(const QString &uid) QString QmlStandaloneApp::symbianTargetUid() const { return !m_symbianTargetUid.isEmpty() ? m_symbianTargetUid - : symbianUidForPath(m_projectPath + m_projectName); + : symbianUidForPath(path(AppProfile, Target)); } void QmlStandaloneApp::setLoadDummyData(bool loadIt) @@ -126,11 +133,12 @@ bool QmlStandaloneApp::networkEnabled() const QString QmlStandaloneApp::path(Path path, Location location) const { + const QString qmlRootFolder = QLatin1String("qml/") + + (useExistingMainQml() ? m_mainQmlFile.dir().dirName() : m_projectName) + + QLatin1Char('/'); const QString sourceRoot = QLatin1String(":/qmlproject/wizards/templates/"); const QString cppSourceSubDir = QLatin1String("cpp/"); - const QString qmlSourceSubDir = QLatin1String("qml/"); const QString cppTargetSubDir = cppSourceSubDir; - const QString qmlTargetSubDir = qmlSourceSubDir; const QString qmlExtension = QLatin1String(".qml"); const QString mainCpp = QLatin1String("main.cpp"); const QString appViewCpp = QLatin1String("qmlapplicationview.cpp"); @@ -141,42 +149,50 @@ QString QmlStandaloneApp::path(Path path, Location location) const switch (location) { case Source: { switch (path) { - case MainQml: return sourceRoot + qmlSourceSubDir + QLatin1String("app.qml"); + case MainQml: return sourceRoot + QLatin1String("qml/app/app.qml"); case AppProfile: return sourceRoot + QLatin1String("app.pro"); case MainCpp: return sourceRoot + cppSourceSubDir + mainCpp; case AppViewerCpp: return sourceRoot + cppSourceSubDir + appViewCpp; case AppViewerH: return sourceRoot + cppSourceSubDir + appViewH; case SymbianSvgIcon: return !m_symbianSvgIcon.isEmpty() ? m_symbianSvgIcon - :sourceRoot + cppSourceSubDir + symbianIcon; + : sourceRoot + cppSourceSubDir + symbianIcon; default: qFatal(errorMessage); } } case Target: { - const QString pathBase = m_projectPath + m_projectName + QDir::separator(); + const QString pathBase = m_projectPath.absoluteFilePath() + QLatin1Char('/') + + m_projectName + QLatin1Char('/'); switch (path) { - case MainQml: return pathBase + qmlTargetSubDir + m_projectName + qmlExtension; + case MainQml: return useExistingMainQml() ? m_mainQmlFile.canonicalFilePath() + : pathBase + qmlRootFolder + m_projectName + qmlExtension; case AppProfile: return pathBase + m_projectName + QLatin1String(".pro"); + case AppProfilePath: return pathBase; case MainCpp: return pathBase + cppTargetSubDir + mainCpp; case AppViewerCpp: return pathBase + cppTargetSubDir + appViewCpp; case AppViewerH: return pathBase + cppTargetSubDir + appViewH; case SymbianSvgIcon: return pathBase + cppTargetSubDir + symbianIcon; + case QmlDir: return pathBase + qmlRootFolder; default: qFatal(errorMessage); } } case AppProfileRelative: { + const QDir appProFilePath(this->path(AppProfilePath, Target)); switch (path) { - case MainQml: return qmlTargetSubDir + m_projectName + qmlExtension; + case MainQml: return useExistingMainQml() ? appProFilePath.relativeFilePath(m_mainQmlFile.canonicalFilePath()) + : qmlRootFolder + m_projectName + qmlExtension; case MainCpp: return cppTargetSubDir + mainCpp; case AppViewerCpp: return cppTargetSubDir + appViewCpp; case AppViewerH: return cppTargetSubDir + appViewH; case SymbianSvgIcon: return cppTargetSubDir + symbianIcon; - case QmlDir: return QString(qmlTargetSubDir).remove(qmlTargetSubDir.length() - 1, 1); + case QmlDir: return useExistingMainQml() ? appProFilePath.relativeFilePath(m_mainQmlFile.canonicalPath()) + : QString(qmlRootFolder).remove(qmlRootFolder.length() - 1, 1); default: qFatal(errorMessage); } } default: { /* case MainCppRelative: */ switch (path) { - case MainQml: return qmlTargetSubDir + m_projectName + qmlExtension; + case MainQml: return useExistingMainQml() ? qmlRootFolder + m_mainQmlFile.fileName() + : QString(qmlRootFolder + m_projectName + qmlExtension); default: qFatal(errorMessage); } } @@ -310,7 +326,8 @@ Core::GeneratedFiles QmlStandaloneApp::generateFiles(QString *errorMessage) cons generatedProFile.setAttributes(Core::GeneratedFile::OpenProjectAttribute); files.append(generatedProFile); - files.append(generateFileCopy(path(MainQml, Source), path(MainQml, Target), true)); + if (!useExistingMainQml()) + files.append(generateFileCopy(path(MainQml, Source), path(MainQml, Target), true)); Core::GeneratedFile generatedMainCppFile(path(MainCpp, Target)); generatedMainCppFile.setContents(generateMainCpp(errorMessage)); @@ -324,5 +341,10 @@ Core::GeneratedFiles QmlStandaloneApp::generateFiles(QString *errorMessage) cons } #endif // CREATORLESSTEST +bool QmlStandaloneApp::useExistingMainQml() const +{ + return !m_mainQmlFile.filePath().isEmpty(); +} + } // namespace Internal } // namespace QmlProjectManager diff --git a/src/plugins/qmlprojectmanager/wizards/qmlstandaloneapp.h b/src/plugins/qmlprojectmanager/wizards/qmlstandaloneapp.h index b1d79e966f..540203e8ca 100644 --- a/src/plugins/qmlprojectmanager/wizards/qmlstandaloneapp.h +++ b/src/plugins/qmlprojectmanager/wizards/qmlstandaloneapp.h @@ -31,6 +31,8 @@ #define QMLSTANDALONEAPP_H #include <QtCore/QString> +#include <QtCore/QFileInfo> + #ifndef CREATORLESSTEST #include <coreplugin/basefilewizard.h> #endif // CREATORLESSTEST @@ -51,6 +53,7 @@ public: MainQml, MainCpp, AppProfile, + AppProfilePath, AppViewerCpp, AppViewerH, SymbianSvgIcon, @@ -66,6 +69,8 @@ public: QmlStandaloneApp(); + void setMainQmlFile(const QString &qmlFile); + QString mainQmlFile() const; void setOrientation(Orientation orientation); Orientation orientation() const; void setProjectName(const QString &name); @@ -86,19 +91,21 @@ public: #else bool generateFiles(QString *errorMessage) const; #endif // CREATORLESSTEST + QString path(Path path, Location location) const; + bool useExistingMainQml() const; private: - QString path(Path path, Location location) const; QByteArray generateMainCpp(const QString *errorMessage) const; QByteArray generateProFile(const QString *errorMessage) const; QString m_projectName; - QString m_projectPath; + QFileInfo m_projectPath; QString m_symbianSvgIcon; QString m_symbianTargetUid; bool m_loadDummyData; Orientation m_orientation; bool m_networkEnabled; + QFileInfo m_mainQmlFile; }; } // end of namespace Internal diff --git a/src/plugins/qmlprojectmanager/wizards/qmlstandaloneappwizard.cpp b/src/plugins/qmlprojectmanager/wizards/qmlstandaloneappwizard.cpp index 977f4c1d25..6921b96232 100644 --- a/src/plugins/qmlprojectmanager/wizards/qmlstandaloneappwizard.cpp +++ b/src/plugins/qmlprojectmanager/wizards/qmlstandaloneappwizard.cpp @@ -28,12 +28,15 @@ **************************************************************************/ #include "qmlstandaloneappwizard.h" -#include "qmlstandaloneappwizardoptionspage.h" +#include "qmlstandaloneappwizardpages.h" #include "qmlstandaloneapp.h" #include "qmlprojectconstants.h" +#include <projectexplorer/baseprojectwizarddialog.h> #include <projectexplorer/customwizard/customwizard.h> +#include <projectexplorer/projectexplorer.h> +#include <coreplugin/editormanager/editormanager.h> #include <QtGui/QIcon> @@ -48,103 +51,142 @@ namespace QmlProjectManager { namespace Internal { -class QmlNewStandaloneAppWizardDialog : public ProjectExplorer::BaseProjectWizardDialog +class QmlStandaloneAppWizardDialog : public ProjectExplorer::BaseProjectWizardDialog { Q_OBJECT public: - explicit QmlNewStandaloneAppWizardDialog(QWidget *parent = 0); + explicit QmlStandaloneAppWizardDialog(QmlStandaloneAppWizard::WizardType type, QWidget *parent = 0); private: - class QmlStandaloneAppWizardOptionPage *m_qmlOptionsPage; - friend class QmlNewStandaloneAppWizard; + QmlStandaloneAppWizard::WizardType m_type; + class QmlStandaloneAppWizardSourcesPage *m_qmlSourcesPage; + class QmlStandaloneAppWizardOptionsPage *m_qmlOptionsPage; + friend class QmlStandaloneAppWizard; }; -QmlNewStandaloneAppWizardDialog::QmlNewStandaloneAppWizardDialog(QWidget *parent) +QmlStandaloneAppWizardDialog::QmlStandaloneAppWizardDialog(QmlStandaloneAppWizard::WizardType type, + QWidget *parent) : ProjectExplorer::BaseProjectWizardDialog(parent) + , m_type(type) { - setWindowTitle(tr("New Standalone QML Project")); - setIntroDescription(tr("This wizard generates a Standalone QML application project.")); - - m_qmlOptionsPage = new QmlStandaloneAppWizardOptionPage; - + 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; const int qmlOptionsPagePageId = addPage(m_qmlOptionsPage); wizardProgress()->item(qmlOptionsPagePageId)->setTitle(tr("Qml App options")); } -QmlNewStandaloneAppWizard::QmlNewStandaloneAppWizard() - : Core::BaseFileWizard(parameters()) - , m_standaloneApp(new QmlStandaloneApp) - , m_wizardDialog(0) +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) { + m_d->type = type; + m_d->standaloneApp = new QmlStandaloneApp; + m_d->wizardDialog = 0; } -QmlNewStandaloneAppWizard::~QmlNewStandaloneAppWizard() +QmlStandaloneAppWizard::~QmlStandaloneAppWizard() { - delete m_standaloneApp; + delete m_d->standaloneApp; } -Core::BaseFileWizardParameters QmlNewStandaloneAppWizard::parameters() +Core::BaseFileWizardParameters QmlStandaloneAppWizard::parameters(WizardType type) { Core::BaseFileWizardParameters parameters(ProjectWizard); parameters.setIcon(QIcon(QLatin1String(Constants::QML_WIZARD_ICON))); - parameters.setDisplayName(tr("Qt QML Standalone Application")); - parameters.setId(QLatin1String("QA.QML Standalone Application")); - parameters.setDescription(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.")); + 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 " + "project. An erxisting QML project will be imported and a lightweight " + "Qt/C++ application with a QDeclarativeView will be created for it.")); parameters.setCategory(QLatin1String(Constants::QML_WIZARD_CATEGORY)); parameters.setDisplayCategory(QCoreApplication::translate(Constants::QML_WIZARD_TR_SCOPE, Constants::QML_WIZARD_TR_CATEGORY)); return parameters; } -QWizard *QmlNewStandaloneAppWizard::createWizardDialog(QWidget *parent, - const QString &defaultPath, - const WizardPageList &extensionPages) const +QWizard *QmlStandaloneAppWizard::createWizardDialog(QWidget *parent, + const QString &defaultPath, + const WizardPageList &extensionPages) const { - m_wizardDialog = new QmlNewStandaloneAppWizardDialog(parent); + m_d->wizardDialog = new QmlStandaloneAppWizardDialog(m_d->type, parent); - m_wizardDialog->setPath(defaultPath); - m_wizardDialog->setProjectName(QmlNewStandaloneAppWizardDialog::uniqueProjectName(defaultPath)); - m_wizardDialog->m_qmlOptionsPage->setSymbianSvgIcon(m_standaloneApp->symbianSvgIcon()); - m_wizardDialog->m_qmlOptionsPage->setOrientation(m_standaloneApp->orientation()); - m_wizardDialog->m_qmlOptionsPage->setNetworkEnabled(m_standaloneApp->networkEnabled()); - m_wizardDialog->m_qmlOptionsPage->setLoadDummyData(m_standaloneApp->loadDummyData()); - connect(m_wizardDialog, SIGNAL(introPageLeft(QString, QString)), SLOT(useProjectPath(QString, QString))); + 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))); foreach (QWizardPage *p, extensionPages) - BaseFileWizard::applyExtensionPageShortTitle(m_wizardDialog, m_wizardDialog->addPage(p)); + BaseFileWizard::applyExtensionPageShortTitle(m_d->wizardDialog, m_d->wizardDialog->addPage(p)); - return m_wizardDialog; + return m_d->wizardDialog; } -Core::GeneratedFiles QmlNewStandaloneAppWizard::generateFiles(const QWizard *w, - QString *errorMessage) const +Core::GeneratedFiles QmlStandaloneAppWizard::generateFiles(const QWizard *w, + QString *errorMessage) const { Q_UNUSED(errorMessage) - const QmlNewStandaloneAppWizardDialog *wizard = qobject_cast<const QmlNewStandaloneAppWizardDialog*>(w); + const QmlStandaloneAppWizardDialog *wizard = qobject_cast<const QmlStandaloneAppWizardDialog*>(w); - m_standaloneApp->setProjectName(wizard->projectName()); - m_standaloneApp->setProjectPath(wizard->path()); - m_standaloneApp->setSymbianTargetUid(wizard->m_qmlOptionsPage->symbianUid()); - m_standaloneApp->setSymbianSvgIcon(wizard->m_qmlOptionsPage->symbianSvgIcon()); - m_standaloneApp->setOrientation(wizard->m_qmlOptionsPage->orientation()); - m_standaloneApp->setNetworkEnabled(wizard->m_qmlOptionsPage->networkEnabled()); + 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()); - return m_standaloneApp->generateFiles(errorMessage); + return m_d->standaloneApp->generateFiles(errorMessage); } -bool QmlNewStandaloneAppWizard::postGenerateFiles(const QWizard *wizard, const Core::GeneratedFiles &l, QString *errorMessage) +bool QmlStandaloneAppWizard::postGenerateFiles(const QWizard *wizard, const Core::GeneratedFiles &l, QString *errorMessage) { Q_UNUSED(wizard) - return ProjectExplorer::CustomProjectWizard::postGenerateOpen(l, errorMessage); + 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; } -void QmlNewStandaloneAppWizard::useProjectPath(const QString &projectName, const QString &projectPath) +void QmlStandaloneAppWizard::useProjectPath(const QString &projectName, const QString &projectPath) { - m_wizardDialog->m_qmlOptionsPage->setSymbianUid(QmlStandaloneApp::symbianUidForPath(projectPath + projectName)); + m_d->wizardDialog->m_qmlOptionsPage->setSymbianUid(QmlStandaloneApp::symbianUidForPath(projectPath + projectName)); } } // namespace Internal diff --git a/src/plugins/qmlprojectmanager/wizards/qmlstandaloneappwizard.h b/src/plugins/qmlprojectmanager/wizards/qmlstandaloneappwizard.h index 6c34812d5d..91ec63d58b 100644 --- a/src/plugins/qmlprojectmanager/wizards/qmlstandaloneappwizard.h +++ b/src/plugins/qmlprojectmanager/wizards/qmlstandaloneappwizard.h @@ -31,19 +31,23 @@ #define QMLSTANDALONEAPPWIZARD_H #include <coreplugin/basefilewizard.h> -#include <projectexplorer/baseprojectwizarddialog.h> namespace QmlProjectManager { namespace Internal { -class QmlNewStandaloneAppWizard : public Core::BaseFileWizard +class QmlStandaloneAppWizard : public Core::BaseFileWizard { Q_OBJECT public: - QmlNewStandaloneAppWizard(); - virtual ~QmlNewStandaloneAppWizard(); - static Core::BaseFileWizardParameters parameters(); + enum WizardType { + NewQmlFile, + ImportQmlFile + }; + + QmlStandaloneAppWizard(WizardType type); + virtual ~QmlStandaloneAppWizard(); + static Core::BaseFileWizardParameters parameters(WizardType type); protected: QWizard *createWizardDialog(QWidget *parent, const QString &defaultPath, @@ -57,8 +61,7 @@ protected slots: void useProjectPath(const QString &projectName, const QString &projectPath); private: - class QmlStandaloneApp *m_standaloneApp; - mutable class QmlNewStandaloneAppWizardDialog *m_wizardDialog; + class QmlStandaloneAppWizardPrivate *m_d; }; } // end of namespace Internal diff --git a/src/plugins/qmlprojectmanager/wizards/qmlstandaloneappwizardoptionspage.cpp b/src/plugins/qmlprojectmanager/wizards/qmlstandaloneappwizardoptionspage.cpp deleted file mode 100644 index 6f18893f7d..0000000000 --- a/src/plugins/qmlprojectmanager/wizards/qmlstandaloneappwizardoptionspage.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/************************************************************************** -** -** 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 "qmlstandaloneappwizardoptionspage.h" -#include "ui_qmlstandaloneappwizardoptionspage.h" - -#include <QtGui/QDesktopServices> -#include <QtGui/QFileDialog> - -namespace QmlProjectManager { -namespace Internal { - -class QmlStandaloneAppWizardOptionPagePrivate -{ - Ui::QmlStandaloneAppWizardOptionPage m_ui; - QString symbianSvgIcon; - friend class QmlStandaloneAppWizardOptionPage; -}; - -QmlStandaloneAppWizardOptionPage::QmlStandaloneAppWizardOptionPage(QWidget *parent) : - QWizardPage(parent), - m_d(new QmlStandaloneAppWizardOptionPagePrivate) -{ - m_d->m_ui.setupUi(this); - - const QIcon open = QApplication::style()->standardIcon(QStyle::SP_DirOpenIcon); - m_d->m_ui.symbianAppIconLoadToolButton->setIcon(open); - connect(m_d->m_ui.symbianAppIconLoadToolButton, SIGNAL(clicked()), SLOT(openSymbianSvgIcon())); - - m_d->m_ui.orientationBehaviorComboBox->addItem(tr("Auto rotate orientation"), - QmlStandaloneApp::Auto); - m_d->m_ui.orientationBehaviorComboBox->addItem(tr("Lock to landscape orientation"), - QmlStandaloneApp::LockLandscape); - m_d->m_ui.orientationBehaviorComboBox->addItem(tr("Lock to portrait orientation"), - QmlStandaloneApp::LockPortrait); -} - -QmlStandaloneAppWizardOptionPage::~QmlStandaloneAppWizardOptionPage() -{ - delete m_d; -} - -bool QmlStandaloneAppWizardOptionPage::isComplete() const -{ - return true; -} - -void QmlStandaloneAppWizardOptionPage::setOrientation(QmlStandaloneApp::Orientation orientation) -{ - QComboBox *const comboBox = m_d->m_ui.orientationBehaviorComboBox; - for (int i = 0; i < comboBox->count(); ++i) - if (comboBox->itemData(i).toInt() == static_cast<int>(orientation)) { - comboBox->setCurrentIndex(i); - break; - } -} - -QmlStandaloneApp::Orientation QmlStandaloneAppWizardOptionPage::orientation() const -{ - const int index = m_d->m_ui.orientationBehaviorComboBox->currentIndex(); - return static_cast<QmlStandaloneApp::Orientation>(m_d->m_ui.orientationBehaviorComboBox->itemData(index).toInt()); -} - -QString QmlStandaloneAppWizardOptionPage::symbianSvgIcon() const -{ - return m_d->symbianSvgIcon; -} - -void QmlStandaloneAppWizardOptionPage::setSymbianSvgIcon(const QString &icon) -{ - QPixmap iconPixmap(icon); - if (!iconPixmap.isNull()) { - const int symbianIconSize = 44; - if (iconPixmap.height() > symbianIconSize || iconPixmap.width() > symbianIconSize) - iconPixmap = iconPixmap.scaledToHeight(symbianIconSize, Qt::SmoothTransformation); - m_d->m_ui.symbianAppIconPreview->setPixmap(iconPixmap); - m_d->symbianSvgIcon = icon; - } -} - -QString QmlStandaloneAppWizardOptionPage::symbianUid() const -{ - return m_d->m_ui.symbianTargetUid3LineEdit->text(); -} - -void QmlStandaloneAppWizardOptionPage::setSymbianUid(const QString &uid) -{ - m_d->m_ui.symbianTargetUid3LineEdit->setText(uid); -} - -void QmlStandaloneAppWizardOptionPage::setLoadDummyData(bool loadIt) -{ - m_d->m_ui.loadDummyDataCheckBox->setChecked(loadIt); -} - -bool QmlStandaloneAppWizardOptionPage::loadDummyData() const -{ - return m_d->m_ui.loadDummyDataCheckBox->isChecked(); -} - -void QmlStandaloneAppWizardOptionPage::setNetworkEnabled(bool enableIt) -{ - m_d->m_ui.symbianEnableNetworkChackBox->setChecked(enableIt); -} - -bool QmlStandaloneAppWizardOptionPage::networkEnabled() const -{ - return m_d->m_ui.symbianEnableNetworkChackBox->isChecked(); -} - -void QmlStandaloneAppWizardOptionPage::openSymbianSvgIcon() -{ - const QString svgIcon = QFileDialog::getOpenFileName( - this, - m_d->m_ui.symbianAppIconLabel->text(), - QDesktopServices::storageLocation(QDesktopServices::PicturesLocation), - QLatin1String("*.svg")); - if (!svgIcon.isEmpty()) - setSymbianSvgIcon(svgIcon); -} - -} // namespace Internal -} // namespace QmlProjectManager diff --git a/src/plugins/qmlprojectmanager/wizards/qmlstandaloneappwizardpages.cpp b/src/plugins/qmlprojectmanager/wizards/qmlstandaloneappwizardpages.cpp new file mode 100644 index 0000000000..1c5f13b7df --- /dev/null +++ b/src/plugins/qmlprojectmanager/wizards/qmlstandaloneappwizardpages.cpp @@ -0,0 +1,183 @@ +/************************************************************************** +** +** 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 "qmlstandaloneappwizardpages.h" +#include "ui_qmlstandaloneappwizardsourcespage.h" +#include "ui_qmlstandaloneappwizardoptionspage.h" + +#include <QtGui/QDesktopServices> +#include <QtGui/QFileDialog> + +namespace QmlProjectManager { +namespace Internal { + +class QmlStandaloneAppWizardSourcesPagePrivate +{ + Ui::QmlStandaloneAppWizardSourcesPage ui; + friend class QmlStandaloneAppWizardSourcesPage; +}; + +QmlStandaloneAppWizardSourcesPage::QmlStandaloneAppWizardSourcesPage(QWidget *parent) + : QWizardPage(parent) + , m_d(new QmlStandaloneAppWizardSourcesPagePrivate) +{ + m_d->ui.setupUi(this); + m_d->ui.mainQmlFileLineEdit->setExpectedKind(Utils::PathChooser::File); + m_d->ui.mainQmlFileLineEdit->setPromptDialogFilter(QLatin1String("*.qml")); + m_d->ui.mainQmlFileLineEdit->setPromptDialogTitle(tr("Select the main QML file of the application.")); + m_d->ui.qmlModulesGroupBox->setEnabled(false); // TODO: implement modules selection + connect(m_d->ui.mainQmlFileLineEdit, SIGNAL(changed(QString)), SIGNAL(completeChanged())); +} + +QmlStandaloneAppWizardSourcesPage::~QmlStandaloneAppWizardSourcesPage() +{ + delete m_d; +} + +QString QmlStandaloneAppWizardSourcesPage::mainQmlFile() const +{ + return m_d->ui.mainQmlFileLineEdit->path(); +} + +bool QmlStandaloneAppWizardSourcesPage::isComplete() const +{ + return m_d->ui.mainQmlFileLineEdit->isValid(); +} + +void QmlStandaloneAppWizardSourcesPage::setMainQmlFileChooserVisible(bool visible) +{ + m_d->ui.mainQmlFileLineEdit->setVisible(visible); +} + +class QmlStandaloneAppWizardOptionsPagePrivate +{ + Ui::QmlStandaloneAppWizardOptionPage ui; + QString symbianSvgIcon; + friend class QmlStandaloneAppWizardOptionsPage; +}; + +QmlStandaloneAppWizardOptionsPage::QmlStandaloneAppWizardOptionsPage(QWidget *parent) + : QWizardPage(parent) + , m_d(new QmlStandaloneAppWizardOptionsPagePrivate) +{ + m_d->ui.setupUi(this); + + const QIcon open = QApplication::style()->standardIcon(QStyle::SP_DirOpenIcon); + m_d->ui.symbianAppIconLoadToolButton->setIcon(open); + connect(m_d->ui.symbianAppIconLoadToolButton, SIGNAL(clicked()), SLOT(openSymbianSvgIcon())); + + m_d->ui.orientationBehaviorComboBox->addItem(tr("Auto rotate orientation"), + QmlStandaloneApp::Auto); + m_d->ui.orientationBehaviorComboBox->addItem(tr("Lock to landscape orientation"), + QmlStandaloneApp::LockLandscape); + m_d->ui.orientationBehaviorComboBox->addItem(tr("Lock to portrait orientation"), + QmlStandaloneApp::LockPortrait); +} + +QmlStandaloneAppWizardOptionsPage::~QmlStandaloneAppWizardOptionsPage() +{ + delete m_d; +} + +void QmlStandaloneAppWizardOptionsPage::setOrientation(QmlStandaloneApp::Orientation orientation) +{ + QComboBox *const comboBox = m_d->ui.orientationBehaviorComboBox; + for (int i = 0; i < comboBox->count(); ++i) + if (comboBox->itemData(i).toInt() == static_cast<int>(orientation)) { + comboBox->setCurrentIndex(i); + break; + } +} + +QmlStandaloneApp::Orientation QmlStandaloneAppWizardOptionsPage::orientation() const +{ + const int index = m_d->ui.orientationBehaviorComboBox->currentIndex(); + return static_cast<QmlStandaloneApp::Orientation>(m_d->ui.orientationBehaviorComboBox->itemData(index).toInt()); +} + +QString QmlStandaloneAppWizardOptionsPage::symbianSvgIcon() const +{ + return m_d->symbianSvgIcon; +} + +void QmlStandaloneAppWizardOptionsPage::setSymbianSvgIcon(const QString &icon) +{ + QPixmap iconPixmap(icon); + if (!iconPixmap.isNull()) { + const int symbianIconSize = 44; + if (iconPixmap.height() > symbianIconSize || iconPixmap.width() > symbianIconSize) + iconPixmap = iconPixmap.scaledToHeight(symbianIconSize, Qt::SmoothTransformation); + m_d->ui.symbianAppIconPreview->setPixmap(iconPixmap); + m_d->symbianSvgIcon = icon; + } +} + +QString QmlStandaloneAppWizardOptionsPage::symbianUid() const +{ + return m_d->ui.symbianTargetUid3LineEdit->text(); +} + +void QmlStandaloneAppWizardOptionsPage::setSymbianUid(const QString &uid) +{ + m_d->ui.symbianTargetUid3LineEdit->setText(uid); +} + +void QmlStandaloneAppWizardOptionsPage::setLoadDummyData(bool loadIt) +{ + m_d->ui.loadDummyDataCheckBox->setChecked(loadIt); +} + +bool QmlStandaloneAppWizardOptionsPage::loadDummyData() const +{ + return m_d->ui.loadDummyDataCheckBox->isChecked(); +} + +void QmlStandaloneAppWizardOptionsPage::setNetworkEnabled(bool enableIt) +{ + m_d->ui.symbianEnableNetworkChackBox->setChecked(enableIt); +} + +bool QmlStandaloneAppWizardOptionsPage::networkEnabled() const +{ + return m_d->ui.symbianEnableNetworkChackBox->isChecked(); +} + +void QmlStandaloneAppWizardOptionsPage::openSymbianSvgIcon() +{ + const QString svgIcon = QFileDialog::getOpenFileName( + this, + m_d->ui.symbianAppIconLabel->text(), + QDesktopServices::storageLocation(QDesktopServices::PicturesLocation), + QLatin1String("*.svg")); + if (!svgIcon.isEmpty()) + setSymbianSvgIcon(svgIcon); +} + +} // namespace Internal +} // namespace QmlProjectManager diff --git a/src/plugins/qmlprojectmanager/wizards/qmlstandaloneappwizardoptionspage.h b/src/plugins/qmlprojectmanager/wizards/qmlstandaloneappwizardpages.h index 4714dd35b6..97abf06bc6 100644 --- a/src/plugins/qmlprojectmanager/wizards/qmlstandaloneappwizardoptionspage.h +++ b/src/plugins/qmlprojectmanager/wizards/qmlstandaloneappwizardpages.h @@ -27,8 +27,8 @@ ** **************************************************************************/ -#ifndef QMLSTANDALONEAPPWIZARDOPTIONPAGE_H -#define QMLSTANDALONEAPPWIZARDOPTIONPAGE_H +#ifndef QMLSTANDALONEAPPWIZARDPAGES_H +#define QMLSTANDALONEAPPWIZARDPAGES_H #include <QtGui/QWizardPage> #include "qmlstandaloneapp.h" @@ -36,16 +36,31 @@ namespace QmlProjectManager { namespace Internal { -class QmlStandaloneAppWizardOptionPage : public QWizardPage +class QmlStandaloneAppWizardSourcesPage : public QWizardPage { Q_OBJECT - Q_DISABLE_COPY(QmlStandaloneAppWizardOptionPage) + Q_DISABLE_COPY(QmlStandaloneAppWizardSourcesPage) public: - explicit QmlStandaloneAppWizardOptionPage(QWidget *parent = 0); - virtual ~QmlStandaloneAppWizardOptionPage(); + explicit QmlStandaloneAppWizardSourcesPage(QWidget *parent = 0); + virtual ~QmlStandaloneAppWizardSourcesPage(); + QString mainQmlFile() const; virtual bool isComplete() const; + void setMainQmlFileChooserVisible(bool visible); + +private: + class QmlStandaloneAppWizardSourcesPagePrivate *m_d; +}; + +class QmlStandaloneAppWizardOptionsPage : public QWizardPage +{ + Q_OBJECT + Q_DISABLE_COPY(QmlStandaloneAppWizardOptionsPage) + +public: + explicit QmlStandaloneAppWizardOptionsPage(QWidget *parent = 0); + virtual ~QmlStandaloneAppWizardOptionsPage(); void setOrientation(QmlStandaloneApp::Orientation orientation); QmlStandaloneApp::Orientation orientation() const; @@ -62,10 +77,10 @@ private slots: void openSymbianSvgIcon(); // Via file open dialog private: - class QmlStandaloneAppWizardOptionPagePrivate *m_d; + class QmlStandaloneAppWizardOptionsPagePrivate *m_d; }; } // end of namespace Internal } // end of namespace QmlProjectManager -#endif // QMLSTANDALONEAPPWIZARDOPTIONPAGE_H +#endif // QMLSTANDALONEAPPWIZARDPAGES_H diff --git a/src/plugins/qmlprojectmanager/wizards/qmlstandaloneappwizardsourcespage.ui b/src/plugins/qmlprojectmanager/wizards/qmlstandaloneappwizardsourcespage.ui new file mode 100644 index 0000000000..40e67a1e17 --- /dev/null +++ b/src/plugins/qmlprojectmanager/wizards/qmlstandaloneappwizardsourcespage.ui @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>QmlStandaloneAppWizardSourcesPage</class> + <widget class="QWizardPage" name="QmlStandaloneAppWizardSourcesPage"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>408</width> + <height>340</height> + </rect> + </property> + <property name="windowTitle"> + <string>WizardPage</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QGroupBox" name="mainQmlFileGroupBox"> + <property name="title"> + <string>Main Qml file</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <item> + <widget class="Utils::PathChooser" name="mainQmlFileLineEdit"/> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="qmlModulesGroupBox"> + <property name="title"> + <string>Qml Modules</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QListWidget" name="qmlModulesListWidget"/> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + <customwidgets> + <customwidget> + <class>Utils::PathChooser</class> + <extends>QLineEdit</extends> + <header location="global">utils/pathchooser.h</header> + </customwidget> + </customwidgets> + <resources/> + <connections/> +</ui> diff --git a/src/plugins/qmlprojectmanager/wizards/templates/app.pro b/src/plugins/qmlprojectmanager/wizards/templates/app.pro index ce18ae6363..63e81221d6 100644 --- a/src/plugins/qmlprojectmanager/wizards/templates/app.pro +++ b/src/plugins/qmlprojectmanager/wizards/templates/app.pro @@ -7,7 +7,7 @@ HEADERS = cpp/qmlapplicationview.h INCLUDEPATH += cpp # DEPLOYMENTFOLDERS # -DEPLOYMENTFOLDERS = qml +DEPLOYMENTFOLDERS = qml/app # Avoid auto screen rotation # ORIENTATIONLOCK # @@ -23,6 +23,7 @@ symbian { ICON = cpp/symbianicon.svg for(deploymentfolder, DEPLOYMENTFOLDERS) { eval(item$${deploymentfolder}.sources = $${deploymentfolder}) + eval(item$${deploymentfolder}.path = qml) eval(DEPLOYMENT += item$${deploymentfolder}) } contains(DEFINES, ORIENTATIONLOCK):LIBS += -lavkon -leikcore -leiksrv -lcone @@ -31,12 +32,15 @@ symbian { # Ossi will want to kill me when he reads this # TODO: let Ossi create a (post link step) deployment for windows !contains(CONFIG, build_pass):for(deploymentfolder, DEPLOYMENTFOLDERS) { - system($$QMAKE_COPY_DIR $$deploymentfolder $${OUTDIR} $$replace(OUT_PWD, /, \\)\\$$deploymentfolder\\) + pathSegments = $$split(deploymentfolder, /) + sourceAndTarget = $$deploymentfolder $$OUT_PWD/qml/$$last(pathSegments) + system($$QMAKE_COPY_DIR $$replace(sourceAndTarget, /, \\)) } } else { # TODO: make this work for(deploymentfolder, DEPLOYMENTFOLDERS) { eval(item$${deploymentfolder}.files = $${deploymentfolder}) + eval(item$${deploymentfolder}.path = qml) eval(INSTALLS += item$${deploymentfolder}) } } diff --git a/src/plugins/qmlprojectmanager/wizards/templates/cpp/main.cpp b/src/plugins/qmlprojectmanager/wizards/templates/cpp/main.cpp index 3ac84b1cfb..092cedb9ee 100644 --- a/src/plugins/qmlprojectmanager/wizards/templates/cpp/main.cpp +++ b/src/plugins/qmlprojectmanager/wizards/templates/cpp/main.cpp @@ -5,7 +5,7 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - QmlApplicationView qmlApp(QLatin1String("app.qml")); // MAINQML + QmlApplicationView qmlApp(QLatin1String("qml/app/app.qml")); // MAINQML QStringList importPaths; // IMPORTPATHSLIST qmlApp.setImportPathList(importPaths); // SETIMPORTPATHLIST qmlApp.setOrientation(QmlApplicationView::Auto); // ORIENTATION diff --git a/src/plugins/qmlprojectmanager/wizards/templates/qml/app.qml b/src/plugins/qmlprojectmanager/wizards/templates/qml/app/app.qml index baa3db352c..baa3db352c 100644 --- a/src/plugins/qmlprojectmanager/wizards/templates/qml/app.qml +++ b/src/plugins/qmlprojectmanager/wizards/templates/qml/app/app.qml |