qt6-bb10/tests/auto/widgets/kernel
Volker Hilsheimer 95d4e6baba ColorScheme: make QStyleHints::colorScheme writable for applications
Applications can request the color scheme to be either explicitly light
or dark, or to follow the system default by setting the scheme to
Qt::ColorScheme::Unknown.

Setting the color scheme will make the request to the QPlatformTheme
implementation, which can then use the appropriate implementation to
set the application's appearance so that both palette and window
decoration follow the requested color scheme. This should trigger
theme change and palette change events. A change to the effective
scheme should then call back into QStyleHintsPrivate::updateColorScheme,
which will emit the changed signal for the property.

Implement this for macOS (Cocoa), iOS, Android, and Windows.

On macOS, we have to use deprecated AppKit APIs; the replacements for
those APIs are not suitable for this use case. On iOS, the setting is
for each UIWindow, which we can update or initialize based on an
explicitly requested scheme.

On Android we can piggy-back on the logic added when dark theme support
was introduced in b4a9bb1f6a.

On Windows, we have to fake a dark palette if the dark scheme is
requested on a light system, as there is no API to read a dark palette.
However, we also have to ignore any application preference if a high-
contrast accessibility theme is selected by the user (we report the
color scheme as unknown; there are both light and dark high-contrast
themes), and read the system palette using the GetSysColor API, which
is used for light mode. And we need to initialize windows with the
correct frame if the application explicitly overrides the system color
scheme.

Add an auto-test to the QApplication test, as that gives us the most
coverage to confirm that QStyleHints emits the changed signal, and that
Theme- and PaletteChange events are received by the toplevel widget
when the color scheme actually changes. This test has to be skipped
on platforms where we cannot set the color scheme programmatically.

Add the option to explicitly select the color scheme to the widget
gallery example, and default it to dark mode.

Fixes: QTBUG-124490
Change-Id: I7302993c0121284bf9d3b72e3149c6abbe6bd261
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2024-05-10 01:15:12 +02:00
..
qaction tst_QAction::disableShortcutsWithBlockedWidgets remove setActiveWindow 2024-04-30 18:30:16 +02:00
qactiongroup Change license for tests files 2024-02-04 09:56:42 +01:00
qapplication ColorScheme: make QStyleHints::colorScheme writable for applications 2024-05-10 01:15:12 +02:00
qboxlayout Remove extra semi-colons 2024-02-06 20:17:18 +09:00
qformlayout Change license for tests files 2024-02-04 09:56:42 +01:00
qgesturerecognizer Change license for tests files 2024-02-04 09:56:42 +01:00
qgridlayout Change license for tests files 2024-02-04 09:56:42 +01:00
qlayout QLayout: Consume ChildRemoved event, when layout is disabled 2024-04-10 19:01:06 +00:00
qshortcut tst_QShortcut::duplicatedShortcutOverride() remove setActiveWindow() 2024-04-26 17:37:57 +02:00
qsizepolicy Change license for tests files 2024-02-04 09:56:42 +01:00
qstackedlayout tst_QStackedLayout::keepFocusAfterSetCurrent() remove setActiveWindow() 2024-05-06 16:29:02 +02:00
qtooltip tst_QTooltip::qtbug64550_stylesheet() remove setActiveWindow() 2024-04-26 18:19:37 +02:00
qwidget QWidget: fix render() in RTL mode 2024-05-08 19:58:17 +02:00
qwidget_window tst_QWidget_window::tst_dnd() remove setActiveWindow() 2024-04-26 18:19:37 +02:00
qwidgetaction Change license for tests files 2024-02-04 09:56:42 +01:00
qwidgetmetatype Change license for tests files 2024-02-04 09:56:42 +01:00
qwidgetrepaintmanager Decouple rate-limiting of paint-on-screen widgets from top level widget 2024-04-04 01:26:56 +02:00
qwidgetsvariant Change license for tests files 2024-02-04 09:56:42 +01:00
qwindowcontainer Set focus to the window container when contained window gains focus 2024-04-22 16:01:01 +02:00
CMakeLists.txt tests: Remove remains of qmake conversion from CMakeLists.txt files 2023-02-17 21:56:49 +01:00