Commit b79f44f4 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇

[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.
parent 879b2b38
......@@ -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;
......
......@@ -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);
......
Markdown is supported
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