┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Uwe Broulik <[email protected]>2024-03-16 18:10:55 +0100
committerMéven Car <[email protected]>2024-03-18 17:48:28 +0000
commitf97c61ffac947582713dfef17f7e2194994c2da9 (patch)
treee1551a3b1b3c536965396da9a4a92a258c416c2a
parent731059d0cea029c12bc526d4ce15237f5b96f541 (diff)
DolphinContextMenu: Add hint that secondary app will be opened by middle click
Displays it in the menu like a keyboard shortcut. Otherwise nobody will ever find this feature.
-rw-r--r--src/dolphincontextmenu.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/dolphincontextmenu.cpp b/src/dolphincontextmenu.cpp
index 26d6eb238..53e0c173e 100644
--- a/src/dolphincontextmenu.cpp
+++ b/src/dolphincontextmenu.cpp
@@ -439,6 +439,21 @@ void DolphinContextMenu::addOpenWithActions()
{
// insert 'Open With...' action or sub menu
m_fileItemActions->insertOpenWithActionsTo(nullptr, this, QStringList{qApp->desktopFileName()});
+
+ // For a single file, hint in "Open with" menu that middle-clicking would open it in the secondary app.
+ if (m_selectedItems.count() == 1 && !m_fileInfo.isDir()) {
+ if (QAction *openWithSubMenu = findChild<QAction *>(QStringLiteral("openWith_submenu"))) {
+ Q_ASSERT(openWithSubMenu->menu());
+ Q_ASSERT(!openWithSubMenu->menu()->isEmpty());
+
+ auto *secondaryApp = openWithSubMenu->menu()->actions().first();
+ // Add it like a keyboard shortcut, Qt uses \t as a separator.
+ if (!secondaryApp->text().contains(QLatin1Char('\t'))) {
+ secondaryApp->setText(secondaryApp->text() + QLatin1Char('\t')
+ + i18nc("@action:inmenu Shortcut, middle click to trigger menu item, keep short", "Middle Click"));
+ }
+ }
+ }
}
void DolphinContextMenu::addAdditionalActions(const KFileItemListProperties &props)