]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Fix middle-click not following the "Open archives as folder" setting
authorJin Liu <m.liu.jin@gmail.com>
Mon, 19 Aug 2024 11:15:23 +0000 (11:15 +0000)
committerFelix Ernst <felixernst@kde.org>
Mon, 19 Aug 2024 11:15:23 +0000 (11:15 +0000)
Previous to this commit middle-clicking an archive would always open it
in a new tab. This contradicts the recent change
d27ee07de7558470ef7b497fbe3d3504ce7cad07 which made it so middle-click
would open an item in the second application that is available to open
a file.

With this commit, middle-clicking will treat the archive like a folder
only when GeneralSettings::browseThroughArchives is enabled or when
there is no second application available. Otherwise middle-click will
open the archive in the second available application.

src/dolphincontextmenu.cpp
src/dolphinviewcontainer.cpp
src/views/dolphinview.cpp

index b4aade6b9a81eb361f4a7a38d15e2f09cb892641..68f6dbd21240a103b30dcee39c1c2911916747f1 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"
@@ -441,7 +442,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());
index f0035a8578492ae951e0bcc6e5154572bb6b972b..ef76042b833fbec4a87ce8aa271149d5ae6b59b8 100644 (file)
@@ -751,6 +751,18 @@ void DolphinViewContainer::slotfileMiddleClickActivated(const KFileItem &item)
         job->setUiDelegate(KIO::createDefaultJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this));
         connect(job, &KIO::OpenUrlJob::finished, this, &DolphinViewContainer::slotOpenUrlFinished);
         job->start();
+    } else {
+        // If no 2nd service available, try to open archives in new tabs, regardless of the "Open archives as folder" setting.
+        const QUrl &url = DolphinView::openItemAsFolderUrl(item);
+        const auto modifiers = QGuiApplication::keyboardModifiers();
+        if (!url.isEmpty()) {
+            // keep in sync with KUrlNavigator::slotNavigatorButtonClicked
+            if (modifiers & Qt::ShiftModifier) {
+                Q_EMIT activeTabRequested(url);
+            } else {
+                Q_EMIT tabRequested(url);
+            }
+        }
     }
 }
 
index 85e652ecf70baa14c8f412399b9f421d89d4c8a6..11c0423bee6954670c74c7fd6d3d22f65cbd0bfe 100644 (file)
@@ -1120,7 +1120,7 @@ void DolphinView::slotItemsActivated(const KItemSet &indexes)
 void DolphinView::slotItemMiddleClicked(int index)
 {
     const KFileItem &item = m_model->fileItem(index);
-    const QUrl &url = openItemAsFolderUrl(item);
+    const QUrl &url = openItemAsFolderUrl(item, GeneralSettings::browseThroughArchives());
     const auto modifiers = QGuiApplication::keyboardModifiers();
     if (!url.isEmpty()) {
         // keep in sync with KUrlNavigator::slotNavigatorButtonClicked