From f97c61ffac947582713dfef17f7e2194994c2da9 Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Sat, 16 Mar 2024 18:10:55 +0100 Subject: [PATCH] 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. --- src/dolphincontextmenu.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/dolphincontextmenu.cpp b/src/dolphincontextmenu.cpp index 26d6eb238a..53e0c173e5 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(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)