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

List:       kde-commits
Subject:    [ark] part: Use Ark part only when mime type exactly matches a supported type
From:       Kai Uwe Broulik <null () kde ! org>
Date:       2018-09-24 10:02:43
Message-ID: E1g4NhT-0004dr-Lh () code ! kde ! org
[Download RAW message or body]

Git commit c737bf53e81691f5eca1ac6c1ef38054134f797c by Kai Uwe Broulik.
Committed on 24/09/2018 at 10:02.
Pushed by broulik into branch 'master'.

Use Ark part only when mime type exactly matches a supported type

Many file types (e.g. Open Document and Office Open XML) are technically just \
archives but browsing their internals is typically not what the user wants.
Only when the mime type matches one of Ark's supported archive types directly, open \
them in the internal previewer. If it turns out to be a genuine archive after all it \
should just open in a new Ark window then.

CHANGELOG: Fixed Ark previeweing certain files (e.g. Open Document) as archives \
instead of opening them in the appropriate application

BUG: 398531
FIXED-IN: 18.12.0

Differential Revision: https://phabricator.kde.org/D15445

M  +16   -0    part/arkviewer.cpp

https://commits.kde.org/ark/c737bf53e81691f5eca1ac6c1ef38054134f797c

diff --git a/part/arkviewer.cpp b/part/arkviewer.cpp
index 0988c6e6..967e34d9 100644
--- a/part/arkviewer.cpp
+++ b/part/arkviewer.cpp
@@ -36,6 +36,8 @@
 #include <QProgressDialog>
 #include <QPushButton>
 
+#include <algorithm>
+
 ArkViewer::ArkViewer()
         : KParts::MainWindow()
 {
@@ -216,6 +218,20 @@ KService::Ptr ArkViewer::getViewer(const QString &mimeType)
     // Try to get a read-only kpart for the internal viewer
     KService::List offers = KMimeTypeTrader::self()->query(mimeType, \
QStringLiteral("KParts/ReadOnlyPart"));  
+    auto arkPartIt = std::find_if(offers.begin(), offers.end(), [](KService::Ptr \
service) { +        return service->storageId() == QLatin1String("ark_part.desktop");
+    });
+
+    // Use the Ark part only when the mime type matches an archive type directly.
+    // Many file types (e.g. Open Document) are technically just archives
+    // but browsing their internals is typically not what the user wants.
+    if (arkPartIt != offers.end()) {
+        // Not using hasMimeType() as we're explicitly not interested in \
inheritance. +        if (!(*arkPartIt)->mimeTypes().contains(mimeType)) {
+            offers.erase(arkPartIt);
+        }
+    }
+
     // If we can't find a kpart, try to get an external application
     if (offers.isEmpty()) {
         offers = KMimeTypeTrader::self()->query(mimeType, \
QStringLiteral("Application"));


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

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