]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphincontextmenu.cpp
Merge remote-tracking branch 'upstream/master' into work/zakharafoniam/useful-groups
[dolphin.git] / src / dolphincontextmenu.cpp
index bc00af7cc5009d7022c836e93e722d256c2d5ec3..15c65ee565946308a6b4eb6453614d623a004cbc 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"
@@ -383,9 +384,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()
@@ -444,7 +444,9 @@ void DolphinContextMenu::addOpenWithActions()
     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()) {
+    // (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());