Commit 28e40097 authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

Port external Systemsettings/KInfoCenter KCM loading away from KpluginMetaData::fromDesktopFile

parent 17c7ed0a
Pipeline #180475 passed with stage
in 1 minute and 40 seconds
......@@ -191,8 +191,7 @@ void MenuItem::setMetaData(const KPluginMetaData &data)
d->comment = data.description();
d->iconName = data.iconName();
d->systemsettingsCategoryModule = data.value(QStringLiteral("X-KDE-System-Settings-Category-Module"));
d->isExternalAppModule = data.serviceTypes().contains(QStringLiteral("SystemSettingsExternalApp")) //
|| data.serviceTypes().contains(QStringLiteral("InfoCenterExternalApp"));
d->isExternalAppModule = data.value(QStringLiteral("IsExternalApp"), false);
}
KPluginMetaData MenuItem::metaData()
......
......@@ -24,14 +24,27 @@ enum MetaDataSource {
inline QList<KPluginMetaData> findExternalKCMModules(MetaDataSource source)
{
const auto findExternalModulesInFilesystem = [](const QString &sourceNamespace, const QString &serviceType) {
const auto findExternalModulesInFilesystem = [](const QString &sourceNamespace) {
const QString sourceNamespaceDirName = QStringLiteral("plasma/%1/externalmodules").arg(sourceNamespace);
const QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, sourceNamespaceDirName, QStandardPaths::LocateDirectory);
const QStringList files = KFileUtils::findAllUniqueFiles(dirs, QStringList{QStringLiteral("*.desktop")});
QList<KPluginMetaData> metaDataList;
for (const QString &file : files) {
metaDataList << KPluginMetaData::fromDesktopFile(file, QStringList(serviceType));
KService service(file);
QJsonObject kplugin;
kplugin.insert(QLatin1String("Name"), service.name());
kplugin.insert(QLatin1String("Icon"), service.icon());
kplugin.insert(QLatin1String("Description"), service.comment());
QJsonObject root;
root.insert(QLatin1String("KPlugin"), kplugin);
root.insert(QLatin1String("X-KDE-Weight"), service.property(QStringLiteral("X-KDE-Weight")).toInt());
root.insert(QLatin1String("X-KDE-KInfoCenter-Category"), service.property(QStringLiteral("X-KDE-KInfoCenter-Category")).toString());
root.insert(QLatin1String("X-KDE-System-Settings-Category"), service.property(QStringLiteral("X-KDE-System-Settings-Category")).toString());
root.insert(QLatin1String("IsExternalApp"), true);
metaDataList << KPluginMetaData(root, file);
}
return metaDataList;
};
......@@ -43,11 +56,11 @@ inline QList<KPluginMetaData> findExternalKCMModules(MetaDataSource source)
const QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("kservices5/") + s->entryPath());
metaDataList << KPluginMetaData::fromDesktopFile(path);
}
metaDataList << findExternalModulesInFilesystem(QStringLiteral("systemsettings"), QStringLiteral("systemsettingsexternalapp.desktop"));
metaDataList << findExternalModulesInFilesystem(QStringLiteral("systemsettings"));
}
if (source & KInfoCenter) {
metaDataList << findExternalModulesInFilesystem(QStringLiteral("kinfocenter"), QStringLiteral("infocenterexternalapp.desktop"));
metaDataList << findExternalModulesInFilesystem(QStringLiteral("kinfocenter"));
}
return metaDataList;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment