Commit 15c0bd8b authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

Put KServiceTypeTrader code in deprecation macros

Task: https://phabricator.kde.org/T14517
parent fd9ed1cc
Pipeline #193282 passed with stage
in 58 seconds
......@@ -31,7 +31,6 @@
#include <KLocalizedString>
#include <KMessageBox>
#include <KPluginMetaData>
#include <KServiceTypeTrader>
#include <KStandardAction>
#include <KToolBar>
#include <KWindowConfig>
......
......@@ -10,9 +10,12 @@
#include <KFileUtils>
#include <KPluginFactory>
#include <KPluginMetaData>
#include <KServiceTypeTrader>
#include <QGuiApplication>
#include <QStandardPaths>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <KServiceTypeTrader>
#endif
#include <kservice.h>
#include <set>
......@@ -51,11 +54,13 @@ inline QList<KPluginMetaData> findExternalKCMModules(MetaDataSource source)
QList<KPluginMetaData> metaDataList;
if (source & SystemSettings) {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
const auto servicesList = KServiceTypeTrader::self()->query(QStringLiteral("SystemSettingsExternalApp"));
for (const auto &s : servicesList) {
const QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("kservices5/") + s->entryPath());
metaDataList << KPluginMetaData::fromDesktopFile(path);
}
#endif
metaDataList << findExternalModulesInFilesystem(QStringLiteral("systemsettings"));
}
......@@ -77,18 +82,24 @@ inline QList<KPluginMetaData> findKCMsMetaData(MetaDataSource source, bool useSy
};
// We need the exist calls because otherwise the trader language aborts if the property doesn't exist and the second part of the or is not evaluated
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
KService::List services;
#endif
QVector<KPluginMetaData> metaDataList = KPluginMetaData::findPlugins(QStringLiteral("plasma/kcms"), filter);
if (source & SystemSettings) {
metaDataList << KPluginMetaData::findPlugins(QStringLiteral("plasma/kcms/systemsettings"), filter);
metaDataList << KPluginMetaData::findPlugins(QStringLiteral("plasma/kcms/systemsettings_qwidgets"), filter);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
services +=
KServiceTypeTrader::self()->query(QStringLiteral("KCModule"),
useSystemsettingsConstraint ? QStringLiteral("[X-KDE-System-Settings-Parent-Category] != ''") : QString());
#endif
}
if (source & KInfoCenter) {
metaDataList << KPluginMetaData::findPlugins(QStringLiteral("plasma/kcms/kinfocenter"), filter);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
services += KServiceTypeTrader::self()->query(QStringLiteral("KCModule"), QStringLiteral("[X-KDE-ParentApp] == 'kinfocenter'"));
#endif
}
for (const auto &m : qAsConst(metaDataList)) {
// We check both since porting a module to loading view KPluginMetaData drops ".desktop" from the pluginId()
......@@ -102,6 +113,7 @@ inline QList<KPluginMetaData> findKCMsMetaData(MetaDataSource source, bool useSy
}
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
for (const auto &s : qAsConst(services)) {
if (!s->noDisplay() && !s->exec().isEmpty() && KAuthorized::authorizeControlModule(s->menuId())) {
const QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("kservices5/") + s->entryPath());
......@@ -112,6 +124,7 @@ inline QList<KPluginMetaData> findKCMsMetaData(MetaDataSource source, bool useSy
}
}
}
#endif
std::stable_sort(modules.begin(), modules.end(), [](const KPluginMetaData &m1, const KPluginMetaData &m2) {
return QString::compare(m1.pluginId(), m2.pluginId(), Qt::CaseInsensitive) < 0;
});
......
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