From f581540a101ac3b3cc7dc4151df874cf7c28e764 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Fri, 19 Jun 2020 18:50:44 +0000 Subject: [PATCH] replace qt_openDocument() and qt_launchWebBrowser() with their body Signed-off-by: Ivailo Monev --- src/gui/util/qdesktopservices.cpp | 42 ++++++++++++++++++++++++----- src/gui/util/qdesktopservices_x11.cpp | 51 ----------------------------------- 2 files changed, 36 insertions(+), 57 deletions(-) diff --git a/src/gui/util/qdesktopservices.cpp b/src/gui/util/qdesktopservices.cpp index b705808f3..9551d6f44 100644 --- a/src/gui/util/qdesktopservices.cpp +++ b/src/gui/util/qdesktopservices.cpp @@ -41,12 +41,16 @@ #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; } /*! diff --git a/src/gui/util/qdesktopservices_x11.cpp b/src/gui/util/qdesktopservices_x11.cpp index 6cba6b1cd..1b7c516e6 100644 --- a/src/gui/util/qdesktopservices_x11.cpp +++ b/src/gui/util/qdesktopservices_x11.cpp @@ -35,8 +35,6 @@ #ifndef QT_NO_DESKTOPSERVICES -#include "qprocess.h" -#include "qurl.h" #include "qdir.h" #include "qfile.h" #include "qtextstream.h" @@ -46,55 +44,6 @@ 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) -- 2.11.0