From 09a62ab6eaa05c8c75b0115f59457c1069942a6a Mon Sep 17 00:00:00 2001 From: MatMoul Date: Sat, 9 Mar 2024 15:05:29 +0100 Subject: [PATCH] Implement show by name option --- src/customdesktopmenu.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/customdesktopmenu.cpp b/src/customdesktopmenu.cpp index f6f4764..5ffeddf 100644 --- a/src/customdesktopmenu.cpp +++ b/src/customdesktopmenu.cpp @@ -122,7 +122,11 @@ void CustomDesktopMenu::parseConfig() // .desktop file if(KDesktopFile::isDesktopFile(cfgLine) == true) { KDesktopFile desktopFile(cfgLine); - action = new QAction(QIcon::fromTheme(desktopFile.readIcon()), desktopFile.readName(), this); + QString text = desktopFile.name(); + if (!m_showAppsByName && !desktopFile.readGenericName().isEmpty()) { + text = desktopFile.readGenericName(); + } + action = new QAction(QIcon::fromTheme(desktopFile.readIcon()), text, this); action->setData(cfgLine); connect(action, &QAction::triggered, [action](){ KService::Ptr service = KService::serviceByDesktopPath(action->data().toString()); @@ -179,7 +183,11 @@ void CustomDesktopMenu::fillPrograms(const QString& path) if(p->isType(KST_KService)) { if(KDesktopFile::isDesktopFile(p->entryPath()) == true) { KDesktopFile desktopFile(p->entryPath()); - action = new QAction(QIcon::fromTheme(desktopFile.readIcon()), desktopFile.readName(), this); + QString text = p->name(); + if (!m_showAppsByName && !desktopFile.readGenericName().isEmpty()) { + text = desktopFile.readGenericName(); + } + action = new QAction(QIcon::fromTheme(desktopFile.readIcon()), text, this); action->setData(p->entryPath()); connect(action, &QAction::triggered, [action](){ KService::Ptr service = KService::serviceByDesktopPath(action->data().toString());