aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTor Arne Vestbø <[email protected]>2025-04-15 12:05:12 +0200
committerTor Arne Vestbø <[email protected]>2025-04-22 22:43:30 +0200
commit457958b4cd68ed38a40cc8e6732f0032496a7bac (patch)
treed5722264f4ad31329128b11977177d8b6aa4a380 /src
parentaefd01697767bda646c597ff774d87e899436ee1 (diff)
Use platform theme's palette in macOS style
Unlike most other styles the macOS style didn't initialize QQuickTheme with a style specific palette (either directly or via a custom theme class). Instead, we would indirectly pick up the platform theme palette when QQuickStylePlugin::createTheme called QQuickStylePrivate::readPalette to read palette settings, as we then default-constructed a QPalette, which picks up its colors from QGuiApplicationPrivate::app_pal, which in turn is based on platform theme palette, via QGuiApp's basePalette. However QQuickStylePlugin::createTheme only initialized the System palette of QQuickTheme, which meant that we failed to use any role specific palettes that the platform theme provided. In addition, because we only initialized the palette once, when creating the theme, we failed to pick up any changes to the platform theme's palette. To fix this we simply tell the QQuickTheme to prefer the platform theme for its palette, which means any query to the theme will go through the platform theme. This also means we don't need to hook into QtQuickControls2StylePlugin::updateTheme() to re-initialize the palette. Technically we do have the same problem with the theme's fonts, but for that we don't have a way to instruct the theme to use the platform theme. Pick-to: 6.9 6.8 6.5 Change-Id: I56eb278a80b184397114282839e958d61bd0028e Reviewed-by: Shawn Rutledge <[email protected]> Reviewed-by: Doris Verria <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/quickcontrols/macos/qtquickcontrols2macosstyleplugin.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/quickcontrols/macos/qtquickcontrols2macosstyleplugin.cpp b/src/quickcontrols/macos/qtquickcontrols2macosstyleplugin.cpp
index ec67ffa4dc..6b1c12fdab 100644
--- a/src/quickcontrols/macos/qtquickcontrols2macosstyleplugin.cpp
+++ b/src/quickcontrols/macos/qtquickcontrols2macosstyleplugin.cpp
@@ -4,6 +4,7 @@
#include <QtQml/qqml.h>
#include <QtQuickControls2/private/qquickstyleplugin_p.h>
#include <QtQuickControls2/qquickstyle.h>
+#include <private/qquicktheme_p.h>
QT_BEGIN_NAMESPACE
@@ -34,8 +35,10 @@ QString QtQuickControls2MacOSStylePlugin::name() const
return QStringLiteral("macOS");
}
-void QtQuickControls2MacOSStylePlugin::initializeTheme(QQuickTheme */*theme*/)
+void QtQuickControls2MacOSStylePlugin::initializeTheme(QQuickTheme *theme)
{
+ Q_ASSERT(theme);
+ theme->setUsePlatformPalette(true);
}
QT_END_NAMESPACE