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
|
||||
|
||||
\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
|
||||
|
||||
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'/>",
|
||||
" </mime-type>",
|
||||
"</mime-info>"
|
||||
]
|
||||
],
|
||||
"JsonWizardPaths" : [":/compilerexplorer/wizard/"]
|
||||
}
|
||||
|
@@ -37,8 +37,6 @@ public:
|
||||
FileIconProvider::registerIconForMimeType(QIcon(":/compilerexplorer/logos/ce.ico"),
|
||||
"application/compiler-explorer");
|
||||
|
||||
ProjectExplorer::JsonWizardFactory::addWizardPath(":/compilerexplorer/wizard/");
|
||||
|
||||
const Id menuId = "Tools.CompilerExplorer";
|
||||
MenuBuilder(menuId)
|
||||
.setTitle(Tr::tr("Compiler Explorer"))
|
||||
|
@@ -127,6 +127,7 @@ QAction *s_inspectWizardAction = nullptr;
|
||||
bool s_areFactoriesLoaded = false;
|
||||
bool s_isWizardRunning = false;
|
||||
QWidget *s_currentWizard = nullptr;
|
||||
static QSet<Id> s_plugins;
|
||||
|
||||
// NewItemDialog reopening data:
|
||||
class NewItemDialogData
|
||||
@@ -385,8 +386,7 @@ void IWizardFactory::destroyFeatureProvider()
|
||||
|
||||
void IWizardFactory::clearWizardFactories()
|
||||
{
|
||||
if (!s_areFactoriesLoaded)
|
||||
return;
|
||||
s_plugins.clear();
|
||||
|
||||
for (IWizardFactory *factory : std::as_const(s_allFactories))
|
||||
ActionManager::unregisterAction(factory->m_action, actionId(factory));
|
||||
@@ -399,16 +399,15 @@ void IWizardFactory::clearWizardFactories()
|
||||
|
||||
QSet<Id> IWizardFactory::pluginFeatures()
|
||||
{
|
||||
static QSet<Id> plugins;
|
||||
if (plugins.isEmpty()) {
|
||||
if (s_plugins.isEmpty()) {
|
||||
// Implicitly create a feature for each plugin loaded:
|
||||
const QVector<ExtensionSystem::PluginSpec *> pluginVector = ExtensionSystem::PluginManager::plugins();
|
||||
for (const ExtensionSystem::PluginSpec *s : pluginVector) {
|
||||
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)
|
||||
|
@@ -16,5 +16,7 @@
|
||||
"Category" : "Version Control",
|
||||
"Description" : "Fossil SCM integration.",
|
||||
"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_UNKNOWN[] = "Unknown";
|
||||
|
||||
// Fossil Json Wizards
|
||||
const char WIZARD_PATH[] = ":/fossil/wizard";
|
||||
|
||||
} // Fossil::Constants
|
||||
|
@@ -217,7 +217,6 @@ FossilPluginPrivate::FossilPluginPrivate()
|
||||
m_commandLocator = new CommandLocator("Fossil", "fossil", "fossil", this);
|
||||
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; });
|
||||
|
||||
connect(&settings(), &AspectContainer::changed,
|
||||
|
@@ -19,5 +19,6 @@
|
||||
" <glob pattern='*.cabal'/>",
|
||||
" </mime-type>",
|
||||
"</mime-info>"
|
||||
]
|
||||
],
|
||||
"JsonWizardPaths" : [ ":/haskell/share/wizards/" ]
|
||||
}
|
||||
|
@@ -39,8 +39,6 @@ public:
|
||||
Tr::tr("Haskell", "SnippetProvider"));
|
||||
|
||||
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 setup function The setup function 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 = {}
|
||||
|
||||
---@class QtcPluginDependency
|
||||
|
@@ -16,5 +16,7 @@
|
||||
"Category" : "Device Support",
|
||||
"Description" : "Helper for MCU related projects.",
|
||||
"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.registerExamples();
|
||||
ProjectExplorer::JsonWizardFactory::addWizardPath(":/mcusupport/wizards/");
|
||||
|
||||
#if defined(WITH_TESTS) && defined(GOOGLE_TEST_IS_FOUND)
|
||||
addTest<Test::McuSupportTest>();
|
||||
|
@@ -16,6 +16,7 @@
|
||||
#include <coreplugin/messagemanager.h>
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <extensionsystem/pluginspec.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/environment.h>
|
||||
@@ -28,6 +29,7 @@
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QJSEngine>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonParseError>
|
||||
@@ -35,6 +37,7 @@
|
||||
#include <QUuid>
|
||||
|
||||
using namespace Utils;
|
||||
using namespace ExtensionSystem;
|
||||
|
||||
namespace ProjectExplorer {
|
||||
|
||||
@@ -564,12 +567,13 @@ static QStringList environmentTemplatesPaths()
|
||||
return paths;
|
||||
}
|
||||
|
||||
static bool s_searchPathsInitialized = false;
|
||||
|
||||
FilePaths &JsonWizardFactory::searchPaths()
|
||||
{
|
||||
static FilePaths m_searchPaths;
|
||||
static bool searchPathsInitialized = false;
|
||||
if (!searchPathsInitialized) {
|
||||
searchPathsInitialized = true;
|
||||
if (!s_searchPathsInitialized) {
|
||||
s_searchPathsInitialized = true;
|
||||
m_searchPaths = {Core::ICore::userResourcePath(WIZARD_PATH),
|
||||
Core::ICore::resourcePath(WIZARD_PATH)};
|
||||
for (const QString &environmentTemplateDirName : environmentTemplatesPaths())
|
||||
@@ -577,11 +581,29 @@ FilePaths &JsonWizardFactory::searchPaths()
|
||||
m_searchPaths << Utils::transform(
|
||||
Core::ICore::settings()->value("Wizards/SearchPaths").toStringList(),
|
||||
[](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;
|
||||
}
|
||||
|
||||
void JsonWizardFactory::resetSearchPaths()
|
||||
{
|
||||
s_searchPathsInitialized = false;
|
||||
}
|
||||
|
||||
void JsonWizardFactory::addWizardPath(const FilePath &path)
|
||||
{
|
||||
searchPaths().append(path);
|
||||
|
@@ -69,6 +69,7 @@ private:
|
||||
const Utils::FilePath &baseDir,
|
||||
QString *errorMessage);
|
||||
static Utils::FilePaths &searchPaths();
|
||||
static void resetSearchPaths();
|
||||
|
||||
static void setVerbose(int level);
|
||||
static int verbose();
|
||||
|
@@ -827,6 +827,11 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
|
||||
setupJsonWizardPages();
|
||||
setupJsonWizardFileGenerator();
|
||||
setupJsonWizardScannerGenerator();
|
||||
// new plugins might add new paths via the plugin spec
|
||||
connect(
|
||||
PluginManager::instance(),
|
||||
&PluginManager::pluginsChanged,
|
||||
&JsonWizardFactory::resetSearchPaths);
|
||||
|
||||
dd->extendFolderNavigationWidgetFactory();
|
||||
|
||||
|
@@ -16,5 +16,7 @@
|
||||
"Category" : "Device Support",
|
||||
"Description" : "Helper plugin for Qt Safe Renderer projects.",
|
||||
"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(errorString)
|
||||
|
||||
// Add Qt Creator project wizard path
|
||||
ProjectExplorer::JsonWizardFactory::addWizardPath(":/saferenderer/wizards/");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -26,5 +26,6 @@ ${IDE_PLUGIN_DEPENDENCIES},
|
||||
" <glob pattern='objects.map'/>",
|
||||
" </mime-type>",
|
||||
"</mime-info>"
|
||||
]
|
||||
],
|
||||
"JsonWizardPaths" : [":/squish/wizard/"]
|
||||
}
|
||||
|
@@ -68,8 +68,6 @@ private:
|
||||
SquishServerSettingsDialog dialog;
|
||||
dialog.exec();
|
||||
});
|
||||
|
||||
ProjectExplorer::JsonWizardFactory::addWizardPath(":/squish/wizard/");
|
||||
}
|
||||
|
||||
bool initializeGlobalScripts()
|
||||
|
@@ -27,5 +27,6 @@
|
||||
" <glob pattern='vcpkg.json' weight='71'/>",
|
||||
" </mime-type>",
|
||||
"</mime-info>"
|
||||
]
|
||||
],
|
||||
"JsonWizardPaths" : [":/vcpkg/wizards/"]
|
||||
}
|
||||
|
@@ -21,8 +21,6 @@ class VcpkgPlugin final : public ExtensionSystem::IPlugin
|
||||
public:
|
||||
void initialize() final
|
||||
{
|
||||
ProjectExplorer::JsonWizardFactory::addWizardPath(":/vcpkg/wizards/");
|
||||
|
||||
setupVcpkgManifestEditor();
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
|
Reference in New Issue
Block a user