From eaaeb1b7629cc3c59933101d24dd0c2c67ef1276 Mon Sep 17 00:00:00 2001 From: Angus McLean Date: Mon, 17 Mar 2025 08:14:55 +0000 Subject: [PATCH] contextmenu: Use default terminal's icons for "Open Terminal" and "Open Terminal Here" actions The "Open Terminal" and "Open Terminal Here" actions now use the icon of the user default terminal emulator application, instead of always using the "utilities-terminal" icon. BUG: 501435 --- src/dolphinmainwindow.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 8a6c99ce5..573582bdd 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -2085,12 +2086,18 @@ void DolphinMainWindow::setupActions() connect(openPreferredSearchTool, &QAction::triggered, this, &DolphinMainWindow::openPreferredSearchTool); if (KAuthorized::authorize(QStringLiteral("shell_access"))) { + // 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(); + QAction *openTerminal = actionCollection()->addAction(QStringLiteral("open_terminal")); openTerminal->setText(i18nc("@action:inmenu Tools", "Open Terminal")); openTerminal->setWhatsThis(xi18nc("@info:whatsthis", "This opens a terminal application for the viewed location." "To learn more about terminals use the help features in the terminal application.")); - openTerminal->setIcon(QIcon::fromTheme(QStringLiteral("utilities-terminal"))); + openTerminal->setIcon(QIcon::fromTheme(terminalIcon)); actionCollection()->setDefaultShortcut(openTerminal, Qt::SHIFT | Qt::Key_F4); connect(openTerminal, &QAction::triggered, this, &DolphinMainWindow::openTerminal); @@ -2100,7 +2107,7 @@ void DolphinMainWindow::setupActions() openTerminalHere->setWhatsThis(xi18nc("@info:whatsthis", "This opens terminal applications for the selected items' locations." "To learn more about terminals use the help features in the terminal application.")); - openTerminalHere->setIcon(QIcon::fromTheme(QStringLiteral("utilities-terminal"))); + openTerminalHere->setIcon(QIcon::fromTheme(terminalIcon)); actionCollection()->setDefaultShortcut(openTerminalHere, Qt::SHIFT | Qt::ALT | Qt::Key_F4); connect(openTerminalHere, &QAction::triggered, this, &DolphinMainWindow::openTerminalHere); } -- 2.47.3