diff --git a/applets/taskmanager/plugin/backend.cpp b/applets/taskmanager/plugin/backend.cpp --- a/applets/taskmanager/plugin/backend.cpp +++ b/applets/taskmanager/plugin/backend.cpp @@ -125,14 +125,27 @@ QVariantList Backend::jumpListActions(const QUrl &launcherUrl, QObject *parent) { - QVariantList actions; + if (!parent) { + return QVariantList(); + } - if (!parent || !launcherUrl.isValid() || !launcherUrl.isLocalFile() - || !KDesktopFile::isDesktopFile(launcherUrl.toLocalFile())) { - return actions; + QUrl desktopEntryUrl = launcherUrl; + + if (launcherUrl.isValid() && launcherUrl.scheme() == QStringLiteral("applications")) { + const KService::Ptr service = KService::serviceByMenuId(launcherUrl.path()); + + if (service) { + desktopEntryUrl = QUrl::fromLocalFile(service->entryPath()); + } + } + + if (!desktopEntryUrl.isValid() || !desktopEntryUrl.isLocalFile() + || !KDesktopFile::isDesktopFile(desktopEntryUrl.toLocalFile())) { + return QVariantList(); } - KDesktopFile desktopFile(launcherUrl.toLocalFile()); + QVariantList actions; + KDesktopFile desktopFile(desktopEntryUrl.toLocalFile()); const QStringList &jumpListActions = desktopFile.readActions(); @@ -178,14 +191,27 @@ QVariantList Backend::placesActions(const QUrl &launcherUrl, bool showAllPlaces, QObject *parent) { - QVariantList actions; + if (!parent) { + return QVariantList(); + } - if (!parent || !launcherUrl.isValid() || !launcherUrl.isLocalFile() - || !KDesktopFile::isDesktopFile(launcherUrl.toLocalFile())) { - return actions; + QUrl desktopEntryUrl = launcherUrl; + + if (launcherUrl.isValid() && launcherUrl.scheme() == QStringLiteral("applications")) { + const KService::Ptr service = KService::serviceByMenuId(launcherUrl.path()); + + if (service) { + desktopEntryUrl = QUrl::fromLocalFile(service->entryPath()); + } + } + + if (!desktopEntryUrl.isValid() || !desktopEntryUrl.isLocalFile() + || !KDesktopFile::isDesktopFile(desktopEntryUrl.toLocalFile())) { + return QVariantList(); } - KDesktopFile desktopFile(launcherUrl.toLocalFile()); + QVariantList actions; + KDesktopFile desktopFile(desktopEntryUrl.toLocalFile()); // Since we can't have dynamic jump list actions, at least add the user's "Places" for file managers. const QStringList &categories = desktopFile.desktopGroup().readXdgListEntry(QStringLiteral("Categories")); @@ -207,8 +233,8 @@ QAction *action = new QAction(icon, title, parent); - connect(action, &QAction::triggered, this, [this, action, url, launcherUrl] { - KService::Ptr service = KService::serviceByDesktopPath(launcherUrl.toLocalFile()); + connect(action, &QAction::triggered, this, [this, action, url, desktopEntryUrl] { + KService::Ptr service = KService::serviceByDesktopPath(desktopEntryUrl.toLocalFile()); if (!service) { return; } @@ -239,14 +265,27 @@ QVariantList Backend::recentDocumentActions(const QUrl &launcherUrl, QObject *parent) { - QVariantList actions; + if (!parent) { + return QVariantList(); + } - if (!parent || !launcherUrl.isValid() || !launcherUrl.isLocalFile() - || !KDesktopFile::isDesktopFile(launcherUrl.toLocalFile())) { - return actions; + QUrl desktopEntryUrl = launcherUrl; + + if (launcherUrl.isValid() && launcherUrl.scheme() == QStringLiteral("applications")) { + const KService::Ptr service = KService::serviceByMenuId(launcherUrl.path()); + + if (service) { + desktopEntryUrl = QUrl::fromLocalFile(service->entryPath()); + } } - QString desktopName = launcherUrl.fileName(); + if (!desktopEntryUrl.isValid() || !desktopEntryUrl.isLocalFile() + || !KDesktopFile::isDesktopFile(desktopEntryUrl.toLocalFile())) { + return QVariantList(); + } + + QVariantList actions; + QString desktopName = desktopEntryUrl.fileName(); QString storageId = desktopName; if (storageId.startsWith(QLatin1String("org.kde."))) { @@ -288,7 +327,7 @@ action->setText(url.fileName()); action->setIcon(QIcon::fromTheme(fileItem.iconName(), QIcon::fromTheme("unknown"))); action->setProperty("agent", storageId); - action->setProperty("entryPath", launcherUrl); + action->setProperty("entryPath", desktopEntryUrl); action->setData(resource); connect(action, &QAction::triggered, this, &Backend::handleRecentDocumentAction);