forked from qt-creator/qt-creator
Make it possible to add wizards paths via plugin meta data
That makes it easy with Lua plugins, and is useful on the C++ side as well. Change-Id: I660956bed47e4c1e27a001ad8999d6701cda86ee Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -323,6 +323,27 @@
|
|||||||
}
|
}
|
||||||
\endcode
|
\endcode
|
||||||
|
|
||||||
|
\section2 Other Meta Data
|
||||||
|
|
||||||
|
\table
|
||||||
|
\header
|
||||||
|
\li Key
|
||||||
|
\li Value Type
|
||||||
|
\li Meaning
|
||||||
|
\row
|
||||||
|
\li Mimetypes
|
||||||
|
\li String or array of strings
|
||||||
|
\li Possibly multiple lines of
|
||||||
|
\l{https://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec/}{XML MIME-info}
|
||||||
|
used for registering additional or adapting built-in MIME types.
|
||||||
|
\row
|
||||||
|
\li JsonWizardPaths
|
||||||
|
\li Array of strings
|
||||||
|
\li A list of paths relative to the plugin location or paths to the
|
||||||
|
\l{The Qt Resource System}{Qt resource system} that are searched for
|
||||||
|
\l{http://doc.qt.io/qtcreator/creator-project-wizards.html}{template-based wizards}.
|
||||||
|
\endtable
|
||||||
|
|
||||||
\section2 A Note on Plugin Versions
|
\section2 A Note on Plugin Versions
|
||||||
|
|
||||||
Plugin versions are in the form \c{x.y.z_n} where, \c x, \c y, \c z and \c n are
|
Plugin versions are in the form \c{x.y.z_n} where, \c x, \c y, \c z and \c n are
|
||||||
|
@@ -26,5 +26,6 @@
|
|||||||
" <glob pattern='*.qtce'/>",
|
" <glob pattern='*.qtce'/>",
|
||||||
" </mime-type>",
|
" </mime-type>",
|
||||||
"</mime-info>"
|
"</mime-info>"
|
||||||
]
|
],
|
||||||
|
"JsonWizardPaths" : [":/compilerexplorer/wizard/"]
|
||||||
}
|
}
|
||||||
|
@@ -37,8 +37,6 @@ public:
|
|||||||
FileIconProvider::registerIconForMimeType(QIcon(":/compilerexplorer/logos/ce.ico"),
|
FileIconProvider::registerIconForMimeType(QIcon(":/compilerexplorer/logos/ce.ico"),
|
||||||
"application/compiler-explorer");
|
"application/compiler-explorer");
|
||||||
|
|
||||||
ProjectExplorer::JsonWizardFactory::addWizardPath(":/compilerexplorer/wizard/");
|
|
||||||
|
|
||||||
const Id menuId = "Tools.CompilerExplorer";
|
const Id menuId = "Tools.CompilerExplorer";
|
||||||
MenuBuilder(menuId)
|
MenuBuilder(menuId)
|
||||||
.setTitle(Tr::tr("Compiler Explorer"))
|
.setTitle(Tr::tr("Compiler Explorer"))
|
||||||
|
@@ -127,6 +127,7 @@ QAction *s_inspectWizardAction = nullptr;
|
|||||||
bool s_areFactoriesLoaded = false;
|
bool s_areFactoriesLoaded = false;
|
||||||
bool s_isWizardRunning = false;
|
bool s_isWizardRunning = false;
|
||||||
QWidget *s_currentWizard = nullptr;
|
QWidget *s_currentWizard = nullptr;
|
||||||
|
static QSet<Id> s_plugins;
|
||||||
|
|
||||||
// NewItemDialog reopening data:
|
// NewItemDialog reopening data:
|
||||||
class NewItemDialogData
|
class NewItemDialogData
|
||||||
@@ -385,8 +386,7 @@ void IWizardFactory::destroyFeatureProvider()
|
|||||||
|
|
||||||
void IWizardFactory::clearWizardFactories()
|
void IWizardFactory::clearWizardFactories()
|
||||||
{
|
{
|
||||||
if (!s_areFactoriesLoaded)
|
s_plugins.clear();
|
||||||
return;
|
|
||||||
|
|
||||||
for (IWizardFactory *factory : std::as_const(s_allFactories))
|
for (IWizardFactory *factory : std::as_const(s_allFactories))
|
||||||
ActionManager::unregisterAction(factory->m_action, actionId(factory));
|
ActionManager::unregisterAction(factory->m_action, actionId(factory));
|
||||||
@@ -399,16 +399,15 @@ void IWizardFactory::clearWizardFactories()
|
|||||||
|
|
||||||
QSet<Id> IWizardFactory::pluginFeatures()
|
QSet<Id> IWizardFactory::pluginFeatures()
|
||||||
{
|
{
|
||||||
static QSet<Id> plugins;
|
if (s_plugins.isEmpty()) {
|
||||||
if (plugins.isEmpty()) {
|
|
||||||
// Implicitly create a feature for each plugin loaded:
|
// Implicitly create a feature for each plugin loaded:
|
||||||
const QVector<ExtensionSystem::PluginSpec *> pluginVector = ExtensionSystem::PluginManager::plugins();
|
const QVector<ExtensionSystem::PluginSpec *> pluginVector = ExtensionSystem::PluginManager::plugins();
|
||||||
for (const ExtensionSystem::PluginSpec *s : pluginVector) {
|
for (const ExtensionSystem::PluginSpec *s : pluginVector) {
|
||||||
if (s->state() == ExtensionSystem::PluginSpec::Running)
|
if (s->state() == ExtensionSystem::PluginSpec::Running)
|
||||||
plugins.insert(Id::fromString(s->name()));
|
s_plugins.insert(Id::fromString(s->name()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return plugins;
|
return s_plugins;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSet<Id> IWizardFactory::availableFeatures(Id platformId)
|
QSet<Id> IWizardFactory::availableFeatures(Id platformId)
|
||||||
|
@@ -16,5 +16,7 @@
|
|||||||
"Category" : "Version Control",
|
"Category" : "Version Control",
|
||||||
"Description" : "Fossil SCM integration.",
|
"Description" : "Fossil SCM integration.",
|
||||||
"Url" : "http://www.qt.io",
|
"Url" : "http://www.qt.io",
|
||||||
${IDE_PLUGIN_DEPENDENCIES}
|
${IDE_PLUGIN_DEPENDENCIES},
|
||||||
|
|
||||||
|
"JsonWizardPaths" : [":/fossil/wizard"]
|
||||||
}
|
}
|
||||||
|
@@ -75,7 +75,4 @@ const char FSTATUS_UPDATED_BY_INTEGRATE[] = "Updated by Integrate";
|
|||||||
const char FSTATUS_RENAMED[] = "Renamed";
|
const char FSTATUS_RENAMED[] = "Renamed";
|
||||||
const char FSTATUS_UNKNOWN[] = "Unknown";
|
const char FSTATUS_UNKNOWN[] = "Unknown";
|
||||||
|
|
||||||
// Fossil Json Wizards
|
|
||||||
const char WIZARD_PATH[] = ":/fossil/wizard";
|
|
||||||
|
|
||||||
} // Fossil::Constants
|
} // Fossil::Constants
|
||||||
|
@@ -217,7 +217,6 @@ FossilPluginPrivate::FossilPluginPrivate()
|
|||||||
m_commandLocator = new CommandLocator("Fossil", "fossil", "fossil", this);
|
m_commandLocator = new CommandLocator("Fossil", "fossil", "fossil", this);
|
||||||
m_commandLocator->setDescription(Tr::tr("Triggers a Fossil version control operation."));
|
m_commandLocator->setDescription(Tr::tr("Triggers a Fossil version control operation."));
|
||||||
|
|
||||||
ProjectExplorer::JsonWizardFactory::addWizardPath(FilePath::fromString(Constants::WIZARD_PATH));
|
|
||||||
JsExpander::registerGlobalObject("Fossil", [] { return new FossilJsExtension; });
|
JsExpander::registerGlobalObject("Fossil", [] { return new FossilJsExtension; });
|
||||||
|
|
||||||
connect(&settings(), &AspectContainer::changed,
|
connect(&settings(), &AspectContainer::changed,
|
||||||
|
@@ -19,5 +19,6 @@
|
|||||||
" <glob pattern='*.cabal'/>",
|
" <glob pattern='*.cabal'/>",
|
||||||
" </mime-type>",
|
" </mime-type>",
|
||||||
"</mime-info>"
|
"</mime-info>"
|
||||||
]
|
],
|
||||||
|
"JsonWizardPaths" : [ ":/haskell/share/wizards/" ]
|
||||||
}
|
}
|
||||||
|
@@ -39,8 +39,6 @@ public:
|
|||||||
Tr::tr("Haskell", "SnippetProvider"));
|
Tr::tr("Haskell", "SnippetProvider"));
|
||||||
|
|
||||||
setupHaskellActions(this);
|
setupHaskellActions(this);
|
||||||
|
|
||||||
ProjectExplorer::JsonWizardFactory::addWizardPath(":/haskell/share/wizards/");
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -21,6 +21,8 @@ Qtc = {}
|
|||||||
---@field DisabledByDefault? boolean Whether the plugin is disabled by default or not. ( Default: true )
|
---@field DisabledByDefault? boolean Whether the plugin is disabled by default or not. ( Default: true )
|
||||||
---@field setup function The setup function of the plugin.
|
---@field setup function The setup function of the plugin.
|
||||||
---@field hooks? Hooks The hooks of the plugin.
|
---@field hooks? Hooks The hooks of the plugin.
|
||||||
|
---@field Mimetypes? string XML MIME-info for registering additional or adapting built-in MIME types.
|
||||||
|
---@field JsonWizardPaths? string[] A list of paths relative to the plugin location or paths to the Qt resource system that are searched for template-based wizards.
|
||||||
QtcPlugin = {}
|
QtcPlugin = {}
|
||||||
|
|
||||||
---@class QtcPluginDependency
|
---@class QtcPluginDependency
|
||||||
|
@@ -16,5 +16,7 @@
|
|||||||
"Category" : "Device Support",
|
"Category" : "Device Support",
|
||||||
"Description" : "Helper for MCU related projects.",
|
"Description" : "Helper for MCU related projects.",
|
||||||
"Url" : "http://www.qt.io",
|
"Url" : "http://www.qt.io",
|
||||||
${IDE_PLUGIN_DEPENDENCIES}
|
${IDE_PLUGIN_DEPENDENCIES},
|
||||||
|
|
||||||
|
"JsonWizardPaths" : [":/mcusupport/wizards/"]
|
||||||
}
|
}
|
||||||
|
@@ -262,7 +262,6 @@ void McuSupportPlugin::initialize()
|
|||||||
|
|
||||||
dd->m_options.registerQchFiles();
|
dd->m_options.registerQchFiles();
|
||||||
dd->m_options.registerExamples();
|
dd->m_options.registerExamples();
|
||||||
ProjectExplorer::JsonWizardFactory::addWizardPath(":/mcusupport/wizards/");
|
|
||||||
|
|
||||||
#if defined(WITH_TESTS) && defined(GOOGLE_TEST_IS_FOUND)
|
#if defined(WITH_TESTS) && defined(GOOGLE_TEST_IS_FOUND)
|
||||||
addTest<Test::McuSupportTest>();
|
addTest<Test::McuSupportTest>();
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
#include <coreplugin/messagemanager.h>
|
#include <coreplugin/messagemanager.h>
|
||||||
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
#include <extensionsystem/pluginspec.h>
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/environment.h>
|
#include <utils/environment.h>
|
||||||
@@ -28,6 +29,7 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QJSEngine>
|
#include <QJSEngine>
|
||||||
|
#include <QJsonArray>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QJsonParseError>
|
#include <QJsonParseError>
|
||||||
@@ -35,6 +37,7 @@
|
|||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
using namespace ExtensionSystem;
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
@@ -564,12 +567,13 @@ static QStringList environmentTemplatesPaths()
|
|||||||
return paths;
|
return paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool s_searchPathsInitialized = false;
|
||||||
|
|
||||||
FilePaths &JsonWizardFactory::searchPaths()
|
FilePaths &JsonWizardFactory::searchPaths()
|
||||||
{
|
{
|
||||||
static FilePaths m_searchPaths;
|
static FilePaths m_searchPaths;
|
||||||
static bool searchPathsInitialized = false;
|
if (!s_searchPathsInitialized) {
|
||||||
if (!searchPathsInitialized) {
|
s_searchPathsInitialized = true;
|
||||||
searchPathsInitialized = true;
|
|
||||||
m_searchPaths = {Core::ICore::userResourcePath(WIZARD_PATH),
|
m_searchPaths = {Core::ICore::userResourcePath(WIZARD_PATH),
|
||||||
Core::ICore::resourcePath(WIZARD_PATH)};
|
Core::ICore::resourcePath(WIZARD_PATH)};
|
||||||
for (const QString &environmentTemplateDirName : environmentTemplatesPaths())
|
for (const QString &environmentTemplateDirName : environmentTemplatesPaths())
|
||||||
@@ -577,11 +581,29 @@ FilePaths &JsonWizardFactory::searchPaths()
|
|||||||
m_searchPaths << Utils::transform(
|
m_searchPaths << Utils::transform(
|
||||||
Core::ICore::settings()->value("Wizards/SearchPaths").toStringList(),
|
Core::ICore::settings()->value("Wizards/SearchPaths").toStringList(),
|
||||||
[](const QString &s) { return FilePath::fromUserInput(s); });
|
[](const QString &s) { return FilePath::fromUserInput(s); });
|
||||||
|
// add paths from enabled plugin meta data
|
||||||
|
for (PluginSpec *plugin : PluginManager::plugins()) {
|
||||||
|
if (plugin->state() == PluginSpec::Running) {
|
||||||
|
const auto base = FilePath::fromString(plugin->filePath()).parentDir();
|
||||||
|
const auto values = plugin->metaData().value("JsonWizardPaths").toArray();
|
||||||
|
for (const QJsonValue &v : values) {
|
||||||
|
const auto path = FilePath::fromString(v.toString());
|
||||||
|
if (!path.isEmpty() && !path.needsDevice()) {
|
||||||
|
m_searchPaths << base.resolvePath(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_searchPaths;
|
return m_searchPaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void JsonWizardFactory::resetSearchPaths()
|
||||||
|
{
|
||||||
|
s_searchPathsInitialized = false;
|
||||||
|
}
|
||||||
|
|
||||||
void JsonWizardFactory::addWizardPath(const FilePath &path)
|
void JsonWizardFactory::addWizardPath(const FilePath &path)
|
||||||
{
|
{
|
||||||
searchPaths().append(path);
|
searchPaths().append(path);
|
||||||
|
@@ -69,6 +69,7 @@ private:
|
|||||||
const Utils::FilePath &baseDir,
|
const Utils::FilePath &baseDir,
|
||||||
QString *errorMessage);
|
QString *errorMessage);
|
||||||
static Utils::FilePaths &searchPaths();
|
static Utils::FilePaths &searchPaths();
|
||||||
|
static void resetSearchPaths();
|
||||||
|
|
||||||
static void setVerbose(int level);
|
static void setVerbose(int level);
|
||||||
static int verbose();
|
static int verbose();
|
||||||
|
@@ -827,6 +827,11 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
|
|||||||
setupJsonWizardPages();
|
setupJsonWizardPages();
|
||||||
setupJsonWizardFileGenerator();
|
setupJsonWizardFileGenerator();
|
||||||
setupJsonWizardScannerGenerator();
|
setupJsonWizardScannerGenerator();
|
||||||
|
// new plugins might add new paths via the plugin spec
|
||||||
|
connect(
|
||||||
|
PluginManager::instance(),
|
||||||
|
&PluginManager::pluginsChanged,
|
||||||
|
&JsonWizardFactory::resetSearchPaths);
|
||||||
|
|
||||||
dd->extendFolderNavigationWidgetFactory();
|
dd->extendFolderNavigationWidgetFactory();
|
||||||
|
|
||||||
|
@@ -16,5 +16,7 @@
|
|||||||
"Category" : "Device Support",
|
"Category" : "Device Support",
|
||||||
"Description" : "Helper plugin for Qt Safe Renderer projects.",
|
"Description" : "Helper plugin for Qt Safe Renderer projects.",
|
||||||
"Url" : "https://www.qt.io",
|
"Url" : "https://www.qt.io",
|
||||||
${IDE_PLUGIN_DEPENDENCIES}
|
${IDE_PLUGIN_DEPENDENCIES},
|
||||||
|
|
||||||
|
"JsonWizardPaths" : [":/saferenderer/wizards/"]
|
||||||
}
|
}
|
||||||
|
@@ -20,9 +20,6 @@ bool SafeRendererPlugin::initialize(const QStringList &arguments, QString *error
|
|||||||
Q_UNUSED(arguments)
|
Q_UNUSED(arguments)
|
||||||
Q_UNUSED(errorString)
|
Q_UNUSED(errorString)
|
||||||
|
|
||||||
// Add Qt Creator project wizard path
|
|
||||||
ProjectExplorer::JsonWizardFactory::addWizardPath(":/saferenderer/wizards/");
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -26,5 +26,6 @@ ${IDE_PLUGIN_DEPENDENCIES},
|
|||||||
" <glob pattern='objects.map'/>",
|
" <glob pattern='objects.map'/>",
|
||||||
" </mime-type>",
|
" </mime-type>",
|
||||||
"</mime-info>"
|
"</mime-info>"
|
||||||
]
|
],
|
||||||
|
"JsonWizardPaths" : [":/squish/wizard/"]
|
||||||
}
|
}
|
||||||
|
@@ -68,8 +68,6 @@ private:
|
|||||||
SquishServerSettingsDialog dialog;
|
SquishServerSettingsDialog dialog;
|
||||||
dialog.exec();
|
dialog.exec();
|
||||||
});
|
});
|
||||||
|
|
||||||
ProjectExplorer::JsonWizardFactory::addWizardPath(":/squish/wizard/");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool initializeGlobalScripts()
|
bool initializeGlobalScripts()
|
||||||
|
@@ -27,5 +27,6 @@
|
|||||||
" <glob pattern='vcpkg.json' weight='71'/>",
|
" <glob pattern='vcpkg.json' weight='71'/>",
|
||||||
" </mime-type>",
|
" </mime-type>",
|
||||||
"</mime-info>"
|
"</mime-info>"
|
||||||
]
|
],
|
||||||
|
"JsonWizardPaths" : [":/vcpkg/wizards/"]
|
||||||
}
|
}
|
||||||
|
@@ -21,8 +21,6 @@ class VcpkgPlugin final : public ExtensionSystem::IPlugin
|
|||||||
public:
|
public:
|
||||||
void initialize() final
|
void initialize() final
|
||||||
{
|
{
|
||||||
ProjectExplorer::JsonWizardFactory::addWizardPath(":/vcpkg/wizards/");
|
|
||||||
|
|
||||||
setupVcpkgManifestEditor();
|
setupVcpkgManifestEditor();
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
|
Reference in New Issue
Block a user