Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package QGnomePlatform for openSUSE:Factory checked in at 2021-05-21 21:49:47 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/QGnomePlatform (Old) and /work/SRC/openSUSE:Factory/.QGnomePlatform.new.2988 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "QGnomePlatform" Fri May 21 21:49:47 2021 rev:6 rq:893947 version:0.7.1 Changes: -------- --- /work/SRC/openSUSE:Factory/QGnomePlatform/QGnomePlatform.changes 2020-06-02 09:32:59.915282806 +0200 +++ /work/SRC/openSUSE:Factory/.QGnomePlatform.new.2988/QGnomePlatform.changes 2021-05-21 21:49:53.690263586 +0200 @@ -1,0 +2,16 @@ +Thu Apr 29 23:15:03 UTC 2021 - Ferdinand Thiessen <r...@fthiessen.de> + +- Update to version 0.7.1: + + Fixed wrong color palette with Qt 5.15 + + Fixed issue when font configuration was not parsed properly + + Use xdg-desktop-portal for opening files + + Prioritize Adwaita dark variant for all themes + containing "-dark" suffix + + Use FileChooser portal only when possible + + Take QT_STYLE_OVERRIDE into account when considering dark variant + + Fixed memory leaks +- Add fix-qt5-x11-config.patch, linking fails because of missing + x11 link time dependency of gtk3 +- Drop QGnomePlatform-qt-5.15.patch: Upstream fixed + +------------------------------------------------------------------- Old: ---- QGnomePlatform-0.6.1.tar.gz QGnomePlatform-qt-5.15.patch New: ---- QGnomePlatform-0.7.1.tar.gz fix-qt5-x11-config.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ QGnomePlatform.spec ++++++ --- /var/tmp/diff_new_pack.MyU2or/_old 2021-05-21 21:49:54.198261482 +0200 +++ /var/tmp/diff_new_pack.MyU2or/_new 2021-05-21 21:49:54.198261482 +0200 @@ -1,7 +1,7 @@ # # spec file for package QGnomePlatform # -# Copyright (c) 2020 SUSE LLC +# Copyright (c) 2021 SUSE LLC # Copyright ?? 2016 Yuriy Gorodilin <yur...@gmail.com> # Copyright ?? 2018???2019 Markus S. <kamika...@opensuse.org> # @@ -19,7 +19,7 @@ Name: QGnomePlatform -Version: 0.6.1 +Version: 0.7.1 Release: 0 Summary: A better Qt application inclusion in GNOME # Most code is LGPL-2.1-or-later but qgtk3dialoghelpers files forked from @@ -29,9 +29,8 @@ URL: https://github.com/FedoraQt/QGnomePlatform/ Source: %{url}/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz Source1: baselibs.conf -# PATCH-FIX-UPSTREAM QGnomePlatform-qt-5.15.patch dims...@opensuse.org -- Fix build with Qt 5.15 -Patch0: QGnomePlatform-qt-5.15.patch -BuildRequires: cmake +# PATCH-FIX-OPENSUSE fix-qt5-x11-config.patch -- x11 requirement is missing from gtk+-x11-3.0 +Patch0: fix-qt5-x11-config.patch BuildRequires: gcc-c++ BuildRequires: libQt5Core-private-headers-devel BuildRequires: libQt5Gui-private-headers-devel @@ -39,15 +38,13 @@ BuildRequires: libqt5-qtwayland-devel BuildRequires: libqt5-qtwayland-private-headers-devel BuildRequires: pkgconfig -BuildRequires: pkgconfig(Qt5Widgets) -BuildRequires: pkgconfig(Qt5X11Extras) -BuildRequires: pkgconfig(gio-2.0) +BuildRequires: pkgconfig(Qt5DBus) >= 5.12 +BuildRequires: pkgconfig(Qt5Widgets) >= 5.12 +BuildRequires: pkgconfig(Qt5X11Extras) >= 5.12 +BuildRequires: pkgconfig(adwaita-qt) BuildRequires: pkgconfig(gtk+-3.0) -BuildRequires: pkgconfig(libinput) -BuildRequires: pkgconfig(udev) -BuildRequires: pkgconfig(xkbcommon) -BuildRequires: pkgconfig(xrandr) -BuildRequires: pkgconfig(xrender) +BuildRequires: pkgconfig(gtk+-x11-3.0) +BuildRequires: pkgconfig(x11) Requires: adwaita-qt5 Supplements: (libQt5Gui5 and gnome-session) @@ -64,8 +61,8 @@ %autosetup -p1 %build -qmake-qt5 -make %{?_smp_mflags} +%qmake5 +%make_build %install %qmake5_install ++++++ QGnomePlatform-0.6.1.tar.gz -> QGnomePlatform-0.7.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/QGnomePlatform-0.6.1/.github/workflows/build.yml new/QGnomePlatform-0.7.1/.github/workflows/build.yml --- old/QGnomePlatform-0.6.1/.github/workflows/build.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/QGnomePlatform-0.7.1/.github/workflows/build.yml 2021-04-08 14:02:16.000000000 +0200 @@ -0,0 +1,55 @@ +name: Automatic build +on: + push: + branches: + - '**' + pull_request: + branches: + - '**' + release: + types: [ created ] +env: + BUILD_TYPE: Release + +jobs: + build: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + + - name: Install dependencies + run: | + sudo apt update + sudo apt install qt5-default libqt5gui5 libqt5x11extras5 cmake pkg-config qtbase5-dev libqt5x11extras5-dev qtbase5-private-dev libqt5waylandclient5-dev libx11-dev xcb libx11-xcb-dev libgtk-3-dev + git clone https://github.com/FedoraQt/adwaita-qt.git adwaita-qt + cd adwaita-qt + mkdir build + cd build + cmake .. -DCMAKE_INSTALL_PREFIX=/usr + make -j2 + sudo make install + + # Enable decorations once we can update to newer Ubuntu, the current one doesn't ship + # private headers for QtWayland + - name: Disable decorations + shell: bash + run: sed -i 's@SUBDIRS += common decoration theme@SUBDIRS += common theme@' qgnomeplatform.pro + + - name: Create Build Environment + run: mkdir ${{runner.workspace}}/build + + - name: Configure QMake + shell: bash + working-directory: ${{runner.workspace}}/build + run: qmake $GITHUB_WORKSPACE + + + - name: Build + working-directory: ${{runner.workspace}}/build + shell: bash + run: make -j2 + + - name: Install + working-directory: ${{runner.workspace}}/build + shell: bash + run: sudo make install diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/QGnomePlatform-0.6.1/common/common.pro new/QGnomePlatform-0.7.1/common/common.pro --- old/QGnomePlatform-0.6.1/common/common.pro 2020-04-19 22:14:28.000000000 +0200 +++ new/QGnomePlatform-0.7.1/common/common.pro 2021-04-08 14:02:16.000000000 +0200 @@ -8,14 +8,17 @@ QT += core \ dbus \ theme_support-private \ - x11extras \ widgets -PKGCONFIG += gtk+-3.0 \ +PKGCONFIG += adwaita-qt \ + gtk+-3.0 \ gtk+-x11-3.0 SOURCES += gnomehintssettings.cpp \ - qgtk3dialoghelpers.cpp + qgtk3dialoghelpers.cpp \ + qxdgdesktopportalfiledialog.cpp + HEADERS += gnomehintssettings.h \ - qgtk3dialoghelpers.h + qgtk3dialoghelpers.h \ + qxdgdesktopportalfiledialog_p.h diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/QGnomePlatform-0.6.1/common/gnomehintssettings.cpp new/QGnomePlatform-0.7.1/common/gnomehintssettings.cpp --- old/QGnomePlatform-0.6.1/common/gnomehintssettings.cpp 2020-04-19 22:14:28.000000000 +0200 +++ new/QGnomePlatform-0.7.1/common/gnomehintssettings.cpp 2021-04-08 14:02:16.000000000 +0200 @@ -31,12 +31,19 @@ #include <QStyleFactory> #include <QSettings> #include <QStandardPaths> +#include <QTimer> #include <QDBusArgument> #include <QDBusConnection> #include <QDBusMessage> - -#include <QX11Info> +#include <QDBusPendingCall> +#include <QDBusPendingCallWatcher> +#include <QDBusPendingReply> + +#include <fcntl.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> Q_LOGGING_CATEGORY(QGnomePlatform, "qt.qpa.qgnomeplatform") @@ -80,8 +87,10 @@ GnomeHintsSettings::GnomeHintsSettings() : QObject(0) , m_usePortal(checkUsePortalSupport()) + , m_canUseFileChooserPortal(!m_usePortal) , m_gnomeDesktopSettings(g_settings_new("org.gnome.desktop.wm.preferences")) , m_settings(g_settings_new("org.gnome.desktop.interface")) + , m_fallbackFont(new QFont(QLatin1String("Sans"), 10)) { gtk_init(nullptr, nullptr); @@ -135,18 +144,60 @@ QStringLiteral("SettingChanged"), this, SLOT(portalSettingChanged(QString,QString,QDBusVariant))); } - if (!QX11Info::isPlatformX11()) + if (QGuiApplication::platformName() != QStringLiteral("xcb")) cursorSizeChanged(); loadFonts(); loadStaticHints(); loadTheme(); loadTitlebar(); + + m_palette = new QPalette(Adwaita::Colors::palette(m_gtkThemeDarkVariant ? Adwaita::ColorVariant::AdwaitaDark : Adwaita::ColorVariant::Adwaita)); + + if (m_canUseFileChooserPortal) { + QTimer::singleShot(0, this, [this] () { + const QString filePath = QStringLiteral("/proc/%1/root").arg(QCoreApplication::applicationPid()); + struct stat info; + if (lstat(filePath.toStdString().c_str(), &info) == 0) { + if (!static_cast<int>(info.st_uid)) { + m_canUseFileChooserPortal = false; + } + } else { + // Do not use FileChooser portal if we fail to get information about the file + m_canUseFileChooserPortal = false; + } + }); + + if (m_canUseFileChooserPortal) { + // Get information about portal version + QDBusMessage message = QDBusMessage::createMethodCall(QLatin1String("org.freedesktop.portal.Desktop"), + QLatin1String("/org/freedesktop/portal/desktop"), + QLatin1String("org.freedesktop.DBus.Properties"), + QLatin1String("Get")); + message << QLatin1String("org.freedesktop.portal.FileChooser") << QLatin1String("version"); + QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message); + QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall); + QObject::connect(watcher, &QDBusPendingCallWatcher::finished, [this] (QDBusPendingCallWatcher *watcher) { + QDBusPendingReply<QVariant> reply = *watcher; + if (reply.isValid()) { + uint fileChooserPortalVersion = reply.value().toUInt(); + if (fileChooserPortalVersion < 3) { + m_canUseFileChooserPortal = false; + } + } else { + m_canUseFileChooserPortal = false; + } + watcher->deleteLater(); + }); + } + } } GnomeHintsSettings::~GnomeHintsSettings() { qDeleteAll(m_fonts); + delete m_fallbackFont; + delete m_palette; if (m_cinnamonSettings) { g_object_unref(m_cinnamonSettings); } @@ -172,7 +223,7 @@ } else if (changedProperty == QStringLiteral("monospace-font-name")) { gnomeHintsSettings->fontChanged(); } else if (changedProperty == QStringLiteral("cursor-size")) { - if (!QX11Info::isPlatformX11()) + if (QGuiApplication::platformName() != QStringLiteral("xcb")) gnomeHintsSettings->cursorSizeChanged(); // Org.gnome.wm.preferences } else if (changedProperty == QStringLiteral("titlebar-font")) { @@ -299,16 +350,32 @@ void GnomeHintsSettings::loadTheme() { + QString styleOverride; + // g_object_get(gtk_settings_get_default(), "gtk-theme-name", &m_gtkTheme, NULL); m_gtkTheme = getSettingsProperty<QString>(QStringLiteral("gtk-theme")); g_object_get(gtk_settings_get_default(), "gtk-application-prefer-dark-theme", &m_gtkThemeDarkVariant, NULL); - if (m_gtkTheme.isEmpty()) { - qCWarning(QGnomePlatform) << "Couldn't get current gtk theme!"; + if (qEnvironmentVariableIsSet("QT_STYLE_OVERRIDE")) { + styleOverride = QString::fromLocal8Bit(qgetenv("QT_STYLE_OVERRIDE")); + } + + if (styleOverride.isEmpty()) { + if (m_gtkTheme.isEmpty()) { + qCWarning(QGnomePlatform) << "Couldn't get current gtk theme!"; + } else { + qCDebug(QGnomePlatform) << "Theme name: " << m_gtkTheme; + + if (m_gtkTheme.toLower().contains("-dark")) { + m_gtkThemeDarkVariant = true; + } + + qCDebug(QGnomePlatform) << "Dark version: " << (m_gtkThemeDarkVariant ? "yes" : "no"); + } } else { - qCDebug(QGnomePlatform) << "Theme name: " << m_gtkTheme; + qCDebug(QGnomePlatform) << "Theme name: " << styleOverride; - if (m_gtkTheme.toLower().endsWith("-dark")) { + if (styleOverride.toLower().contains("-dark")) { m_gtkThemeDarkVariant = true; } @@ -359,7 +426,7 @@ bool bold = false; int fontSize; QString name; - QRegExp re("(.+)[ \t]+([0-9]+)"); + QRegExp re("^([^,]+)[, \t]+([0-9]+)$"); if (re.indexIn(fontName) == 0) { fontSize = re.cap(2).toInt(); name = re.cap(1); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/QGnomePlatform-0.6.1/common/gnomehintssettings.h new/QGnomePlatform-0.7.1/common/gnomehintssettings.h --- old/QGnomePlatform-0.6.1/common/gnomehintssettings.h 2020-04-19 22:14:28.000000000 +0200 +++ new/QGnomePlatform-0.7.1/common/gnomehintssettings.h 2021-04-08 14:02:16.000000000 +0200 @@ -24,8 +24,10 @@ #include <QFont> #include <QFlags> #include <QObject> +#include <QPalette> #include <QVariant> +#include <cmath> #include <memory> #undef signals @@ -34,8 +36,9 @@ #include <gtk-3.0/gtk/gtksettings.h> #define signals Q_SIGNALS -#include <qpa/qplatformtheme.h> +#include <AdwaitaQt/adwaitacolors.h> +#include <qpa/qplatformtheme.h> class GnomeHintsSettings : public QObject { @@ -64,10 +67,20 @@ return m_fonts[QPlatformTheme::SystemFont]; } else { // GTK default font - return new QFont(QLatin1String("Sans"), 10); + return m_fallbackFont; } } + inline QPalette * palette() const + { + return m_palette; + } + + inline bool canUseFileChooserPortal() const + { + return m_canUseFileChooserPortal; + } + inline bool gtkThemeDarkVariant() const { return m_gtkThemeDarkVariant; @@ -158,6 +171,7 @@ void configureKvantum(const QString &theme) const; bool m_usePortal; + bool m_canUseFileChooserPortal = false; bool m_gtkThemeDarkVariant = false; TitlebarButtons m_titlebarButtons = TitlebarButton::CloseButton; TitlebarButtonsPlacement m_titlebarButtonPlacement = TitlebarButtonsPlacement::RightPlacement; @@ -168,6 +182,8 @@ QHash<QPlatformTheme::Font, QFont*> m_fonts; QHash<QPlatformTheme::ThemeHint, QVariant> m_hints; QMap<QString, QVariantMap> m_portalSettings; + QPalette *m_palette = nullptr; + QFont *m_fallbackFont = nullptr; }; template <> inline int GnomeHintsSettings::getSettingsProperty(GSettings *settings, const QString &property, bool *ok) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/QGnomePlatform-0.6.1/common/qgtk3dialoghelpers.cpp new/QGnomePlatform-0.7.1/common/qgtk3dialoghelpers.cpp --- old/QGnomePlatform-0.6.1/common/qgtk3dialoghelpers.cpp 2020-04-19 22:14:28.000000000 +0200 +++ new/QGnomePlatform-0.7.1/common/qgtk3dialoghelpers.cpp 2021-04-08 14:02:16.000000000 +0200 @@ -87,24 +87,18 @@ protected: static void onResponse(QGtk3Dialog *dialog, int response); - static void onUpdatePreview(QGtk3Dialog *dialog); private slots: void onParentWindowDestroyed(); private: GtkWidget *gtkWidget; - GtkWidget *previewWidget; }; QGtk3Dialog::QGtk3Dialog(GtkWidget *gtkWidget) : gtkWidget(gtkWidget) { g_signal_connect_swapped(G_OBJECT(gtkWidget), "response", G_CALLBACK(onResponse), this); g_signal_connect(G_OBJECT(gtkWidget), "delete-event", G_CALLBACK(gtk_widget_hide_on_delete), NULL); - - previewWidget = gtk_image_new(); - g_signal_connect_swapped(G_OBJECT(gtkWidget), "update-preview", G_CALLBACK(onUpdatePreview), this); - gtk_file_chooser_set_preview_widget(GTK_FILE_CHOOSER(gtkWidget), previewWidget); } QGtk3Dialog::~QGtk3Dialog() @@ -180,32 +174,6 @@ emit dialog->reject(); } -void QGtk3Dialog::onUpdatePreview(QGtk3Dialog *dialog) { - gchar *filename = gtk_file_chooser_get_preview_filename(GTK_FILE_CHOOSER(dialog->gtkWidget)); - if (!filename) { - gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(dialog->gtkWidget), false); - return; - } - - // Don't attempt to open anything which isn't a regular file. If a named pipe, - // this may hang. See https://crbug.com/534754. - QFileInfo fileinfo(filename); - if (!fileinfo.exists() || !fileinfo.isFile()) { - g_free(filename); - gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(dialog->gtkWidget), false); - return; - } - - // This will preserve the image's aspect ratio. - GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file_at_size(filename, PREVIEW_WIDTH, PREVIEW_HEIGHT, 0); - g_free(filename); - if (pixbuf) { - gtk_image_set_from_pixbuf(GTK_IMAGE(dialog->previewWidget), pixbuf); - g_object_unref(pixbuf); - } - gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(dialog->gtkWidget), pixbuf ? true : false); -} - void QGtk3Dialog::onParentWindowDestroyed() { // The QGtk3*DialogHelper classes own this object. Make sure the parent doesn't delete it. @@ -293,12 +261,21 @@ g_signal_connect(GTK_FILE_CHOOSER(d->gtkDialog()), "selection-changed", G_CALLBACK(onSelectionChanged), this); g_signal_connect_swapped(GTK_FILE_CHOOSER(d->gtkDialog()), "current-folder-changed", G_CALLBACK(onCurrentFolderChanged), this); + + previewWidget = gtk_image_new(); + g_signal_connect(G_OBJECT(d->gtkDialog()), "update-preview", G_CALLBACK(onUpdatePreview), this); + gtk_file_chooser_set_preview_widget(GTK_FILE_CHOOSER(d->gtkDialog()), previewWidget); } QGtk3FileDialogHelper::~QGtk3FileDialogHelper() { } +GtkImage *QGtk3FileDialogHelper::previewImage() const +{ + return GTK_IMAGE(previewWidget); +} + bool QGtk3FileDialogHelper::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) { _dir.clear(); @@ -435,6 +412,33 @@ emit dialog->directoryEntered(dialog->directory()); } +void QGtk3FileDialogHelper::onUpdatePreview(GtkDialog *gtkDialog, QGtk3FileDialogHelper *helper) +{ + gchar *filename = gtk_file_chooser_get_preview_filename(GTK_FILE_CHOOSER(gtkDialog)); + if (!filename) { + gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(gtkDialog), false); + return; + } + + // Don't attempt to open anything which isn't a regular file. If a named pipe, + // this may hang. See https://crbug.com/534754. + QFileInfo fileinfo(filename); + if (!fileinfo.exists() || !fileinfo.isFile()) { + g_free(filename); + gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(gtkDialog), false); + return; + } + + // This will preserve the image's aspect ratio. + GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file_at_size(filename, PREVIEW_WIDTH, PREVIEW_HEIGHT, 0); + g_free(filename); + if (pixbuf) { + gtk_image_set_from_pixbuf(helper->previewImage(), pixbuf); + g_object_unref(pixbuf); + } + gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(gtkDialog), pixbuf ? true : false); +} + static GtkFileChooserAction gtkFileChooserAction(const QSharedPointer<QFileDialogOptions> &options) { switch (options->fileMode()) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/QGnomePlatform-0.6.1/common/qgtk3dialoghelpers.h new/QGnomePlatform-0.7.1/common/qgtk3dialoghelpers.h --- old/QGnomePlatform-0.6.1/common/qgtk3dialoghelpers.h 2020-04-19 22:14:28.000000000 +0200 +++ new/QGnomePlatform-0.7.1/common/qgtk3dialoghelpers.h 2021-04-08 14:02:16.000000000 +0200 @@ -47,6 +47,8 @@ #include <QtCore/qstring.h> #include <qpa/qplatformdialoghelper.h> +typedef struct _GtkWidget GtkWidget; +typedef struct _GtkImage GtkImage; typedef struct _GtkDialog GtkDialog; typedef struct _GtkFileFilter GtkFileFilter; @@ -88,6 +90,8 @@ QGtk3FileDialogHelper(); ~QGtk3FileDialogHelper(); + GtkImage *previewImage() const; + bool show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) Q_DECL_OVERRIDE; void exec() Q_DECL_OVERRIDE; void hide() Q_DECL_OVERRIDE; @@ -107,6 +111,7 @@ private: static void onSelectionChanged(GtkDialog *dialog, QGtk3FileDialogHelper *helper); static void onCurrentFolderChanged(QGtk3FileDialogHelper *helper); + static void onUpdatePreview(GtkDialog *dialog, QGtk3FileDialogHelper *helper); void applyOptions(); void setNameFilters(const QStringList &filters); @@ -115,6 +120,7 @@ QHash<QString, GtkFileFilter*> _filters; QHash<GtkFileFilter*, QString> _filterNames; QScopedPointer<QGtk3Dialog> d; + GtkWidget *previewWidget; }; class QGtk3FontDialogHelper : public QPlatformFontDialogHelper diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/QGnomePlatform-0.6.1/common/qxdgdesktopportalfiledialog.cpp new/QGnomePlatform-0.7.1/common/qxdgdesktopportalfiledialog.cpp --- old/QGnomePlatform-0.6.1/common/qxdgdesktopportalfiledialog.cpp 1970-01-01 01:00:00.000000000 +0100 +++ new/QGnomePlatform-0.7.1/common/qxdgdesktopportalfiledialog.cpp 2021-04-08 14:02:16.000000000 +0200 @@ -0,0 +1,469 @@ +/**************************************************************************** +** +** Copyright (C) 2017-2018 Red Hat, Inc +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qxdgdesktopportalfiledialog_p.h" + +#include <QtCore/qeventloop.h> + +#include <QtDBus/QtDBus> +#include <QDBusConnection> +#include <QDBusMessage> +#include <QDBusPendingCall> +#include <QDBusPendingCallWatcher> +#include <QDBusPendingReply> + +#include <QFile> +#include <QMetaType> +#include <QMimeType> +#include <QMimeDatabase> +#include <QRandomGenerator> +#include <QWindow> + +QT_BEGIN_NAMESPACE + +QDBusArgument &operator <<(QDBusArgument &arg, const QXdgDesktopPortalFileDialog::FilterCondition &filterCondition) +{ + arg.beginStructure(); + arg << filterCondition.type << filterCondition.pattern; + arg.endStructure(); + return arg; +} + +const QDBusArgument &operator >>(const QDBusArgument &arg, QXdgDesktopPortalFileDialog::FilterCondition &filterCondition) +{ + uint type; + QString filterPattern; + arg.beginStructure(); + arg >> type >> filterPattern; + filterCondition.type = (QXdgDesktopPortalFileDialog::ConditionType)type; + filterCondition.pattern = filterPattern; + arg.endStructure(); + + return arg; +} + +QDBusArgument &operator <<(QDBusArgument &arg, const QXdgDesktopPortalFileDialog::Filter filter) +{ + arg.beginStructure(); + arg << filter.name << filter.filterConditions; + arg.endStructure(); + return arg; +} + +const QDBusArgument &operator >>(const QDBusArgument &arg, QXdgDesktopPortalFileDialog::Filter &filter) +{ + QString name; + QXdgDesktopPortalFileDialog::FilterConditionList filterConditions; + arg.beginStructure(); + arg >> name >> filterConditions; + filter.name = name; + filter.filterConditions = filterConditions; + arg.endStructure(); + + return arg; +} + +class QXdgDesktopPortalFileDialogPrivate +{ +public: + QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog) + : nativeFileDialog(nativeFileDialog) + { } + + WId winId = 0; + bool directoryMode = false; + bool modal = false; + bool multipleFiles = false; + bool saveFile = false; + QString acceptLabel; + QString directory; + QString title; + QStringList nameFilters; + QStringList mimeTypesFilters; + // maps user-visible name for portal to full name filter + QMap<QString, QString> userVisibleToNameFilter; + QString selectedMimeTypeFilter; + QString selectedNameFilter; + QStringList selectedFiles; + QPlatformFileDialogHelper *nativeFileDialog = nullptr; +}; + +QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog) + : QPlatformFileDialogHelper() + , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog)) +{ + Q_D(QXdgDesktopPortalFileDialog); + + if (d->nativeFileDialog) { + connect(d->nativeFileDialog, SIGNAL(accept()), this, SIGNAL(accept())); + connect(d->nativeFileDialog, SIGNAL(reject()), this, SIGNAL(reject())); + } +} + +QXdgDesktopPortalFileDialog::~QXdgDesktopPortalFileDialog() +{ +} + +void QXdgDesktopPortalFileDialog::initializeDialog() +{ + Q_D(QXdgDesktopPortalFileDialog); + + if (d->nativeFileDialog) + d->nativeFileDialog->setOptions(options()); + + if (options()->fileMode() == QFileDialogOptions::ExistingFiles) + d->multipleFiles = true; + + if (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly) + d->directoryMode = true; + + if (options()->isLabelExplicitlySet(QFileDialogOptions::Accept)) + d->acceptLabel = options()->labelText(QFileDialogOptions::Accept); + + if (!options()->windowTitle().isEmpty()) + d->title = options()->windowTitle(); + + if (options()->acceptMode() == QFileDialogOptions::AcceptSave) + d->saveFile = true; + + if (!options()->nameFilters().isEmpty()) + d->nameFilters = options()->nameFilters(); + + if (!options()->mimeTypeFilters().isEmpty()) + d->mimeTypesFilters = options()->mimeTypeFilters(); + + if (!options()->initiallySelectedMimeTypeFilter().isEmpty()) + d->selectedMimeTypeFilter = options()->initiallySelectedMimeTypeFilter(); + + if (!options()->initiallySelectedNameFilter().isEmpty()) + d->selectedNameFilter = options()->initiallySelectedNameFilter(); + + setDirectory(options()->initialDirectory()); +} + +void QXdgDesktopPortalFileDialog::openPortal() +{ + Q_D(QXdgDesktopPortalFileDialog); + + QDBusMessage message = QDBusMessage::createMethodCall(QLatin1String("org.freedesktop.portal.Desktop"), + QLatin1String("/org/freedesktop/portal/desktop"), + QLatin1String("org.freedesktop.portal.FileChooser"), + d->saveFile ? QLatin1String("SaveFile") : QLatin1String("OpenFile")); + QString parentWindowId = QLatin1String("x11:") + QString::number(d->winId); + + QVariantMap options; + if (!d->acceptLabel.isEmpty()) + options.insert(QLatin1String("accept_label"), d->acceptLabel); + + options.insert(QLatin1String("modal"), d->modal); + options.insert(QLatin1String("multiple"), d->multipleFiles); + options.insert(QLatin1String("directory"), d->directoryMode); + + if (d->saveFile) { + if (!d->directory.isEmpty()) + options.insert(QLatin1String("current_folder"), QFile::encodeName(d->directory).append('\0')); + + if (!d->selectedFiles.isEmpty()) + options.insert(QLatin1String("current_file"), QFile::encodeName(d->selectedFiles.first()).append('\0')); + } + + // Insert filters + qDBusRegisterMetaType<FilterCondition>(); + qDBusRegisterMetaType<FilterConditionList>(); + qDBusRegisterMetaType<Filter>(); + qDBusRegisterMetaType<FilterList>(); + + FilterList filterList; + auto selectedFilterIndex = filterList.size() - 1; + + d->userVisibleToNameFilter.clear(); + + if (!d->mimeTypesFilters.isEmpty()) { + for (const QString &mimeTypefilter : d->mimeTypesFilters) { + QMimeDatabase mimeDatabase; + QMimeType mimeType = mimeDatabase.mimeTypeForName(mimeTypefilter); + + // Creates e.g. (1, "image/png") + FilterCondition filterCondition; + filterCondition.type = MimeType; + filterCondition.pattern = mimeTypefilter; + + // Creates e.g. [((1, "image/png"))] + FilterConditionList filterConditions; + filterConditions << filterCondition; + + // Creates e.g. [("Images", [((1, "image/png"))])] + Filter filter; + filter.name = mimeType.comment(); + filter.filterConditions = filterConditions; + + filterList << filter; + + if (!d->selectedMimeTypeFilter.isEmpty() && d->selectedMimeTypeFilter == mimeTypefilter) + selectedFilterIndex = filterList.size() - 1; + } + } else if (!d->nameFilters.isEmpty()) { + for (const QString &nameFilter : d->nameFilters) { + // Do parsing: + // Supported format is ("Images (*.png *.jpg)") + QRegularExpression regexp(QPlatformFileDialogHelper::filterRegExp); + QRegularExpressionMatch match = regexp.match(nameFilter); + if (match.hasMatch()) { + QString userVisibleName = match.captured(1); + QStringList filterStrings = match.captured(2).split(QLatin1Char(' '), QString::SkipEmptyParts); + + if (filterStrings.isEmpty()) { + qWarning() << "Filter " << userVisibleName << " is empty and will be ignored."; + continue; + } + + FilterConditionList filterConditions; + for (const QString &filterString : filterStrings) { + FilterCondition filterCondition; + filterCondition.type = GlobalPattern; + filterCondition.pattern = filterString; + filterConditions << filterCondition; + } + + Filter filter; + filter.name = userVisibleName; + filter.filterConditions = filterConditions; + + filterList << filter; + + d->userVisibleToNameFilter.insert(userVisibleName, nameFilter); + + if (!d->selectedNameFilter.isEmpty() && d->selectedNameFilter == nameFilter) + selectedFilterIndex = filterList.size() - 1; + } + } + } + + if (!filterList.isEmpty()) + options.insert(QLatin1String("filters"), QVariant::fromValue(filterList)); + + if (selectedFilterIndex != -1) + options.insert(QLatin1String("current_filter"), QVariant::fromValue(filterList[selectedFilterIndex])); + + options.insert(QLatin1String("handle_token"), QStringLiteral("qt%1").arg(QRandomGenerator::global()->generate())); + + // TODO choices a(ssa(ss)s) + // List of serialized combo boxes to add to the file chooser. + + message << parentWindowId << d->title << options; + + QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message); + QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall); + connect(watcher, &QDBusPendingCallWatcher::finished, this, [this] (QDBusPendingCallWatcher *watcher) { + QDBusPendingReply<QDBusObjectPath> reply = *watcher; + if (reply.isError()) { + Q_EMIT reject(); + } else { + QDBusConnection::sessionBus().connect(nullptr, + reply.value().path(), + QLatin1String("org.freedesktop.portal.Request"), + QLatin1String("Response"), + this, + SLOT(gotResponse(uint,QVariantMap))); + } + watcher->deleteLater(); + }); +} + +bool QXdgDesktopPortalFileDialog::defaultNameFilterDisables() const +{ + return false; +} + +void QXdgDesktopPortalFileDialog::setDirectory(const QUrl &directory) +{ + Q_D(QXdgDesktopPortalFileDialog); + + if (d->nativeFileDialog) { + d->nativeFileDialog->setOptions(options()); + d->nativeFileDialog->setDirectory(directory); + } + + d->directory = directory.path(); +} + +QUrl QXdgDesktopPortalFileDialog::directory() const +{ + Q_D(const QXdgDesktopPortalFileDialog); + + if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly)) + return d->nativeFileDialog->directory(); + + return d->directory; +} + +void QXdgDesktopPortalFileDialog::selectFile(const QUrl &filename) +{ + Q_D(QXdgDesktopPortalFileDialog); + + if (d->nativeFileDialog) { + d->nativeFileDialog->setOptions(options()); + d->nativeFileDialog->selectFile(filename); + } + + d->selectedFiles << filename.path(); +} + +QList<QUrl> QXdgDesktopPortalFileDialog::selectedFiles() const +{ + Q_D(const QXdgDesktopPortalFileDialog); + + if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly)) + return d->nativeFileDialog->selectedFiles(); + + QList<QUrl> files; + for (const QString &file : d->selectedFiles) { + files << QUrl(file); + } + return files; +} + +void QXdgDesktopPortalFileDialog::setFilter() +{ + Q_D(QXdgDesktopPortalFileDialog); + + if (d->nativeFileDialog) { + d->nativeFileDialog->setOptions(options()); + d->nativeFileDialog->setFilter(); + } +} + +void QXdgDesktopPortalFileDialog::selectMimeTypeFilter(const QString &filter) +{ + Q_D(QXdgDesktopPortalFileDialog); + if (d->nativeFileDialog) { + d->nativeFileDialog->setOptions(options()); + d->nativeFileDialog->selectMimeTypeFilter(filter); + } +} + +QString QXdgDesktopPortalFileDialog::selectedMimeTypeFilter() const +{ + Q_D(const QXdgDesktopPortalFileDialog); + return d->selectedMimeTypeFilter; +} + +void QXdgDesktopPortalFileDialog::selectNameFilter(const QString &filter) +{ + Q_D(QXdgDesktopPortalFileDialog); + + if (d->nativeFileDialog) { + d->nativeFileDialog->setOptions(options()); + d->nativeFileDialog->selectNameFilter(filter); + } +} + +QString QXdgDesktopPortalFileDialog::selectedNameFilter() const +{ + Q_D(const QXdgDesktopPortalFileDialog); + return d->selectedNameFilter; +} + +void QXdgDesktopPortalFileDialog::exec() +{ + Q_D(QXdgDesktopPortalFileDialog); + + if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly)) { + d->nativeFileDialog->exec(); + return; + } + + // HACK we have to avoid returning until we emit that the dialog was accepted or rejected + QEventLoop loop; + loop.connect(this, SIGNAL(accept()), SLOT(quit())); + loop.connect(this, SIGNAL(reject()), SLOT(quit())); + loop.exec(); +} + +void QXdgDesktopPortalFileDialog::hide() +{ + Q_D(QXdgDesktopPortalFileDialog); + + if (d->nativeFileDialog) + d->nativeFileDialog->hide(); +} + +bool QXdgDesktopPortalFileDialog::show(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent) +{ + Q_D(QXdgDesktopPortalFileDialog); + + initializeDialog(); + + d->modal = windowModality != Qt::NonModal; + d->winId = parent ? parent->winId() : 0; + + if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly)) + return d->nativeFileDialog->show(windowFlags, windowModality, parent); + + openPortal(); + + return true; +} + +void QXdgDesktopPortalFileDialog::gotResponse(uint response, const QVariantMap &results) +{ + Q_D(QXdgDesktopPortalFileDialog); + + if (!response) { + if (results.contains(QLatin1String("uris"))) + d->selectedFiles = results.value(QLatin1String("uris")).toStringList(); + + if (results.contains(QLatin1String("current_filter"))) { + const Filter selectedFilter = qdbus_cast<Filter>(results.value(QStringLiteral("current_filter"))); + if (!selectedFilter.filterConditions.empty() && selectedFilter.filterConditions[0].type == MimeType) { + // s.a. QXdgDesktopPortalFileDialog::openPortal which basically does the inverse + d->selectedMimeTypeFilter = selectedFilter.filterConditions[0].pattern; + d->selectedNameFilter.clear(); + } else { + d->selectedNameFilter = d->userVisibleToNameFilter.value(selectedFilter.name); + d->selectedMimeTypeFilter.clear(); + } + } + Q_EMIT accept(); + } else { + Q_EMIT reject(); + } +} + +QT_END_NAMESPACE diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/QGnomePlatform-0.6.1/common/qxdgdesktopportalfiledialog_p.h new/QGnomePlatform-0.7.1/common/qxdgdesktopportalfiledialog_p.h --- old/QGnomePlatform-0.6.1/common/qxdgdesktopportalfiledialog_p.h 1970-01-01 01:00:00.000000000 +0100 +++ new/QGnomePlatform-0.7.1/common/qxdgdesktopportalfiledialog_p.h 2021-04-08 14:02:16.000000000 +0200 @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2017-2018 Red Hat, Inc +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QXDGDESKTOPPORTALFILEDIALOG_P_H +#define QXDGDESKTOPPORTALFILEDIALOG_P_H + +#include <qpa/qplatformdialoghelper.h> +#include <QVector> + +QT_BEGIN_NAMESPACE + +class QXdgDesktopPortalFileDialogPrivate; + +class QXdgDesktopPortalFileDialog : public QPlatformFileDialogHelper +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QXdgDesktopPortalFileDialog) +public: + enum ConditionType : uint { + GlobalPattern = 0, + MimeType = 1 + }; + // Filters a(sa(us)) + // Example: [('Images', [(0, '*.ico'), (1, 'image/png')]), ('Text', [(0, '*.txt')])] + struct FilterCondition { + ConditionType type; + QString pattern; // E.g. '*ico' or 'image/png' + }; + typedef QVector<FilterCondition> FilterConditionList; + + struct Filter { + QString name; // E.g. 'Images' or 'Text + FilterConditionList filterConditions;; // E.g. [(0, '*.ico'), (1, 'image/png')] or [(0, '*.txt')] + }; + typedef QVector<Filter> FilterList; + + QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr); + ~QXdgDesktopPortalFileDialog(); + + bool defaultNameFilterDisables() const override; + QUrl directory() const override; + void setDirectory(const QUrl &directory) override; + void selectFile(const QUrl &filename) override; + QList<QUrl> selectedFiles() const override; + void setFilter() override; + void selectNameFilter(const QString &filter) override; + QString selectedNameFilter() const override; + void selectMimeTypeFilter(const QString &filter) override; + QString selectedMimeTypeFilter() const override; + + void exec() override; + bool show(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent) override; + void hide() override; + +private Q_SLOTS: + void gotResponse(uint response, const QVariantMap &results); + +private: + void initializeDialog(); + void openPortal(); + + QScopedPointer<QXdgDesktopPortalFileDialogPrivate> d_ptr; +}; + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QXdgDesktopPortalFileDialog::FilterCondition); +Q_DECLARE_METATYPE(QXdgDesktopPortalFileDialog::FilterConditionList); +Q_DECLARE_METATYPE(QXdgDesktopPortalFileDialog::Filter); +Q_DECLARE_METATYPE(QXdgDesktopPortalFileDialog::FilterList); + +#endif // QXDGDESKTOPPORTALFILEDIALOG_P_H + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/QGnomePlatform-0.6.1/decoration/decoration.pro new/QGnomePlatform-0.7.1/decoration/decoration.pro --- old/QGnomePlatform-0.6.1/decoration/decoration.pro 2020-04-19 22:14:28.000000000 +0200 +++ new/QGnomePlatform-0.7.1/decoration/decoration.pro 2021-04-08 14:02:16.000000000 +0200 @@ -12,14 +12,13 @@ QT += core \ gui \ waylandclient-private \ - widgets \ - x11extras + widgets LIBS += -lcommon QMAKE_USE += wayland-client -PKGCONFIG += gtk+-3.0 +PKGCONFIG += adwaita-qt gtk+-3.0 TARGET = qgnomeplatformdecoration target.path += $$[QT_INSTALL_PLUGINS]/wayland-decoration-client diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/QGnomePlatform-0.6.1/decoration/qgnomeplatformdecoration.cpp new/QGnomePlatform-0.7.1/decoration/qgnomeplatformdecoration.cpp --- old/QGnomePlatform-0.6.1/decoration/qgnomeplatformdecoration.cpp 2020-04-19 22:14:28.000000000 +0200 +++ new/QGnomePlatform-0.7.1/decoration/qgnomeplatformdecoration.cpp 2021-04-08 14:02:16.000000000 +0200 @@ -46,6 +46,7 @@ #include <QtGui/QCursor> #include <QtGui/QLinearGradient> #include <QtGui/QPainter> +#include <QtGui/QPainterPath> #include <QtGui/QPalette> #include <QtGui/QPixmap> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/QGnomePlatform-0.6.1/qgnomeplatform.pro new/QGnomePlatform-0.7.1/qgnomeplatform.pro --- old/QGnomePlatform-0.6.1/qgnomeplatform.pro 2020-04-19 22:14:28.000000000 +0200 +++ new/QGnomePlatform-0.7.1/qgnomeplatform.pro 2021-04-08 14:02:16.000000000 +0200 @@ -4,3 +4,8 @@ decoration.depends = common theme.depends = common + +equals(QT_MAJOR_VERSION, 5):lessThan(QT_MINOR_VERSION, 12) { + message("Cannot use Qt $${QT_VERSION}") + error("Qt 5.12 and newer is required") +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/QGnomePlatform-0.6.1/theme/qgnomeplatformtheme.cpp new/QGnomePlatform-0.7.1/theme/qgnomeplatformtheme.cpp --- old/QGnomePlatform-0.6.1/theme/qgnomeplatformtheme.cpp 2020-04-19 22:14:28.000000000 +0200 +++ new/QGnomePlatform-0.7.1/theme/qgnomeplatformtheme.cpp 2021-04-08 14:02:16.000000000 +0200 @@ -21,10 +21,11 @@ #include "qgnomeplatformtheme.h" #include "gnomehintssettings.h" #include "qgtk3dialoghelpers.h" +#include "qxdgdesktopportalfiledialog_p.h" #include <QApplication> +#include <QGuiApplication> #include <QStyleFactory> -#include <QX11Info> #if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON) #include <private/qdbustrayicon_p.h> @@ -32,7 +33,7 @@ QGnomePlatformTheme::QGnomePlatformTheme() { - if (!QX11Info::isPlatformX11()) { + if (QGuiApplication::platformName() != QStringLiteral("xcb")) { if (!qEnvironmentVariableIsSet("QT_WAYLAND_DECORATION")) qputenv("QT_WAYLAND_DECORATION", "gnome"); } @@ -68,7 +69,9 @@ const QPalette *QGnomePlatformTheme::palette(Palette type) const { - return QPlatformTheme::palette(type); + Q_UNUSED(type); + + return m_hints->palette(); } bool QGnomePlatformTheme::usePlatformNativeDialog(QPlatformTheme::DialogType type) const @@ -89,8 +92,13 @@ QPlatformDialogHelper *QGnomePlatformTheme::createPlatformDialogHelper(QPlatformTheme::DialogType type) const { switch (type) { - case QPlatformTheme::FileDialog: - return new QGtk3FileDialogHelper(); + case QPlatformTheme::FileDialog: { + if (m_hints->canUseFileChooserPortal()) { + return new QXdgDesktopPortalFileDialog; + } else { + return new QGtk3FileDialogHelper; + } + } case QPlatformTheme::FontDialog: return new QGtk3FontDialogHelper(); case QPlatformTheme::ColorDialog: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/QGnomePlatform-0.6.1/theme/theme.pro new/QGnomePlatform-0.7.1/theme/theme.pro --- old/QGnomePlatform-0.6.1/theme/theme.pro 2020-04-19 22:14:28.000000000 +0200 +++ new/QGnomePlatform-0.7.1/theme/theme.pro 2021-04-08 14:02:16.000000000 +0200 @@ -13,12 +13,12 @@ dbus \ gui-private \ theme_support-private \ - x11extras \ widgets LIBS += -lcommon -PKGCONFIG += gtk+-3.0 \ +PKGCONFIG += adwaita-qt \ + gtk+-3.0 \ gtk+-x11-3.0 TARGET = qgnomeplatform ++++++ fix-qt5-x11-config.patch ++++++ diff -Nur QGnomePlatform-0.7.1/theme/theme.pro new/theme/theme.pro --- QGnomePlatform-0.7.1/theme/theme.pro 2021-04-08 14:02:16.000000000 +0200 +++ new/theme/theme.pro 2021-04-30 02:00:39.333569873 +0200 @@ -19,6 +19,7 @@ PKGCONFIG += adwaita-qt \ gtk+-3.0 \ + x11 \ gtk+-x11-3.0 TARGET = qgnomeplatform