]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Use QDesktopServices to open urls not supported by dolphin
authorMéven Car <meven.car@enioka.com>
Fri, 17 Jan 2020 17:10:40 +0000 (18:10 +0100)
committerMéven Car <meven.car@enioka.com>
Mon, 20 Jan 2020 15:50:14 +0000 (16:50 +0100)
Summary:

This improves portability.
QDesktopServices uses standard mimetype base resolution to find the app to use.

BUG: 372642
FIXED-IN: 20.04

Test Plan:
 * Open http://google.com, opened default web browser
 * Open mms:// (on my test system opened vlc)

Reviewers: #dolphin, elvisangelaccio, ngraham

Reviewed By: #dolphin, elvisangelaccio, ngraham

Subscribers: nicolasfella, kfm-devel

Tags: #dolphin

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

src/dolphinviewcontainer.cpp

index 9ed7654fafaf9388e9a4e4cd368aa15044dbe0da..bd3c8ed20f1d18f05ab15a61e8f86b2038f700b8 100644 (file)
@@ -50,6 +50,7 @@
 #include <QTimer>
 #include <QUrl>
 #include <QVBoxLayout>
+#include <QDesktopServices>
 
 DolphinViewContainer::DolphinViewContainer(const QUrl& url, QWidget* parent) :
     QWidget(parent),
@@ -691,30 +692,18 @@ void DolphinViewContainer::slotUrlNavigatorLocationChanged(const QUrl& url)
             QTimer::singleShot(0, this, &DolphinViewContainer::requestFocus);
         }
     } else if (KProtocolManager::isSourceProtocol(url)) {
-        QString app = QStringLiteral("konqueror");
         if (url.scheme().startsWith(QLatin1String("http"))) {
             showMessage(i18nc("@info:status", // krazy:exclude=qmethods
                               "Dolphin does not support web pages, the web browser has been launched"),
                         Information);
-
-            const KConfigGroup config(KSharedConfig::openConfig(QStringLiteral("kdeglobals")), "General");
-            const QString browser = config.readEntry("BrowserApplication");
-            if (!browser.isEmpty()) {
-                app = browser;
-                if (app.startsWith('!')) {
-                    // a literal command has been configured, remove the '!' prefix
-                    app.remove(0, 1);
-                }
-            }
         } else {
             showMessage(i18nc("@info:status",
-                              "Protocol not supported by Dolphin, Konqueror has been launched"),
+                              "Protocol not supported by Dolphin, default application has been launched"),
                         Information);
         }
 
-        const QString secureUrl = KShell::quoteArg(url.toDisplayString(QUrl::PreferLocalFile));
-        const QString command = app + ' ' + secureUrl;
-        KRun::runCommand(command, app, app, this);
+        QDesktopServices::openUrl(url);
+        redirect(QUrl(), m_urlNavigator->locationUrl(1));
     } else {
         showMessage(i18nc("@info:status", "Invalid protocol"), Error);
     }