summaryrefslogtreecommitdiff
path: root/src/plugins/qmlprojectmanager
diff options
context:
space:
mode:
authorjkobus <jaroslaw.kobus@digia.com>2013-11-05 13:45:39 +0100
committerJarek Kobus <jaroslaw.kobus@digia.com>2013-11-06 10:23:49 +0100
commit62590507b137009508ff7ed08d728a293fcb29d8 (patch)
tree506b1902ae6e03dadaf51d91dfe457d5664e1f0d /src/plugins/qmlprojectmanager
parent6313b2ca4bd5eb3a00d54512f9fe5bc5b566db56 (diff)
downloadqt-creator-62590507b137009508ff7ed08d728a293fcb29d8.tar.gz
Merge multi Qt Quick UI wizards into one
Change-Id: Ia984c36864dacd5b71c76976a351767bb4c3693c Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Diffstat (limited to 'src/plugins/qmlprojectmanager')
-rw-r--r--src/plugins/qmlprojectmanager/qmlapp.cpp62
-rw-r--r--src/plugins/qmlprojectmanager/qmlapp.h8
-rw-r--r--src/plugins/qmlprojectmanager/qmlapplicationwizard.cpp61
-rw-r--r--src/plugins/qmlprojectmanager/qmlapplicationwizard.h10
-rw-r--r--src/plugins/qmlprojectmanager/qmlapplicationwizardpages.cpp96
-rw-r--r--src/plugins/qmlprojectmanager/qmlapplicationwizardpages.h60
-rw-r--r--src/plugins/qmlprojectmanager/qmlprojectmanager.pro6
-rw-r--r--src/plugins/qmlprojectmanager/qmlprojectmanager.qbs1
-rw-r--r--src/plugins/qmlprojectmanager/qmlprojectplugin.cpp3
9 files changed, 218 insertions, 89 deletions
diff --git a/src/plugins/qmlprojectmanager/qmlapp.cpp b/src/plugins/qmlprojectmanager/qmlapp.cpp
index fd3998a08a..9086286d19 100644
--- a/src/plugins/qmlprojectmanager/qmlapp.cpp
+++ b/src/plugins/qmlprojectmanager/qmlapp.cpp
@@ -50,16 +50,11 @@ static QStringList binaryFiles()
return result;
}
-QString QmlApp::templateRootDirectory()
+static QString templateRootDirectory()
{
return Core::ICore::resourcePath() + QLatin1String("/templates/qml/");
}
-TemplateInfo::TemplateInfo()
- : priority(5)
-{
-}
-
QmlApp::QmlApp(QObject *parent)
: QObject(parent)
{
@@ -100,18 +95,13 @@ QString QmlApp::creatorFileName() const
return m_creatorFileName;
}
-const TemplateInfo &QmlApp::templateInfo() const
-{
- return m_templateInfo;
-}
-
QString QmlApp::templateDirectory() const
{
const QDir dir(templateRootDirectory() + m_templateInfo.templateName);
return QDir::cleanPath(dir.absolutePath());
}
-QStringList QmlApp::templateNames()
+static QStringList templateNames()
{
QStringList templateNameList;
const QDir templateRoot(templateRootDirectory());
@@ -177,7 +167,7 @@ static bool parseTemplateXml(QXmlStreamReader &reader, TemplateInfo *info)
if (reader.name() == tag_template) {
info->openFile = reader.attributes().value(attribute_openEditor).toString();
if (reader.attributes().hasAttribute(attribute_priority))
- info->priority = reader.attributes().value(attribute_priority).toString().toInt();
+ info->priority = reader.attributes().value(attribute_priority).toString();
if (reader.attributes().hasAttribute(attribute_id))
info->wizardId = reader.attributes().value(attribute_id).toString();
@@ -201,24 +191,39 @@ static bool parseTemplateXml(QXmlStreamReader &reader, TemplateInfo *info)
return true;
}
-QList<TemplateInfo> QmlApp::templateInfos()
+class TemplateInfoList
{
- QList<TemplateInfo> result;
- foreach (const QString &templateName, templateNames()) {
- const QString templatePath = templateRootDirectory() + templateName;
- QFile xmlFile(templatePath + QLatin1String("/template.xml"));
- if (!xmlFile.open(QIODevice::ReadOnly)) {
- qWarning().nospace() << QString::fromLatin1("Cannot open %1").arg(QDir::toNativeSeparators(QFileInfo(xmlFile.fileName()).absoluteFilePath()));
- continue;
+public:
+ TemplateInfoList()
+ {
+ QMultiMap<QString, TemplateInfo> multiMap;
+ foreach (const QString &templateName, templateNames()) {
+ const QString templatePath = templateRootDirectory() + templateName;
+ QFile xmlFile(templatePath + QLatin1String("/template.xml"));
+ if (!xmlFile.open(QIODevice::ReadOnly)) {
+ qWarning().nospace() << QString::fromLatin1("Cannot open %1").arg(QDir::toNativeSeparators(QFileInfo(xmlFile.fileName()).absoluteFilePath()));
+ continue;
+ }
+ TemplateInfo info;
+ info.templateName = templateName;
+ info.templatePath = templatePath;
+ QXmlStreamReader reader(&xmlFile);
+ if (parseTemplateXml(reader, &info))
+ multiMap.insert(info.priority, info);
}
- TemplateInfo info;
- info.templateName = templateName;
- info.templatePath = templatePath;
- QXmlStreamReader reader(&xmlFile);
- if (parseTemplateXml(reader, &info))
- result.append(info);
+ m_templateInfoList = multiMap.values();
}
- return result;
+ QList<TemplateInfo> templateInfoList() const { return m_templateInfoList; }
+
+private:
+ QList<TemplateInfo> m_templateInfoList;
+};
+
+Q_GLOBAL_STATIC(TemplateInfoList, templateInfoList)
+
+QList<TemplateInfo> QmlApp::templateInfos()
+{
+ return templateInfoList()->templateInfoList();
}
static QFileInfoList allFilesRecursive(const QString &path)
@@ -361,7 +366,6 @@ QString QmlApp::renameQmlFile(const QString &fileName) {
Core::GeneratedFiles QmlApp::generateFiles(QString *errorMessage)
{
-
Core::GeneratedFiles files;
QTC_ASSERT(errorMessage, return files);
diff --git a/src/plugins/qmlprojectmanager/qmlapp.h b/src/plugins/qmlprojectmanager/qmlapp.h
index 4d40e337d1..9dd566689b 100644
--- a/src/plugins/qmlprojectmanager/qmlapp.h
+++ b/src/plugins/qmlprojectmanager/qmlapp.h
@@ -42,8 +42,6 @@ namespace Internal {
class TemplateInfo
{
public:
- TemplateInfo();
-
QString templateName;
QString templatePath;
QString displayName;
@@ -51,8 +49,7 @@ public:
QString openFile;
QString wizardId;
QString featuresRequired;
-
- int priority;
+ QString priority;
};
class QmlApp : public QObject
@@ -66,11 +63,8 @@ public:
QString mainQmlFileName() const;
QString projectDirectory() const;
QString projectName() const;
- const TemplateInfo &templateInfo() const;
QString templateDirectory() const;
- static QString templateRootDirectory();
- static QStringList templateNames();
static QList<TemplateInfo> templateInfos();
Core::GeneratedFiles generateFiles(QString *errorMessage);
diff --git a/src/plugins/qmlprojectmanager/qmlapplicationwizard.cpp b/src/plugins/qmlprojectmanager/qmlapplicationwizard.cpp
index 6ae705ddb8..3b99c6ef57 100644
--- a/src/plugins/qmlprojectmanager/qmlapplicationwizard.cpp
+++ b/src/plugins/qmlprojectmanager/qmlapplicationwizard.cpp
@@ -41,6 +41,7 @@
#include "qmlprojectmanager.h"
#include "qmlproject.h"
+#include "qmlapplicationwizardpages.h"
#include <QIcon>
@@ -52,20 +53,23 @@ using namespace QmakeProjectManager;
namespace QmlProjectManager {
namespace Internal {
-QmlApplicationWizardDialog::QmlApplicationWizardDialog(QmlApp *qmlApp, QWidget *parent, const WizardDialogParameters &parameters)
- : BaseProjectWizardDialog(parent, parameters),
- m_qmlApp(qmlApp)
+QmlApplicationWizardDialog::QmlApplicationWizardDialog(QWidget *parent, const WizardDialogParameters &parameters)
+ : BaseProjectWizardDialog(parent, parameters)
{
setWindowTitle(tr("New Qt Quick UI Project"));
setIntroDescription(tr("This wizard generates a Qt Quick UI project."));
+ m_componentSetPage = new QmlComponentSetPage;
+ const int pageId = addPage(m_componentSetPage);
+ wizardProgress()->item(pageId)->setTitle(tr("Component Set"));
}
-QmlApp *QmlApplicationWizardDialog::qmlApp() const
+TemplateInfo QmlApplicationWizardDialog::templateInfo() const
{
- return m_qmlApp;
+ return m_componentSetPage->templateInfo();
}
-QmlApplicationWizard::QmlApplicationWizard(const TemplateInfo &templateInfo)
+
+QmlApplicationWizard::QmlApplicationWizard()
: m_qmlApp(new QmlApp(this))
{
setWizardKind(ProjectWizard);
@@ -74,47 +78,14 @@ QmlApplicationWizard::QmlApplicationWizard(const TemplateInfo &templateInfo)
setIcon(QIcon(QLatin1String(QmakeProjectManager::Constants::ICON_QTQUICK_APP)));
setDisplayCategory(
QLatin1String(ProjectExplorer::Constants::QT_APPLICATION_WIZARD_CATEGORY_DISPLAY));
- setDisplayName(tr("Qt Quick Application"));
- setDescription(tr("Creates a Qt Quick application project."));
-
- m_qmlApp->setTemplateInfo(templateInfo);
-}
-
-void QmlApplicationWizard::createInstances(ExtensionSystem::IPlugin *plugin)
-{
- foreach (const TemplateInfo &templateInfo, QmlApp::templateInfos()) {
- QmlApplicationWizard *wizard = new QmlApplicationWizard(templateInfo);
- wizard->setDisplayName(templateInfo.displayName);
- wizard->setDescription(templateInfo.description);
- const QString imagePath = templateInfo.templatePath + QLatin1String("/template.png");
- if (QFileInfo(imagePath).exists())
- wizard->setDescriptionImage(imagePath);
- wizard->setCategory(
- QLatin1String(ProjectExplorer::Constants::QT_APPLICATION_WIZARD_CATEGORY));
- wizard->setDisplayCategory(
- QLatin1String(ProjectExplorer::Constants::QT_APPLICATION_WIZARD_CATEGORY_DISPLAY));
- wizard->setWizardKind(IWizard::ProjectWizard);
- wizard->setId(templateInfo.wizardId);
-
- QStringList stringList =
- templateInfo.featuresRequired.split(QLatin1Char(','), QString::SkipEmptyParts);
- FeatureSet features;
- foreach (const QString &string, stringList) {
- Feature feature(Id::fromString(string.trimmed()));
- features |= feature;
- }
-
- wizard->setRequiredFeatures(features);
- wizard->setIcon(QIcon(QLatin1String(QmakeProjectManager::Constants::ICON_QTQUICK_APP)));
- plugin->addAutoReleasedObject(wizard);
- }
+ setDisplayName(tr("Qt Quick UI"));
+ setDescription(tr("Creates a Qt Quick UI project."));
}
QWizard *QmlApplicationWizard::createWizardDialog(QWidget *parent,
const WizardDialogParameters &wizardDialogParameters) const
{
- QmlApplicationWizardDialog *wizardDialog = new QmlApplicationWizardDialog(m_qmlApp,
- parent, wizardDialogParameters);
+ QmlApplicationWizardDialog *wizardDialog = new QmlApplicationWizardDialog(parent, wizardDialogParameters);
connect(wizardDialog, SIGNAL(projectParametersChanged(QString,QString)), m_qmlApp,
SLOT(setProjectNameAndBaseDirectory(QString,QString)));
@@ -129,9 +100,11 @@ QWizard *QmlApplicationWizard::createWizardDialog(QWidget *parent,
return wizardDialog;
}
-GeneratedFiles QmlApplicationWizard::generateFiles(const QWizard * /*wizard*/,
- QString *errorMessage) const
+GeneratedFiles QmlApplicationWizard::generateFiles(const QWizard *w,
+ QString *errorMessage) const
{
+ const QmlApplicationWizardDialog *wizard = qobject_cast<const QmlApplicationWizardDialog*>(w);
+ m_qmlApp->setTemplateInfo(wizard->templateInfo());
return m_qmlApp->generateFiles(errorMessage);
}
diff --git a/src/plugins/qmlprojectmanager/qmlapplicationwizard.h b/src/plugins/qmlprojectmanager/qmlapplicationwizard.h
index 6d56198837..b5d0952588 100644
--- a/src/plugins/qmlprojectmanager/qmlapplicationwizard.h
+++ b/src/plugins/qmlprojectmanager/qmlapplicationwizard.h
@@ -42,18 +42,19 @@ namespace Internal {
class QmlApp;
class TemplateInfo;
+class QmlComponentSetPage;
class QmlApplicationWizardDialog : public ProjectExplorer::BaseProjectWizardDialog
{
Q_OBJECT
public:
- QmlApplicationWizardDialog(QmlApp *qmlApp, QWidget *parent,
+ QmlApplicationWizardDialog(QWidget *parent,
const Core::WizardDialogParameters &parameters);
- QmlApp *qmlApp() const;
+ TemplateInfo templateInfo() const;
private:
- QmlApp *m_qmlApp;
+ QmlComponentSetPage *m_componentSetPage;
};
@@ -62,7 +63,7 @@ class QmlApplicationWizard : public Core::BaseFileWizard
Q_OBJECT
public:
- explicit QmlApplicationWizard(const TemplateInfo &templateInfo);
+ explicit QmlApplicationWizard();
static void createInstances(ExtensionSystem::IPlugin *plugin);
@@ -74,7 +75,6 @@ private:
bool postGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l, QString *errorMessage);
private:
-// mutable QString m_id;
QmlApp *m_qmlApp;
};
diff --git a/src/plugins/qmlprojectmanager/qmlapplicationwizardpages.cpp b/src/plugins/qmlprojectmanager/qmlapplicationwizardpages.cpp
new file mode 100644
index 0000000000..107c761e6f
--- /dev/null
+++ b/src/plugins/qmlprojectmanager/qmlapplicationwizardpages.cpp
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "qmlapplicationwizardpages.h"
+#include "qmlapp.h"
+#include <QComboBox>
+#include <QLabel>
+#include <QVBoxLayout>
+
+namespace QmlProjectManager {
+namespace Internal {
+
+class QmlComponentSetPagePrivate
+{
+public:
+ QComboBox *m_versionComboBox;
+ QLabel *m_detailedDescriptionLabel;
+};
+
+QmlComponentSetPage::QmlComponentSetPage(QWidget *parent)
+ : QWizardPage(parent)
+ , d(new QmlComponentSetPagePrivate)
+{
+ setTitle(tr("Select Qt Quick Component Set"));
+ QVBoxLayout *mainLayout = new QVBoxLayout(this);
+ QHBoxLayout *l = new QHBoxLayout();
+
+ QLabel *label = new QLabel(tr("Qt Quick component set:"), this);
+ d->m_versionComboBox = new QComboBox(this);
+
+ foreach (const TemplateInfo &templateInfo, QmlApp::templateInfos())
+ d->m_versionComboBox->addItem(templateInfo.displayName);
+
+ l->addWidget(label);
+ l->addWidget(d->m_versionComboBox);
+
+ d->m_detailedDescriptionLabel = new QLabel(this);
+ d->m_detailedDescriptionLabel->setWordWrap(true);
+ d->m_detailedDescriptionLabel->setTextFormat(Qt::RichText);
+ connect(d->m_versionComboBox, SIGNAL(currentIndexChanged(int)), this,
+ SLOT(updateDescription(int)));
+ updateDescription(d->m_versionComboBox->currentIndex());
+
+ mainLayout->addLayout(l);
+ mainLayout->addWidget(d->m_detailedDescriptionLabel);
+}
+
+QmlComponentSetPage::~QmlComponentSetPage()
+{
+ delete d;
+}
+
+TemplateInfo QmlComponentSetPage::templateInfo() const
+{
+ if (QmlApp::templateInfos().isEmpty())
+ return TemplateInfo();
+ return QmlApp::templateInfos().at(d->m_versionComboBox->currentIndex());
+}
+
+void QmlComponentSetPage::updateDescription(int index)
+{
+ if (QmlApp::templateInfos().isEmpty())
+ return;
+
+ const TemplateInfo templateInfo = QmlApp::templateInfos().at(index);
+ d->m_detailedDescriptionLabel->setText(templateInfo.description);
+}
+
+} // namespace Internal
+} // namespace QmlProjectManager
diff --git a/src/plugins/qmlprojectmanager/qmlapplicationwizardpages.h b/src/plugins/qmlprojectmanager/qmlapplicationwizardpages.h
new file mode 100644
index 0000000000..a39ace52ae
--- /dev/null
+++ b/src/plugins/qmlprojectmanager/qmlapplicationwizardpages.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef QMLAPPLICATIONWIZARDPAGES_H
+#define QMLAPPLICATIONWIZARDPAGES_H
+
+#include <QWizardPage>
+
+namespace QmlProjectManager {
+namespace Internal {
+
+class TemplateInfo;
+
+class QmlComponentSetPage : public QWizardPage
+{
+ Q_OBJECT
+
+public:
+ explicit QmlComponentSetPage(QWidget *parent = 0);
+ ~QmlComponentSetPage();
+
+ TemplateInfo templateInfo() const;
+
+private slots:
+ void updateDescription(int index);
+
+private:
+ class QmlComponentSetPagePrivate *d;
+};
+
+} // namespace Internal
+} // namespace QmlProjectManager
+
+#endif // QMLAPPLICATIONWIZARDPAGES_H
diff --git a/src/plugins/qmlprojectmanager/qmlprojectmanager.pro b/src/plugins/qmlprojectmanager/qmlprojectmanager.pro
index 662e882865..4c8a6211e4 100644
--- a/src/plugins/qmlprojectmanager/qmlprojectmanager.pro
+++ b/src/plugins/qmlprojectmanager/qmlprojectmanager.pro
@@ -17,7 +17,8 @@ HEADERS += qmlproject.h \
qmlprojectmanagerconstants.h \
qmlprojectrunconfigurationwidget.h \
qmlapp.h \
- qmlapplicationwizard.h
+ qmlapplicationwizard.h \
+ qmlapplicationwizardpages.h
SOURCES += qmlproject.cpp \
qmlprojectenvironmentaspect.cpp \
@@ -29,6 +30,7 @@ SOURCES += qmlproject.cpp \
qmlprojectrunconfigurationfactory.cpp \
qmlprojectrunconfigurationwidget.cpp \
qmlapp.cpp \
- qmlapplicationwizard.cpp
+ qmlapplicationwizard.cpp \
+ qmlapplicationwizardpages.cpp
RESOURCES += qmlproject.qrc
diff --git a/src/plugins/qmlprojectmanager/qmlprojectmanager.qbs b/src/plugins/qmlprojectmanager/qmlprojectmanager.qbs
index 473569d626..9aa2166f3f 100644
--- a/src/plugins/qmlprojectmanager/qmlprojectmanager.qbs
+++ b/src/plugins/qmlprojectmanager/qmlprojectmanager.qbs
@@ -21,6 +21,7 @@ QtcPlugin {
files: [
"qmlapp.cpp", "qmlapp.h",
"qmlapplicationwizard.cpp", "qmlapplicationwizard.h",
+ "qmlapplicationwizardpages.cpp", "qmlapplicationwizardpages.h",
"qmlproject.cpp", "qmlproject.h",
"qmlproject.qrc",
"qmlprojectconstants.h",
diff --git a/src/plugins/qmlprojectmanager/qmlprojectplugin.cpp b/src/plugins/qmlprojectmanager/qmlprojectplugin.cpp
index b871be0795..b4495cb8ae 100644
--- a/src/plugins/qmlprojectmanager/qmlprojectplugin.cpp
+++ b/src/plugins/qmlprojectmanager/qmlprojectplugin.cpp
@@ -66,8 +66,7 @@ bool QmlProjectPlugin::initialize(const QStringList &, QString *errorMessage)
addAutoReleasedObject(new Internal::Manager);
addAutoReleasedObject(new Internal::QmlProjectRunConfigurationFactory);
-
- Internal::QmlApplicationWizard::createInstances(this);
+ addAutoReleasedObject(new Internal::QmlApplicationWizard);
FileIconProvider::registerIconOverlayForSuffix(":/qmlproject/images/qmlproject.png", "qmlproject");
return true;