1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
| | To make Qt respect the user's settings for the preferred browser, use xdg-open
even if it is not installed in the profile. The patch makes Qt always use
xdg-open, and makes the path used easy to substitute when building.
========================================================================
--- qtbase-everywhere-src-5.12.6.orig/src/platformsupport/services/genericunix/qgenericunixservices.cpp 2020-01-01 20:47:16.775671802 +0100
+++ qtbase-everywhere-src-5.12.6/src/platformsupport/services/genericunix/qgenericunixservices.cpp 2020-01-01 20:56:22.167662035 +0100
@@ -117,47 +117,6 @@
return QByteArrayLiteral("UNKNOWN");
}
-static inline bool checkExecutable(const QString &candidate, QString *result)
-{
- *result = QStandardPaths::findExecutable(candidate);
- return !result->isEmpty();
-}
-
-static inline bool detectWebBrowser(const QByteArray &desktop,
- bool checkBrowserVariable,
- QString *browser)
-{
- const char *browsers[] = {"google-chrome", "firefox", "mozilla", "opera"};
-
- browser->clear();
- if (checkExecutable(QStringLiteral("xdg-open"), browser))
- return true;
-
- if (checkBrowserVariable) {
- QByteArray browserVariable = qgetenv("DEFAULT_BROWSER");
- if (browserVariable.isEmpty())
- browserVariable = qgetenv("BROWSER");
- if (!browserVariable.isEmpty() && checkExecutable(QString::fromLocal8Bit(browserVariable), browser))
- return true;
- }
-
- if (desktop == QByteArray("KDE")) {
- // Konqueror launcher
- if (checkExecutable(QStringLiteral("kfmclient"), browser)) {
- browser->append(QLatin1String(" exec"));
- return true;
- }
- } else if (desktop == QByteArray("GNOME")) {
- if (checkExecutable(QStringLiteral("gnome-open"), browser))
- return true;
- }
-
- for (size_t i = 0; i < sizeof(browsers)/sizeof(char *); ++i)
- if (checkExecutable(QLatin1String(browsers[i]), browser))
- return true;
- return false;
-}
-
static inline bool launch(const QString &launcher, const QUrl &url)
{
const QString command = launcher + QLatin1Char(' ') + QLatin1String(url.toEncoded());
@@ -297,6 +256,8 @@
return result;
}
+static QString xdg_open = QStringLiteral("@@GUIX:XDG-OPEN@@");
+
bool QGenericUnixServices::openUrl(const QUrl &url)
{
if (url.scheme() == QLatin1String("mailto")) {
@@ -320,11 +281,7 @@
}
#endif
- if (m_webBrowser.isEmpty() && !detectWebBrowser(desktopEnvironment(), true, &m_webBrowser)) {
- qWarning("Unable to detect a web browser to launch '%s'", qPrintable(url.toString()));
- return false;
- }
- return launch(m_webBrowser, url);
+ return launch(xdg_open, url);
}
bool QGenericUnixServices::openDocument(const QUrl &url)
@@ -337,11 +294,7 @@
}
#endif
- if (m_documentLauncher.isEmpty() && !detectWebBrowser(desktopEnvironment(), false, &m_documentLauncher)) {
- qWarning("Unable to detect a launcher for '%s'", qPrintable(url.toString()));
- return false;
- }
- return launch(m_documentLauncher, url);
+ return launch(xdg_open, url);
}
#else
diff -ur qtbase-everywhere-src-5.12.6.orig/src/platformsupport/services/genericunix/qgenericunixservices_p.h qtbase-everywhere-src-5.12.6/src/platformsupport/services/genericunix/qgenericunixservices_p.h
--- qtbase-everywhere-src-5.12.6.orig/src/platformsupport/services/genericunix/qgenericunixservices_p.h 2020-01-01 20:47:16.775671802 +0100
+++ qtbase-everywhere-src-5.12.6/src/platformsupport/services/genericunix/qgenericunixservices_p.h 2020-01-01 20:54:12.135664364 +0100
@@ -65,10 +65,6 @@
bool openUrl(const QUrl &url) override;
bool openDocument(const QUrl &url) override;
-
-private:
- QString m_webBrowser;
- QString m_documentLauncher;
};
QT_END_NAMESPACE
|