From b79f44f4e1cee14e2c3b3faaa2c7ba4462623d27 Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Tue, 13 Oct 2020 21:51:07 +0200 Subject: [PATCH] [Kicker] Show frequently used system settings modules for System Settings For System Settings the frequently used settings modules are shown in the same way they are done on System Settings home page. The default set is taken from its jump list actions when there aren't enough (5) frequent entries yet. This matches System Settings behavior, too. --- applets/kicker/plugin/actionlist.cpp | 42 ++++++++++++++++++++++++++++ applets/kicker/plugin/actionlist.h | 1 + 2 files changed, 43 insertions(+) diff --git a/applets/kicker/plugin/actionlist.cpp b/applets/kicker/plugin/actionlist.cpp index 738f927b8..cf8fcb971 100644 --- a/applets/kicker/plugin/actionlist.cpp +++ b/applets/kicker/plugin/actionlist.cpp @@ -215,6 +215,15 @@ QVariantList jumpListActions(KService::Ptr service) return list; } + // Add frequently used settings modules similar to SystemSetting's overview page. + if (service->storageId() == QLatin1String("systemsettings.desktop")) { + list = systemSettingsActions(); + + if (!list.isEmpty()) { + return list; + } + } + const auto &actions = service->actions(); foreach (const KServiceAction &action, actions) { if (action.text().isEmpty() || action.exec().isEmpty()) { @@ -229,6 +238,39 @@ QVariantList jumpListActions(KService::Ptr service) return list; } +QVariantList systemSettingsActions() +{ + QVariantList list; + + auto query = AllResources + | Agent(QStringLiteral("org.kde.systemsettings")) + | HighScoredFirst + | Limit(5); + + ResultSet results(query); + + QStringList ids; + for (const ResultSet::Result &result : results) { + ids << QUrl(result.resource()).path(); + } + + if (ids.count() < 5) { + // We'll load the default set of settings from its jump list actions. + return list; + } + + for (const QString &id : ids) { + KService::Ptr service = KService::serviceByStorageId(id); + if (!service || !service->isValid()) { + continue; + } + + list << createActionItem(service->name(), service->icon(), QStringLiteral("_kicker_jumpListAction"), service->exec()); + } + + return list; +} + QVariantList recentDocumentActions(KService::Ptr service) { QVariantList list; diff --git a/applets/kicker/plugin/actionlist.h b/applets/kicker/plugin/actionlist.h index dd23ca4a8..1b28da233 100644 --- a/applets/kicker/plugin/actionlist.h +++ b/applets/kicker/plugin/actionlist.h @@ -57,6 +57,7 @@ QVariantList createAddLauncherActionList(QObject *appletInterface, const KServic bool handleAddLauncherAction(const QString &actionId, QObject *appletInterface, const KService::Ptr &service); QVariantList jumpListActions(KService::Ptr service); +QVariantList systemSettingsActions(); QVariantList recentDocumentActions(KService::Ptr service); bool handleRecentDocumentAction(KService::Ptr service, const QString &actionId, const QVariant &argument);