]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphincontextmenu.cpp
Accessibility: Fix message boxes not being announced
[dolphin.git] / src / dolphincontextmenu.cpp
index 34d2102ef0e83df6e5a90fb3fc09cf105c11436b..3ce1d1d51c82fb178d202f458d00c5ba82ee9f83 100644 (file)
@@ -7,6 +7,7 @@
 #include "dolphincontextmenu.h"
 
 #include "dolphin_contextmenusettings.h"
+#include "dolphin_generalsettings.h"
 #include "dolphinmainwindow.h"
 #include "dolphinnewfilemenu.h"
 #include "dolphinplacesmodelsingleton.h"
@@ -357,7 +358,7 @@ void DolphinContextMenu::insertDefaultItemActions(const KFileItemListProperties
     addSeparator();
 
     // Insert 'Move to Trash' and/or 'Delete'
-    const bool showDeleteAction = (KSharedConfig::openConfig()->group("KDE").readEntry("ShowDeleteCommand", false) || !properties.isLocal());
+    const bool showDeleteAction = (KSharedConfig::openConfig()->group(QStringLiteral("KDE")).readEntry("ShowDeleteCommand", false) || !properties.isLocal());
     const bool showMoveToTrashAction = (properties.isLocal() && properties.supportsMoving());
 
     if (showDeleteAction && showMoveToTrashAction) {
@@ -380,9 +381,8 @@ bool DolphinContextMenu::placeExists(const QUrl &url) const
 {
     const KFilePlacesModel *placesModel = DolphinPlacesModelSingleton::instance().placesModel();
 
-    const auto &matchedPlaces = placesModel->match(placesModel->index(0, 0), KFilePlacesModel::UrlRole, url, 1, Qt::MatchExactly);
-
-    return !matchedPlaces.isEmpty();
+    QModelIndex url_index = placesModel->closestItem(url);
+    return url_index.isValid() && placesModel->url(url_index).matches(url, QUrl::StripTrailingSlash);
 }
 
 QAction *DolphinContextMenu::createPasteAction()
@@ -439,6 +439,23 @@ 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).)
+    const QUrl &url = DolphinView::openItemAsFolderUrl(m_fileInfo, GeneralSettings::browseThroughArchives());
+    if (m_selectedItems.count() == 1 && url.isEmpty()) {
+        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)
@@ -454,6 +471,7 @@ void DolphinContextMenu::addAdditionalActions(const KFileItemListProperties &pro
     const DolphinView *view = m_mainWindow->activeViewContainer()->view();
     const QList<QAction *> versionControlActions = view->versionControlActions(m_selectedItems);
     if (!versionControlActions.isEmpty()) {
+        addSeparator();
         addActions(versionControlActions);
         addSeparator();
     }