[system/dolphin] src: When archive KIO claims unsupported, offer opening in archiver

Kai Uwe Broulik <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 235c73efa2170f2a67ca61975abb34da6ff97b95 by Kai Uwe Broulik.
Committed on 23/07/2026 at 12:21.
Pushed by broulik into branch 'master'.

When archive KIO claims unsupported, offer opening in archiver

There are cases where KArchive doesn't support a given archive
but Ark would open it just fine.

While not necessarily great UX, this at least gives the user
a quick way out to try a "proper" archiver.

M  +26   -0    src/dolphinviewcontainer.cpp
M  +2    -0    src/dolphinviewcontainer.h

https://invent.kde.org/system/dolphin/-/commit/235c73efa2170f2a67ca61975abb34da6ff97b95

diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp
index 968919b636..530021caa2 100644
--- a/src/dolphinviewcontainer.cpp
+++ b/src/dolphinviewcontainer.cpp
@@ -1055,6 +1055,32 @@ void DolphinViewContainer::slotErrorMessageFromView(const QString &message, cons
         }
         showMessage(message, KMessageWidget::Error, {m_createFolderAction});
         return;
+    } else if (kioErrorCode == KIO::ERR_WORKER_DEFINED) {
+        QUrl url = m_view->url();
+        const QStringList archiveTypes = KProtocolInfo::archiveMimetypes(url.scheme());
+        // When archive KIO claims unsupported, offer opening in archive viewer.
+        if (!archiveTypes.isEmpty()) {
+            url.setScheme(QStringLiteral("file"));
+
+            if (auto archiverService = KApplicationTrader::preferredService(archiveTypes.first())) {
+                if (!m_openInArchiveViewer) {
+                    m_openInArchiveViewer = new QAction(this);
+                    connect(m_openInArchiveViewer, &QAction::triggered, this, [this, url] {
+                        KIO::OpenUrlJob *job = new KIO::OpenUrlJob(url);
+                        // Auto*Warning*Handling, errors are put in a KMessageWidget by us in slotOpenUrlFinished.
+                        job->setUiDelegate(KIO::createDefaultJobUiDelegate(KJobUiDelegate::AutoWarningHandlingEnabled, this));
+                        job->setShowOpenOrExecuteDialog(true);
+                        connect(job, &KIO::OpenUrlJob::finished, this, &DolphinViewContainer::slotOpenUrlFinished);
+                        job->start();
+                    });
+                }
+                // Updating icon and name every time, preferred service might have changed.
+                m_openInArchiveViewer->setText(i18nc("@action:button", "Open with %1", archiverService->name()));
+                m_openInArchiveViewer->setIcon(QIcon::fromTheme(archiverService->icon()));
+                showMessage(message, KMessageWidget::Error, {m_openInArchiveViewer});
+                return;
+            }
+        }
     }
     Q_EMIT showErrorMessage(message);
 }
diff --git a/src/dolphinviewcontainer.h b/src/dolphinviewcontainer.h
index 9c6dbb611f..217292b70e 100644
--- a/src/dolphinviewcontainer.h
+++ b/src/dolphinviewcontainer.h
@@ -506,6 +506,8 @@ private:
     QAction *m_createFolderAction;
     /// An action to open the url as file instead of as directory. Lazily initialized.
     QAction *m_openAsFile = nullptr;
+    /// An action to open the url in the default archive viewer. Lazily initialized.
+    QAction *m_openInArchiveViewer = nullptr;
 
     KMessageWidget *m_messageWidget;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.