forked from qt-creator/qt-creator
Wizards: Simplify checking for plugins
Change-Id: Ifc63d075462562a2efef5208e37458a16ac640ca Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
"icon": "../../global/consoleapplication.png",
|
"icon": "../../global/consoleapplication.png",
|
||||||
"iconKind": "Themed",
|
"iconKind": "Themed",
|
||||||
"featuresRequired": [ "QtSupport.Wizards.FeatureQt" ],
|
"featuresRequired": [ "QtSupport.Wizards.FeatureQt" ],
|
||||||
"enabled": "%{JS: value('Plugins').indexOf('QmakeProjectManager') >= 0 || value('Plugins').indexOf('QbsProjectManager') >= 0 || value('Plugins').indexOf('CMakeProjectManager') >= 0 || value('Plugins').indexOf('MesonProjectManager') >= 0}",
|
"enabled": "%{JS: isAnyPluginRunning(['qmakeprojectmanager', 'qbsprojectmanager', 'cmakeprojectmanager', 'mesonprojectmanager'])}",
|
||||||
|
|
||||||
"options":
|
"options":
|
||||||
[
|
[
|
||||||
@@ -51,27 +51,27 @@
|
|||||||
{
|
{
|
||||||
"trKey": "qmake",
|
"trKey": "qmake",
|
||||||
"value": "qmake",
|
"value": "qmake",
|
||||||
"condition": "%{JS: value('Plugins').indexOf('QmakeProjectManager') >= 0}"
|
"condition": "%{JS: isPluginRunning('qmakeprojectmanager')}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"trKey": "CMake",
|
"trKey": "CMake",
|
||||||
"value": "cmake",
|
"value": "cmake",
|
||||||
"condition": "%{JS: value('Plugins').indexOf('CMakeProjectManager') >= 0}"
|
"condition": "%{JS: isPluginRunning('cmakeprojectmanager')}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"trKey": "CMake for Qt 6.5 and Later",
|
"trKey": "CMake for Qt 6.5 and Later",
|
||||||
"value": "cmake-qt6",
|
"value": "cmake-qt6",
|
||||||
"condition": "%{JS: value('Plugins').indexOf('CMakeProjectManager') >= 0}"
|
"condition": "%{JS: isPluginRunning('cmakeprojectmanager')}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"trKey": "Qbs",
|
"trKey": "Qbs",
|
||||||
"value": "qbs",
|
"value": "qbs",
|
||||||
"condition": "%{JS: value('Plugins').indexOf('QbsProjectManager') >= 0}"
|
"condition": "%{JS: isPluginRunning('qbsprojectmanager')}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"trKey": "Meson",
|
"trKey": "Meson",
|
||||||
"value": "meson",
|
"value": "meson",
|
||||||
"condition": "%{JS: value('Plugins').indexOf('MesonProjectManager') >= 0}"
|
"condition": "%{JS: isPluginRunning('mesonprojectmanager')}"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
"icon": "../../global/guiapplication.png",
|
"icon": "../../global/guiapplication.png",
|
||||||
"iconKind": "Themed",
|
"iconKind": "Themed",
|
||||||
"featuresRequired": [ "QtSupport.Wizards.FeatureQt" ],
|
"featuresRequired": [ "QtSupport.Wizards.FeatureQt" ],
|
||||||
"enabled": "%{JS: value('Plugins').indexOf('QmakeProjectManager') >= 0 || value('Plugins').indexOf('CMakeProjectManager') >= 0 || value('Plugins').indexOf('QbsProjectManager') >= 0 || value('Plugins').indexOf('MesonProjectManager') >= 0}",
|
"enabled": "%{JS: isAnyPluginRunning(['qmakeprojectmanager', 'qbsprojectmanager', 'cmakeprojectmanager', 'mesonprojectmanager'])}",
|
||||||
|
|
||||||
"options":
|
"options":
|
||||||
[
|
[
|
||||||
@@ -56,27 +56,27 @@
|
|||||||
{
|
{
|
||||||
"trKey": "qmake",
|
"trKey": "qmake",
|
||||||
"value": "qmake",
|
"value": "qmake",
|
||||||
"condition": "%{JS: value('Plugins').indexOf('QmakeProjectManager') >= 0}"
|
"condition": "%{JS: isPluginRunning('qmakeprojectmanager')}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"trKey": "CMake",
|
"trKey": "CMake",
|
||||||
"value": "cmake",
|
"value": "cmake",
|
||||||
"condition": "%{JS: value('Plugins').indexOf('CMakeProjectManager') >= 0}"
|
"condition": "%{JS: isPluginRunning('cmakeprojectmanager')}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"trKey": "CMake for Qt 6.5 and Later",
|
"trKey": "CMake for Qt 6.5 and Later",
|
||||||
"value": "cmake-qt6",
|
"value": "cmake-qt6",
|
||||||
"condition": "%{JS: value('Plugins').indexOf('CMakeProjectManager') >= 0}"
|
"condition": "%{JS: isPluginRunning('cmakeprojectmanager')}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"trKey": "Meson",
|
"trKey": "Meson",
|
||||||
"value": "meson",
|
"value": "meson",
|
||||||
"condition": "%{JS: value('Plugins').indexOf('MesonProjectManager') >= 0}"
|
"condition": "%{JS: isPluginRunning('mesonprojectmanager')}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"trKey": "Qbs",
|
"trKey": "Qbs",
|
||||||
"value": "qbs",
|
"value": "qbs",
|
||||||
"condition": "%{JS: value('Plugins').indexOf('QbsProjectManager') >= 0}"
|
"condition": "%{JS: isPluginRunning('qbsprojectmanager')}"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@@ -16,6 +16,9 @@
|
|||||||
#include <coreplugin/editormanager/ieditor.h>
|
#include <coreplugin/editormanager/ieditor.h>
|
||||||
#include <coreplugin/messagemanager.h>
|
#include <coreplugin/messagemanager.h>
|
||||||
|
|
||||||
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
#include <extensionsystem/pluginspec.h>
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/itemviews.h>
|
#include <utils/itemviews.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
@@ -143,6 +146,9 @@ JsonWizard::JsonWizard(QWidget *parent)
|
|||||||
// override default JS macro by custom one that adds Wizard specific features
|
// override default JS macro by custom one that adds Wizard specific features
|
||||||
m_jsExpander.registerObject("Wizard", new Internal::JsonWizardJsExtension(this));
|
m_jsExpander.registerObject("Wizard", new Internal::JsonWizardJsExtension(this));
|
||||||
m_jsExpander.engine().evaluate("var value = Wizard.value");
|
m_jsExpander.engine().evaluate("var value = Wizard.value");
|
||||||
|
m_jsExpander.engine().evaluate("var isPluginRunning = Wizard.isPluginRunning");
|
||||||
|
m_jsExpander.engine().evaluate("var isAnyPluginRunning = Wizard.isAnyPluginRunning");
|
||||||
|
|
||||||
m_jsExpander.registerForExpander(&m_expander);
|
m_jsExpander.registerForExpander(&m_expander);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -536,5 +542,24 @@ QVariant JsonWizardJsExtension::value(const QString &name) const
|
|||||||
return m_wizard->expander()->expandVariant(m_wizard->value(name));
|
return m_wizard->expander()->expandVariant(m_wizard->value(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool JsonWizardJsExtension::isPluginRunning(const QString &id) const
|
||||||
|
{
|
||||||
|
return Internal::isAnyPluginRunning({id});
|
||||||
|
}
|
||||||
|
bool JsonWizardJsExtension::isAnyPluginRunning(const QStringList &ids) const
|
||||||
|
{
|
||||||
|
return Internal::isAnyPluginRunning(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isAnyPluginRunning(const QStringList &ids)
|
||||||
|
{
|
||||||
|
QTC_CHECK(Utils::allOf(ids, [](const QString &id) { return id.isLower(); }));
|
||||||
|
|
||||||
|
return Utils::anyOf(
|
||||||
|
ExtensionSystem::PluginManager::plugins(), [ids](const ExtensionSystem::PluginSpec *s) {
|
||||||
|
return s->state() == ExtensionSystem::PluginSpec::Running && ids.contains(s->id());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace ProjectExplorer
|
} // namespace ProjectExplorer
|
||||||
|
@@ -22,6 +22,8 @@ class JsonWizardGenerator;
|
|||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
bool isAnyPluginRunning(const QStringList &ids);
|
||||||
|
|
||||||
class JsonWizardJsExtension : public QObject
|
class JsonWizardJsExtension : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -29,6 +31,8 @@ public:
|
|||||||
JsonWizardJsExtension(JsonWizard *wizard);
|
JsonWizardJsExtension(JsonWizard *wizard);
|
||||||
|
|
||||||
Q_INVOKABLE QVariant value(const QString &name) const;
|
Q_INVOKABLE QVariant value(const QString &name) const;
|
||||||
|
Q_INVOKABLE bool isPluginRunning(const QString &id) const;
|
||||||
|
Q_INVOKABLE bool isAnyPluginRunning(const QStringList &ids) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
JsonWizard *m_wizard;
|
JsonWizard *m_wizard;
|
||||||
|
@@ -109,6 +109,14 @@ public:
|
|||||||
return Id::toStringList(m_pluginFeatures);
|
return Id::toStringList(m_pluginFeatures);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
Q_INVOKABLE bool isPluginRunning(const QString &id) const
|
||||||
|
{
|
||||||
|
return Internal::isAnyPluginRunning({id});
|
||||||
|
}
|
||||||
|
Q_INVOKABLE bool isAnyPluginRunning(const QStringList &ids) const
|
||||||
|
{
|
||||||
|
return Internal::isAnyPluginRunning(ids);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Id m_platformId;
|
Id m_platformId;
|
||||||
@@ -802,6 +810,9 @@ bool JsonWizardFactory::isAvailable(Id platformId) const
|
|||||||
platformId),
|
platformId),
|
||||||
pluginFeatures()));
|
pluginFeatures()));
|
||||||
jsExpander.engine().evaluate("var value = Wizard.value");
|
jsExpander.engine().evaluate("var value = Wizard.value");
|
||||||
|
jsExpander.engine().evaluate("var isPluginRunning = Wizard.isPluginRunning");
|
||||||
|
jsExpander.engine().evaluate("var isAnyPluginRunning = Wizard.isAnyPluginRunning");
|
||||||
|
|
||||||
jsExpander.registerForExpander(e);
|
jsExpander.registerForExpander(e);
|
||||||
return JsonWizard::boolFromVariant(m_enabledExpression, &expander);
|
return JsonWizard::boolFromVariant(m_enabledExpression, &expander);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user