Commit 62590507 authored by jkobus's avatar jkobus Committed by Jarek Kobus

Merge multi Qt Quick UI wizards into one

Change-Id: Ia984c36864dacd5b71c76976a351767bb4c3693c
Reviewed-by: default avatarKai Koehne <kai.koehne@digia.com>
parent 6313b2ca
<?xml version="1.0" encoding="UTF-8"?>
<template openeditor="main.qml" priority="2"
<template openeditor="main.qml" priority="C"
featuresRequired="QtSupport.Wizards.FeatureQtQuickProject, QtSupport.Wizards.FeatureQtQuick, QtSupport.Wizards.FeatureQtQuick.1.1"
id="QB.QML Application for Qt Quick 1.1">
<displayname>Qt Quick 1 UI</displayname>
<displayname xml:lang="de">Qt Quick 1 UI</displayname>
<displayname>Qt Quick 1.1</displayname>
<description>Creates a Qt Quick 1 UI project with a single QML file that contains the main view. You can review Qt Quick 1 UI projects in the QML Viewer and you need not build them. You do not need to have the development environment installed on your computer to create and run this type of project. Requires Qt 4.8 or newer.</description>
</template>
<?xml version="1.0" encoding="UTF-8"?>
<template openeditor="main.qml" priority="2"
<template openeditor="main.qml" priority="B"
featuresRequired="QtSupport.Wizards.FeatureQtQuickProject, QtSupport.Wizards.FeatureQtQuick, QtSupport.Wizards.FeatureQtQuick.2"
id="QB.QML Application for Qt Quick 2.0">
<displayname>Qt Quick 2 UI</displayname>
<displayname xml:lang="de">Qt Quick 2 UI</displayname>
<displayname>Qt Quick 2.0</displayname>
<description>Creates a Qt Quick 2 UI project with a single QML file that contains the main view. You can review Qt Quick 2 UI projects in the QML Scene and you need not build them. You do not need to have the development environment installed on your computer to create and run this type of project. Requires Qt 5.0 or newer.</description>
</template>
<?xml version="1.0" encoding="UTF-8"?>
<template openeditor="main.qml" priority="2"
<template openeditor="main.qml" priority="A"
featuresRequired="QtSupport.Wizards.FeatureQtQuickProject, QtSupport.Wizards.FeatureQtQuick, QtSupport.Wizards.FeatureQtQuick.2, QtSupport.Wizards.FeatureQtQuick.Controls"
id="QB.QML Application for Qt Quick 2.0">
<displayname>Qt Quick 2 UI with Controls</displayname>
<displayname>Qt Quick Controls 1.0</displayname>
<description>Creates a Qt Quick 2 UI project with a single QML file that contains the main view and uses Qt Quick Controls. You can review Qt Quick 2 UI projects in the QML Scene and you need not build them. This project requires that you have installed Qt Quick Controls for your Qt version. Requires Qt 5.1 or newer.</description>
</template>
......@@ -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);
......
......@@ -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);
......
......@@ -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);
}
......
......@@ -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;
};
......
/****************************************************************************
**
** 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
/****************************************************************************
**
** 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
......@@ -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
......@@ -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",
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment