Drop QPlatformTheme::Appearance() backports breaking ABI
This commit is contained in:
parent
4764b5f6a1
commit
d2061e2275
@ -1,7 +1,7 @@
|
||||
From dacd0c6b3466258d175e7119a8e4836171400820 Mon Sep 17 00:00:00 2001
|
||||
From: Jan Grulich <jgrulich@redhat.com>
|
||||
Date: Wed, 26 Jul 2023 12:03:46 +0200
|
||||
Subject: [PATCH 01/22] Use Wayland by default on GNOME
|
||||
Subject: [PATCH 01/15] Use Wayland by default on GNOME
|
||||
|
||||
---
|
||||
src/gui/kernel/qguiapplication.cpp | 9 +--------
|
||||
|
@ -1,119 +0,0 @@
|
||||
From 488d73ca92deb669abc724c82dbd3206597107fd Mon Sep 17 00:00:00 2001
|
||||
From: Jan Grulich <jgrulich@redhat.com>
|
||||
Date: Wed, 26 Jul 2023 12:04:21 +0200
|
||||
Subject: [PATCH 02/22] Add QPlatformTheme::Appearance for detecting light/dark
|
||||
modes
|
||||
|
||||
And implement it on Windows and macOS.
|
||||
---
|
||||
src/gui/kernel/qplatformtheme.cpp | 5 +++++
|
||||
src/gui/kernel/qplatformtheme.h | 8 ++++++++
|
||||
src/plugins/platforms/cocoa/qcocoatheme.h | 1 +
|
||||
src/plugins/platforms/cocoa/qcocoatheme.mm | 5 +++++
|
||||
src/plugins/platforms/windows/qwindowstheme.cpp | 5 +++++
|
||||
src/plugins/platforms/windows/qwindowstheme.h | 3 +++
|
||||
6 files changed, 27 insertions(+)
|
||||
|
||||
diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp
|
||||
index 2325873245..662fef1426 100644
|
||||
--- a/src/gui/kernel/qplatformtheme.cpp
|
||||
+++ b/src/gui/kernel/qplatformtheme.cpp
|
||||
@@ -399,6 +399,11 @@ QPlatformDialogHelper *QPlatformTheme::createPlatformDialogHelper(DialogType typ
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
+QPlatformTheme::Appearance QPlatformTheme::appearance() const
|
||||
+{
|
||||
+ return Appearance::Unknown;
|
||||
+}
|
||||
+
|
||||
const QPalette *QPlatformTheme::palette(Palette type) const
|
||||
{
|
||||
Q_D(const QPlatformTheme);
|
||||
diff --git a/src/gui/kernel/qplatformtheme.h b/src/gui/kernel/qplatformtheme.h
|
||||
index 7e6c9d5740..c0dee4c581 100644
|
||||
--- a/src/gui/kernel/qplatformtheme.h
|
||||
+++ b/src/gui/kernel/qplatformtheme.h
|
||||
@@ -131,6 +131,12 @@ public:
|
||||
MessageDialog
|
||||
};
|
||||
|
||||
+ enum class Appearance {
|
||||
+ Unknown = 0x0000,
|
||||
+ Light = 0x0001,
|
||||
+ Dark = 0x0002
|
||||
+ };
|
||||
+
|
||||
enum Palette {
|
||||
SystemPalette,
|
||||
ToolTipPalette,
|
||||
@@ -320,6 +326,8 @@ public:
|
||||
virtual QString standardButtonText(int button) const;
|
||||
virtual QKeySequence standardButtonShortcut(int button) const;
|
||||
|
||||
+ virtual Appearance appearance() const;
|
||||
+
|
||||
static QVariant defaultThemeHint(ThemeHint hint);
|
||||
static QString defaultStandardButtonText(int button);
|
||||
static QString removeMnemonics(const QString &original);
|
||||
diff --git a/src/plugins/platforms/cocoa/qcocoatheme.h b/src/plugins/platforms/cocoa/qcocoatheme.h
|
||||
index 50e56ef1bf..f719fd943b 100644
|
||||
--- a/src/plugins/platforms/cocoa/qcocoatheme.h
|
||||
+++ b/src/plugins/platforms/cocoa/qcocoatheme.h
|
||||
@@ -73,6 +73,7 @@ public:
|
||||
QIcon fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions options = {}) const override;
|
||||
|
||||
QVariant themeHint(ThemeHint hint) const override;
|
||||
+ Appearance appearance() const override;
|
||||
QString standardButtonText(int button) const override;
|
||||
QKeySequence standardButtonShortcut(int button) const override;
|
||||
|
||||
diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm
|
||||
index d73b028afb..a79fa4e4b9 100644
|
||||
--- a/src/plugins/platforms/cocoa/qcocoatheme.mm
|
||||
+++ b/src/plugins/platforms/cocoa/qcocoatheme.mm
|
||||
@@ -544,6 +544,11 @@ QVariant QCocoaTheme::themeHint(ThemeHint hint) const
|
||||
return QPlatformTheme::themeHint(hint);
|
||||
}
|
||||
|
||||
+QPlatformTheme::Appearance QCocoaTheme::appearance() const
|
||||
+{
|
||||
+ return qt_mac_applicationIsInDarkMode() ? Appearance::Dark : Appearance::Light;
|
||||
+}
|
||||
+
|
||||
QString QCocoaTheme::standardButtonText(int button) const
|
||||
{
|
||||
return button == QPlatformDialogHelper::Discard ?
|
||||
diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp
|
||||
index 25e083fd5c..510b8746da 100644
|
||||
--- a/src/plugins/platforms/windows/qwindowstheme.cpp
|
||||
+++ b/src/plugins/platforms/windows/qwindowstheme.cpp
|
||||
@@ -520,6 +520,11 @@ QVariant QWindowsTheme::themeHint(ThemeHint hint) const
|
||||
return QPlatformTheme::themeHint(hint);
|
||||
}
|
||||
|
||||
+QPlatformTheme::Appearance QWindowsTheme::appearance() const
|
||||
+{
|
||||
+ return QWindowsContext::isDarkMode() ? Appearance::Dark : Appearance::Light;
|
||||
+}
|
||||
+
|
||||
void QWindowsTheme::clearPalettes()
|
||||
{
|
||||
qDeleteAll(m_palettes, m_palettes + NPalettes);
|
||||
diff --git a/src/plugins/platforms/windows/qwindowstheme.h b/src/plugins/platforms/windows/qwindowstheme.h
|
||||
index af28f2878c..9d5fcc92fe 100644
|
||||
--- a/src/plugins/platforms/windows/qwindowstheme.h
|
||||
+++ b/src/plugins/platforms/windows/qwindowstheme.h
|
||||
@@ -64,6 +64,9 @@ public:
|
||||
QPlatformSystemTrayIcon *createPlatformSystemTrayIcon() const override;
|
||||
#endif
|
||||
QVariant themeHint(ThemeHint) const override;
|
||||
+
|
||||
+ Appearance appearance() const override;
|
||||
+
|
||||
const QPalette *palette(Palette type = SystemPalette) const override
|
||||
{ return m_palettes[type]; }
|
||||
const QFont *font(Font type = SystemFont) const override
|
||||
--
|
||||
2.41.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
From cf96f7cecf8d02722e303687c1f30361a4a55cd0 Mon Sep 17 00:00:00 2001
|
||||
From c41101241ce626dd38ee71d5a37c6aeb434eddf4 Mon Sep 17 00:00:00 2001
|
||||
From: Jan Grulich <jgrulich@redhat.com>
|
||||
Date: Wed, 26 Jul 2023 12:06:29 +0200
|
||||
Subject: [PATCH 03/22] Add enum class Qt::Appearance
|
||||
Subject: [PATCH 02/15] Add enum class Qt::Appearance
|
||||
|
||||
It has been decided to add an appearance property in QStyleHints, which
|
||||
will be propagated to classes that do not include QPlatformTheme.
|
@ -1,7 +1,7 @@
|
||||
From d0f0010b49eb40477ea42496063766199e857312 Mon Sep 17 00:00:00 2001
|
||||
From fb0bc2e9f466c37f398af4a7a374fee2b29f5073 Mon Sep 17 00:00:00 2001
|
||||
From: Jan Grulich <jgrulich@redhat.com>
|
||||
Date: Wed, 26 Jul 2023 13:43:29 +0200
|
||||
Subject: [PATCH 09/22] Sync and assert StandardPixmap enums in QPlatformTheme
|
||||
Subject: [PATCH 03/15] Sync and assert StandardPixmap enums in QPlatformTheme
|
||||
and QStyle
|
||||
|
||||
Add missing enum values in QPlatformTheme::standardPixmap to sync with
|
||||
@ -20,7 +20,7 @@ not documented).
|
||||
3 files changed, 14 insertions(+)
|
||||
|
||||
diff --git a/src/gui/kernel/qplatformtheme.h b/src/gui/kernel/qplatformtheme.h
|
||||
index 41213bf32b..210bd40afa 100644
|
||||
index 7e6c9d5740..99a30337f5 100644
|
||||
--- a/src/gui/kernel/qplatformtheme.h
|
||||
+++ b/src/gui/kernel/qplatformtheme.h
|
||||
@@ -256,6 +256,15 @@ public:
|
@ -1,89 +0,0 @@
|
||||
From 1d693df019b1ebf54980a015000b01ae947f82ee Mon Sep 17 00:00:00 2001
|
||||
From: Jan Grulich <jgrulich@redhat.com>
|
||||
Date: Wed, 26 Jul 2023 12:26:39 +0200
|
||||
Subject: [PATCH 04/22] QGtk3Theme: implement appearance function to detect
|
||||
dark themes
|
||||
|
||||
This allows Qt Quick Controls to detect if a dark theme is in use,
|
||||
and if so, use a dark theme of the current style (if available).
|
||||
---
|
||||
.../platformthemes/gtk3/qgtk3theme.cpp | 42 +++++++++++++++++++
|
||||
src/plugins/platformthemes/gtk3/qgtk3theme.h | 2 +
|
||||
2 files changed, 44 insertions(+)
|
||||
|
||||
diff --git a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
|
||||
index 93520344f8..a47720384c 100644
|
||||
--- a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
|
||||
+++ b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
|
||||
@@ -41,6 +41,7 @@
|
||||
#include "qgtk3dialoghelpers.h"
|
||||
#include "qgtk3menu.h"
|
||||
#include <QVariant>
|
||||
+#include <QtCore/qregularexpression.h>
|
||||
|
||||
#undef signals
|
||||
#include <gtk/gtk.h>
|
||||
@@ -147,6 +148,47 @@ QString QGtk3Theme::gtkFontName() const
|
||||
return QGnomeTheme::gtkFontName();
|
||||
}
|
||||
|
||||
+QPlatformTheme::Appearance QGtk3Theme::appearance() const
|
||||
+{
|
||||
+ /*
|
||||
+ https://docs.gtk.org/gtk3/running.html
|
||||
+
|
||||
+ It's possible to set a theme variant after the theme name when using GTK_THEME:
|
||||
+
|
||||
+ GTK_THEME=Adwaita:dark
|
||||
+
|
||||
+ Some themes also have "-dark" as part of their name.
|
||||
+
|
||||
+ We test this environment variable first because the documentation says
|
||||
+ it's mainly used for easy debugging, so it should be possible to use it
|
||||
+ to override any other settings.
|
||||
+ */
|
||||
+ QString themeName = qEnvironmentVariable("GTK_THEME");
|
||||
+ const QRegularExpression darkRegex(QStringLiteral("[:-]dark"), QRegularExpression::CaseInsensitiveOption);
|
||||
+ if (!themeName.isEmpty())
|
||||
+ return darkRegex.match(themeName).hasMatch() ? Appearance::Dark : Appearance::Light;
|
||||
+
|
||||
+ /*
|
||||
+ https://docs.gtk.org/gtk3/property.Settings.gtk-application-prefer-dark-theme.html
|
||||
+
|
||||
+ This setting controls which theme is used when the theme specified by
|
||||
+ gtk-theme-name provides both light and dark variants. We can save a
|
||||
+ regex check by testing this property first.
|
||||
+ */
|
||||
+ const auto preferDark = gtkSetting<bool>("gtk-application-prefer-dark-theme");
|
||||
+ if (preferDark)
|
||||
+ return Appearance::Dark;
|
||||
+
|
||||
+ /*
|
||||
+ https://docs.gtk.org/gtk3/property.Settings.gtk-theme-name.html
|
||||
+ */
|
||||
+ themeName = gtkSetting("gtk-theme-name");
|
||||
+ if (!themeName.isEmpty())
|
||||
+ return darkRegex.match(themeName).hasMatch() ? Appearance::Dark : Appearance::Light;
|
||||
+
|
||||
+ return Appearance::Unknown;
|
||||
+}
|
||||
+
|
||||
bool QGtk3Theme::usePlatformNativeDialog(DialogType type) const
|
||||
{
|
||||
switch (type) {
|
||||
diff --git a/src/plugins/platformthemes/gtk3/qgtk3theme.h b/src/plugins/platformthemes/gtk3/qgtk3theme.h
|
||||
index 54296d2ff1..5f439067af 100644
|
||||
--- a/src/plugins/platformthemes/gtk3/qgtk3theme.h
|
||||
+++ b/src/plugins/platformthemes/gtk3/qgtk3theme.h
|
||||
@@ -52,6 +52,8 @@ public:
|
||||
virtual QVariant themeHint(ThemeHint hint) const override;
|
||||
virtual QString gtkFontName() const override;
|
||||
|
||||
+ Appearance appearance() const override;
|
||||
+
|
||||
bool usePlatformNativeDialog(DialogType type) const override;
|
||||
QPlatformDialogHelper *createPlatformDialogHelper(DialogType type) const override;
|
||||
|
||||
--
|
||||
2.41.0
|
||||
|
@ -1,14 +1,14 @@
|
||||
From b6bf671270aea7bddbb98c69ff395ae649d0edf8 Mon Sep 17 00:00:00 2001
|
||||
From 24b6ad903ab2ed620f8c754aafb727e6aa342aca Mon Sep 17 00:00:00 2001
|
||||
From: Jan Grulich <jgrulich@redhat.com>
|
||||
Date: Wed, 26 Jul 2023 15:38:13 +0200
|
||||
Subject: [PATCH 10/22] QGtk3Theme: subscribe to theme hint changes
|
||||
Subject: [PATCH 04/15] QGtk3Theme: subscribe to theme hint changes
|
||||
|
||||
---
|
||||
.../platformthemes/gtk3/qgtk3theme.cpp | 20 +++++++++++++++++++
|
||||
1 file changed, 20 insertions(+)
|
||||
|
||||
diff --git a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
|
||||
index 2a70d5f3dd..0e940ae690 100644
|
||||
index 93520344f8..7540cb43cf 100644
|
||||
--- a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
|
||||
+++ b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
|
||||
@@ -40,6 +40,7 @@
|
||||
@ -17,9 +17,9 @@ index 2a70d5f3dd..0e940ae690 100644
|
||||
#include "qgtk3menu.h"
|
||||
+#include "qpa/qwindowsysteminterface.h"
|
||||
#include <QVariant>
|
||||
#include <QtCore/qregularexpression.h>
|
||||
|
||||
@@ -101,6 +102,25 @@ QGtk3Theme::QGtk3Theme()
|
||||
#undef signals
|
||||
@@ -100,6 +101,25 @@ QGtk3Theme::QGtk3Theme()
|
||||
|
||||
/* Use our custom log handler. */
|
||||
g_log_set_handler("Gtk", G_LOG_LEVEL_MESSAGE, gtkMessageHandler, nullptr);
|
@ -1,128 +0,0 @@
|
||||
From 3d8874aaf5384818a51f158cd2880b7976c9a93a Mon Sep 17 00:00:00 2001
|
||||
From: Jan Grulich <jgrulich@redhat.com>
|
||||
Date: Wed, 26 Jul 2023 12:41:53 +0200
|
||||
Subject: [PATCH 05/22] Account for dark system themes in qt_fusionPalette
|
||||
|
||||
On Ubuntu (Gnome), the Fusion style didn't account for when a dark
|
||||
theme was set in the system's settings. Neither QGtk3Theme, nor
|
||||
QGnomeTheme (which it derives from) provide a palette() implementation,
|
||||
so they'd fall back to QPlatformTheme's. This default implementation
|
||||
calls QPlatformThemePrivate::initializeSystemPalette(), which uses
|
||||
qt_fusionPalette().
|
||||
|
||||
This patch accounts for QPlatformTheme::appearance() in
|
||||
qt_fusionPalette(), adjusting the palette roles accordingly
|
||||
to look correct when run under a dark theme.
|
||||
|
||||
This also fixes the same issue for the Fusion style in Qt Quick
|
||||
Controls.
|
||||
---
|
||||
src/gui/kernel/qpalette.cpp | 36 -------------------------
|
||||
src/gui/kernel/qplatformtheme.cpp | 44 ++++++++++++++++++++++++++++++-
|
||||
2 files changed, 43 insertions(+), 37 deletions(-)
|
||||
|
||||
diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp
|
||||
index a192b7aef4..0549f19699 100644
|
||||
--- a/src/gui/kernel/qpalette.cpp
|
||||
+++ b/src/gui/kernel/qpalette.cpp
|
||||
@@ -1164,42 +1164,6 @@ void QPalette::setColorGroup(ColorGroup cg, const QBrush &foreground, const QBru
|
||||
setBrush(cg, ToolTipText, toolTipText);
|
||||
}
|
||||
|
||||
-Q_GUI_EXPORT QPalette qt_fusionPalette()
|
||||
-{
|
||||
- QColor backGround(239, 239, 239);
|
||||
- QColor light = backGround.lighter(150);
|
||||
- QColor mid(backGround.darker(130));
|
||||
- QColor midLight = mid.lighter(110);
|
||||
- QColor base = Qt::white;
|
||||
- QColor disabledBase(backGround);
|
||||
- QColor dark = backGround.darker(150);
|
||||
- QColor darkDisabled = QColor(209, 209, 209).darker(110);
|
||||
- QColor text = Qt::black;
|
||||
- QColor hightlightedText = Qt::white;
|
||||
- QColor disabledText = QColor(190, 190, 190);
|
||||
- QColor button = backGround;
|
||||
- QColor shadow = dark.darker(135);
|
||||
- QColor disabledShadow = shadow.lighter(150);
|
||||
-
|
||||
- QPalette fusionPalette(Qt::black,backGround,light,dark,mid,text,base);
|
||||
- fusionPalette.setBrush(QPalette::Midlight, midLight);
|
||||
- fusionPalette.setBrush(QPalette::Button, button);
|
||||
- fusionPalette.setBrush(QPalette::Shadow, shadow);
|
||||
- fusionPalette.setBrush(QPalette::HighlightedText, hightlightedText);
|
||||
-
|
||||
- fusionPalette.setBrush(QPalette::Disabled, QPalette::Text, disabledText);
|
||||
- fusionPalette.setBrush(QPalette::Disabled, QPalette::WindowText, disabledText);
|
||||
- fusionPalette.setBrush(QPalette::Disabled, QPalette::ButtonText, disabledText);
|
||||
- fusionPalette.setBrush(QPalette::Disabled, QPalette::Base, disabledBase);
|
||||
- fusionPalette.setBrush(QPalette::Disabled, QPalette::Dark, darkDisabled);
|
||||
- fusionPalette.setBrush(QPalette::Disabled, QPalette::Shadow, disabledShadow);
|
||||
-
|
||||
- fusionPalette.setBrush(QPalette::Active, QPalette::Highlight, QColor(48, 140, 198));
|
||||
- fusionPalette.setBrush(QPalette::Inactive, QPalette::Highlight, QColor(48, 140, 198));
|
||||
- fusionPalette.setBrush(QPalette::Disabled, QPalette::Highlight, QColor(145, 145, 145));
|
||||
- return fusionPalette;
|
||||
-}
|
||||
-
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
QDebug operator<<(QDebug dbg, const QPalette &p)
|
||||
{
|
||||
diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp
|
||||
index 662fef1426..62f569bbef 100644
|
||||
--- a/src/gui/kernel/qplatformtheme.cpp
|
||||
+++ b/src/gui/kernel/qplatformtheme.cpp
|
||||
@@ -364,7 +364,49 @@ QPlatformThemePrivate::~QPlatformThemePrivate()
|
||||
delete systemPalette;
|
||||
}
|
||||
|
||||
-Q_GUI_EXPORT QPalette qt_fusionPalette();
|
||||
+Q_GUI_EXPORT QPalette qt_fusionPalette()
|
||||
+{
|
||||
+ const bool darkAppearance = QGuiApplicationPrivate::platformTheme()->appearance()
|
||||
+ == QPlatformTheme::Appearance::Dark;
|
||||
+ const QColor windowText = darkAppearance ? QColor(240, 240, 240) : Qt::black;
|
||||
+ const QColor backGround = darkAppearance ? QColor(50, 50, 50) : QColor(239, 239, 239);
|
||||
+ const QColor light = backGround.lighter(150);
|
||||
+ const QColor mid = (backGround.darker(130));
|
||||
+ const QColor midLight = mid.lighter(110);
|
||||
+ const QColor base = darkAppearance ? backGround.darker(140) : Qt::white;
|
||||
+ const QColor disabledBase(backGround);
|
||||
+ const QColor dark = backGround.darker(150);
|
||||
+ const QColor darkDisabled = QColor(209, 209, 209).darker(110);
|
||||
+ const QColor text = darkAppearance ? windowText : Qt::black;
|
||||
+ const QColor hightlightedText = darkAppearance ? windowText : Qt::white;
|
||||
+ const QColor disabledText = darkAppearance ? QColor(130, 130, 130) : QColor(190, 190, 190);
|
||||
+ const QColor button = backGround;
|
||||
+ const QColor shadow = dark.darker(135);
|
||||
+ const QColor disabledShadow = shadow.lighter(150);
|
||||
+ QColor placeholder = text;
|
||||
+ placeholder.setAlpha(128);
|
||||
+
|
||||
+ QPalette fusionPalette(windowText, backGround, light, dark, mid, text, base);
|
||||
+ fusionPalette.setBrush(QPalette::Midlight, midLight);
|
||||
+ fusionPalette.setBrush(QPalette::Button, button);
|
||||
+ fusionPalette.setBrush(QPalette::Shadow, shadow);
|
||||
+ fusionPalette.setBrush(QPalette::HighlightedText, hightlightedText);
|
||||
+
|
||||
+ fusionPalette.setBrush(QPalette::Disabled, QPalette::Text, disabledText);
|
||||
+ fusionPalette.setBrush(QPalette::Disabled, QPalette::WindowText, disabledText);
|
||||
+ fusionPalette.setBrush(QPalette::Disabled, QPalette::ButtonText, disabledText);
|
||||
+ fusionPalette.setBrush(QPalette::Disabled, QPalette::Base, disabledBase);
|
||||
+ fusionPalette.setBrush(QPalette::Disabled, QPalette::Dark, darkDisabled);
|
||||
+ fusionPalette.setBrush(QPalette::Disabled, QPalette::Shadow, disabledShadow);
|
||||
+
|
||||
+ fusionPalette.setBrush(QPalette::Active, QPalette::Highlight, QColor(48, 140, 198));
|
||||
+ fusionPalette.setBrush(QPalette::Inactive, QPalette::Highlight, QColor(48, 140, 198));
|
||||
+ fusionPalette.setBrush(QPalette::Disabled, QPalette::Highlight, QColor(145, 145, 145));
|
||||
+
|
||||
+ fusionPalette.setBrush(QPalette::PlaceholderText, placeholder);
|
||||
+
|
||||
+ return fusionPalette;
|
||||
+}
|
||||
|
||||
void QPlatformThemePrivate::initializeSystemPalette()
|
||||
{
|
||||
--
|
||||
2.41.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
From 232211f5867878e64bed10d4dff0f94a6326a94f Mon Sep 17 00:00:00 2001
|
||||
From f9d7c6b4157046a06f4ce04726e743d43ab711a2 Mon Sep 17 00:00:00 2001
|
||||
From: Jan Grulich <jgrulich@redhat.com>
|
||||
Date: Wed, 26 Jul 2023 15:38:38 +0200
|
||||
Subject: [PATCH 11/22] Gtk3Theme: set XCURSOR_SIZE and XCURSOR_THEME for
|
||||
Subject: [PATCH 05/15] Gtk3Theme: set XCURSOR_SIZE and XCURSOR_THEME for
|
||||
wayland sessions
|
||||
|
||||
GNOME doesn't set these for Wayland session and without those env
|
||||
@ -17,7 +17,7 @@ Qt Wayland QPA plugin still tries to load from those two envs.
|
||||
1 file changed, 15 insertions(+)
|
||||
|
||||
diff --git a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
|
||||
index 0e940ae690..8688fe205e 100644
|
||||
index 7540cb43cf..aceacda4b8 100644
|
||||
--- a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
|
||||
+++ b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
|
||||
@@ -41,6 +41,7 @@
|
||||
@ -26,9 +26,9 @@ index 0e940ae690..8688fe205e 100644
|
||||
#include "qpa/qwindowsysteminterface.h"
|
||||
+#include <QGuiApplication>
|
||||
#include <QVariant>
|
||||
#include <QtCore/qregularexpression.h>
|
||||
|
||||
@@ -121,6 +122,20 @@ QGtk3Theme::QGtk3Theme()
|
||||
#undef signals
|
||||
@@ -120,6 +121,20 @@ QGtk3Theme::QGtk3Theme()
|
||||
SETTING_CONNECT("gtk-application-prefer-dark-theme");
|
||||
SETTING_CONNECT("gtk-theme-name");
|
||||
#undef SETTING_CONNECT
|
@ -1,7 +1,7 @@
|
||||
From 753c0dea114812a2d3b721cb72fda1b49a3c38c2 Mon Sep 17 00:00:00 2001
|
||||
From ffab9df46c5f2cb411765f72ecd6f5dcdb62fbb4 Mon Sep 17 00:00:00 2001
|
||||
From: Jan Grulich <jgrulich@redhat.com>
|
||||
Date: Thu, 27 Jul 2023 11:54:44 +0200
|
||||
Subject: [PATCH 13/22] Re-implement palette, standardPixmap, file icons, fonts
|
||||
Subject: [PATCH 06/15] Re-implement palette, standardPixmap, file icons, fonts
|
||||
in QGtk3Theme
|
||||
|
||||
Read theme colors from GTK3 style context and build platform theme
|
||||
@ -19,9 +19,9 @@ and file icons.
|
||||
src/plugins/platformthemes/gtk3/qgtk3json_p.h | 102 ++
|
||||
.../platformthemes/gtk3/qgtk3storage.cpp | 470 +++++++
|
||||
.../platformthemes/gtk3/qgtk3storage_p.h | 234 ++++
|
||||
.../platformthemes/gtk3/qgtk3theme.cpp | 32 +-
|
||||
.../platformthemes/gtk3/qgtk3theme.cpp | 23 +
|
||||
src/plugins/platformthemes/gtk3/qgtk3theme.h | 8 +
|
||||
11 files changed, 3161 insertions(+), 3 deletions(-)
|
||||
11 files changed, 3155 insertions(+)
|
||||
create mode 100644 include/QtCore/5.15.10/QtCore/private/qflatmap_p.h
|
||||
create mode 100644 src/corelib/tools/qflatmap_p.h
|
||||
create mode 100644 src/plugins/platformthemes/gtk3/qgtk3interface.cpp
|
||||
@ -3220,10 +3220,10 @@ index 0000000000..57f6aeea96
|
||||
+QT_END_NAMESPACE
|
||||
+#endif // QGTK3STORAGE_H
|
||||
diff --git a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
|
||||
index c01947e402..5d9fc24d71 100644
|
||||
index aceacda4b8..ee6e0f3dd9 100644
|
||||
--- a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
|
||||
+++ b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
|
||||
@@ -136,6 +136,8 @@ QGtk3Theme::QGtk3Theme()
|
||||
@@ -135,6 +135,8 @@ QGtk3Theme::QGtk3Theme()
|
||||
qputenv("XCURSOR_THEME", cursorTheme.toUtf8());
|
||||
}
|
||||
}
|
||||
@ -3232,38 +3232,7 @@ index c01947e402..5d9fc24d71 100644
|
||||
}
|
||||
|
||||
static inline QVariant gtkGetLongPressTime()
|
||||
@@ -185,6 +187,8 @@ QString QGtk3Theme::gtkFontName() const
|
||||
|
||||
Qt::Appearance QGtk3Theme::appearance() const
|
||||
{
|
||||
+ if (m_storage)
|
||||
+ return m_storage->appearance();
|
||||
/*
|
||||
https://docs.gtk.org/gtk3/running.html
|
||||
|
||||
@@ -199,9 +203,9 @@ Qt::Appearance QGtk3Theme::appearance() const
|
||||
to override any other settings.
|
||||
*/
|
||||
QString themeName = qEnvironmentVariable("GTK_THEME");
|
||||
- const QRegularExpression darkRegex(QStringLiteral("[:-]dark"), QRegularExpression::CaseInsensitiveOption);
|
||||
if (!themeName.isEmpty())
|
||||
- return darkRegex.match(themeName).hasMatch() ? Qt::Appearance::Dark : Qt::Appearance::Light;
|
||||
+ return themeName.contains("dark", Qt::CaseInsensitive)
|
||||
+ ? Qt::Appearance::Dark : Qt::Appearance::Light;
|
||||
|
||||
/*
|
||||
https://docs.gtk.org/gtk3/property.Settings.gtk-application-prefer-dark-theme.html
|
||||
@@ -219,7 +223,8 @@ Qt::Appearance QGtk3Theme::appearance() const
|
||||
*/
|
||||
themeName = gtkSetting("gtk-theme-name");
|
||||
if (!themeName.isEmpty())
|
||||
- return darkRegex.match(themeName).hasMatch() ? Qt::Appearance::Dark : Qt::Appearance::Light;
|
||||
+ return themeName.contains("dark", Qt::CaseInsensitive)
|
||||
+ ? Qt::Appearance::Dark : Qt::Appearance::Light;
|
||||
|
||||
return Qt::Appearance::Unknown;
|
||||
}
|
||||
@@ -277,4 +282,25 @@ bool QGtk3Theme::useNativeFileDialog()
|
||||
@@ -235,4 +237,25 @@ bool QGtk3Theme::useNativeFileDialog()
|
||||
return gtk_check_version(3, 15, 5) == nullptr;
|
||||
}
|
||||
|
||||
@ -3290,7 +3259,7 @@ index c01947e402..5d9fc24d71 100644
|
||||
+
|
||||
QT_END_NAMESPACE
|
||||
diff --git a/src/plugins/platformthemes/gtk3/qgtk3theme.h b/src/plugins/platformthemes/gtk3/qgtk3theme.h
|
||||
index 89a3b98994..73f4399894 100644
|
||||
index 54296d2ff1..99e896c020 100644
|
||||
--- a/src/plugins/platformthemes/gtk3/qgtk3theme.h
|
||||
+++ b/src/plugins/platformthemes/gtk3/qgtk3theme.h
|
||||
@@ -41,6 +41,7 @@
|
||||
@ -3301,7 +3270,7 @@ index 89a3b98994..73f4399894 100644
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
@@ -60,9 +61,16 @@ public:
|
||||
@@ -58,9 +59,16 @@ public:
|
||||
QPlatformMenu* createPlatformMenu() const override;
|
||||
QPlatformMenuItem* createPlatformMenuItem() const override;
|
||||
|
@ -1,49 +0,0 @@
|
||||
From 84b0d114d98c58ecf00e20987321182e8e2ba4c1 Mon Sep 17 00:00:00 2001
|
||||
From: Jan Grulich <jgrulich@redhat.com>
|
||||
Date: Wed, 26 Jul 2023 12:44:00 +0200
|
||||
Subject: [PATCH 06/22] qt_fusionPalette: make links more legible on dark
|
||||
backgrounds
|
||||
|
||||
QPalette's default for Link is Qt::blue, which is difficult to read
|
||||
on dark backgrounds.
|
||||
|
||||
Use the same blue that is already used for Highlight, as it is
|
||||
consistent and easy to read.
|
||||
---
|
||||
src/gui/kernel/qplatformtheme.cpp | 9 +++++++--
|
||||
1 file changed, 7 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp
|
||||
index 62f569bbef..14fdf94755 100644
|
||||
--- a/src/gui/kernel/qplatformtheme.cpp
|
||||
+++ b/src/gui/kernel/qplatformtheme.cpp
|
||||
@@ -378,6 +378,7 @@ Q_GUI_EXPORT QPalette qt_fusionPalette()
|
||||
const QColor dark = backGround.darker(150);
|
||||
const QColor darkDisabled = QColor(209, 209, 209).darker(110);
|
||||
const QColor text = darkAppearance ? windowText : Qt::black;
|
||||
+ const QColor highlight = QColor(48, 140, 198);
|
||||
const QColor hightlightedText = darkAppearance ? windowText : Qt::white;
|
||||
const QColor disabledText = darkAppearance ? QColor(130, 130, 130) : QColor(190, 190, 190);
|
||||
const QColor button = backGround;
|
||||
@@ -399,12 +400,16 @@ Q_GUI_EXPORT QPalette qt_fusionPalette()
|
||||
fusionPalette.setBrush(QPalette::Disabled, QPalette::Dark, darkDisabled);
|
||||
fusionPalette.setBrush(QPalette::Disabled, QPalette::Shadow, disabledShadow);
|
||||
|
||||
- fusionPalette.setBrush(QPalette::Active, QPalette::Highlight, QColor(48, 140, 198));
|
||||
- fusionPalette.setBrush(QPalette::Inactive, QPalette::Highlight, QColor(48, 140, 198));
|
||||
+ fusionPalette.setBrush(QPalette::Active, QPalette::Highlight, highlight);
|
||||
+ fusionPalette.setBrush(QPalette::Inactive, QPalette::Highlight, highlight);
|
||||
fusionPalette.setBrush(QPalette::Disabled, QPalette::Highlight, QColor(145, 145, 145));
|
||||
|
||||
fusionPalette.setBrush(QPalette::PlaceholderText, placeholder);
|
||||
|
||||
+ // Use a more legible light blue on dark backgrounds than the default Qt::blue.
|
||||
+ if (darkAppearance)
|
||||
+ fusionPalette.setBrush(QPalette::Link, highlight);
|
||||
+
|
||||
return fusionPalette;
|
||||
}
|
||||
|
||||
--
|
||||
2.41.0
|
||||
|
@ -1,29 +0,0 @@
|
||||
From dff40b9fed2b91244d6664342daf859b3aa0375f Mon Sep 17 00:00:00 2001
|
||||
From: Jan Grulich <jgrulich@redhat.com>
|
||||
Date: Wed, 26 Jul 2023 12:44:37 +0200
|
||||
Subject: [PATCH 07/22] Add nullptr check for theme when initializing palette
|
||||
|
||||
---
|
||||
src/gui/kernel/qplatformtheme.cpp | 6 ++++--
|
||||
1 file changed, 4 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp
|
||||
index 14fdf94755..827829c4a5 100644
|
||||
--- a/src/gui/kernel/qplatformtheme.cpp
|
||||
+++ b/src/gui/kernel/qplatformtheme.cpp
|
||||
@@ -366,8 +366,10 @@ QPlatformThemePrivate::~QPlatformThemePrivate()
|
||||
|
||||
Q_GUI_EXPORT QPalette qt_fusionPalette()
|
||||
{
|
||||
- const bool darkAppearance = QGuiApplicationPrivate::platformTheme()->appearance()
|
||||
- == QPlatformTheme::Appearance::Dark;
|
||||
+ auto theme = QGuiApplicationPrivate::platformTheme();
|
||||
+ const bool darkAppearance = theme
|
||||
+ ? theme->appearance() == QPlatformTheme::Appearance::Dark
|
||||
+ : false;
|
||||
const QColor windowText = darkAppearance ? QColor(240, 240, 240) : Qt::black;
|
||||
const QColor backGround = darkAppearance ? QColor(50, 50, 50) : QColor(239, 239, 239);
|
||||
const QColor light = backGround.lighter(150);
|
||||
--
|
||||
2.41.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
From 376815da4038c757a42f316c4cb7e2a6793fec00 Mon Sep 17 00:00:00 2001
|
||||
From c05835195cb9c0eb811625e048a52d09ffef255f Mon Sep 17 00:00:00 2001
|
||||
From: Jan Grulich <jgrulich@redhat.com>
|
||||
Date: Thu, 27 Jul 2023 12:35:44 +0200
|
||||
Subject: [PATCH 14/22] GTK3 theme: simplify code
|
||||
Subject: [PATCH 07/15] GTK3 theme: simplify code
|
||||
|
||||
There's no need to first convert to QString and then convert back to
|
||||
QByteArray.
|
||||
@ -10,10 +10,10 @@ QByteArray.
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
|
||||
index 5d9fc24d71..fcd466f768 100644
|
||||
index ee6e0f3dd9..5f5fee4f3b 100644
|
||||
--- a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
|
||||
+++ b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
|
||||
@@ -128,7 +128,7 @@ QGtk3Theme::QGtk3Theme()
|
||||
@@ -127,7 +127,7 @@ QGtk3Theme::QGtk3Theme()
|
||||
if (qEnvironmentVariableIsEmpty("XCURSOR_SIZE")) {
|
||||
const int cursorSize = gtkSetting<gint>("gtk-cursor-theme-size");
|
||||
if (cursorSize > 0)
|
@ -1,7 +1,7 @@
|
||||
From 40d1e750fd1b0f646724b383928b8f70a7a3abe8 Mon Sep 17 00:00:00 2001
|
||||
From 99fd51406053e789b9e02dd5fdbf63d79cb4d7ff Mon Sep 17 00:00:00 2001
|
||||
From: Jan Grulich <jgrulich@redhat.com>
|
||||
Date: Thu, 27 Jul 2023 12:36:14 +0200
|
||||
Subject: [PATCH 15/22] Fix checkbox and radiobutton background in QGtk3Theme
|
||||
Subject: [PATCH 08/15] Fix checkbox and radiobutton background in QGtk3Theme
|
||||
|
||||
The background color for radio buttons and checkboxes was not
|
||||
correctly read from the current GTK3 theme in light mode.
|
@ -1,202 +0,0 @@
|
||||
From 240ce954220d713968e608f2766144c7657bceed Mon Sep 17 00:00:00 2001
|
||||
From: Jan Grulich <jgrulich@redhat.com>
|
||||
Date: Wed, 26 Jul 2023 12:56:06 +0200
|
||||
Subject: [PATCH 08/22] Replace QPlatformTheme::Appearance by Qt:Appearance
|
||||
|
||||
With the introduction of Qt:Appearance, its predecessor in
|
||||
QPlatformTheme has become redundant.
|
||||
|
||||
This patch replaces all occurrences of QPlatformTheme::Appearance with
|
||||
the new enum class.
|
||||
---
|
||||
src/gui/kernel/qplatformtheme.cpp | 6 +++---
|
||||
src/gui/kernel/qplatformtheme.h | 8 +-------
|
||||
src/plugins/platforms/cocoa/qcocoatheme.h | 2 +-
|
||||
src/plugins/platforms/cocoa/qcocoatheme.mm | 4 ++--
|
||||
src/plugins/platforms/windows/qwindowstheme.cpp | 4 ++--
|
||||
src/plugins/platforms/windows/qwindowstheme.h | 2 +-
|
||||
src/plugins/platformthemes/gtk3/qgtk3theme.cpp | 10 +++++-----
|
||||
src/plugins/platformthemes/gtk3/qgtk3theme.h | 2 +-
|
||||
src/plugins/styles/mac/qmacstyle_mac.mm | 2 +-
|
||||
9 files changed, 17 insertions(+), 23 deletions(-)
|
||||
|
||||
diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp
|
||||
index 827829c4a5..6dd7d5c923 100644
|
||||
--- a/src/gui/kernel/qplatformtheme.cpp
|
||||
+++ b/src/gui/kernel/qplatformtheme.cpp
|
||||
@@ -368,7 +368,7 @@ Q_GUI_EXPORT QPalette qt_fusionPalette()
|
||||
{
|
||||
auto theme = QGuiApplicationPrivate::platformTheme();
|
||||
const bool darkAppearance = theme
|
||||
- ? theme->appearance() == QPlatformTheme::Appearance::Dark
|
||||
+ ? theme->appearance() == Qt::Appearance::Dark
|
||||
: false;
|
||||
const QColor windowText = darkAppearance ? QColor(240, 240, 240) : Qt::black;
|
||||
const QColor backGround = darkAppearance ? QColor(50, 50, 50) : QColor(239, 239, 239);
|
||||
@@ -448,9 +448,9 @@ QPlatformDialogHelper *QPlatformTheme::createPlatformDialogHelper(DialogType typ
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
-QPlatformTheme::Appearance QPlatformTheme::appearance() const
|
||||
+Qt::Appearance QPlatformTheme::appearance() const
|
||||
{
|
||||
- return Appearance::Unknown;
|
||||
+ return Qt::Appearance::Unknown;
|
||||
}
|
||||
|
||||
const QPalette *QPlatformTheme::palette(Palette type) const
|
||||
diff --git a/src/gui/kernel/qplatformtheme.h b/src/gui/kernel/qplatformtheme.h
|
||||
index c0dee4c581..41213bf32b 100644
|
||||
--- a/src/gui/kernel/qplatformtheme.h
|
||||
+++ b/src/gui/kernel/qplatformtheme.h
|
||||
@@ -131,12 +131,6 @@ public:
|
||||
MessageDialog
|
||||
};
|
||||
|
||||
- enum class Appearance {
|
||||
- Unknown = 0x0000,
|
||||
- Light = 0x0001,
|
||||
- Dark = 0x0002
|
||||
- };
|
||||
-
|
||||
enum Palette {
|
||||
SystemPalette,
|
||||
ToolTipPalette,
|
||||
@@ -326,7 +320,7 @@ public:
|
||||
virtual QString standardButtonText(int button) const;
|
||||
virtual QKeySequence standardButtonShortcut(int button) const;
|
||||
|
||||
- virtual Appearance appearance() const;
|
||||
+ virtual Qt::Appearance appearance() const;
|
||||
|
||||
static QVariant defaultThemeHint(ThemeHint hint);
|
||||
static QString defaultStandardButtonText(int button);
|
||||
diff --git a/src/plugins/platforms/cocoa/qcocoatheme.h b/src/plugins/platforms/cocoa/qcocoatheme.h
|
||||
index f719fd943b..78ff7cb51c 100644
|
||||
--- a/src/plugins/platforms/cocoa/qcocoatheme.h
|
||||
+++ b/src/plugins/platforms/cocoa/qcocoatheme.h
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
QIcon fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions options = {}) const override;
|
||||
|
||||
QVariant themeHint(ThemeHint hint) const override;
|
||||
- Appearance appearance() const override;
|
||||
+ Qt::Appearance appearance() const override;
|
||||
QString standardButtonText(int button) const override;
|
||||
QKeySequence standardButtonShortcut(int button) const override;
|
||||
|
||||
diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm
|
||||
index a79fa4e4b9..cd2e7ef90a 100644
|
||||
--- a/src/plugins/platforms/cocoa/qcocoatheme.mm
|
||||
+++ b/src/plugins/platforms/cocoa/qcocoatheme.mm
|
||||
@@ -544,9 +544,9 @@ QVariant QCocoaTheme::themeHint(ThemeHint hint) const
|
||||
return QPlatformTheme::themeHint(hint);
|
||||
}
|
||||
|
||||
-QPlatformTheme::Appearance QCocoaTheme::appearance() const
|
||||
+Qt::Appearance QCocoaTheme::appearance() const
|
||||
{
|
||||
- return qt_mac_applicationIsInDarkMode() ? Appearance::Dark : Appearance::Light;
|
||||
+ return qt_mac_applicationIsInDarkMode() ? Qt::Appearance::Dark : Qt::Appearance::Light;
|
||||
}
|
||||
|
||||
QString QCocoaTheme::standardButtonText(int button) const
|
||||
diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp
|
||||
index 510b8746da..5d006e6ba9 100644
|
||||
--- a/src/plugins/platforms/windows/qwindowstheme.cpp
|
||||
+++ b/src/plugins/platforms/windows/qwindowstheme.cpp
|
||||
@@ -520,9 +520,9 @@ QVariant QWindowsTheme::themeHint(ThemeHint hint) const
|
||||
return QPlatformTheme::themeHint(hint);
|
||||
}
|
||||
|
||||
-QPlatformTheme::Appearance QWindowsTheme::appearance() const
|
||||
+Qt::Appearance QWindowsTheme::appearance() const
|
||||
{
|
||||
- return QWindowsContext::isDarkMode() ? Appearance::Dark : Appearance::Light;
|
||||
+ return QWindowsContext::isDarkMode() ? Qt::Appearance::Dark : Qt::Appearance::Light;
|
||||
}
|
||||
|
||||
void QWindowsTheme::clearPalettes()
|
||||
diff --git a/src/plugins/platforms/windows/qwindowstheme.h b/src/plugins/platforms/windows/qwindowstheme.h
|
||||
index 9d5fcc92fe..ea72c96049 100644
|
||||
--- a/src/plugins/platforms/windows/qwindowstheme.h
|
||||
+++ b/src/plugins/platforms/windows/qwindowstheme.h
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
#endif
|
||||
QVariant themeHint(ThemeHint) const override;
|
||||
|
||||
- Appearance appearance() const override;
|
||||
+ Qt::Appearance appearance() const override;
|
||||
|
||||
const QPalette *palette(Palette type = SystemPalette) const override
|
||||
{ return m_palettes[type]; }
|
||||
diff --git a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
|
||||
index a47720384c..2a70d5f3dd 100644
|
||||
--- a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
|
||||
+++ b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
|
||||
@@ -148,7 +148,7 @@ QString QGtk3Theme::gtkFontName() const
|
||||
return QGnomeTheme::gtkFontName();
|
||||
}
|
||||
|
||||
-QPlatformTheme::Appearance QGtk3Theme::appearance() const
|
||||
+Qt::Appearance QGtk3Theme::appearance() const
|
||||
{
|
||||
/*
|
||||
https://docs.gtk.org/gtk3/running.html
|
||||
@@ -166,7 +166,7 @@ QPlatformTheme::Appearance QGtk3Theme::appearance() const
|
||||
QString themeName = qEnvironmentVariable("GTK_THEME");
|
||||
const QRegularExpression darkRegex(QStringLiteral("[:-]dark"), QRegularExpression::CaseInsensitiveOption);
|
||||
if (!themeName.isEmpty())
|
||||
- return darkRegex.match(themeName).hasMatch() ? Appearance::Dark : Appearance::Light;
|
||||
+ return darkRegex.match(themeName).hasMatch() ? Qt::Appearance::Dark : Qt::Appearance::Light;
|
||||
|
||||
/*
|
||||
https://docs.gtk.org/gtk3/property.Settings.gtk-application-prefer-dark-theme.html
|
||||
@@ -177,16 +177,16 @@ QPlatformTheme::Appearance QGtk3Theme::appearance() const
|
||||
*/
|
||||
const auto preferDark = gtkSetting<bool>("gtk-application-prefer-dark-theme");
|
||||
if (preferDark)
|
||||
- return Appearance::Dark;
|
||||
+ return Qt::Appearance::Dark;
|
||||
|
||||
/*
|
||||
https://docs.gtk.org/gtk3/property.Settings.gtk-theme-name.html
|
||||
*/
|
||||
themeName = gtkSetting("gtk-theme-name");
|
||||
if (!themeName.isEmpty())
|
||||
- return darkRegex.match(themeName).hasMatch() ? Appearance::Dark : Appearance::Light;
|
||||
+ return darkRegex.match(themeName).hasMatch() ? Qt::Appearance::Dark : Qt::Appearance::Light;
|
||||
|
||||
- return Appearance::Unknown;
|
||||
+ return Qt::Appearance::Unknown;
|
||||
}
|
||||
|
||||
bool QGtk3Theme::usePlatformNativeDialog(DialogType type) const
|
||||
diff --git a/src/plugins/platformthemes/gtk3/qgtk3theme.h b/src/plugins/platformthemes/gtk3/qgtk3theme.h
|
||||
index 5f439067af..89a3b98994 100644
|
||||
--- a/src/plugins/platformthemes/gtk3/qgtk3theme.h
|
||||
+++ b/src/plugins/platformthemes/gtk3/qgtk3theme.h
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
virtual QVariant themeHint(ThemeHint hint) const override;
|
||||
virtual QString gtkFontName() const override;
|
||||
|
||||
- Appearance appearance() const override;
|
||||
+ Qt::Appearance appearance() const override;
|
||||
|
||||
bool usePlatformNativeDialog(DialogType type) const override;
|
||||
QPlatformDialogHelper *createPlatformDialogHelper(DialogType type) const override;
|
||||
diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm
|
||||
index 4171e08286..fa748eb38a 100644
|
||||
--- a/src/plugins/styles/mac/qmacstyle_mac.mm
|
||||
+++ b/src/plugins/styles/mac/qmacstyle_mac.mm
|
||||
@@ -303,7 +303,7 @@ static const qreal titleBarButtonSpacing = 8;
|
||||
// active: window is active
|
||||
// selected: tab is selected
|
||||
// hovered: tab is hovered
|
||||
-bool isDarkMode() { return qt_mac_applicationIsInDarkMode(); }
|
||||
+bool isDarkMode() { return QGuiApplicationPrivate::platformTheme()->appearance() == Qt::Appearance::Dark; }
|
||||
|
||||
#if QT_CONFIG(tabbar)
|
||||
static const QColor lightTabBarTabBackgroundActive(190, 190, 190);
|
||||
--
|
||||
2.41.0
|
||||
|
51
0009-Cleanup-QGtk3Theme.patch
Normal file
51
0009-Cleanup-QGtk3Theme.patch
Normal file
@ -0,0 +1,51 @@
|
||||
From 41d23f13c9aede66a6c9044869b0ef5f52f7d71d Mon Sep 17 00:00:00 2001
|
||||
From: Jan Grulich <jgrulich@redhat.com>
|
||||
Date: Thu, 27 Jul 2023 12:38:53 +0200
|
||||
Subject: [PATCH 09/15] Cleanup QGtk3Theme
|
||||
|
||||
1. Remove unused include.
|
||||
2. Replace unnecessary null checks with asserts.
|
||||
3. Remove dead code after the cleanup.
|
||||
---
|
||||
src/plugins/platformthemes/gtk3/qgtk3theme.cpp | 12 ++++++++----
|
||||
1 file changed, 8 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
|
||||
index 5f5fee4f3b..0de9dd3866 100644
|
||||
--- a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
|
||||
+++ b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
|
||||
@@ -239,23 +239,27 @@ bool QGtk3Theme::useNativeFileDialog()
|
||||
|
||||
const QPalette *QGtk3Theme::palette(Palette type) const
|
||||
{
|
||||
- return m_storage ? m_storage->palette(type) : QPlatformTheme::palette(type);
|
||||
+ Q_ASSERT(m_storage);
|
||||
+ return m_storage->palette(type);
|
||||
}
|
||||
|
||||
QPixmap QGtk3Theme::standardPixmap(StandardPixmap sp, const QSizeF &size) const
|
||||
{
|
||||
- return m_storage ? m_storage->standardPixmap(sp, size) : QPlatformTheme::standardPixmap(sp, size);
|
||||
+ Q_ASSERT(m_storage);
|
||||
+ return m_storage->standardPixmap(sp, size);
|
||||
}
|
||||
|
||||
const QFont *QGtk3Theme::font(Font type) const
|
||||
{
|
||||
- return m_storage ? m_storage->font(type) : QGnomeTheme::font(type);
|
||||
+ Q_ASSERT(m_storage);
|
||||
+ return m_storage->font(type);
|
||||
}
|
||||
|
||||
QIcon QGtk3Theme::fileIcon(const QFileInfo &fileInfo,
|
||||
QPlatformTheme::IconOptions iconOptions) const
|
||||
{
|
||||
- return m_storage ? m_storage->fileIcon(fileInfo) : QGnomeTheme::fileIcon(fileInfo, iconOptions);
|
||||
+ Q_ASSERT(m_storage);
|
||||
+ return m_storage->fileIcon(fileInfo);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
--
|
||||
2.41.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
From 8f256a33fa60b249ee6fc7347f917f29a11c1e32 Mon Sep 17 00:00:00 2001
|
||||
From f0117fa2110e8b6d71c82272fda1d264e7921a24 Mon Sep 17 00:00:00 2001
|
||||
From: Jan Grulich <jgrulich@redhat.com>
|
||||
Date: Thu, 27 Jul 2023 12:40:32 +0200
|
||||
Subject: [PATCH 17/22] Detect appearance by colors unless GTK theme name
|
||||
Subject: [PATCH 10/15] Detect appearance by colors unless GTK theme name
|
||||
contains "dark"
|
||||
|
||||
QGtk3Theme detects the appearance property by theme name: If the name
|
@ -1,7 +1,7 @@
|
||||
From d998c808ece0fb3e243bb28913a27bbedf0db974 Mon Sep 17 00:00:00 2001
|
||||
From 85d72b8bf0db7349dafce252d18ce17677eef46e Mon Sep 17 00:00:00 2001
|
||||
From: Jan Grulich <jgrulich@redhat.com>
|
||||
Date: Thu, 27 Jul 2023 12:41:06 +0200
|
||||
Subject: [PATCH 18/22] Change parsing log output in QGtk3Json from qCDebug to
|
||||
Subject: [PATCH 11/15] Change parsing log output in QGtk3Json from qCDebug to
|
||||
qCInfo
|
||||
|
||||
When a palette mapping is imported from a Json file, parsing errors are
|
@ -1,7 +1,7 @@
|
||||
From fa0c84d609a44aa630dbbb498ffe3bf11326647e Mon Sep 17 00:00:00 2001
|
||||
From a2c6ba19ea2aafd1ec92fdd150ac14fe2424a394 Mon Sep 17 00:00:00 2001
|
||||
From: Jan Grulich <jgrulich@redhat.com>
|
||||
Date: Thu, 27 Jul 2023 12:42:04 +0200
|
||||
Subject: [PATCH 19/22] Document QGtk3Interface
|
||||
Subject: [PATCH 12/15] Document QGtk3Interface
|
||||
|
||||
Add internal documentation to header and implementation of
|
||||
QGtk3Interface
|
@ -1,29 +0,0 @@
|
||||
From dc373fc0d7dc14107e06aca4b5664c830d681494 Mon Sep 17 00:00:00 2001
|
||||
From: Jan Grulich <jgrulich@redhat.com>
|
||||
Date: Wed, 26 Jul 2023 15:39:31 +0200
|
||||
Subject: [PATCH 12/22] Gtk3: fix stack smashing on mismatch between bool and
|
||||
gboolean
|
||||
|
||||
Glib is written in C and predates C99 (though not really, glib 2.0 was
|
||||
released in 2002), so it defines gboolean as int, a 4-byte type. C++'s
|
||||
bool is a 1-byte type, so this caused a buffer overflow.
|
||||
---
|
||||
src/plugins/platformthemes/gtk3/qgtk3theme.cpp | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
|
||||
index 8688fe205e..c01947e402 100644
|
||||
--- a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
|
||||
+++ b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
|
||||
@@ -210,7 +210,7 @@ Qt::Appearance QGtk3Theme::appearance() const
|
||||
gtk-theme-name provides both light and dark variants. We can save a
|
||||
regex check by testing this property first.
|
||||
*/
|
||||
- const auto preferDark = gtkSetting<bool>("gtk-application-prefer-dark-theme");
|
||||
+ const auto preferDark = gtkSetting<gboolean>("gtk-application-prefer-dark-theme");
|
||||
if (preferDark)
|
||||
return Qt::Appearance::Dark;
|
||||
|
||||
--
|
||||
2.41.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
From 65aff839101ef829c14b69a815a34eeda00abd3e Mon Sep 17 00:00:00 2001
|
||||
From f5e74db1b5245814d5993b6b16d58274ca8b89ab Mon Sep 17 00:00:00 2001
|
||||
From: Jan Grulich <jgrulich@redhat.com>
|
||||
Date: Thu, 27 Jul 2023 12:42:49 +0200
|
||||
Subject: [PATCH 20/22] Document QGtk3Storage
|
||||
Subject: [PATCH 13/15] Document QGtk3Storage
|
||||
|
||||
Add internal documentation to header and implementation of
|
||||
QGtk3Storage
|
@ -1,7 +1,7 @@
|
||||
From dfb10f3d3b689c172e53a94074b696d1eb9e6acd Mon Sep 17 00:00:00 2001
|
||||
From 9628ad303ad924255a224fdcc113ff8264172fc7 Mon Sep 17 00:00:00 2001
|
||||
From: Jan Grulich <jgrulich@redhat.com>
|
||||
Date: Thu, 27 Jul 2023 12:44:11 +0200
|
||||
Subject: [PATCH 21/22] QGtk3Theme: Improve fixed font delivery
|
||||
Subject: [PATCH 14/15] QGtk3Theme: Improve fixed font delivery
|
||||
|
||||
The gtk_fixed widget was used as a reference to obtain a fixed font
|
||||
and HeaderViewFont.
|
@ -1,7 +1,7 @@
|
||||
From 410808ea61b30e886830bc8bdc0db562eb0b56b4 Mon Sep 17 00:00:00 2001
|
||||
From 6a9a896ae86a69a3c8bcbaaf7e2e2fd2105723a4 Mon Sep 17 00:00:00 2001
|
||||
From: Jan Grulich <jgrulich@redhat.com>
|
||||
Date: Thu, 27 Jul 2023 12:44:31 +0200
|
||||
Subject: [PATCH 22/22] QGtk3Theme: Do not default Active WindowText to button
|
||||
Subject: [PATCH 15/15] QGtk3Theme: Do not default Active WindowText to button
|
||||
foreground
|
||||
|
||||
QGtk3Theme uses the GTK button foreground as a default for the
|
@ -1,108 +0,0 @@
|
||||
From 615966a0e855712898ba92681a08825f4b322e4b Mon Sep 17 00:00:00 2001
|
||||
From: Jan Grulich <jgrulich@redhat.com>
|
||||
Date: Thu, 27 Jul 2023 12:38:53 +0200
|
||||
Subject: [PATCH 16/22] Cleanup QGtk3Theme
|
||||
|
||||
1. Remove unused include.
|
||||
2. Replace unnecessary null checks with asserts.
|
||||
3. Remove dead code after the cleanup.
|
||||
---
|
||||
.../platformthemes/gtk3/qgtk3theme.cpp | 55 ++++---------------
|
||||
1 file changed, 10 insertions(+), 45 deletions(-)
|
||||
|
||||
diff --git a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
|
||||
index fcd466f768..d3383097fc 100644
|
||||
--- a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
|
||||
+++ b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
|
||||
@@ -43,7 +43,6 @@
|
||||
#include "qpa/qwindowsysteminterface.h"
|
||||
#include <QGuiApplication>
|
||||
#include <QVariant>
|
||||
-#include <QtCore/qregularexpression.h>
|
||||
|
||||
#undef signals
|
||||
#include <gtk/gtk.h>
|
||||
@@ -187,46 +186,8 @@ QString QGtk3Theme::gtkFontName() const
|
||||
|
||||
Qt::Appearance QGtk3Theme::appearance() const
|
||||
{
|
||||
- if (m_storage)
|
||||
- return m_storage->appearance();
|
||||
- /*
|
||||
- https://docs.gtk.org/gtk3/running.html
|
||||
-
|
||||
- It's possible to set a theme variant after the theme name when using GTK_THEME:
|
||||
-
|
||||
- GTK_THEME=Adwaita:dark
|
||||
-
|
||||
- Some themes also have "-dark" as part of their name.
|
||||
-
|
||||
- We test this environment variable first because the documentation says
|
||||
- it's mainly used for easy debugging, so it should be possible to use it
|
||||
- to override any other settings.
|
||||
- */
|
||||
- QString themeName = qEnvironmentVariable("GTK_THEME");
|
||||
- if (!themeName.isEmpty())
|
||||
- return themeName.contains("dark", Qt::CaseInsensitive)
|
||||
- ? Qt::Appearance::Dark : Qt::Appearance::Light;
|
||||
-
|
||||
- /*
|
||||
- https://docs.gtk.org/gtk3/property.Settings.gtk-application-prefer-dark-theme.html
|
||||
-
|
||||
- This setting controls which theme is used when the theme specified by
|
||||
- gtk-theme-name provides both light and dark variants. We can save a
|
||||
- regex check by testing this property first.
|
||||
- */
|
||||
- const auto preferDark = gtkSetting<gboolean>("gtk-application-prefer-dark-theme");
|
||||
- if (preferDark)
|
||||
- return Qt::Appearance::Dark;
|
||||
-
|
||||
- /*
|
||||
- https://docs.gtk.org/gtk3/property.Settings.gtk-theme-name.html
|
||||
- */
|
||||
- themeName = gtkSetting("gtk-theme-name");
|
||||
- if (!themeName.isEmpty())
|
||||
- return themeName.contains("dark", Qt::CaseInsensitive)
|
||||
- ? Qt::Appearance::Dark : Qt::Appearance::Light;
|
||||
-
|
||||
- return Qt::Appearance::Unknown;
|
||||
+ Q_ASSERT(m_storage);
|
||||
+ return m_storage->appearance();
|
||||
}
|
||||
|
||||
bool QGtk3Theme::usePlatformNativeDialog(DialogType type) const
|
||||
@@ -284,23 +245,27 @@ bool QGtk3Theme::useNativeFileDialog()
|
||||
|
||||
const QPalette *QGtk3Theme::palette(Palette type) const
|
||||
{
|
||||
- return m_storage ? m_storage->palette(type) : QPlatformTheme::palette(type);
|
||||
+ Q_ASSERT(m_storage);
|
||||
+ return m_storage->palette(type);
|
||||
}
|
||||
|
||||
QPixmap QGtk3Theme::standardPixmap(StandardPixmap sp, const QSizeF &size) const
|
||||
{
|
||||
- return m_storage ? m_storage->standardPixmap(sp, size) : QPlatformTheme::standardPixmap(sp, size);
|
||||
+ Q_ASSERT(m_storage);
|
||||
+ return m_storage->standardPixmap(sp, size);
|
||||
}
|
||||
|
||||
const QFont *QGtk3Theme::font(Font type) const
|
||||
{
|
||||
- return m_storage ? m_storage->font(type) : QGnomeTheme::font(type);
|
||||
+ Q_ASSERT(m_storage);
|
||||
+ return m_storage->font(type);
|
||||
}
|
||||
|
||||
QIcon QGtk3Theme::fileIcon(const QFileInfo &fileInfo,
|
||||
QPlatformTheme::IconOptions iconOptions) const
|
||||
{
|
||||
- return m_storage ? m_storage->fileIcon(fileInfo) : QGnomeTheme::fileIcon(fileInfo, iconOptions);
|
||||
+ Q_ASSERT(m_storage);
|
||||
+ return m_storage->fileIcon(fileInfo);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
--
|
||||
2.41.0
|
||||
|
@ -57,7 +57,7 @@
|
||||
Name: qt5-qtbase
|
||||
Summary: Qt5 - QtBase components
|
||||
Version: 5.15.10
|
||||
Release: 7%{?dist}
|
||||
Release: 8%{?dist}
|
||||
|
||||
# See LGPL_EXCEPTIONS.txt, for exception details
|
||||
License: LGPL-3.0-only OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
@ -156,27 +156,20 @@ Patch150: 0001-Use-Wayland-by-default-on-GNOME.patch
|
||||
|
||||
# https://fedoraproject.org/wiki/Changes/NoCustomQtThemingForWorkstation
|
||||
# https://bugzilla.redhat.com/show_bug.cgi?id=2226797
|
||||
Patch151: 0002-Add-QPlatformTheme-Appearance-for-detecting-light-da.patch
|
||||
Patch152: 0003-Add-enum-class-Qt-Appearance.patch
|
||||
Patch153: 0004-QGtk3Theme-implement-appearance-function-to-detect-d.patch
|
||||
Patch154: 0005-Account-for-dark-system-themes-in-qt_fusionPalette.patch
|
||||
Patch155: 0006-qt_fusionPalette-make-links-more-legible-on-dark-bac.patch
|
||||
Patch156: 0007-Add-nullptr-check-for-theme-when-initializing-palett.patch
|
||||
Patch157: 0008-Replace-QPlatformTheme-Appearance-by-Qt-Appearance.patch
|
||||
Patch158: 0009-Sync-and-assert-StandardPixmap-enums-in-QPlatformThe.patch
|
||||
Patch159: 0010-QGtk3Theme-subscribe-to-theme-hint-changes.patch
|
||||
Patch160: 0011-Gtk3Theme-set-XCURSOR_SIZE-and-XCURSOR_THEME-for-way.patch
|
||||
Patch161: 0012-Gtk3-fix-stack-smashing-on-mismatch-between-bool-and.patch
|
||||
Patch162: 0013-Re-implement-palette-standardPixmap-file-icons-fonts.patch
|
||||
Patch163: 0014-GTK3-theme-simplify-code.patch
|
||||
Patch164: 0015-Fix-checkbox-and-radiobutton-background-in-QGtk3Them.patch
|
||||
Patch165: 0016-Cleanup-QGtk3Theme.patch
|
||||
Patch166: 0017-Detect-appearance-by-colors-unless-GTK-theme-name-co.patch
|
||||
Patch167: 0018-Change-parsing-log-output-in-QGtk3Json-from-qCDebug-.patch
|
||||
Patch168: 0019-Document-QGtk3Interface.patch
|
||||
Patch169: 0020-Document-QGtk3Storage.patch
|
||||
Patch170: 0021-QGtk3Theme-Improve-fixed-font-delivery.patch
|
||||
Patch171: 0022-QGtk3Theme-Do-not-default-Active-WindowText-to-butto.patch
|
||||
Patch151: 0002-Add-enum-class-Qt-Appearance.patch
|
||||
Patch152: 0003-Sync-and-assert-StandardPixmap-enums-in-QPlatformThe.patch
|
||||
Patch153: 0004-QGtk3Theme-subscribe-to-theme-hint-changes.patch
|
||||
Patch154: 0005-Gtk3Theme-set-XCURSOR_SIZE-and-XCURSOR_THEME-for-way.patch
|
||||
Patch155: 0006-Re-implement-palette-standardPixmap-file-icons-fonts.patch
|
||||
Patch156: 0007-GTK3-theme-simplify-code.patch
|
||||
Patch157: 0008-Fix-checkbox-and-radiobutton-background-in-QGtk3Them.patch
|
||||
Patch158: 0009-Cleanup-QGtk3Theme.patch
|
||||
Patch159: 0010-Detect-appearance-by-colors-unless-GTK-theme-name-co.patch
|
||||
Patch160: 0011-Change-parsing-log-output-in-QGtk3Json-from-qCDebug-.patch
|
||||
Patch161: 0012-Document-QGtk3Interface.patch
|
||||
Patch162: 0013-Document-QGtk3Storage.patch
|
||||
Patch163: 0014-QGtk3Theme-Improve-fixed-font-delivery.patch
|
||||
Patch164: 0015-QGtk3Theme-Do-not-default-Active-WindowText-to-butto.patch
|
||||
|
||||
# Latest QGnomePlatform needs to be specified to be used
|
||||
Patch200: qtbase-use-qgnomeplatform-as-default-platform-theme-on-gnome.patch
|
||||
@ -478,13 +471,6 @@ Qt5 libraries used for drawing widgets and OpenGL items.
|
||||
%patch -P162 -p1
|
||||
%patch -P163 -p1
|
||||
%patch -P164 -p1
|
||||
%patch -P165 -p1
|
||||
%patch -P166 -p1
|
||||
%patch -P167 -p1
|
||||
%patch -P168 -p1
|
||||
%patch -P169 -p1
|
||||
%patch -P170 -p1
|
||||
%patch -P171 -p1
|
||||
%endif
|
||||
|
||||
%if 0%{?fedora} < 39
|
||||
@ -1170,6 +1156,9 @@ fi
|
||||
|
||||
|
||||
%changelog
|
||||
* Tue Aug 22 2023 Jan Grulich <jgrulich@redhat.com> - 5.15.10-8
|
||||
- Drop QPlatformTheme::Appearance() backports breaking ABI
|
||||
|
||||
* Mon Aug 21 2023 Jan Grulich <jgrulich@redhat.com> - 5.15.10-7
|
||||
- Drop unnecessary backports
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user