Commit 0c8e0e7d authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇

[Task Manager] Show frequently used 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 0743238b
......@@ -160,6 +160,13 @@ QVariantList Backend::jumpListActions(const QUrl &launcherUrl, QObject *parent)
return actions;
}
if (service->storageId() == QLatin1String("systemsettings.desktop")) {
actions = systemSettingsActions(parent);
if (!actions.isEmpty()) {
return actions;
}
}
const auto jumpListActions = service->actions();
for (const KServiceAction &serviceAction : jumpListActions) {
......@@ -188,6 +195,50 @@ QVariantList Backend::jumpListActions(const QUrl &launcherUrl, QObject *parent)
return actions;
}
QVariantList Backend::systemSettingsActions(QObject *parent) const
{
QVariantList actions;
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 actions;
}
for (const QString &id : ids) {
KService::Ptr service = KService::serviceByStorageId(id);
if (!service || !service->isValid()) {
continue;
}
QAction *action = new QAction(parent);
action->setText(service->name());
action->setIcon(QIcon::fromTheme(service->icon()));
connect(action, &QAction::triggered, this, [this, service]() {
auto *job = new KIO::ApplicationLauncherJob(service);
auto *delegate = new KNotificationJobUiDelegate;
delegate->setAutoErrorHandlingEnabled(true);
job->setUiDelegate(delegate);
job->start();
});
actions << QVariant::fromValue<QAction *>(action);
}
return actions;
}
QVariantList Backend::placesActions(const QUrl &launcherUrl, bool showAllPlaces, QObject *parent)
{
if (!parent) {
......
......@@ -113,6 +113,8 @@ class Backend : public QObject
private:
void updateWindowHighlight();
QVariantList systemSettingsActions(QObject *parent) const;
QQuickItem *m_taskManagerItem = nullptr;
QQuickItem *m_toolTipItem = nullptr;
QQuickWindow *m_groupDialog = nullptr;
......
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