qt6-bb10/src/plugins/platforms/windows
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
..
images
openglblacklists openglblacklists: Fix typo in description 2021-10-12 23:15:45 +02:00
uiautomation Use QComObject with QWindowsUiaMainProvider 2024-04-18 15:25:21 +02:00
CMakeLists.txt Remove QWindowsComBase 2024-04-19 14:54:17 +02:00
main.cpp Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qtwindowsglobal.h Rename QtWindows::KeyboardLayoutChangeEven -> InputLanguageChangeEvent 2023-09-29 20:22:34 +02:00
qwin10helpers.cpp Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qwin10helpers.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qwindowsapplication.cpp ColorScheme: remove unused QWindowsApplication::isDarkMode 2024-04-25 17:18:25 +02:00
qwindowsapplication.h ColorScheme: remove unused QWindowsApplication::isDarkMode 2024-04-25 17:18:25 +02:00
qwindowsbackingstore.cpp Fix a regression when painting CMYK over ARGB32_Premultiplied 2024-04-04 18:27:41 +02:00
qwindowsbackingstore.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qwindowsclipboard.cpp Windows: centralize how we handle error messages 2022-11-16 19:44:43 +08:00
qwindowsclipboard.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qwindowscontext.cpp ColorScheme: consolidate dark mode handling on Windows into Theme 2024-04-25 17:18:22 +02:00
qwindowscontext.h ColorScheme: consolidate dark mode handling on Windows into Theme 2024-04-25 17:18:22 +02:00
qwindowscursor.cpp QWindowsCursor: create correct DDB in createBitmapCursor() 2023-12-14 04:39:06 +01:00
qwindowscursor.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qwindowsdialoghelpers.cpp Replace QWindowsComBase with QComObject 2024-02-27 22:26:02 +01:00
qwindowsdialoghelpers.h Windows: fix crash on closing an app when native file dialog is opened 2022-06-03 09:34:19 +03:00
qwindowsdrag.cpp Replace QWindowsComBase with QComObject 2024-02-27 22:26:02 +01:00
qwindowsdrag.h Replace QWindowsComBase with QComObject 2024-02-27 22:26:02 +01:00
qwindowsdropdataobject.cpp platform plugins: use string view types more 2023-10-08 11:38:41 +03:00
qwindowsdropdataobject.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qwindowsgdiintegration.cpp Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qwindowsgdiintegration.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qwindowsgdinativeinterface.cpp Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qwindowsgdinativeinterface.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qwindowsglcontext.cpp windows: Remove workaround for delayed OpenGL initialization 2024-03-01 20:41:29 +01:00
qwindowsglcontext.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qwindowsiconengine.cpp WindowsIconEngine: Use the correct icon for document-properties 2024-04-12 19:55:30 +00:00
qwindowsiconengine.h QIcon: clean up Windows and Android icon engines 2023-12-07 12:39:06 +01:00
qwindowsinputcontext.cpp Remove QT_MAKE_UNCHECKED_ARRAY_ITERATOR 2023-12-07 22:56:30 +01:00
qwindowsinputcontext.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qwindowsintegration.cpp Windows: Prevent potential "crash" in setApplicationBadge 2024-04-26 12:55:34 +02:00
qwindowsintegration.h Windows: Default to DirectWrite font backend 2024-02-06 13:04:26 +01:00
qwindowsinternalmimedata.cpp Reintroduce converter APIs for supporting native clipboard formats 2022-11-16 22:14:00 +01:00
qwindowsinternalmimedata.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qwindowskeymapper.cpp Windows: use MSG timestamps for input events 2024-04-03 21:29:41 +01:00
qwindowskeymapper.h Implement QWindowsKeyMapper in terms of QPlatformKeyMapper 2023-10-09 19:24:07 +02:00
qwindowsmenu.cpp QtGui: Add a header declaring the Windows image conversion functions 2023-02-08 21:13:08 +01:00
qwindowsmenu.h Remove redundant QPair includes 2023-09-06 17:24:40 +00:00
qwindowsmimeregistry.cpp platforms/windows: use qimage rvalue overloads more 2023-09-18 10:14:33 +03:00
qwindowsmimeregistry.h Reintroduce converter APIs for supporting native clipboard formats 2022-11-16 22:14:00 +01:00
qwindowsmousehandler.cpp Windows: use MSG timestamps for input events 2024-04-03 21:29:41 +01:00
qwindowsmousehandler.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qwindowsnativeinterface.cpp Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qwindowsnativeinterface.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qwindowsole.cpp Rename QWindowsMimeConverter to QWindowsMimeRegistry, rename files 2022-11-03 17:29:07 +01:00
qwindowsole.h Replace QWindowsComBase with QComObject 2024-02-27 22:26:02 +01:00
qwindowsopenglcontext.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qwindowsopengltester.cpp Fix building with disabled OpenGL after switching to the syncqt tool 2022-09-29 17:18:55 +03:00
qwindowsopengltester.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qwindowspointerhandler.cpp Windows: use MSG timestamps for input events 2024-04-03 21:29:41 +01:00
qwindowspointerhandler.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qwindowsscreen.cpp Remove ambiguity in handling of registry keys from setupAPI.h 2023-11-17 23:29:00 +01:00
qwindowsscreen.h Make some QScreen native interfaces public 2023-12-08 14:53:37 +01:00
qwindowsservices.cpp platform plugins: use string view types more 2023-10-08 11:38:41 +03:00
qwindowsservices.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qwindowssessionmanager.cpp Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qwindowssessionmanager.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qwindowssystemtrayicon.cpp Unify behavior of QSystemTrayIcon::geometry for hidden icons on Windows 2024-04-10 21:01:06 +02:00
qwindowssystemtrayicon.h Unify behavior of QSystemTrayIcon::geometry for hidden icons on Windows 2024-04-10 21:01:06 +02:00
qwindowstabletsupport.cpp Implement QWindowsKeyMapper in terms of QPlatformKeyMapper 2023-10-09 19:24:07 +02:00
qwindowstabletsupport.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qwindowstheme.cpp ColorScheme: make QStyleHints::colorScheme writable for applications 2024-05-10 01:15:12 +02:00
qwindowstheme.h ColorScheme: make QStyleHints::colorScheme writable for applications 2024-05-10 01:15:12 +02:00
qwindowsthreadpoolrunner.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qwindowsvulkaninstance.cpp Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qwindowsvulkaninstance.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qwindowswindow.cpp ColorScheme: make QStyleHints::colorScheme writable for applications 2024-05-10 01:15:12 +02:00
qwindowswindow.h windows: Remove workaround for delayed OpenGL initialization 2024-03-01 20:41:29 +01:00
windows.json