forked from qt-creator/qt-creator
Restructure qtquick templates, read them dynamically
Change-Id: I11dfac8ce8d6b1e68df0151516cdc03247fffe3a Reviewed-by: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
+1
-1
@@ -8,7 +8,7 @@ int main(int argc, char *argv[])
|
||||
QtQuick1ApplicationViewer viewer;
|
||||
viewer.addImportPath(QLatin1String("modules")); // ADDIMPORTPATH
|
||||
viewer.setOrientation(QtQuick1ApplicationViewer::ScreenOrientationAuto); // ORIENTATION
|
||||
viewer.setMainQmlFile(QLatin1String("qml/app/qtquick10/main.qml")); // MAINQML
|
||||
viewer.setMainQmlFile(QLatin1String("qml/app/main.qml")); // MAINQML
|
||||
viewer.showExpanded();
|
||||
|
||||
return app.exec();
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<template openeditor="main.qml" priority="C"
|
||||
featuresRequired="QtSupport.Wizards.FeatureQtQuick, QtSupport.Wizards.FeatureQtQuick.1.1"
|
||||
viewerdir="qtquick1applicationviewer"
|
||||
viewerclassname="QtQuick1ApplicationViewer"
|
||||
stubversionminor="24">
|
||||
<displayname>Qt Quick 1.1</displayname>
|
||||
<description>Creates a Qt Quick 1 application project that can contain both QML and C++ code and includes a QDeclarativeView. The built-in QML types in the QtQuick 1 namespace allow you to write cross-platform applications with a custom look and feel. Requires Qt 4.8 or newer.</description>
|
||||
</template>
|
||||
+1
-1
@@ -6,7 +6,7 @@ int main(int argc, char *argv[])
|
||||
QGuiApplication app(argc, argv);
|
||||
|
||||
QtQuick2ApplicationViewer viewer;
|
||||
viewer.setMainQmlFile(QStringLiteral("qml/app/qtquick20/main.qml")); // MAINQML
|
||||
viewer.setMainQmlFile(QStringLiteral("qml/app/main.qml")); // MAINQML
|
||||
viewer.showExpanded();
|
||||
|
||||
return app.exec();
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<template openeditor="main.qml" priority="B"
|
||||
featuresRequired="QtSupport.Wizards.FeatureQtQuick, QtSupport.Wizards.FeatureQtQuick.2"
|
||||
viewerdir="qtquick2applicationviewer"
|
||||
viewerclassname="QtQuick2ApplicationViewer"
|
||||
stubversionminor="5">
|
||||
<displayname>Qt Quick 2.0</displayname>
|
||||
<description>Creates a Qt Quick 2 application project that can contain both QML and C++ code and includes a QQuickView. The built-in QML types in the QtQuick 2 namespace allow you to write cross-platform applications with a custom look and feel. Requires Qt 5.0 or newer.</description>
|
||||
</template>
|
||||
+1
-1
@@ -5,7 +5,7 @@ int main(int argc, char *argv[])
|
||||
Application app(argc, argv);
|
||||
|
||||
QtQuick2ControlsApplicationViewer viewer;
|
||||
viewer.setMainQmlFile(QStringLiteral("qml/app/qtquick21/main.qml")); // MAINQML
|
||||
viewer.setMainQmlFile(QStringLiteral("qml/app/main.qml")); // MAINQML
|
||||
viewer.show();
|
||||
|
||||
return app.exec();
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<template openeditor="main.qml" priority="A"
|
||||
featuresRequired="QtSupport.Wizards.FeatureQtQuick, QtSupport.Wizards.FeatureQtQuick.2, QtSupport.Wizards.FeatureQtQuick.Controls"
|
||||
viewerdir="qtquick2controlsapplicationviewer"
|
||||
viewerclassname="QtQuick2ControlsApplicationViewer"
|
||||
stubversionminor="1">
|
||||
<displayname>Qt Quick Controls 1.0</displayname>
|
||||
<description>Creates a Qt Quick 2 application project that can contain both QML and C++ code and includes a QQuickView. Creates a deployable Qt Quick application using Qt Quick Controls. All files and directories that reside in the same directory as the main .qml file are deployed. You can modify the contents of the directory any time before deploying. Requires Qt 5.1 or newer.</description>
|
||||
</template>
|
||||
@@ -0,0 +1,6 @@
|
||||
let $prefix := string("QT_TRANSLATE_NOOP("QmakeProjectManager::QtQuickAppWizard", "")
|
||||
let $suffix := concat("")", codepoints-to-string(10))
|
||||
for $file in tokenize($files, string("\|"))
|
||||
let $doc := doc($file)
|
||||
for $text in ($doc/*:template/*:description, $doc/*:template/*:displayname)
|
||||
return fn:concat($prefix, data($text), $suffix)
|
||||
@@ -22,6 +22,7 @@ TRANSLATIONS = $$prependAll(LANGUAGES, $$PWD/qtcreator_,.ts)
|
||||
MIME_TR_H = $$OUT_PWD/mime_tr.h
|
||||
CUSTOMWIZARD_TR_H = $$OUT_PWD/customwizard_tr.h
|
||||
QMLWIZARD_TR_H = $$OUT_PWD/qmlwizard_tr.h
|
||||
QTQUICKWIZARD_TR_H = $$OUT_PWD/qtquickwizard_tr.h
|
||||
EXTERNALTOOLS_TR_H = $$OUT_PWD/externaltools_tr.h
|
||||
|
||||
for(dir, $$list($$files($$IDE_SOURCE_TREE/src/plugins/*))):MIMETYPES_FILES += $$files($$dir/*.mimetypes.xml)
|
||||
@@ -33,6 +34,9 @@ CUSTOMWIZARD_FILES = \"$$join(CUSTOMWIZARD_FILES, |)\"
|
||||
for(dir, $$list($$files($$IDE_SOURCE_TREE/share/qtcreator/templates/qml/*))):QMLWIZARD_FILES += $$files($$dir/template.xml)
|
||||
QMLWIZARD_FILES = \"$$join(QMLWIZARD_FILES, |)\"
|
||||
|
||||
for(dir, $$list($$files($$IDE_SOURCE_TREE/share/qtcreator/templates/qtquick/*))):QTQUICKWIZARD_FILES += $$files($$dir/template.xml)
|
||||
QTQUICKWIZARD_FILES = \"$$join(QTQUICKWIZARD_FILES, |)\"
|
||||
|
||||
for(file, $$list($$files($$IDE_SOURCE_TREE/src/share/qtcreator/externaltools/*))):EXTERNALTOOLS_FILES += $$files($$file)
|
||||
EXTERNALTOOLS_FILES = \"$$join(EXTERNALTOOLS_FILES, |)\"
|
||||
|
||||
@@ -40,6 +44,7 @@ extract.commands += \
|
||||
$$XMLPATTERNS -output $$MIME_TR_H -param files=$$MIMETYPES_FILES $$PWD/extract-mimetypes.xq $$escape_expand(\\n\\t) \
|
||||
$$XMLPATTERNS -output $$CUSTOMWIZARD_TR_H -param files=$$CUSTOMWIZARD_FILES $$PWD/extract-customwizards.xq $$escape_expand(\\n\\t) \
|
||||
$$XMLPATTERNS -output $$QMLWIZARD_TR_H -param files=$$QMLWIZARD_FILES $$PWD/extract-qmlwizards.xq $$escape_expand(\\n\\t) \
|
||||
$$XMLPATTERNS -output $$QTQUICKWIZARD_TR_H -param files=$$QTQUICKWIZARD_FILES $$PWD/extract-qtquickwizards.xq $$escape_expand(\\n\\t) \
|
||||
$$XMLPATTERNS -output $$EXTERNALTOOLS_TR_H -param files=$$EXTERNALTOOLS_FILES $$PWD/extract-externaltools.xq
|
||||
QMAKE_EXTRA_TARGETS += extract
|
||||
|
||||
@@ -59,12 +64,12 @@ files = $$files($$PWD/*_??.ts) $$PWD/qtcreator_untranslated.ts
|
||||
for(file, files) {
|
||||
lang = $$replace(file, .*_([^/]*)\\.ts, \\1)
|
||||
v = ts-$${lang}.commands
|
||||
$$v = cd $$wd && $$LUPDATE $$sources $$MIME_TR_H $$CUSTOMWIZARD_TR_H $$QMLWIZARD_TR_H $$EXTERNALTOOLS_TR_H -ts $$file
|
||||
$$v = cd $$wd && $$LUPDATE $$sources $$MIME_TR_H $$CUSTOMWIZARD_TR_H $$QMLWIZARD_TR_H $$QTQUICKWIZARD_TR_H $$EXTERNALTOOLS_TR_H -ts $$file
|
||||
v = ts-$${lang}.depends
|
||||
$$v = extract
|
||||
QMAKE_EXTRA_TARGETS += ts-$$lang
|
||||
}
|
||||
ts-all.commands = cd $$wd && $$LUPDATE $$sources $$MIME_TR_H $$CUSTOMWIZARD_TR_H $$QMLWIZARD_TR_H $$EXTERNALTOOLS_TR_H -ts $$files
|
||||
ts-all.commands = cd $$wd && $$LUPDATE $$sources $$MIME_TR_H $$CUSTOMWIZARD_TR_H $$QMLWIZARD_TR_H $$QTQUICKWIZARD_TR_H$$EXTERNALTOOLS_TR_H -ts $$files
|
||||
ts-all.depends = extract
|
||||
QMAKE_EXTRA_TARGETS += ts-all
|
||||
|
||||
|
||||
@@ -429,10 +429,10 @@ bool QmakeProject::fromMap(const QVariantMap &map)
|
||||
foreach (QmakeProFileNode *node, applicationProFiles(QmakeProject::ExactAndCumulativeParse)) {
|
||||
const QString path = node->path();
|
||||
|
||||
qtQuickApp.setComponentSet(QtQuickApp::QtQuick10Components);
|
||||
updateBoilerPlateCodeFiles(&qtQuickApp, path);
|
||||
qtQuickApp.setComponentSet(QtQuickApp::QtQuick20Components);
|
||||
updateBoilerPlateCodeFiles(&qtQuickApp, path);
|
||||
foreach (TemplateInfo info, QtQuickApp::templateInfos()) {
|
||||
qtQuickApp.setTemplateInfo(info);
|
||||
updateBoilerPlateCodeFiles(&qtQuickApp, path);
|
||||
}
|
||||
updateBoilerPlateCodeFiles(&html5App, path);
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "qtquickapp.h"
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
@@ -43,20 +44,152 @@
|
||||
namespace QmakeProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
static QString templateRootDirectory()
|
||||
{
|
||||
return Core::ICore::resourcePath() + QLatin1String("/templates/qtquick/");
|
||||
}
|
||||
|
||||
static QStringList templateNames()
|
||||
{
|
||||
QStringList templateNameList;
|
||||
const QDir templateRoot(templateRootDirectory());
|
||||
|
||||
foreach (const QFileInfo &subDirectory,
|
||||
templateRoot.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot))
|
||||
templateNameList.append(subDirectory.fileName());
|
||||
|
||||
return templateNameList;
|
||||
}
|
||||
|
||||
// Return locale language attribute "de_UTF8" -> "de", empty string for "C"
|
||||
static QString languageSetting()
|
||||
{
|
||||
#ifdef QT_CREATOR
|
||||
QString name = Core::ICore::userInterfaceLanguage();
|
||||
const int underScorePos = name.indexOf(QLatin1Char('_'));
|
||||
if (underScorePos != -1)
|
||||
name.truncate(underScorePos);
|
||||
if (name.compare(QLatin1String("C"), Qt::CaseInsensitive) == 0)
|
||||
name.clear();
|
||||
return name;
|
||||
#else
|
||||
return QLocale::system().name();
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline bool assignLanguageElementText(QXmlStreamReader &reader,
|
||||
const QString &desiredLanguage,
|
||||
QString *target)
|
||||
{
|
||||
const QStringRef elementLanguage = reader.attributes().value(QLatin1String("xml:lang"));
|
||||
if (elementLanguage.isEmpty()) {
|
||||
// Try to find a translation for our Wizards
|
||||
*target = QCoreApplication::translate("QmakeProjectManager::QtQuickAppWizard",
|
||||
reader.readElementText().toLatin1().constData());
|
||||
return true;
|
||||
}
|
||||
if (elementLanguage == desiredLanguage) {
|
||||
*target = reader.readElementText();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool parseTemplateXml(QXmlStreamReader &reader, TemplateInfo *info)
|
||||
{
|
||||
const QString locale = languageSetting();
|
||||
|
||||
static const QLatin1String tag_template("template");
|
||||
static const QLatin1String tag_displayName("displayname");
|
||||
static const QLatin1String tag_description("description");
|
||||
static const QLatin1String attribute_featuresRequired("featuresRequired");
|
||||
static const QLatin1String attribute_openEditor("openeditor");
|
||||
static const QLatin1String attribute_priority("priority");
|
||||
static const QLatin1String attribute_viewerdir("viewerdir");
|
||||
static const QLatin1String attribute_viewerclassname("viewerclassname");
|
||||
static const QLatin1String attribute_stubversionminor("stubversionminor");
|
||||
|
||||
while (!reader.atEnd() && !reader.hasError()) {
|
||||
reader.readNext();
|
||||
if (reader.tokenType() != QXmlStreamReader::StartElement)
|
||||
continue;
|
||||
|
||||
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();
|
||||
|
||||
if (reader.attributes().hasAttribute(attribute_featuresRequired))
|
||||
info->featuresRequired = reader.attributes().value(attribute_featuresRequired).toString();
|
||||
|
||||
if (reader.attributes().hasAttribute(attribute_viewerdir))
|
||||
info->viewerDir = reader.attributes().value(attribute_viewerdir).toString();
|
||||
|
||||
if (reader.attributes().hasAttribute(attribute_viewerclassname))
|
||||
info->viewerClassName = reader.attributes().value(attribute_viewerclassname).toString();
|
||||
|
||||
if (reader.attributes().hasAttribute(attribute_stubversionminor))
|
||||
info->stubVersionMinor = reader.attributes().value(attribute_stubversionminor).toString().toInt();
|
||||
|
||||
} else if (reader.name() == tag_displayName) {
|
||||
if (!assignLanguageElementText(reader, locale, &info->displayName))
|
||||
continue;
|
||||
} else if (reader.name() == tag_description) {
|
||||
if (!assignLanguageElementText(reader, locale, &info->description))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (reader.hasError()) {
|
||||
qWarning() << reader.errorString();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
class TemplateInfoList
|
||||
{
|
||||
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);
|
||||
}
|
||||
m_templateInfoList = multiMap.values();
|
||||
}
|
||||
QList<TemplateInfo> templateInfoList() const { return m_templateInfoList; }
|
||||
|
||||
private:
|
||||
QList<TemplateInfo> m_templateInfoList;
|
||||
};
|
||||
|
||||
Q_GLOBAL_STATIC(TemplateInfoList, templateInfoList)
|
||||
|
||||
QList<TemplateInfo> QtQuickApp::templateInfos()
|
||||
{
|
||||
return templateInfoList()->templateInfoList();
|
||||
}
|
||||
|
||||
QtQuickApp::QtQuickApp()
|
||||
: AbstractMobileApp()
|
||||
, m_componentSet(QtQuick10Components)
|
||||
{
|
||||
}
|
||||
|
||||
void QtQuickApp::setComponentSet(ComponentSet componentSet)
|
||||
void QtQuickApp::setTemplateInfo(const TemplateInfo &templateInfo)
|
||||
{
|
||||
m_componentSet = componentSet;
|
||||
}
|
||||
|
||||
QtQuickApp::ComponentSet QtQuickApp::componentSet() const
|
||||
{
|
||||
return m_componentSet;
|
||||
m_templateInfo = templateInfo;
|
||||
}
|
||||
|
||||
QString QtQuickApp::pathExtended(int fileType) const
|
||||
@@ -88,28 +221,12 @@ QString QtQuickApp::pathExtended(int fileType) const
|
||||
|
||||
QString QtQuickApp::originsRoot() const
|
||||
{
|
||||
switch (m_componentSet) {
|
||||
case QtQuickControls10: return templatesRoot() + QLatin1String("qtquick2controls/");
|
||||
case QtQuick20Components: return templatesRoot() + QLatin1String("qtquick2app/");
|
||||
case QtQuick10Components: return templatesRoot() + QLatin1String("qtquick1app/");
|
||||
}
|
||||
|
||||
qWarning() << "QtQuickApp::originsRoot() - unhandled component set"
|
||||
<< m_componentSet;
|
||||
return QString();
|
||||
return m_templateInfo.templatePath + QLatin1Char('/');
|
||||
}
|
||||
|
||||
QString QtQuickApp::mainWindowClassName() const
|
||||
{
|
||||
switch (m_componentSet) {
|
||||
case QtQuickControls10: return QLatin1String("QtQuick2ControlsApplicationViewer");
|
||||
case QtQuick20Components: return QLatin1String("QtQuick2ApplicationViewer");
|
||||
case QtQuick10Components: return QLatin1String("QtQuick1ApplicationViewer");
|
||||
}
|
||||
|
||||
qWarning() << "QtQuickApp::mainWindowClassName() - unhandled component set"
|
||||
<< m_componentSet;
|
||||
return QString();
|
||||
return m_templateInfo.viewerClassName;
|
||||
}
|
||||
|
||||
bool QtQuickApp::adaptCurrentMainCppTemplateLine(QString &line) const
|
||||
@@ -162,15 +279,7 @@ bool QtQuickApp::useExistingMainQml() const
|
||||
|
||||
QString QtQuickApp::appViewerBaseName() const
|
||||
{
|
||||
switch (m_componentSet) {
|
||||
case QtQuickControls10: return QLatin1String("qtquick2controlsapplicationviewer");
|
||||
case QtQuick20Components: return QLatin1String("qtquick2applicationviewer");
|
||||
case QtQuick10Components: return QLatin1String("qtquick1applicationviewer");
|
||||
}
|
||||
|
||||
qWarning() << "QtQuickApp::appViewerBaseName() - unhandled component set"
|
||||
<< m_componentSet;
|
||||
return QString();
|
||||
return m_templateInfo.viewerDir;
|
||||
}
|
||||
|
||||
QString QtQuickApp::fileName(QtQuickApp::ExtendedFileType type) const
|
||||
@@ -217,7 +326,7 @@ QByteArray QtQuickApp::generateFileExtended(int fileType,
|
||||
|
||||
int QtQuickApp::stubVersionMinor() const
|
||||
{
|
||||
return (m_componentSet == QtQuick20Components || m_componentSet == QtQuickControls10) ? 5 : 24;
|
||||
return m_templateInfo.stubVersionMinor;
|
||||
}
|
||||
|
||||
QList<AbstractGeneratedFileInfo> QtQuickApp::updateableFiles(const QString &mainProFile) const
|
||||
|
||||
@@ -47,6 +47,22 @@ struct QtQuickAppGeneratedFileInfo : public AbstractGeneratedFileInfo
|
||||
QtQuickAppGeneratedFileInfo() : AbstractGeneratedFileInfo() {}
|
||||
};
|
||||
|
||||
class TemplateInfo
|
||||
{
|
||||
public:
|
||||
TemplateInfo() : stubVersionMinor(9) {}
|
||||
QString templateName;
|
||||
QString templatePath;
|
||||
QString displayName;
|
||||
QString description;
|
||||
QString openFile;
|
||||
QString featuresRequired;
|
||||
QString priority;
|
||||
QString viewerClassName;
|
||||
QString viewerDir;
|
||||
int stubVersionMinor;
|
||||
};
|
||||
|
||||
class QtQuickApp : public AbstractMobileApp
|
||||
{
|
||||
public:
|
||||
@@ -63,16 +79,11 @@ public:
|
||||
QmlDirProFileRelative
|
||||
};
|
||||
|
||||
enum ComponentSet {
|
||||
QtQuick10Components,
|
||||
QtQuick20Components,
|
||||
QtQuickControls10
|
||||
};
|
||||
|
||||
QtQuickApp();
|
||||
|
||||
void setComponentSet(ComponentSet componentSet);
|
||||
ComponentSet componentSet() const;
|
||||
static QList<TemplateInfo> templateInfos();
|
||||
|
||||
void setTemplateInfo(const TemplateInfo &templateInfo);
|
||||
|
||||
#ifndef CREATORLESSTEST
|
||||
virtual Core::GeneratedFiles generateFiles(QString *errorMessage) const;
|
||||
@@ -103,7 +114,7 @@ private:
|
||||
QList<DeploymentFolder> deploymentFolders() const;
|
||||
|
||||
QFileInfo m_mainQmlFile;
|
||||
ComponentSet m_componentSet;
|
||||
TemplateInfo m_templateInfo;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -49,7 +49,7 @@ class QtQuickAppWizardDialog : public AbstractMobileAppWizardDialog
|
||||
|
||||
public:
|
||||
explicit QtQuickAppWizardDialog(QWidget *parent, const Core::WizardDialogParameters ¶meters);
|
||||
QtQuickApp::ComponentSet componentSet() const { return m_componentSetPage->componentSet(); }
|
||||
TemplateInfo templateInfo() const;
|
||||
|
||||
protected:
|
||||
void initializePage(int id);
|
||||
@@ -76,26 +76,26 @@ QtQuickAppWizardDialog::QtQuickAppWizardDialog(QWidget *parent,
|
||||
void QtQuickAppWizardDialog::initializePage(int id)
|
||||
{
|
||||
if (page(id) == kitsPage()) {
|
||||
Core::FeatureSet features = Core::Feature(QtSupport::Constants::FEATURE_QT_QUICK_1);
|
||||
QtQuickApp::ComponentSet components = componentSet();
|
||||
switch (components) {
|
||||
case QtQuickApp::QtQuick10Components:
|
||||
features = Core::Feature(QtSupport::Constants::FEATURE_QT_QUICK_1);
|
||||
break;
|
||||
case QtQuickApp::QtQuick20Components:
|
||||
features = Core::Feature(QtSupport::Constants::FEATURE_QT_QUICK_2);
|
||||
break;
|
||||
case QtQuickApp::QtQuickControls10:
|
||||
features = Core::Feature(QtSupport::Constants::FEATURE_QT_QUICK_2)
|
||||
| Core::Feature(QtSupport::Constants::FEATURE_QT_QUICK_CONTROLS);
|
||||
break;
|
||||
QStringList stringList =
|
||||
templateInfo().featuresRequired.split(QLatin1Char(','), QString::SkipEmptyParts);
|
||||
Core::FeatureSet features;
|
||||
foreach (const QString &string, stringList) {
|
||||
Core::Feature feature(Core::Id::fromString(string.trimmed()));
|
||||
features |= feature;
|
||||
}
|
||||
|
||||
setRequiredFeatures(features);
|
||||
updateKitsPage();
|
||||
}
|
||||
AbstractMobileAppWizardDialog::initializePage(id);
|
||||
}
|
||||
|
||||
TemplateInfo QtQuickAppWizardDialog::templateInfo() const
|
||||
{
|
||||
return m_componentSetPage->templateInfo();
|
||||
}
|
||||
|
||||
|
||||
class QtQuickAppWizardPrivate
|
||||
{
|
||||
class QtQuickApp *app;
|
||||
@@ -143,7 +143,7 @@ void QtQuickAppWizard::prepareGenerateFiles(const QWizard *w,
|
||||
{
|
||||
Q_UNUSED(errorMessage)
|
||||
const QtQuickAppWizardDialog *wizard = qobject_cast<const QtQuickAppWizardDialog*>(w);
|
||||
d->app->setComponentSet(wizard->componentSet());
|
||||
d->app->setTemplateInfo(wizard->templateInfo());
|
||||
}
|
||||
|
||||
QString QtQuickAppWizard::fileToOpenPostGeneration() const
|
||||
|
||||
@@ -42,31 +42,6 @@ public:
|
||||
QLabel *m_descriptionLabel;
|
||||
};
|
||||
|
||||
QString QtQuickComponentSetPage::description(QtQuickApp::ComponentSet componentSet) const
|
||||
{
|
||||
const QString basicDescription = tr("Creates a Qt Quick 1 application project that can contain "
|
||||
"both QML and C++ code and includes a QDeclarativeView.<br><br>");
|
||||
const QString basicDescription2 = tr("Creates a Qt Quick 2 application project that can contain "
|
||||
"both QML and C++ code and includes a QQuickView.<br><br>");
|
||||
switch (componentSet) {
|
||||
case QtQuickApp::QtQuickControls10:
|
||||
return basicDescription2 + tr("Creates a deployable Qt Quick application using "
|
||||
"Qt Quick Controls. All files and directories that "
|
||||
"reside in the same directory as the main .qml file "
|
||||
"are deployed. You can modify the contents of the "
|
||||
"directory any time before deploying.\n\nRequires <b>Qt 5.1</b> or newer.");
|
||||
case QtQuickApp::QtQuick20Components:
|
||||
return basicDescription2 + tr("The built-in QML types in the QtQuick 2 namespace allow "
|
||||
"you to write cross-platform applications with "
|
||||
"a custom look and feel.\n\nRequires <b>Qt 5.0</b> or newer.");
|
||||
case QtQuickApp::QtQuick10Components:
|
||||
return basicDescription + tr("The built-in QML types in the QtQuick 1 namespace allow "
|
||||
"you to write cross-platform applications with "
|
||||
"a custom look and feel.\n\nRequires <b>Qt 4.8</b> or newer.");
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
QtQuickComponentSetPage::QtQuickComponentSetPage(QWidget *parent)
|
||||
: QWizardPage(parent)
|
||||
, d(new QtQuickComponentSetPagePrivate)
|
||||
@@ -77,9 +52,8 @@ QtQuickComponentSetPage::QtQuickComponentSetPage(QWidget *parent)
|
||||
|
||||
QLabel *label = new QLabel(tr("Qt Quick component set:"), this);
|
||||
d->m_versionComboBox = new QComboBox(this);
|
||||
d->m_versionComboBox->addItem(tr("Qt Quick Controls 1.0"), QtQuickApp::QtQuickControls10);
|
||||
d->m_versionComboBox->addItem(tr("Qt Quick 2.0"), QtQuickApp::QtQuick20Components);
|
||||
d->m_versionComboBox->addItem(tr("Qt Quick 1.1"), QtQuickApp::QtQuick10Components);
|
||||
foreach (const TemplateInfo &templateInfo, QtQuickApp::templateInfos())
|
||||
d->m_versionComboBox->addItem(templateInfo.displayName);
|
||||
|
||||
l->addWidget(label);
|
||||
l->addWidget(d->m_versionComboBox);
|
||||
@@ -87,7 +61,8 @@ QtQuickComponentSetPage::QtQuickComponentSetPage(QWidget *parent)
|
||||
d->m_descriptionLabel = new QLabel(this);
|
||||
d->m_descriptionLabel->setWordWrap(true);
|
||||
d->m_descriptionLabel->setTextFormat(Qt::RichText);
|
||||
connect(d->m_versionComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateDescription(int)));
|
||||
connect(d->m_versionComboBox, SIGNAL(currentIndexChanged(int)),
|
||||
this, SLOT(updateDescription(int)));
|
||||
updateDescription(d->m_versionComboBox->currentIndex());
|
||||
|
||||
mainLayout->addLayout(l);
|
||||
@@ -99,19 +74,20 @@ QtQuickComponentSetPage::~QtQuickComponentSetPage()
|
||||
delete d;
|
||||
}
|
||||
|
||||
QtQuickApp::ComponentSet QtQuickComponentSetPage::componentSet(int index) const
|
||||
TemplateInfo QtQuickComponentSetPage::templateInfo() const
|
||||
{
|
||||
return (QtQuickApp::ComponentSet)d->m_versionComboBox->itemData(index).toInt();
|
||||
}
|
||||
|
||||
QtQuickApp::ComponentSet QtQuickComponentSetPage::componentSet() const
|
||||
{
|
||||
return componentSet(d->m_versionComboBox->currentIndex());
|
||||
if (QtQuickApp::templateInfos().isEmpty())
|
||||
return TemplateInfo();
|
||||
return QtQuickApp::templateInfos().at(d->m_versionComboBox->currentIndex());
|
||||
}
|
||||
|
||||
void QtQuickComponentSetPage::updateDescription(int index)
|
||||
{
|
||||
d->m_descriptionLabel->setText(description(componentSet(index)));
|
||||
if (QtQuickApp::templateInfos().isEmpty())
|
||||
return;
|
||||
|
||||
const TemplateInfo templateInfo = QtQuickApp::templateInfos().at(index);
|
||||
d->m_descriptionLabel->setText(templateInfo.description);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -44,15 +44,12 @@ public:
|
||||
explicit QtQuickComponentSetPage(QWidget *parent = 0);
|
||||
virtual ~QtQuickComponentSetPage();
|
||||
|
||||
QtQuickApp::ComponentSet componentSet() const;
|
||||
TemplateInfo templateInfo() const;
|
||||
|
||||
private slots:
|
||||
void updateDescription(int index);
|
||||
|
||||
private:
|
||||
QtQuickApp::ComponentSet componentSet(int index) const;
|
||||
QString description(QtQuickApp::ComponentSet componentSet) const;
|
||||
|
||||
class QtQuickComponentSetPagePrivate *d;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user