From f4320f119b53b72dfc7b234da6d65fe983557843 Mon Sep 17 00:00:00 2001
From: Joshua Goins <josh@redstrate.com>
Date: Sun, 2 Mar 2025 13:05:34 -0500
Subject: [PATCH] Fix Gwenview being unable to open OpenRaster (ora) files

Despite having an ORA image plugin in kimageformats, Gwenview was unable to open
them. It instead preferred to open them as a zip file, which is technically
right but UX-wise wrong.

There was an explicit workaround to stop this from happening for svgz files
which are also ZIPs. We should instead check the supported image mime types
from Qt, and use that instead of hardcoding specific mimetypes.
---
 lib/archiveutils.cpp | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/lib/archiveutils.cpp b/lib/archiveutils.cpp
index 62777b4b6..d9926d598 100644
--- a/lib/archiveutils.cpp
+++ b/lib/archiveutils.cpp
@@ -22,6 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 #include "archiveutils.h"
 
 // Qt
+#include <QImageReader>
 #include <QMimeDatabase>
 
 // KF
@@ -58,9 +59,11 @@ QString protocolForMimeType(const QString &mimeType)
         return it.value();
     }
 
-    if (mimeType == QLatin1String("image/svg+xml-compressed")) {
-        // We don't want .svgz to be considered as archives because QtSvg knows
-        // how to decode gzip-ed svg files
+    // If we find an image plugin that supports this mime type, use it to open instead
+    // of falling back to a protocol. This ensures we read .ora and .svgz correctly
+    // before opening them as zips.
+    const auto supportedMimeTypes = QImageReader::supportedMimeTypes();
+    if (supportedMimeTypes.contains(mimeType)) {
         cache.insert(mimeType, QString());
         return {};
     }
-- 
GitLab

