Commit 53969701 authored by Rainer Keller's avatar Rainer Keller
Browse files

Show Qt Quick templates only when needed plugins are available



A Qt Quick template should only be visible if its required plugins are
available.

Change-Id: I932563cb9ffd2a2eca0e77e9945638573d07ba3e
Reviewed-by: default avatarJarek Kobus <jaroslaw.kobus@digia.com>
parent 12103e0f
......@@ -119,6 +119,7 @@ static bool parseTemplateXml(QXmlStreamReader &reader, TemplateInfo *info)
static const QLatin1String attribute_viewerclassname("viewerclassname");
static const QLatin1String attribute_qrcdeployment("qrcdeployment");
static const QLatin1String attribute_stubversionminor("stubversionminor");
static const QLatin1String attribute_requiredPlugins("requiredPlugins");
while (!reader.atEnd() && !reader.hasError()) {
reader.readNext();
......@@ -145,6 +146,12 @@ static bool parseTemplateXml(QXmlStreamReader &reader, TemplateInfo *info)
if (reader.attributes().hasAttribute(attribute_stubversionminor))
info->stubVersionMinor = reader.attributes().value(attribute_stubversionminor).toString().toInt();
// This attribute is currently used in enterprise addons to filter out templates when the enterprise
// addon is not installed. This applies to the Boot To Qt addon for example.
if (reader.attributes().hasAttribute(attribute_requiredPlugins))
info->requiredPlugins = reader.attributes().value(attribute_requiredPlugins).toString()
.split(QLatin1Char(','), QString::SkipEmptyParts);
} else if (reader.name() == tag_displayName) {
if (!assignLanguageElementText(reader, locale, &info->displayName))
continue;
......
......@@ -63,6 +63,7 @@ public:
QString viewerClassName;
QString viewerDir;
QString qrcDeployment;
QStringList requiredPlugins;
int stubVersionMinor;
};
......
......@@ -30,6 +30,8 @@
#include "qtquickappwizardpages.h"
#include <utils/wizard.h>
#include <extensionsystem/pluginmanager.h>
#include <extensionsystem/pluginspec.h>
#include <QComboBox>
#include <QLabel>
......@@ -55,8 +57,24 @@ QtQuickComponentSetPage::QtQuickComponentSetPage(QWidget *parent)
QLabel *label = new QLabel(tr("Qt Quick component set:"), this);
d->m_versionComboBox = new QComboBox(this);
foreach (const TemplateInfo &templateInfo, QtQuickApp::templateInfos())
d->m_versionComboBox->addItem(templateInfo.displayName);
QSet<QString> availablePlugins;
foreach (ExtensionSystem::PluginSpec *s, ExtensionSystem::PluginManager::plugins()) {
if (s->state() == ExtensionSystem::PluginSpec::Running && !s->hasError())
availablePlugins += s->name();
}
foreach (const TemplateInfo &templateInfo, QtQuickApp::templateInfos()) {
bool ok = true;
foreach (const QString &neededPlugin, templateInfo.requiredPlugins) {
if (!availablePlugins.contains(neededPlugin)) {
ok = false;
break;
}
}
if (ok)
d->m_versionComboBox->addItem(templateInfo.displayName);
}
l->addWidget(label);
l->addWidget(d->m_versionComboBox);
......
Supports Markdown
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