summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authorJan Grulich <jgrulich@redhat.com>2017-12-11 09:53:49 +0100
committerJan Grulich <jgrulich@redhat.com>2017-12-16 08:17:05 +0000
commit84731fbb2bafe4d92bec6cc60db5115279bc6e38 (patch)
treeb4418825b020cfe6bfca3c9bd2280951c75fc80a /src/gui/kernel
parent91aa782f0197034e0755f131e63fcec5bbf1e956 (diff)
Add support for FileChooser flatpak portal
Adds support for FileChooser Flatpak portal. To support them we just do specific DBus calls, which are then caught and forwarded by xdg-desktop- portal daemon/service. This is needed for Qt applications running in sandbox. [ChangeLog][Platform Specific Changes][Linux] Added support for flatpak portals. Flatpak is a software utility for software deployment and package management. It provides a sandbox environment in which users can run applications in isolation from the rest of the system. To communicate with the system flatpak uses portals, which are designed to be a bridge between sandboxed applications and desktop/system running on user's computer. Flatpak runs this service (called xdg-desktop-portal) automatically. It exports the portals via DBus and they are visible by default to all applications running under Flatpak. Change-Id: I4de1402434ba7cbcc805eab51c30f84f8ba0c5c5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qguiapplication.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 37fbfe679d..5004582c5f 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -53,6 +53,7 @@
#include <qpa/qplatformdrag.h>
#include <QtCore/QAbstractEventDispatcher>
+#include <QtCore/QStandardPaths>
#include <QtCore/QVariant>
#include <QtCore/private/qcoreapplication_p.h>
#include <QtCore/private/qabstracteventdispatcher_p.h>
@@ -244,6 +245,15 @@ static inline void clearFontUnlocked()
QGuiApplicationPrivate::app_font = 0;
}
+static bool checkRunningUnderFlatpak()
+{
+#if QT_CONFIG(dbus)
+ return !QStandardPaths::locate(QStandardPaths::RuntimeLocation, QLatin1String("flatpak-info")).isEmpty();
+#else
+ return false;
+#endif // QT_CONFIG(dbus)
+}
+
// Using aggregate initialization instead of ctor so we can have a POD global static
#define Q_WINDOW_GEOMETRY_SPECIFICATION_INITIALIZER { Qt::TopLeftCorner, -1, -1, -1, -1 }
@@ -1179,16 +1189,21 @@ static void init_platform(const QString &pluginArgument, const QString &platform
if (!platformThemeName.isEmpty())
themeNames.append(platformThemeName);
- // 2) Ask the platform integration for a list of theme names
+ // 2) Special case - check whether we are in sandbox to use flatpak platform theme for portals support
+ if (checkRunningUnderFlatpak()) {
+ themeNames.append(QStringLiteral("flatpak"));
+ }
+
+ // 3) Ask the platform integration for a list of theme names
themeNames += QGuiApplicationPrivate::platform_integration->themeNames();
- // 3) Look for a theme plugin.
+ // 4) Look for a theme plugin.
for (const QString &themeName : qAsConst(themeNames)) {
QGuiApplicationPrivate::platform_theme = QPlatformThemeFactory::create(themeName, platformPluginPath);
if (QGuiApplicationPrivate::platform_theme)
break;
}
- // 4) If no theme plugin was found ask the platform integration to
+ // 5) If no theme plugin was found ask the platform integration to
// create a theme
if (!QGuiApplicationPrivate::platform_theme) {
for (const QString &themeName : qAsConst(themeNames)) {
@@ -1199,7 +1214,7 @@ static void init_platform(const QString &pluginArgument, const QString &platform
// No error message; not having a theme plugin is allowed.
}
- // 5) Fall back on the built-in "null" platform theme.
+ // 6) Fall back on the built-in "null" platform theme.
if (!QGuiApplicationPrivate::platform_theme)
QGuiApplicationPrivate::platform_theme = new QPlatformTheme;