From 101cb8e5d97f2f26ff0b3efd7b6e8b0e336e62be Mon Sep 17 00:00:00 2001 From: Jan Grulich Date: Thu, 30 Aug 2018 10:45:49 +0200 Subject: Make flatpak portal support to be used also by Snap applications Snap now uses xdg-desktop-portal for portal support. Add check for apps running in Snap and make them use portals by default. We also should be using different name for the platform theme used by sandboxed apps. Change-Id: Ibaa35b7549b3d94775d7edb937f729a300d071b6 Reviewed-by: Thiago Macieira --- .../services/genericunix/qgenericunixservices.cpp | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/platformsupport/services/genericunix') diff --git a/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/src/platformsupport/services/genericunix/qgenericunixservices.cpp index 5b15cccaf1..67884cef92 100644 --- a/src/platformsupport/services/genericunix/qgenericunixservices.cpp +++ b/src/platformsupport/services/genericunix/qgenericunixservices.cpp @@ -50,7 +50,7 @@ #include #if QT_CONFIG(dbus) -// These QtCore includes are needed for flatpak support +// These QtCore includes are needed for xdg-desktop-portal support #include #include @@ -172,12 +172,12 @@ static inline bool launch(const QString &launcher, const QUrl &url) } #if QT_CONFIG(dbus) -static inline bool checkRunningUnderFlatpak() +static inline bool checkNeedPortalSupport() { - return !QStandardPaths::locate(QStandardPaths::RuntimeLocation, QLatin1String("flatpak-info")).isEmpty(); + return !QStandardPaths::locate(QStandardPaths::RuntimeLocation, QLatin1String("flatpak-info")).isEmpty() || qEnvironmentVariableIsSet("SNAP"); } -static inline bool flatpakOpenFile(const QUrl &url) +static inline bool xdgDesktopPortalOpenFile(const QUrl &url) { // DBus signature: // OpenFile (IN s parent_window, @@ -212,7 +212,7 @@ static inline bool flatpakOpenFile(const QUrl &url) return false; } -static inline bool flatpakOpenUrl(const QUrl &url) +static inline bool xdgDesktopPortalOpenUrl(const QUrl &url) { // DBus signature: // OpenURI (IN s parent_window, @@ -236,7 +236,7 @@ static inline bool flatpakOpenUrl(const QUrl &url) return !reply.isError(); } -static inline bool flatpakSendEmail(const QUrl &url) +static inline bool xdgDesktopPortalSendEmail(const QUrl &url) { // DBus signature: // ComposeEmail (IN s parent_window, @@ -294,15 +294,15 @@ bool QGenericUnixServices::openUrl(const QUrl &url) { if (url.scheme() == QLatin1String("mailto")) { #if QT_CONFIG(dbus) - if (checkRunningUnderFlatpak()) - return flatpakSendEmail(url); + if (checkNeedPortalSupport()) + return xdgDesktopPortalSendEmail(url); #endif return openDocument(url); } #if QT_CONFIG(dbus) - if (checkRunningUnderFlatpak()) - return flatpakOpenUrl(url); + if (checkNeedPortalSupport()) + return xdgDesktopPortalOpenUrl(url); #endif if (m_webBrowser.isEmpty() && !detectWebBrowser(desktopEnvironment(), true, &m_webBrowser)) { @@ -315,8 +315,8 @@ bool QGenericUnixServices::openUrl(const QUrl &url) bool QGenericUnixServices::openDocument(const QUrl &url) { #if QT_CONFIG(dbus) - if (checkRunningUnderFlatpak()) - return flatpakOpenFile(url); + if (checkNeedPortalSupport()) + return xdgDesktopPortalOpenFile(url); #endif if (m_documentLauncher.isEmpty() && !detectWebBrowser(desktopEnvironment(), false, &m_documentLauncher)) { -- cgit v1.2.3