Commit c95566f
committed
GUI: forward styling/theming relevant events to the QStyleHints object
QStyleHints is a singleton that provides both Widgets and Quick with
information about system properties, including the color scheme. The
system palette and font however are provided by QGuiApplication, which
informs all windows via events when those change.
The styling infrastructure in Qt Quick Controls knows about QStyleHints,
but QGuiApplication only knows about the list of QWindow instances.
There is no specific "style object" that QGuiApplication knows about and
could inform about theme changes. On the Widgets side, QApplication
knows about the QStyle instance, and uses polishing to let the style
adjust the palette.
This makes it cumbersome for Qt Quick Control styles to react to changes
to global theme attributes like the palette or the font, as we would
either have to filter events on QGuiApplication - very costly as all
events to all objects pass through such an event filter - or maintain a
list of windows to filter events on.
QStyleHints is the most appropriate object we have for a UI-framework
independent global "style object" that can get informed about theme
changes using the established event machinery. It makes sense to forward
theming-related events to this object, which then allows Qt Quick
Controls to filter events on that instance, avoiding the cost of an
application event filter.
Since the QApplication test case counts exact number of events seen by
a global event filter, adjust it by first flushing the events that now
get posted to QStyleHints when the palette gets initialized, and then
including the additional event seen by the filter.
It also provides us with an opportunity to clean up the entanglement of
QPlatformTheme implementations updating the QStyleHints object directly
when accessibility settings or color scheme changes: this could now be
done in a QStyleHints::event implementation, assuming that such changes
are going through event delivery. This is left for a future commit. For
now, we simply send relevant events to the QStyleHints object to enable
fixes and improvements in Qt Quick Controls' system theme awareness.
Pick-to: 6.8
Task-number: QTBUG-140507
Change-Id: Ib00bdb2f31fa124b572b68dd195253baafff3d3d
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 8e7b97b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit ed0e2f9)
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>1 parent b9f112a commit c95566f
File tree
2 files changed
+8
-3
lines changed- src/gui/kernel
- tests/auto/widgets/kernel/qapplication
2 files changed
+8
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2076 | 2076 | | |
2077 | 2077 | | |
2078 | 2078 | | |
| 2079 | + | |
2079 | 2080 | | |
2080 | 2081 | | |
2081 | 2082 | | |
2082 | 2083 | | |
2083 | 2084 | | |
2084 | 2085 | | |
| 2086 | + | |
2085 | 2087 | | |
2086 | 2088 | | |
2087 | 2089 | | |
| |||
Lines changed: 6 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
263 | 263 | | |
264 | 264 | | |
265 | 265 | | |
| 266 | + | |
266 | 267 | | |
267 | 268 | | |
268 | 269 | | |
| |||
273 | 274 | | |
274 | 275 | | |
275 | 276 | | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
276 | 282 | | |
277 | 283 | | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | 284 | | |
282 | 285 | | |
283 | 286 | | |
| |||
0 commit comments