[system/dolphin] src: Fix icon lookup for "Open Terminal" actions

Méven Car <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 62b12e9c307372100a7e70176abd45f6628d1b2b by Méven Car, on behalf of Bharadwaj Raju.
Committed on 07/08/2026 at 10:17.
Pushed by meven into branch 'master'.

Fix icon lookup for "Open Terminal" actions

Using KDesktopFile to read the desktop entry from a desktop name (i.e.
"org.something.terminalapp.desktop") is incorrect; KDesktopFile is for
making modifications to a desktop entry, and hence does not even try to
find existing desktop entries in the correct places.
See src/core/kdesktopfile.cpp in the KConfig source code, particularly
the call to KConfigPrivate::changeFileName.

The result of this is that ultimately it does not find desktop entries
located in /usr/share/applications or the Flatpak equivalent, and hence
fails to locate icons.

Instead, use KService::serviceByStorageId.

Steps to reproduce:
  1. Install a terminal app like WezTerm
  2. Set it as default in System Settings > Default Applications
  3. Right click inside a folder in Dolphin
  4. Observe the lack of an icon

BUG: 501435
CCBUG: 436178

M  +3    -3    src/dolphinmainwindow.cpp

https://invent.kde.org/system/dolphin/-/commit/62b12e9c307372100a7e70176abd45f6628d1b2b

diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp
index a29fe0df39..903b2d9d1b 100644
--- a/src/dolphinmainwindow.cpp
+++ b/src/dolphinmainwindow.cpp
@@ -46,7 +46,6 @@
 #include <KColorSchemeMenu>
 #include <KConfig>
 #include <KConfigGui>
-#include <KDesktopFile>
 #include <KDialogJobUiDelegate>
 #include <KDualAction>
 #include <KFileItemListProperties>
@@ -61,6 +60,7 @@
 #include <KProtocolManager>
 #include <KRecentFilesAction>
 #include <KRuntimePlatform>
+#include <KService>
 #include <KShell>
 #include <KShortcutsDialog>
 #include <KStandardAction>
@@ -2191,8 +2191,8 @@ void DolphinMainWindow::setupActions()
         // Get icon of user default terminal emulator application
         const KConfigGroup group(KSharedConfig::openConfig(QStringLiteral("kdeglobals"), KConfig::SimpleConfig), QStringLiteral("General"));
         const QString terminalDesktopFilename = group.readEntry("TerminalService");
-        // Use utilities-terminal icon from theme if readEntry() has failed
-        const QString terminalIcon = terminalDesktopFilename.isEmpty() ? "utilities-terminal" : KDesktopFile(terminalDesktopFilename).readIcon();
+        const KService::Ptr terminalService = KService::serviceByStorageId(terminalDesktopFilename);
+        const QString terminalIcon = terminalService ? terminalService->icon() : QLatin1String("utilities-terminal");
 
         QAction *openTerminal = actionCollection()->addAction(QStringLiteral("open_terminal"));
         openTerminal->setText(i18nc("@action:inmenu Tools", "Open Terminal"));
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.