From bdb142dad33cd350c880c4dfecc0c69ecb7149af Mon Sep 17 00:00:00 2001 From: Nate Graham Date: Thu, 22 May 2025 09:06:52 -0600 Subject: [PATCH] [PATCH] libtaskmanager: show Comment for launcher icons when appropriate Right now, launcher icons get a caption equal to the app's GenericName, if one is set in the metadata. If not, it gets no caption. This differs from what Kicker and Kickoff Manager do: a more complex behavior to show the Comment if the app has no GenericName or if its GenericName is equal to its Name. Let's replicate the same logic here. BUG: 504431 FIXED-IN: 6.4.0 (cherry picked from commit ae39f3219d6fc849fe8de0d1c165a572598082fe) Co-authored-by: Nate Graham Gbp-Pq: Name upstream_45784326_libtaskmanager-show-Comment-for-launcher-icons-when-appropriate.patch --- libtaskmanager/tasktools.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/libtaskmanager/tasktools.cpp b/libtaskmanager/tasktools.cpp index 873d9eac..e46d9638 100644 --- a/libtaskmanager/tasktools.cpp +++ b/libtaskmanager/tasktools.cpp @@ -34,6 +34,20 @@ using namespace Qt::StringLiterals; +static const QString appropriateCaption(const KService::Ptr &service) +{ + if (!service) { + return {}; + } + + const QString genericName = service->genericName(); + if (!genericName.isEmpty() && genericName != service->name()) { + return genericName; + } + + return service->comment(); +} + namespace TaskManager { AppData appDataFromUrl(const QUrl &url, const QIcon &fallbackIcon) @@ -65,7 +79,7 @@ AppData appDataFromUrl(const QUrl &url, const QIcon &fallbackIcon) if (service && url.path() == service->menuId()) { data.name = service->name(); - data.genericName = service->genericName(); + data.genericName = appropriateCaption(service); data.id = service->storageId(); if (data.icon.isNull()) { @@ -89,7 +103,7 @@ AppData appDataFromUrl(const QUrl &url, const QIcon &fallbackIcon) if (service && QUrl::fromLocalFile(service->entryPath()) == url) { data.name = service->name(); - data.genericName = service->genericName(); + data.genericName = appropriateCaption(service); data.id = service->storageId(); if (data.icon.isNull()) { @@ -99,7 +113,7 @@ AppData appDataFromUrl(const QUrl &url, const QIcon &fallbackIcon) KDesktopFile f(url.toLocalFile()); if (f.tryExec()) { data.name = f.readName(); - data.genericName = f.readGenericName(); + data.genericName = appropriateCaption(KService::serviceByDesktopPath(url.toLocalFile())); data.id = QUrl::fromLocalFile(f.fileName()).fileName(); if (data.icon.isNull()) { @@ -144,7 +158,7 @@ AppData appDataFromUrl(const QUrl &url, const QIcon &fallbackIcon) const QString &desktopFile = service->entryPath(); data.name = service->name(); - data.genericName = service->genericName(); + data.genericName = appropriateCaption(service); data.id = service->storageId(); if (data.icon.isNull()) { -- 2.30.2