diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index bc1f83a9c8..9bf2a33e2a 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -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 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)) { diff --git a/src/plugins/platformthemes/flatpak/flatpak.json b/src/plugins/platformthemes/flatpak/flatpak.json deleted file mode 100644 index 71f834fd08..0000000000 --- a/src/plugins/platformthemes/flatpak/flatpak.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "Keys": [ "flatpak" ] -} diff --git a/src/plugins/platformthemes/flatpak/flatpak.pro b/src/plugins/platformthemes/flatpak/flatpak.pro deleted file mode 100644 index 1e5dbb7a6c..0000000000 --- a/src/plugins/platformthemes/flatpak/flatpak.pro +++ /dev/null @@ -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 diff --git a/src/plugins/platformthemes/platformthemes.pro b/src/plugins/platformthemes/platformthemes.pro index 17b1d91c6a..06ffc4cc9f 100644 --- a/src/plugins/platformthemes/platformthemes.pro +++ b/src/plugins/platformthemes/platformthemes.pro @@ -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 diff --git a/src/plugins/platformthemes/flatpak/main.cpp b/src/plugins/platformthemes/xdgdesktopportal/main.cpp similarity index 80% rename from src/plugins/platformthemes/flatpak/main.cpp rename to src/plugins/platformthemes/xdgdesktopportal/main.cpp index 7888eed8b2..64a03d479f 100644 --- a/src/plugins/platformthemes/flatpak/main.cpp +++ b/src/plugins/platformthemes/xdgdesktopportal/main.cpp @@ -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 -#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; } diff --git a/src/plugins/platformthemes/flatpak/qflatpakfiledialog.cpp b/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp similarity index 82% rename from src/plugins/platformthemes/flatpak/qflatpakfiledialog.cpp rename to src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp index 39b93bc4b8..cda267d24b 100644 --- a/src/plugins/platformthemes/flatpak/qflatpakfiledialog.cpp +++ b/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp @@ -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 @@ -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 QFlatpakFileDialog::selectedFiles() const +QList 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 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"))) diff --git a/src/plugins/platformthemes/flatpak/qflatpakfiledialog_p.h b/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h similarity index 81% rename from src/plugins/platformthemes/flatpak/qflatpakfiledialog_p.h rename to src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h index bd1dae209d..c1f1a2c005 100644 --- a/src/plugins/platformthemes/flatpak/qflatpakfiledialog_p.h +++ b/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h @@ -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 #include 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 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 d_ptr; + QScopedPointer 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 diff --git a/src/plugins/platformthemes/flatpak/qflatpaktheme.cpp b/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp similarity index 65% rename from src/plugins/platformthemes/flatpak/qflatpaktheme.cpp rename to src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp index 142d91a00b..f07ca3f098 100644 --- a/src/plugins/platformthemes/flatpak/qflatpaktheme.cpp +++ b/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp @@ -37,8 +37,8 @@ ** ****************************************************************************/ -#include "qflatpaktheme.h" -#include "qflatpakfiledialog_p.h" +#include "qxdgdesktopportaltheme.h" +#include "qxdgdesktopportalfiledialog_p.h" #include #include @@ -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(d->baseTheme->createPlatformDialogHelper(type))); + return new QXdgDesktopPortalFileDialog(static_cast(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 QFlatpakTheme::keyBindings(QKeySequence::StandardKey key) const +QList 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); } diff --git a/src/plugins/platformthemes/flatpak/qflatpaktheme.h b/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.h similarity index 89% rename from src/plugins/platformthemes/flatpak/qflatpaktheme.h rename to src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.h index 87f79a2395..b72e676419 100644 --- a/src/plugins/platformthemes/flatpak/qflatpaktheme.h +++ b/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.h @@ -37,20 +37,20 @@ ** ****************************************************************************/ -#ifndef QFLATPAKTHEME_H -#define QFLATPAKTHEME_H +#ifndef QXDGDESKTOPPORTALTHEME_H +#define QXDGDESKTOPPORTALTHEME_H #include 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 d_ptr; - Q_DISABLE_COPY(QFlatpakTheme) + QScopedPointer d_ptr; + Q_DISABLE_COPY(QXdgDesktopPortalTheme) }; QT_END_NAMESPACE -#endif // QFLATPAKTHEME_H +#endif // QXDGDESKTOPPORTALTHEME_H diff --git a/src/plugins/platformthemes/xdgdesktopportal/xdgdesktopportal.json b/src/plugins/platformthemes/xdgdesktopportal/xdgdesktopportal.json new file mode 100644 index 0000000000..c69062d9a1 --- /dev/null +++ b/src/plugins/platformthemes/xdgdesktopportal/xdgdesktopportal.json @@ -0,0 +1,3 @@ +{ + "Keys": [ "xdgdesktopportal", "flatpak", "snap" ] +} diff --git a/src/plugins/platformthemes/xdgdesktopportal/xdgdesktopportal.pro b/src/plugins/platformthemes/xdgdesktopportal/xdgdesktopportal.pro new file mode 100644 index 0000000000..0a71484cf9 --- /dev/null +++ b/src/plugins/platformthemes/xdgdesktopportal/xdgdesktopportal.pro @@ -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