diff --git a/libtaskmanager/tasktools.cpp b/libtaskmanager/tasktools.cpp --- a/libtaskmanager/tasktools.cpp +++ b/libtaskmanager/tasktools.cpp @@ -615,11 +615,31 @@ bool launcherUrlsMatch(const QUrl &a, const QUrl &b, UrlComparisonMode mode) { + QUrl sanitizedA = a; + QUrl sanitizedB = b; + if (mode == IgnoreQueryItems) { - return (a.adjusted(QUrl::RemoveQuery) == b.adjusted(QUrl::RemoveQuery)); + sanitizedA = a.adjusted(QUrl::RemoveQuery); + sanitizedB = b.adjusted(QUrl::RemoveQuery); } - return (a == b); + auto tryResolveToApplicationsUrl = [](const QUrl &url) -> QUrl { + QUrl resolvedUrl = url; + if (url.isLocalFile() && url.fileName().endsWith(QLatin1String(".desktop"))) { + const KService::Ptr service = KService::serviceByDesktopPath(url.toLocalFile()); + if (service) { + // Doing setScheme + setPath results in an invalid URL, hence constructing a new one. + resolvedUrl = QUrl(QStringLiteral("applications:") + service->menuId()); + resolvedUrl.setQuery(url.query()); + } + } + return resolvedUrl; + }; + + sanitizedA = tryResolveToApplicationsUrl(sanitizedA); + sanitizedB = tryResolveToApplicationsUrl(sanitizedB); + + return (sanitizedA == sanitizedB); } bool appsMatch(const QModelIndex &a, const QModelIndex &b)