[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kde-baseapps/KDE/4.14] dolphin/src: Make it possible to open archives via the command line
From:       Frank Reininghaus <frank78ac () googlemail ! com>
Date:       2014-08-31 22:17:13
Message-ID: E1XODQv-0001PC-0u () scm ! kde ! org
[Download RAW message or body]

Git commit 421e7ea410af32be2dff06207b459cefbdf43306 by Frank Reininghaus.
Committed on 31/08/2014 at 22:06.
Pushed by freininghaus into branch 'KDE/4.14'.

Make it possible to open archives via the command line

This used to work before afcf8961f6666a912e0e6e5072a000837f7cf6aa (only
if "Open archives as folder" was enabled in the settings though). The
reason why this commit broke it is that the mime type of a file is not
determined automatically any more before asking
KProtocolManager::protocolForArchiveMimetype for the correct protocol,
so the determination of the protocol may fail.

Keeping the isMimeTypeKnown() check in DolphinView::openItemAsFolderUrl
still makes sense, because it prevents GUI blocking if the user tries
to open many files at the same time.

Therefore, we now call determineMimeType() in
DolphinViewContainer::slotUrlIsFileError(const KUrl&) and then try to
determine the correct protocol and use it to open the archive in the
view, rather than hoping that slotItemActivated(item) will do the right
thing.

BUG: 333078
REVIEW: 119877
FIXED-IN: 4.14.1

M  +10   -1    dolphin/src/dolphinviewcontainer.cpp

http://commits.kde.org/kde-baseapps/421e7ea410af32be2dff06207b459cefbdf43306

diff --git a/dolphin/src/dolphinviewcontainer.cpp b/dolphin/src/dolphinviewcontainer.cpp
index 93af3e8..a11ba42 100644
--- a/dolphin/src/dolphinviewcontainer.cpp
+++ b/dolphin/src/dolphinviewcontainer.cpp
@@ -463,7 +463,16 @@ void DolphinViewContainer::slotDirectoryLoadingCanceled()
 void DolphinViewContainer::slotUrlIsFileError(const KUrl& url)
 {
     const KFileItem item(KFileItem::Unknown, KFileItem::Unknown, url);
-    slotItemActivated(item);
+
+    // Find out if the file can be opened in the view (for example, this is the
+    // case if the file is an archive). The mime type must be known for that.
+    item.determineMimeType();
+    const KUrl& folderUrl = DolphinView::openItemAsFolderUrl(item, true);
+    if (!folderUrl.isEmpty()) {
+        m_view->setUrl(folderUrl);
+    } else {
+        slotItemActivated(item);
+    }
 }
 
 void DolphinViewContainer::slotItemActivated(const KFileItem& item)
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic