Commit 404b2be2 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇

[Icon Applet] Port jump list actions to KServiceAction

Differential Revision: https://phabricator.kde.org/D29133
parent 881d1efc
......@@ -40,12 +40,14 @@
#include <KFileItemListProperties>
#include <KFileUtils>
#include <KJobWidgets>
#include <KIO/ApplicationLauncherJob>
#include <KLocalizedString>
#include <KNotificationJobUiDelegate>
#include <KProtocolManager>
#include <KRun>
#include <KService>
#include <KServiceAction>
#include <KIO/ApplicationLauncherJob>
#include <KIO/DropJob>
#include <KIO/FavIconRequestJob>
#include <KIO/OpenFileManagerWindowJob>
......@@ -335,23 +337,24 @@ QList<QAction *> IconApplet::contextualActions()
KDesktopFile desktopFile(m_localPath);
if (m_jumpListActions.isEmpty()) {
const QStringList actions = desktopFile.readActions();
for (const QString &actionName : actions) {
const KConfigGroup &actionGroup = desktopFile.actionGroup(actionName);
const KService service(m_localPath);
if (!actionGroup.isValid() || !actionGroup.exists()) {
const auto jumpListActions = service.actions();
for (const KServiceAction &serviceAction : jumpListActions) {
if (serviceAction.noDisplay()) {
continue;
}
const QString name = actionGroup.readEntry(QStringLiteral("Name"));
const QString exec = actionGroup.readEntry(QStringLiteral("Exec"));
if (name.isEmpty() || exec.isEmpty()) {
continue;
QAction *action = new QAction(QIcon::fromTheme(serviceAction.icon()), serviceAction.text(), this);
if (serviceAction.isSeparator()) {
action->setSeparator(true);
}
QAction *action = new QAction(QIcon::fromTheme(actionGroup.readEntry("Icon")), name, this);
connect(action, &QAction::triggered, this, [this, exec] {
KRun::run(exec, {}, nullptr, m_name, m_iconName);
connect(action, &QAction::triggered, this, [this, serviceAction]() {
auto *job = new KIO::ApplicationLauncherJob(serviceAction);
auto *delegate = new KNotificationJobUiDelegate(KJobUiDelegate::AutoErrorHandlingEnabled);
job->setUiDelegate(delegate);
job->start();
});
m_jumpListActions << action;
......
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