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 <thiago.macieira@intel.com>
This commit is contained in:
parent
7c0884f2a2
commit
101cb8e5d9
@ -256,10 +256,10 @@ static inline void clearFontUnlocked()
|
||||
QGuiApplicationPrivate::app_font = 0;
|
||||
}
|
||||
|
||||
static bool checkRunningUnderFlatpak()
|
||||
static bool checkNeedPortalSupport()
|
||||
{
|
||||
#if QT_CONFIG(dbus)
|
||||
return !QStandardPaths::locate(QStandardPaths::RuntimeLocation, QLatin1String("flatpak-info")).isEmpty();
|
||||
return !QStandardPaths::locate(QStandardPaths::RuntimeLocation, QLatin1String("flatpak-info")).isEmpty() || qEnvironmentVariableIsSet("SNAP");
|
||||
#else
|
||||
return false;
|
||||
#endif // QT_CONFIG(dbus)
|
||||
@ -1225,9 +1225,9 @@ static void init_platform(const QString &pluginNamesWithArguments, const QString
|
||||
if (!platformThemeName.isEmpty())
|
||||
themeNames.append(platformThemeName);
|
||||
|
||||
// 2) Special case - check whether we are in sandbox to use flatpak platform theme for portals support
|
||||
if (checkRunningUnderFlatpak()) {
|
||||
themeNames.append(QStringLiteral("flatpak"));
|
||||
// 2) Special case - check whether it's a flatpak or snap app to use xdg-desktop-portal platform theme for portals support
|
||||
if (checkNeedPortalSupport()) {
|
||||
themeNames.append(QStringLiteral("xdgdesktopportal"));
|
||||
}
|
||||
|
||||
// 3) Ask the platform integration for a list of theme names
|
||||
|
@ -50,7 +50,7 @@
|
||||
#include <QtCore/QUrl>
|
||||
|
||||
#if QT_CONFIG(dbus)
|
||||
// These QtCore includes are needed for flatpak support
|
||||
// These QtCore includes are needed for xdg-desktop-portal support
|
||||
#include <QtCore/private/qcore_unix_p.h>
|
||||
|
||||
#include <QtCore/QFileInfo>
|
||||
@ -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)) {
|
||||
|
@ -1,3 +0,0 @@
|
||||
{
|
||||
"Keys": [ "flatpak" ]
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
TARGET = qflatpak
|
||||
|
||||
PLUGIN_TYPE = platformthemes
|
||||
PLUGIN_EXTENDS = -
|
||||
PLUGIN_CLASS_NAME = QFlatpakThemePlugin
|
||||
load(qt_plugin)
|
||||
|
||||
QT += core-private dbus gui-private theme_support-private
|
||||
|
||||
HEADERS += \
|
||||
qflatpaktheme.h \
|
||||
qflatpakfiledialog_p.h
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
qflatpaktheme.cpp \
|
||||
qflatpakfiledialog.cpp
|
@ -1,6 +1,6 @@
|
||||
TEMPLATE = subdirs
|
||||
QT_FOR_CONFIG += widgets-private
|
||||
|
||||
qtConfig(dbus):qtConfig(regularexpression): SUBDIRS += flatpak
|
||||
qtConfig(dbus):qtConfig(regularexpression): SUBDIRS += xdgdesktopportal
|
||||
|
||||
qtHaveModule(widgets):qtConfig(gtk3): SUBDIRS += gtk3
|
||||
|
@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2017 Red Hat, Inc
|
||||
** Copyright (C) 2017-2018 Red Hat, Inc
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the plugins of the Qt Toolkit.
|
||||
@ -38,24 +38,26 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <qpa/qplatformthemeplugin.h>
|
||||
#include "qflatpaktheme.h"
|
||||
#include "qxdgdesktopportaltheme.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QFlatpakThemePlugin : public QPlatformThemePlugin
|
||||
class QXdgDesktopPortalThemePlugin : public QPlatformThemePlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID QPlatformThemeFactoryInterface_iid FILE "flatpak.json")
|
||||
Q_PLUGIN_METADATA(IID QPlatformThemeFactoryInterface_iid FILE "xdgdesktopportal.json")
|
||||
|
||||
public:
|
||||
QPlatformTheme *create(const QString &key, const QStringList ¶ms) override;
|
||||
};
|
||||
|
||||
QPlatformTheme *QFlatpakThemePlugin::create(const QString &key, const QStringList ¶ms)
|
||||
QPlatformTheme *QXdgDesktopPortalThemePlugin::create(const QString &key, const QStringList ¶ms)
|
||||
{
|
||||
Q_UNUSED(params);
|
||||
if (!key.compare(QLatin1String("flatpak"), Qt::CaseInsensitive))
|
||||
return new QFlatpakTheme;
|
||||
if (!key.compare(QLatin1String("xdgdesktopportal"), Qt::CaseInsensitive) ||
|
||||
!key.compare(QLatin1String("flatpak"), Qt::CaseInsensitive) ||
|
||||
!key.compare(QLatin1String("snap"), Qt::CaseInsensitive))
|
||||
return new QXdgDesktopPortalTheme;
|
||||
|
||||
return nullptr;
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2017 Red Hat, Inc
|
||||
** Copyright (C) 2017-2018 Red Hat, Inc
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the plugins of the Qt Toolkit.
|
||||
@ -37,7 +37,7 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qflatpakfiledialog_p.h"
|
||||
#include "qxdgdesktopportalfiledialog_p.h"
|
||||
|
||||
#include <QtCore/qeventloop.h>
|
||||
|
||||
@ -56,7 +56,7 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QDBusArgument &operator <<(QDBusArgument &arg, const QFlatpakFileDialog::FilterCondition &filterCondition)
|
||||
QDBusArgument &operator <<(QDBusArgument &arg, const QXdgDesktopPortalFileDialog::FilterCondition &filterCondition)
|
||||
{
|
||||
arg.beginStructure();
|
||||
arg << filterCondition.type << filterCondition.pattern;
|
||||
@ -64,20 +64,20 @@ QDBusArgument &operator <<(QDBusArgument &arg, const QFlatpakFileDialog::FilterC
|
||||
return arg;
|
||||
}
|
||||
|
||||
const QDBusArgument &operator >>(const QDBusArgument &arg, QFlatpakFileDialog::FilterCondition &filterCondition)
|
||||
const QDBusArgument &operator >>(const QDBusArgument &arg, QXdgDesktopPortalFileDialog::FilterCondition &filterCondition)
|
||||
{
|
||||
uint type;
|
||||
QString filterPattern;
|
||||
arg.beginStructure();
|
||||
arg >> type >> filterPattern;
|
||||
filterCondition.type = (QFlatpakFileDialog::ConditionType)type;
|
||||
filterCondition.type = (QXdgDesktopPortalFileDialog::ConditionType)type;
|
||||
filterCondition.pattern = filterPattern;
|
||||
arg.endStructure();
|
||||
|
||||
return arg;
|
||||
}
|
||||
|
||||
QDBusArgument &operator <<(QDBusArgument &arg, const QFlatpakFileDialog::Filter filter)
|
||||
QDBusArgument &operator <<(QDBusArgument &arg, const QXdgDesktopPortalFileDialog::Filter filter)
|
||||
{
|
||||
arg.beginStructure();
|
||||
arg << filter.name << filter.filterConditions;
|
||||
@ -85,10 +85,10 @@ QDBusArgument &operator <<(QDBusArgument &arg, const QFlatpakFileDialog::Filter
|
||||
return arg;
|
||||
}
|
||||
|
||||
const QDBusArgument &operator >>(const QDBusArgument &arg, QFlatpakFileDialog::Filter &filter)
|
||||
const QDBusArgument &operator >>(const QDBusArgument &arg, QXdgDesktopPortalFileDialog::Filter &filter)
|
||||
{
|
||||
QString name;
|
||||
QFlatpakFileDialog::FilterConditionList filterConditions;
|
||||
QXdgDesktopPortalFileDialog::FilterConditionList filterConditions;
|
||||
arg.beginStructure();
|
||||
arg >> name >> filterConditions;
|
||||
filter.name = name;
|
||||
@ -98,10 +98,10 @@ const QDBusArgument &operator >>(const QDBusArgument &arg, QFlatpakFileDialog::F
|
||||
return arg;
|
||||
}
|
||||
|
||||
class QFlatpakFileDialogPrivate
|
||||
class QXdgDesktopPortalFileDialogPrivate
|
||||
{
|
||||
public:
|
||||
QFlatpakFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog)
|
||||
QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog)
|
||||
: nativeFileDialog(nativeFileDialog)
|
||||
{ }
|
||||
|
||||
@ -118,11 +118,11 @@ public:
|
||||
QPlatformFileDialogHelper *nativeFileDialog = nullptr;
|
||||
};
|
||||
|
||||
QFlatpakFileDialog::QFlatpakFileDialog(QPlatformFileDialogHelper *nativeFileDialog)
|
||||
QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog)
|
||||
: QPlatformFileDialogHelper()
|
||||
, d_ptr(new QFlatpakFileDialogPrivate(nativeFileDialog))
|
||||
, d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog))
|
||||
{
|
||||
Q_D(QFlatpakFileDialog);
|
||||
Q_D(QXdgDesktopPortalFileDialog);
|
||||
|
||||
if (d->nativeFileDialog) {
|
||||
connect(d->nativeFileDialog, SIGNAL(accept()), this, SIGNAL(accept()));
|
||||
@ -130,13 +130,13 @@ QFlatpakFileDialog::QFlatpakFileDialog(QPlatformFileDialogHelper *nativeFileDial
|
||||
}
|
||||
}
|
||||
|
||||
QFlatpakFileDialog::~QFlatpakFileDialog()
|
||||
QXdgDesktopPortalFileDialog::~QXdgDesktopPortalFileDialog()
|
||||
{
|
||||
}
|
||||
|
||||
void QFlatpakFileDialog::initializeDialog()
|
||||
void QXdgDesktopPortalFileDialog::initializeDialog()
|
||||
{
|
||||
Q_D(QFlatpakFileDialog);
|
||||
Q_D(QXdgDesktopPortalFileDialog);
|
||||
|
||||
if (d->nativeFileDialog)
|
||||
d->nativeFileDialog->setOptions(options());
|
||||
@ -162,9 +162,9 @@ void QFlatpakFileDialog::initializeDialog()
|
||||
setDirectory(options()->initialDirectory());
|
||||
}
|
||||
|
||||
void QFlatpakFileDialog::openPortal()
|
||||
void QXdgDesktopPortalFileDialog::openPortal()
|
||||
{
|
||||
Q_D(const QFlatpakFileDialog);
|
||||
Q_D(const QXdgDesktopPortalFileDialog);
|
||||
|
||||
QDBusMessage message = QDBusMessage::createMethodCall(QLatin1String("org.freedesktop.portal.Desktop"),
|
||||
QLatin1String("/org/freedesktop/portal/desktop"),
|
||||
@ -270,14 +270,14 @@ void QFlatpakFileDialog::openPortal()
|
||||
});
|
||||
}
|
||||
|
||||
bool QFlatpakFileDialog::defaultNameFilterDisables() const
|
||||
bool QXdgDesktopPortalFileDialog::defaultNameFilterDisables() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void QFlatpakFileDialog::setDirectory(const QUrl &directory)
|
||||
void QXdgDesktopPortalFileDialog::setDirectory(const QUrl &directory)
|
||||
{
|
||||
Q_D(QFlatpakFileDialog);
|
||||
Q_D(QXdgDesktopPortalFileDialog);
|
||||
|
||||
if (d->nativeFileDialog) {
|
||||
d->nativeFileDialog->setOptions(options());
|
||||
@ -287,9 +287,9 @@ void QFlatpakFileDialog::setDirectory(const QUrl &directory)
|
||||
d->directory = directory.path();
|
||||
}
|
||||
|
||||
QUrl QFlatpakFileDialog::directory() const
|
||||
QUrl QXdgDesktopPortalFileDialog::directory() const
|
||||
{
|
||||
Q_D(const QFlatpakFileDialog);
|
||||
Q_D(const QXdgDesktopPortalFileDialog);
|
||||
|
||||
if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
|
||||
return d->nativeFileDialog->directory();
|
||||
@ -297,9 +297,9 @@ QUrl QFlatpakFileDialog::directory() const
|
||||
return d->directory;
|
||||
}
|
||||
|
||||
void QFlatpakFileDialog::selectFile(const QUrl &filename)
|
||||
void QXdgDesktopPortalFileDialog::selectFile(const QUrl &filename)
|
||||
{
|
||||
Q_D(QFlatpakFileDialog);
|
||||
Q_D(QXdgDesktopPortalFileDialog);
|
||||
|
||||
if (d->nativeFileDialog) {
|
||||
d->nativeFileDialog->setOptions(options());
|
||||
@ -309,9 +309,9 @@ void QFlatpakFileDialog::selectFile(const QUrl &filename)
|
||||
d->selectedFiles << filename.path();
|
||||
}
|
||||
|
||||
QList<QUrl> QFlatpakFileDialog::selectedFiles() const
|
||||
QList<QUrl> QXdgDesktopPortalFileDialog::selectedFiles() const
|
||||
{
|
||||
Q_D(const QFlatpakFileDialog);
|
||||
Q_D(const QXdgDesktopPortalFileDialog);
|
||||
|
||||
if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
|
||||
return d->nativeFileDialog->selectedFiles();
|
||||
@ -323,9 +323,9 @@ QList<QUrl> QFlatpakFileDialog::selectedFiles() const
|
||||
return files;
|
||||
}
|
||||
|
||||
void QFlatpakFileDialog::setFilter()
|
||||
void QXdgDesktopPortalFileDialog::setFilter()
|
||||
{
|
||||
Q_D(QFlatpakFileDialog);
|
||||
Q_D(QXdgDesktopPortalFileDialog);
|
||||
|
||||
if (d->nativeFileDialog) {
|
||||
d->nativeFileDialog->setOptions(options());
|
||||
@ -333,9 +333,9 @@ void QFlatpakFileDialog::setFilter()
|
||||
}
|
||||
}
|
||||
|
||||
void QFlatpakFileDialog::selectNameFilter(const QString &filter)
|
||||
void QXdgDesktopPortalFileDialog::selectNameFilter(const QString &filter)
|
||||
{
|
||||
Q_D(QFlatpakFileDialog);
|
||||
Q_D(QXdgDesktopPortalFileDialog);
|
||||
|
||||
if (d->nativeFileDialog) {
|
||||
d->nativeFileDialog->setOptions(options());
|
||||
@ -343,15 +343,15 @@ void QFlatpakFileDialog::selectNameFilter(const QString &filter)
|
||||
}
|
||||
}
|
||||
|
||||
QString QFlatpakFileDialog::selectedNameFilter() const
|
||||
QString QXdgDesktopPortalFileDialog::selectedNameFilter() const
|
||||
{
|
||||
// TODO
|
||||
return QString();
|
||||
}
|
||||
|
||||
void QFlatpakFileDialog::exec()
|
||||
void QXdgDesktopPortalFileDialog::exec()
|
||||
{
|
||||
Q_D(QFlatpakFileDialog);
|
||||
Q_D(QXdgDesktopPortalFileDialog);
|
||||
|
||||
if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly)) {
|
||||
d->nativeFileDialog->exec();
|
||||
@ -365,17 +365,17 @@ void QFlatpakFileDialog::exec()
|
||||
loop.exec();
|
||||
}
|
||||
|
||||
void QFlatpakFileDialog::hide()
|
||||
void QXdgDesktopPortalFileDialog::hide()
|
||||
{
|
||||
Q_D(QFlatpakFileDialog);
|
||||
Q_D(QXdgDesktopPortalFileDialog);
|
||||
|
||||
if (d->nativeFileDialog)
|
||||
d->nativeFileDialog->hide();
|
||||
}
|
||||
|
||||
bool QFlatpakFileDialog::show(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent)
|
||||
bool QXdgDesktopPortalFileDialog::show(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent)
|
||||
{
|
||||
Q_D(QFlatpakFileDialog);
|
||||
Q_D(QXdgDesktopPortalFileDialog);
|
||||
|
||||
initializeDialog();
|
||||
|
||||
@ -390,9 +390,9 @@ bool QFlatpakFileDialog::show(Qt::WindowFlags windowFlags, Qt::WindowModality wi
|
||||
return true;
|
||||
}
|
||||
|
||||
void QFlatpakFileDialog::gotResponse(uint response, const QVariantMap &results)
|
||||
void QXdgDesktopPortalFileDialog::gotResponse(uint response, const QVariantMap &results)
|
||||
{
|
||||
Q_D(QFlatpakFileDialog);
|
||||
Q_D(QXdgDesktopPortalFileDialog);
|
||||
|
||||
if (!response) {
|
||||
if (results.contains(QLatin1String("uris")))
|
@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2017 Red Hat, Inc
|
||||
** Copyright (C) 2017-2018 Red Hat, Inc
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the plugins of the Qt Toolkit.
|
||||
@ -36,20 +36,20 @@
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
#ifndef QFLATPAKFILEDIALOG_P_H
|
||||
#define QFLATPAKFILEDIALOG_P_H
|
||||
#ifndef QXDGDESKTOPPORTALFILEDIALOG_P_H
|
||||
#define QXDGDESKTOPPORTALFILEDIALOG_P_H
|
||||
|
||||
#include <qpa/qplatformdialoghelper.h>
|
||||
#include <QVector>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QFlatpakFileDialogPrivate;
|
||||
class QXdgDesktopPortalFileDialogPrivate;
|
||||
|
||||
class QFlatpakFileDialog : public QPlatformFileDialogHelper
|
||||
class QXdgDesktopPortalFileDialog : public QPlatformFileDialogHelper
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PRIVATE(QFlatpakFileDialog)
|
||||
Q_DECLARE_PRIVATE(QXdgDesktopPortalFileDialog)
|
||||
public:
|
||||
enum ConditionType : uint {
|
||||
GlobalPattern = 0,
|
||||
@ -69,8 +69,8 @@ public:
|
||||
};
|
||||
typedef QVector<Filter> FilterList;
|
||||
|
||||
QFlatpakFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr);
|
||||
~QFlatpakFileDialog();
|
||||
QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr);
|
||||
~QXdgDesktopPortalFileDialog();
|
||||
|
||||
bool defaultNameFilterDisables() const override;
|
||||
QUrl directory() const override;
|
||||
@ -92,15 +92,15 @@ private:
|
||||
void initializeDialog();
|
||||
void openPortal();
|
||||
|
||||
QScopedPointer<QFlatpakFileDialogPrivate> d_ptr;
|
||||
QScopedPointer<QXdgDesktopPortalFileDialogPrivate> d_ptr;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
Q_DECLARE_METATYPE(QFlatpakFileDialog::FilterCondition);
|
||||
Q_DECLARE_METATYPE(QFlatpakFileDialog::FilterConditionList);
|
||||
Q_DECLARE_METATYPE(QFlatpakFileDialog::Filter);
|
||||
Q_DECLARE_METATYPE(QFlatpakFileDialog::FilterList);
|
||||
Q_DECLARE_METATYPE(QXdgDesktopPortalFileDialog::FilterCondition);
|
||||
Q_DECLARE_METATYPE(QXdgDesktopPortalFileDialog::FilterConditionList);
|
||||
Q_DECLARE_METATYPE(QXdgDesktopPortalFileDialog::Filter);
|
||||
Q_DECLARE_METATYPE(QXdgDesktopPortalFileDialog::FilterList);
|
||||
|
||||
#endif // QFLATPAKFILEDIALOG_P_H
|
||||
#endif // QXDGDESKTOPPORTALFILEDIALOG_P_H
|
||||
|
@ -37,8 +37,8 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qflatpaktheme.h"
|
||||
#include "qflatpakfiledialog_p.h"
|
||||
#include "qxdgdesktopportaltheme.h"
|
||||
#include "qxdgdesktopportalfiledialog_p.h"
|
||||
|
||||
#include <private/qguiapplication_p.h>
|
||||
#include <qpa/qplatformtheme_p.h>
|
||||
@ -47,14 +47,14 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QFlatpakThemePrivate : public QPlatformThemePrivate
|
||||
class QXdgDesktopPortalThemePrivate : public QPlatformThemePrivate
|
||||
{
|
||||
public:
|
||||
QFlatpakThemePrivate()
|
||||
QXdgDesktopPortalThemePrivate()
|
||||
: QPlatformThemePrivate()
|
||||
{ }
|
||||
|
||||
~QFlatpakThemePrivate()
|
||||
~QXdgDesktopPortalThemePrivate()
|
||||
{
|
||||
delete baseTheme;
|
||||
}
|
||||
@ -62,10 +62,10 @@ public:
|
||||
QPlatformTheme *baseTheme;
|
||||
};
|
||||
|
||||
QFlatpakTheme::QFlatpakTheme()
|
||||
: d_ptr(new QFlatpakThemePrivate)
|
||||
QXdgDesktopPortalTheme::QXdgDesktopPortalTheme()
|
||||
: d_ptr(new QXdgDesktopPortalThemePrivate)
|
||||
{
|
||||
Q_D(QFlatpakTheme);
|
||||
Q_D(QXdgDesktopPortalTheme);
|
||||
|
||||
QStringList themeNames;
|
||||
themeNames += QGuiApplicationPrivate::platform_integration->themeNames();
|
||||
@ -92,33 +92,33 @@ QFlatpakTheme::QFlatpakTheme()
|
||||
d->baseTheme = new QPlatformTheme;
|
||||
}
|
||||
|
||||
QPlatformMenuItem* QFlatpakTheme::createPlatformMenuItem() const
|
||||
QPlatformMenuItem* QXdgDesktopPortalTheme::createPlatformMenuItem() const
|
||||
{
|
||||
Q_D(const QFlatpakTheme);
|
||||
Q_D(const QXdgDesktopPortalTheme);
|
||||
return d->baseTheme->createPlatformMenuItem();
|
||||
}
|
||||
|
||||
QPlatformMenu* QFlatpakTheme::createPlatformMenu() const
|
||||
QPlatformMenu* QXdgDesktopPortalTheme::createPlatformMenu() const
|
||||
{
|
||||
Q_D(const QFlatpakTheme);
|
||||
Q_D(const QXdgDesktopPortalTheme);
|
||||
return d->baseTheme->createPlatformMenu();
|
||||
}
|
||||
|
||||
QPlatformMenuBar* QFlatpakTheme::createPlatformMenuBar() const
|
||||
QPlatformMenuBar* QXdgDesktopPortalTheme::createPlatformMenuBar() const
|
||||
{
|
||||
Q_D(const QFlatpakTheme);
|
||||
Q_D(const QXdgDesktopPortalTheme);
|
||||
return d->baseTheme->createPlatformMenuBar();
|
||||
}
|
||||
|
||||
void QFlatpakTheme::showPlatformMenuBar()
|
||||
void QXdgDesktopPortalTheme::showPlatformMenuBar()
|
||||
{
|
||||
Q_D(const QFlatpakTheme);
|
||||
Q_D(const QXdgDesktopPortalTheme);
|
||||
return d->baseTheme->showPlatformMenuBar();
|
||||
}
|
||||
|
||||
bool QFlatpakTheme::usePlatformNativeDialog(DialogType type) const
|
||||
bool QXdgDesktopPortalTheme::usePlatformNativeDialog(DialogType type) const
|
||||
{
|
||||
Q_D(const QFlatpakTheme);
|
||||
Q_D(const QXdgDesktopPortalTheme);
|
||||
|
||||
if (type == FileDialog)
|
||||
return true;
|
||||
@ -126,74 +126,74 @@ bool QFlatpakTheme::usePlatformNativeDialog(DialogType type) const
|
||||
return d->baseTheme->usePlatformNativeDialog(type);
|
||||
}
|
||||
|
||||
QPlatformDialogHelper* QFlatpakTheme::createPlatformDialogHelper(DialogType type) const
|
||||
QPlatformDialogHelper* QXdgDesktopPortalTheme::createPlatformDialogHelper(DialogType type) const
|
||||
{
|
||||
Q_D(const QFlatpakTheme);
|
||||
Q_D(const QXdgDesktopPortalTheme);
|
||||
|
||||
if (type == FileDialog) {
|
||||
if (d->baseTheme->usePlatformNativeDialog(type))
|
||||
return new QFlatpakFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)));
|
||||
return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)));
|
||||
|
||||
return new QFlatpakFileDialog;
|
||||
return new QXdgDesktopPortalFileDialog;
|
||||
}
|
||||
|
||||
return d->baseTheme->createPlatformDialogHelper(type);
|
||||
}
|
||||
|
||||
#ifndef QT_NO_SYSTEMTRAYICON
|
||||
QPlatformSystemTrayIcon* QFlatpakTheme::createPlatformSystemTrayIcon() const
|
||||
QPlatformSystemTrayIcon* QXdgDesktopPortalTheme::createPlatformSystemTrayIcon() const
|
||||
{
|
||||
Q_D(const QFlatpakTheme);
|
||||
Q_D(const QXdgDesktopPortalTheme);
|
||||
return d->baseTheme->createPlatformSystemTrayIcon();
|
||||
}
|
||||
#endif
|
||||
|
||||
const QPalette *QFlatpakTheme::palette(Palette type) const
|
||||
const QPalette *QXdgDesktopPortalTheme::palette(Palette type) const
|
||||
{
|
||||
Q_D(const QFlatpakTheme);
|
||||
Q_D(const QXdgDesktopPortalTheme);
|
||||
return d->baseTheme->palette(type);
|
||||
}
|
||||
|
||||
const QFont* QFlatpakTheme::font(Font type) const
|
||||
const QFont* QXdgDesktopPortalTheme::font(Font type) const
|
||||
{
|
||||
Q_D(const QFlatpakTheme);
|
||||
Q_D(const QXdgDesktopPortalTheme);
|
||||
return d->baseTheme->font(type);
|
||||
}
|
||||
|
||||
QVariant QFlatpakTheme::themeHint(ThemeHint hint) const
|
||||
QVariant QXdgDesktopPortalTheme::themeHint(ThemeHint hint) const
|
||||
{
|
||||
Q_D(const QFlatpakTheme);
|
||||
Q_D(const QXdgDesktopPortalTheme);
|
||||
return d->baseTheme->themeHint(hint);
|
||||
}
|
||||
|
||||
QPixmap QFlatpakTheme::standardPixmap(StandardPixmap sp, const QSizeF &size) const
|
||||
QPixmap QXdgDesktopPortalTheme::standardPixmap(StandardPixmap sp, const QSizeF &size) const
|
||||
{
|
||||
Q_D(const QFlatpakTheme);
|
||||
Q_D(const QXdgDesktopPortalTheme);
|
||||
return d->baseTheme->standardPixmap(sp, size);
|
||||
}
|
||||
|
||||
QIcon QFlatpakTheme::fileIcon(const QFileInfo &fileInfo,
|
||||
QIcon QXdgDesktopPortalTheme::fileIcon(const QFileInfo &fileInfo,
|
||||
QPlatformTheme::IconOptions iconOptions) const
|
||||
{
|
||||
Q_D(const QFlatpakTheme);
|
||||
Q_D(const QXdgDesktopPortalTheme);
|
||||
return d->baseTheme->fileIcon(fileInfo, iconOptions);
|
||||
}
|
||||
|
||||
QIconEngine * QFlatpakTheme::createIconEngine(const QString &iconName) const
|
||||
QIconEngine * QXdgDesktopPortalTheme::createIconEngine(const QString &iconName) const
|
||||
{
|
||||
Q_D(const QFlatpakTheme);
|
||||
Q_D(const QXdgDesktopPortalTheme);
|
||||
return d->baseTheme->createIconEngine(iconName);
|
||||
}
|
||||
|
||||
QList<QKeySequence> QFlatpakTheme::keyBindings(QKeySequence::StandardKey key) const
|
||||
QList<QKeySequence> QXdgDesktopPortalTheme::keyBindings(QKeySequence::StandardKey key) const
|
||||
{
|
||||
Q_D(const QFlatpakTheme);
|
||||
Q_D(const QXdgDesktopPortalTheme);
|
||||
return d->baseTheme->keyBindings(key);
|
||||
}
|
||||
|
||||
QString QFlatpakTheme::standardButtonText(int button) const
|
||||
QString QXdgDesktopPortalTheme::standardButtonText(int button) const
|
||||
{
|
||||
Q_D(const QFlatpakTheme);
|
||||
Q_D(const QXdgDesktopPortalTheme);
|
||||
return d->baseTheme->standardButtonText(button);
|
||||
}
|
||||
|
@ -37,20 +37,20 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QFLATPAKTHEME_H
|
||||
#define QFLATPAKTHEME_H
|
||||
#ifndef QXDGDESKTOPPORTALTHEME_H
|
||||
#define QXDGDESKTOPPORTALTHEME_H
|
||||
|
||||
#include <qpa/qplatformtheme.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QFlatpakThemePrivate;
|
||||
class QXdgDesktopPortalThemePrivate;
|
||||
|
||||
class QFlatpakTheme : public QPlatformTheme
|
||||
class QXdgDesktopPortalTheme : public QPlatformTheme
|
||||
{
|
||||
Q_DECLARE_PRIVATE(QFlatpakTheme)
|
||||
Q_DECLARE_PRIVATE(QXdgDesktopPortalTheme)
|
||||
public:
|
||||
QFlatpakTheme();
|
||||
QXdgDesktopPortalTheme();
|
||||
|
||||
QPlatformMenuItem *createPlatformMenuItem() const override;
|
||||
QPlatformMenu *createPlatformMenu() const override;
|
||||
@ -81,10 +81,10 @@ public:
|
||||
QString standardButtonText(int button) const override;
|
||||
|
||||
private:
|
||||
QScopedPointer<QFlatpakThemePrivate> d_ptr;
|
||||
Q_DISABLE_COPY(QFlatpakTheme)
|
||||
QScopedPointer<QXdgDesktopPortalThemePrivate> d_ptr;
|
||||
Q_DISABLE_COPY(QXdgDesktopPortalTheme)
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QFLATPAKTHEME_H
|
||||
#endif // QXDGDESKTOPPORTALTHEME_H
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"Keys": [ "xdgdesktopportal", "flatpak", "snap" ]
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
TARGET = qxdgdesktopportal
|
||||
|
||||
PLUGIN_TYPE = platformthemes
|
||||
PLUGIN_EXTENDS = -
|
||||
PLUGIN_CLASS_NAME = QXdgDesktopPortalThemePlugin
|
||||
load(qt_plugin)
|
||||
|
||||
QT += core-private dbus gui-private theme_support-private
|
||||
|
||||
HEADERS += \
|
||||
qxdgdesktopportaltheme.h \
|
||||
qxdgdesktopportalfiledialog_p.h
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
qxdgdesktopportaltheme.cpp \
|
||||
qxdgdesktopportalfiledialog.cpp
|
Loading…
Reference in New Issue
Block a user