From b24492c6e9f06a180b7f7902c298158d3f5b7cf2 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Thu, 25 Jul 2024 13:00:56 +0200 Subject: [PATCH] ExtensionSystem: Add field "DocumentationUrl" to PluginSpec Task-number: QTCREATORBUG-31199 Change-Id: Ieb20d35cc9b4fe976207491bd201750fa4ca0032 Reviewed-by: Eike Ziller --- doc/qtcreatordev/src/plugin-metadata.qdoc | 6 ++++++ .../wizards/qtcreatorplugin/MyPlugin.json.in | 1 + src/libs/extensionsystem/plugindetailsview.cpp | 9 ++++++++- src/libs/extensionsystem/pluginspec.cpp | 16 ++++++++++++++++ src/libs/extensionsystem/pluginspec.h | 1 + src/plugins/extensionmanager/extensionsmodel.cpp | 4 ++++ src/plugins/lua/meta/qtc.lua | 1 + src/plugins/lua/wizards/plugin/plugin.lua.tpl | 1 + 8 files changed, 38 insertions(+), 1 deletion(-) diff --git a/doc/qtcreatordev/src/plugin-metadata.qdoc b/doc/qtcreatordev/src/plugin-metadata.qdoc index 20d4073fd14..9963aae4e36 100644 --- a/doc/qtcreatordev/src/plugin-metadata.qdoc +++ b/doc/qtcreatordev/src/plugin-metadata.qdoc @@ -132,6 +132,11 @@ \li String \li Link to further information about the plugin, like \c{http://www.mycompany-online.com/products/greatplugin}. + \row + \li DocumentationUrl + \li String + \li Link to online documentation for the plugin, like + \c{https://www.mycompany-online.com/docs/greatplugin/manual.html}. \endtable \section2 Dependencies @@ -309,6 +314,7 @@ "It demonstrates the great use of the plugin meta data." ], "Url" : "http://www.mycompany-online.com/products/greatplugin", + "DocumentationUrl" : "https://www.mycompany-online.com/docs/greatplugin/manual.html", "Arguments" : [ { "Name" : "-variant", diff --git a/share/qtcreator/templates/wizards/qtcreatorplugin/MyPlugin.json.in b/share/qtcreator/templates/wizards/qtcreatorplugin/MyPlugin.json.in index 2e62c447394..2de2ccc6fbe 100644 --- a/share/qtcreator/templates/wizards/qtcreatorplugin/MyPlugin.json.in +++ b/share/qtcreator/templates/wizards/qtcreatorplugin/MyPlugin.json.in @@ -7,5 +7,6 @@ \"License\" : \"%{License}\", \"Description\" : \"%{Description}\", \"Url\" : \"%{Url}\", + \"DocumentationUrl\" : \"\", ${IDE_PLUGIN_DEPENDENCIES} } diff --git a/src/libs/extensionsystem/plugindetailsview.cpp b/src/libs/extensionsystem/plugindetailsview.cpp index 1eeffaf4dac..389f8a513a8 100644 --- a/src/libs/extensionsystem/plugindetailsview.cpp +++ b/src/libs/extensionsystem/plugindetailsview.cpp @@ -49,6 +49,7 @@ public: , vendor(createContentsLabel()) , component(createContentsLabel()) , url(createContentsLabel()) + , documentationUrl(createContentsLabel()) , location(createContentsLabel()) , platforms(createContentsLabel()) , description(createTextEdit()) @@ -67,6 +68,7 @@ public: Tr::tr("Vendor:"), vendor, br, Tr::tr("Group:"), component, br, Tr::tr("URL:"), url, br, + Tr::tr("Documentation:"), documentationUrl, br, Tr::tr("Location:"), location, br, Tr::tr("Platforms:"), platforms, br, Tr::tr("Description:"), description, br, @@ -87,6 +89,7 @@ public: QLabel *vendor = nullptr; QLabel *component = nullptr; QLabel *url = nullptr; + QLabel *documentationUrl = nullptr; QLabel *location = nullptr; QLabel *platforms = nullptr; QTextEdit *description = nullptr; @@ -145,7 +148,11 @@ void PluginDetailsView::update(PluginSpec *spec) d->compatVersion->setText(spec->compatVersion()); d->vendor->setText(spec->vendor()); d->component->setText(spec->category().isEmpty() ? Tr::tr("None") : spec->category()); - d->url->setText(QString::fromLatin1("%1").arg(spec->url())); + const auto toHtmlLink = [](const QString &url) { + return QString::fromLatin1("%1").arg(url); + }; + d->url->setText(toHtmlLink(spec->url())); + d->documentationUrl->setText(toHtmlLink(spec->documentationUrl())); d->location->setText(spec->filePath().toUserOutput()); const QString pattern = spec->platformSpecification().pattern(); const QString platform = pattern.isEmpty() ? Tr::tr("All") : pattern; diff --git a/src/libs/extensionsystem/pluginspec.cpp b/src/libs/extensionsystem/pluginspec.cpp index d2515760493..f4369cbc217 100644 --- a/src/libs/extensionsystem/pluginspec.cpp +++ b/src/libs/extensionsystem/pluginspec.cpp @@ -193,6 +193,7 @@ public: QString description; QString longDescription; QString url; + QString documentationUrl; QString license; QString revision; QString copyright; @@ -324,6 +325,15 @@ QString PluginSpec::url() const return d->url; } +/*! + Returns the documentation URL where you can find the online manual about the plugin. + This is valid after the PluginSpec::Read state is reached. +*/ +QString PluginSpec::documentationUrl() const +{ + return d->documentationUrl; +} + /*! Returns the category that the plugin belongs to. Categories are used to group plugins together in the UI. @@ -676,6 +686,7 @@ namespace { const char DESCRIPTION[] = "Description"; const char LONGDESCRIPTION[] = "LongDescription"; const char URL[] = "Url"; + const char DOCUMENTATIONURL[] = "DocumentationUrl"; const char CATEGORY[] = "Category"; const char PLATFORM[] = "Platform"; const char DEPENDENCIES[] = "Dependencies"; @@ -877,6 +888,11 @@ Utils::expected_str PluginSpecPrivate::readMetaData(const QJsonObject &dat return reportError(msgValueIsNotAString(URL)); url = value.toString(); + value = metaData.value(QLatin1String(DOCUMENTATIONURL)); + if (!value.isUndefined() && !value.isString()) + return reportError(msgValueIsNotAString(DOCUMENTATIONURL)); + documentationUrl = value.toString(); + value = metaData.value(QLatin1String(CATEGORY)); if (!value.isUndefined() && !value.isString()) return reportError(msgValueIsNotAString(CATEGORY)); diff --git a/src/libs/extensionsystem/pluginspec.h b/src/libs/extensionsystem/pluginspec.h index e9a771d4a99..db6070bd65a 100644 --- a/src/libs/extensionsystem/pluginspec.h +++ b/src/libs/extensionsystem/pluginspec.h @@ -104,6 +104,7 @@ public: virtual QString description() const; virtual QString longDescription() const; virtual QString url() const; + virtual QString documentationUrl() const; virtual QString category() const; virtual QString revision() const; virtual QRegularExpression platformSpecification() const; diff --git a/src/plugins/extensionmanager/extensionsmodel.cpp b/src/plugins/extensionmanager/extensionsmodel.cpp index 6a4fd30429c..d9732105e4c 100644 --- a/src/plugins/extensionmanager/extensionsmodel.cpp +++ b/src/plugins/extensionmanager/extensionsmodel.cpp @@ -3,6 +3,8 @@ #include "extensionsmodel.h" +#include "extensionmanagertr.h" + #include "utils/algorithm.h" #include @@ -224,6 +226,8 @@ static Extension extensionFromPluginSpec(const PluginSpec *pluginSpec) LinksData links; if (const QString url = pluginSpec->url(); !url.isEmpty()) links.append({{}, url}); + if (const QString docUrl = pluginSpec->documentationUrl(); !docUrl.isEmpty()) + links.append({{Tr::tr("Documentation")}, docUrl}); const Description description = { .images = {}, .links = links, diff --git a/src/plugins/lua/meta/qtc.lua b/src/plugins/lua/meta/qtc.lua index 01ff31bb971..6a02f4bb965 100644 --- a/src/plugins/lua/meta/qtc.lua +++ b/src/plugins/lua/meta/qtc.lua @@ -18,6 +18,7 @@ Qtc = {} ---@field Description? string A short one line description of the plugin. ---@field LongDescription? string A long description of the plugin. Can contain newlines. ---@field Url? string The url of the plugin. +---@field DocumentationUrl? string The url of the online documentation for the plugin. ---@field License? string The license text of the plugin. ---@field Revision? string The revision of the plugin. ---@field Copyright? string The copyright of the plugin. diff --git a/src/plugins/lua/wizards/plugin/plugin.lua.tpl b/src/plugins/lua/wizards/plugin/plugin.lua.tpl index 67d6e2966dd..72ccf152485 100644 --- a/src/plugins/lua/wizards/plugin/plugin.lua.tpl +++ b/src/plugins/lua/wizards/plugin/plugin.lua.tpl @@ -8,6 +8,7 @@ return { Category = "My Plugins", Description = "%{Description}", Url = "%{Url}", + DocumentationUrl = "", Experimental = true, DisabledByDefault = false, LongDescription = [[