OSDN Git Service

replace qt_openDocument() and qt_launchWebBrowser() with their body
authorIvailo Monev <xakepa10@laimg.moc>
Fri, 19 Jun 2020 18:50:44 +0000 (18:50 +0000)
committerIvailo Monev <xakepa10@laimg.moc>
Fri, 19 Jun 2020 18:52:22 +0000 (18:52 +0000)
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
src/gui/util/qdesktopservices.cpp
src/gui/util/qdesktopservices_x11.cpp

index b705808..9551d6f 100644 (file)
 #include "qcoreapplication.h"
 #include "qurl.h"
 #include "qmutex.h"
+#include "qprocess.h"
 
 QT_BEGIN_NAMESPACE
 
-// in qdesktopservices_x11.cpp
-extern bool qt_openDocument(const QUrl &url);
-extern bool qt_launchWebBrowser(const QUrl &url);
+
+inline static bool qt_launch(const QUrl &url, const QString &client)
+{
+    QString command = client + QLatin1Char(' ') + url.toEncoded();
+    return QProcess::startDetached(command);
+}
 
 class QOpenUrlHandlerRegistry : public QObject
 {
@@ -178,10 +182,36 @@ bool QDesktopServices::openUrl(const QUrl &url)
         }
     }
 
-    if (url.scheme() == QLatin1String("file"))
-        return qt_openDocument(url);
+    if (!url.isValid())
+        return false;
+
+    if (url.scheme() == QLatin1String("file") || url.scheme() == QLatin1String("mailto")) {
+        if (qt_launch(url, QLatin1String("xdg-open")))
+            return true;
+
+        if (qt_launch(url, QLatin1String("firefox")))
+            return true;
+        if (qt_launch(url, QLatin1String("chromium")))
+            return true;
+        if (qt_launch(url, QLatin1String("opera")))
+            return true;
+        return false;
+    }
 
-    return qt_launchWebBrowser(url);
+    if (qt_launch(url, QLatin1String("xdg-open")))
+        return true;
+    if (qt_launch(url, QLatin1String(qgetenv("DEFAULT_BROWSER"))))
+        return true;
+    if (qt_launch(url, QLatin1String(qgetenv("BROWSER"))))
+        return true;
+
+    if (qt_launch(url, QLatin1String("firefox")))
+        return true;
+    if (qt_launch(url, QLatin1String("chromium")))
+        return true;
+    if (qt_launch(url, QLatin1String("opera")))
+        return true;
+    return false;
 }
 
 /*!
index 6cba6b1..1b7c516 100644 (file)
@@ -35,8 +35,6 @@
 
 #ifndef QT_NO_DESKTOPSERVICES
 
-#include "qprocess.h"
-#include "qurl.h"
 #include "qdir.h"
 #include "qfile.h"
 #include "qtextstream.h"
 
 QT_BEGIN_NAMESPACE
 
-inline static bool launch(const QUrl &url, const QString &client)
-{
-    QString command = client + QLatin1Char(' ') + url.toEncoded();
-    return (QProcess::startDetached(command));
-}
-
-bool qt_openDocument(const QUrl &url)
-{
-    if (!url.isValid())
-        return false;
-
-    if (launch(url, QLatin1String("xdg-open")))
-        return true;
-
-    if (launch(url, QLatin1String("firefox")))
-        return true;
-    if (launch(url, QLatin1String("chromium")))
-        return true;
-    if (launch(url, QLatin1String("opera")))
-        return true;
-
-    return false;
-}
-
-bool qt_launchWebBrowser(const QUrl &url)
-{
-    if (!url.isValid())
-        return false;
-    if (url.scheme() == QLatin1String("mailto"))
-        return qt_openDocument(url);
-
-    if (launch(url, QLatin1String("xdg-open")))
-        return true;
-    if (launch(url, QLatin1String(qgetenv("DEFAULT_BROWSER"))))
-        return true;
-    if (launch(url, QLatin1String(qgetenv("BROWSER"))))
-        return true;
-
-    if (launch(url, QLatin1String("firefox")))
-        return true;
-    if (launch(url, QLatin1String("chromium")))
-        return true;
-    if (launch(url, QLatin1String("opera")))
-        return true;
-    return false;
-}
-
-
-
 QString QDesktopServices::storageLocation(StandardLocation type)
 {
     if (type == QDesktopServices::HomeLocation)