Use KPluginMetaData to list containmentActions
Add a new method that uses KPluginMetaData to list the containmentActions and deprecate the KPLuginInfo-based one
This commit is contained in:
parent
d7f118e589
commit
007eacca5b
@ -45,7 +45,7 @@ void PluginTest::listAppletCategories()
|
|||||||
|
|
||||||
void PluginTest::listContainmentActions()
|
void PluginTest::listContainmentActions()
|
||||||
{
|
{
|
||||||
const KPluginInfo::List plugins = Plasma::PluginLoader::self()->listContainmentActionsInfo(QStringLiteral("plasma-shell"));
|
const QVector<KPluginMetaData> plugins = Plasma::PluginLoader::self()->listContainmentActionsMetaData(QStringLiteral("plasma-shell"));
|
||||||
qDebug() << "Categories: " << plugins.count();
|
qDebug() << "Categories: " << plugins.count();
|
||||||
//QVERIFY(plugins.count() > 0 || m_buildonly);
|
//QVERIFY(plugins.count() > 0 || m_buildonly);
|
||||||
}
|
}
|
||||||
|
@ -756,41 +756,51 @@ QVector<KPluginMetaData> PluginLoader::listDataEngineMetaData(const QString &par
|
|||||||
return plugins;
|
return plugins;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if PLASMA_BUILD_DEPRECATED_SINCE(5, 77)
|
||||||
KPluginInfo::List PluginLoader::listContainmentActionsInfo(const QString &parentApp)
|
KPluginInfo::List PluginLoader::listContainmentActionsInfo(const QString &parentApp)
|
||||||
{
|
{
|
||||||
KPluginInfo::List list;
|
return KPluginInfo::fromMetaData(listContainmentActionsMetaData(parentApp));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!d->isDefaultLoader && (parentApp.isEmpty() || parentApp == QCoreApplication::instance()->applicationName())) {
|
QVector<KPluginMetaData> PluginLoader::listContainmentActionsMetaData(const QString &parentApp)
|
||||||
list = internalContainmentActionsInfo();
|
{
|
||||||
}
|
auto filter = [&parentApp](const KPluginMetaData &md) -> bool
|
||||||
|
{
|
||||||
|
return md.value(QStringLiteral("X-KDE-ParentApp")) == parentApp;
|
||||||
|
};
|
||||||
|
|
||||||
QString constraint;
|
QVector<KPluginMetaData> plugins;
|
||||||
if (!parentApp.isEmpty()) {
|
if (parentApp.isEmpty()) {
|
||||||
constraint = QLatin1String("[X-KDE-ParentApp] == '") + parentApp + QLatin1Char('\'');
|
plugins = KPluginLoader::findPlugins(PluginLoaderPrivate::s_containmentActionsPluginDir);
|
||||||
}
|
} else {
|
||||||
|
plugins = KPluginLoader::findPlugins(PluginLoaderPrivate::s_containmentActionsPluginDir, filter);
|
||||||
list.append(KPluginTrader::self()->query(PluginLoaderPrivate::s_containmentActionsPluginDir, QStringLiteral("Plasma/ContainmentActions"), constraint));
|
|
||||||
|
|
||||||
QSet<QString> knownPlugins;
|
|
||||||
for (const KPluginInfo &p : qAsConst(list)) {
|
|
||||||
knownPlugins.insert(p.pluginName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if KSERVICE_BUILD_DEPRECATED_SINCE(5, 0)
|
#if KSERVICE_BUILD_DEPRECATED_SINCE(5, 0)
|
||||||
//FIXME: this is only for backwards compatibility, but probably will have to stay
|
//FIXME: this is only for backwards compatibility, but probably will have to stay
|
||||||
//for the time being
|
//for the time being
|
||||||
|
QSet<QString> knownPlugins;
|
||||||
|
for (const KPluginMetaData &p : qAsConst(plugins)) {
|
||||||
|
knownPlugins.insert(p.pluginId());
|
||||||
|
}
|
||||||
|
QString constraint;
|
||||||
|
if (!parentApp.isEmpty()) {
|
||||||
|
constraint = QLatin1String("[X-KDE-ParentApp] == '") + parentApp + QLatin1Char('\'');
|
||||||
|
}
|
||||||
const KService::List offers = KServiceTypeTrader::self()->query(QStringLiteral("Plasma/ContainmentActions"), constraint);
|
const KService::List offers = KServiceTypeTrader::self()->query(QStringLiteral("Plasma/ContainmentActions"), constraint);
|
||||||
for (KService::Ptr s : offers) {
|
for (KService::Ptr s : offers) {
|
||||||
if (!knownPlugins.contains(s->pluginKeyword())) {
|
if (!knownPlugins.contains(s->pluginKeyword())) {
|
||||||
QT_WARNING_PUSH
|
QT_WARNING_PUSH
|
||||||
QT_WARNING_DISABLE_CLANG("-Wdeprecated-declarations")
|
QT_WARNING_DISABLE_CLANG("-Wdeprecated-declarations")
|
||||||
QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations")
|
QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations")
|
||||||
list.append(KPluginInfo(s));
|
plugins.append(KPluginInfo(s).toMetaData());
|
||||||
QT_WARNING_POP
|
QT_WARNING_POP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return list;
|
|
||||||
|
return plugins;
|
||||||
}
|
}
|
||||||
|
|
||||||
Applet *PluginLoader::internalLoadApplet(const QString &name, uint appletId, const QVariantList &args)
|
Applet *PluginLoader::internalLoadApplet(const QString &name, uint appletId, const QVariantList &args)
|
||||||
|
@ -342,6 +342,7 @@ public:
|
|||||||
**/
|
**/
|
||||||
QVector<KPluginMetaData> listDataEngineMetaData(const QString &parentApp = QString());
|
QVector<KPluginMetaData> listDataEngineMetaData(const QString &parentApp = QString());
|
||||||
|
|
||||||
|
#if PLASMA_ENABLE_DEPRECATED_SINCE(5, 77)
|
||||||
/**
|
/**
|
||||||
* Returns a list of all known ContainmentActions.
|
* Returns a list of all known ContainmentActions.
|
||||||
*
|
*
|
||||||
@ -350,8 +351,23 @@ public:
|
|||||||
* The default value of QString() will result in a
|
* The default value of QString() will result in a
|
||||||
* list of all ContainmentActions.
|
* list of all ContainmentActions.
|
||||||
* @return list of ContainmentActions
|
* @return list of ContainmentActions
|
||||||
|
* @deprecated since 5.77, use listContainmentActionsMetaData()
|
||||||
**/
|
**/
|
||||||
|
PLASMA_DEPRECATED_VERSION(5, 77, "Use listContainmentActionsMetaData()")
|
||||||
KPluginInfo::List listContainmentActionsInfo(const QString &parentApp);
|
KPluginInfo::List listContainmentActionsInfo(const QString &parentApp);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of all known ContainmentActions.
|
||||||
|
*
|
||||||
|
* @param parentApp the application to filter ContainmentActions on. Uses the
|
||||||
|
* X-KDE-ParentApp entry (if any) in the plugin metadata.
|
||||||
|
* The default value of QString() will result in a
|
||||||
|
* list of all ContainmentActions.
|
||||||
|
* @return list of ContainmentActions
|
||||||
|
* @since 5.77
|
||||||
|
**/
|
||||||
|
QVector<KPluginMetaData> listContainmentActionsMetaData(const QString &parentApp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the plugin loader which will be queried for all loads.
|
* Set the plugin loader which will be queried for all loads.
|
||||||
|
Loading…
Reference in New Issue
Block a user