[pluginloader] Add methods to list containments using KPluginMetaData
To replace the KPluginInfo-based variants
This commit is contained in:
parent
cde7f8a986
commit
bfa1100523
@ -55,6 +55,10 @@ void PluginTest::listContainmentsOfType()
|
||||
const KPluginInfo::List plugins = Plasma::PluginLoader::listContainmentsOfType(QStringLiteral("Desktop"));
|
||||
qDebug() << "Desktop Containments: " << plugins.count();
|
||||
QVERIFY(plugins.count() > 0 || m_buildonly);
|
||||
|
||||
const QList<KPluginMetaData> pluginsMetaData = Plasma::PluginLoader::listContainmentsMetaDataOfType(QStringLiteral("Desktop"));
|
||||
qDebug() << "Desktop Containments MetaData: " << pluginsMetaData.count();
|
||||
QVERIFY(pluginsMetaData.count() > 0 || m_buildonly);
|
||||
}
|
||||
|
||||
static const auto source = QStringLiteral("Europe/Sofia");
|
||||
|
@ -663,6 +663,28 @@ KPluginInfo::List PluginLoader::listContainments(const QString &category, const
|
||||
return listContainmentsOfType(QString(), category, parentApp);
|
||||
}
|
||||
|
||||
QList<KPluginMetaData> PluginLoader::listContainmentsMetaData(std::function<bool(const KPluginMetaData &)> filter)
|
||||
{
|
||||
auto ownFilter = [filter](const KPluginMetaData &md) -> bool {
|
||||
if (!md.serviceTypes().contains(QLatin1String("Plasma/Containment"))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return filter(md);
|
||||
};
|
||||
|
||||
return KPackage::PackageLoader::self()->findPackages(QStringLiteral("Plasma/Applet"), QString(), ownFilter);
|
||||
}
|
||||
|
||||
QList<KPluginMetaData> PluginLoader::listContainmentsMetaDataOfType(const QString &type)
|
||||
{
|
||||
auto filter = [type](const KPluginMetaData &md) -> bool {
|
||||
return md.value(QStringLiteral("X-Plasma-ContainmentType")) == type;
|
||||
};
|
||||
|
||||
return listContainmentsMetaData(filter);
|
||||
}
|
||||
|
||||
KPluginInfo::List PluginLoader::listContainmentsOfType(const QString &type, const QString &category, const QString &parentApp)
|
||||
{
|
||||
KConfigGroup group(KSharedConfig::openConfig(), "General");
|
||||
|
@ -280,6 +280,24 @@ public:
|
||||
**/
|
||||
static KPluginInfo::List listContainments(const QString &category = QString(), const QString &parentApp = QString());
|
||||
|
||||
/**
|
||||
* Returns a list of all known containments.
|
||||
*
|
||||
* @param filter An optional predicate that can be used for filtering.
|
||||
*
|
||||
* @return list of containments
|
||||
*/
|
||||
static QList<KPluginMetaData> listContainmentsMetaData(std::function<bool(const KPluginMetaData &)> filter = {});
|
||||
|
||||
/**
|
||||
* Returns a list of containments of the specified type.
|
||||
*
|
||||
* @param type The target containment type
|
||||
*
|
||||
* @return list of containments
|
||||
*/
|
||||
static QList<KPluginMetaData> listContainmentsMetaDataOfType(const QString &type);
|
||||
|
||||
/**
|
||||
* Returns a list of all known containments that match the parameters.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user