From d444d1033a16e3f1a540a82af266203ca48aa239 Mon Sep 17 00:00:00 2001 From: Tomasz Kot Date: Sun, 16 Nov 2025 18:59:53 +0000 Subject: dolphincontextmenu: Add hint that shift+middle-click opens the third app Checks if the second action in the submenu is actually an app and not a separator, and add hint "Shift + Middle Click". --- src/dolphincontextmenu.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/dolphincontextmenu.cpp') diff --git a/src/dolphincontextmenu.cpp b/src/dolphincontextmenu.cpp index 1ca885817..53f155af4 100644 --- a/src/dolphincontextmenu.cpp +++ b/src/dolphincontextmenu.cpp @@ -492,8 +492,9 @@ 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. - // (Unless middle-clicking would open it as a folder in a new tab (e.g. archives).) + // For a single file, hint in "Open with" menu that middle-clicking would open it in the secondary app, + // and shift + middle-clicking would open it in the third associated app. + // (Unless those actions would open it as a folder in a new tab (e.g. archives).) const QUrl &url = DolphinView::openItemAsFolderUrl(m_fileInfo, GeneralSettings::browseThroughArchives()); if (m_selectedItems.count() == 1 && url.isEmpty()) { if (QAction *openWithSubMenu = findChild(QStringLiteral("openWith_submenu"))) { @@ -506,6 +507,18 @@ void DolphinContextMenu::addOpenWithActions() secondaryApp->setText(secondaryApp->text() + QLatin1Char('\t') + i18nc("@action:inmenu Shortcut, middle click to trigger menu item, keep short", "Middle Click")); } + + // To add a hint for the third app, check if it is defined. + // Note: Apart from apps, the submenu contains an empty action (separator) and "Other application" action (in this order). + // Thus, add the hint only when there are four actions - two apps + two of the above. + if (openWithSubMenu->menu()->actions().size() >= 4) { + auto *thirdApp = *(openWithSubMenu->menu()->actions().begin() + 1); + Q_ASSERT(!thirdApp->isSeparator()); + if (!thirdApp->text().contains(QLatin1Char('\t'))) { + thirdApp->setText(thirdApp->text() + QLatin1Char('\t') + + i18nc("@action:inmenu Shortcut, shift + middle click to trigger menu item, keep short", "Shift+Middle Click")); + } + } } } } -- cgit v1.3