9#include <QtCore/QJsonArray>
10#include <QtCore/QJsonValue>
14class QxPluginSpecPrivate
20 QVersionNumber version;
21 QVersionNumber compatVersion;
27 QStringList dependencies;
28 QStringList optionalDependencies;
29 bool enabledByDefault =
true;
37QxPluginSpec::QxPluginSpec()
38 : d_ptr(new QxPluginSpecPrivate)
59 return d->compatVersion;
83 return d->description;
95 return d->dependencies;
101 return d->optionalDependencies;
107 return d->enabledByDefault;
147 const QString
name = metaData.value(QStringLiteral(
"Name")).toString();
148 if (
name.isEmpty()) {
149 d->error = QStringLiteral(
"plugin metadata has no \"Name\"");
154 QVersionNumber ver = QVersionNumber::fromString(metaData.value(QStringLiteral(
"Version")).toString());
156 ver = QVersionNumber(1, 0, 0);
158 QVersionNumber compat = QVersionNumber::fromString(metaData.value(QStringLiteral(
"CompatVersion")).toString());
161 d->compatVersion = compat;
163 d->vendor = metaData.value(QStringLiteral(
"Vendor")).toString();
164 d->copyright = metaData.value(QStringLiteral(
"Copyright")).toString();
165 d->category = metaData.value(QStringLiteral(
"Category")).toString();
166 d->description = metaData.value(QStringLiteral(
"Description")).toString();
167 d->url = metaData.value(QStringLiteral(
"Url")).toString();
168 d->enabledByDefault = metaData.value(QStringLiteral(
"EnabledByDefault")).toBool(
true);
170 const QJsonValue deps = metaData.value(QStringLiteral(
"Dependencies"));
171 if (!deps.isUndefined()) {
172 if (!deps.isArray()) {
173 d->error = QStringLiteral(
"plugin '%1': \"Dependencies\" is not an array").arg(
name);
176 for (
const QJsonValue &entry : deps.toArray()) {
177 const QJsonObject obj = entry.toObject();
178 const QString depName = obj.value(QStringLiteral(
"Name")).toString();
179 if (depName.isEmpty())
181 const QString type = obj.value(QStringLiteral(
"Type")).toString();
182 if (type == QStringLiteral(
"optional")) {
183 d->optionalDependencies.append(depName);
184 }
else if (type != QStringLiteral(
"test")) {
191 d->dependencies.append(depName);
206void QxPluginSpec::setError(
const QString &error)
212void QxPluginSpec::setPlugin(
QxPlugin *plugin)
A read-only view of one plugin's metadata, plus the runtime state the manager attaches to it.
QString error() const
Why the plugin is not running; empty when it runs or is only skipped by default.
QString copyright() const
QVersionNumber version() const
QString description() const
bool read(const QString &filePath, const QJsonObject &metaData)
Fills the spec from metadata; returns false (and records error()) on a malformed document.
bool isEnabledByDefault() const
True when the plugin starts unless explicitly disabled (EnabledByDefault).
QString filePath() const
Path of the metadata file (dynamic) or the registration key (static).
QStringList optionalDependencies() const
Optional dependency ids (Type == "optional" in the metadata), in declaration order.
QxPluginState state() const
QxPlugin * plugin() const
The live instance, or null until Loaded.
bool isDisabled() const
True when the plugin will not run: forced off, skipped by default, or failed.
QString id() const
Stable plugin id; also the base name of its library and metadata file.
QStringList dependencies() const
Required dependency ids, in declaration order.
QVersionNumber compatVersion() const
Lowest host version the plugin still supports; the host must be in [compatVersion,...
Copyright (C) 2026 maminjie canpool@163.com SPDX-License-Identifier: MulanPSL-2.0
QxPluginState
Lifecycle state of a single plugin, as the manager drives it:
#define QX_DECLARE_PUBLIC(Class)
#define Q_NULLPTR
Copyleft (C) 2025 maminjie canpool@163.com SPDX-License-Identifier: MulanPSL-2.0
#define QX_FINI_PRIVATE()
#define QX_PLUGIN_BEGIN_NAMESPACE
#define QX_PLUGIN_END_NAMESPACE