From 43ef22045c6f4fbf76d5cfa4ca32160d919b9984 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Tue, 12 Jul 2022 10:15:52 +0200 Subject: Windows: Turn on dark mode support by default The implementation was already there, and handles theme changes at runtime as well. However, it was disabled unless the QPA parameter "darkmode" was set to either 1 (supporting only the frame) or 2 (the Windows theme also supports dark mode when reading the palette). With both Windows 10 and Windows 11 now having dark mode as a fully supported feature that is easily accessible to end-users, we should respect that setting by default. So change the default: support both dark window frames and palette, and let users turn this partially off by setting darkmode=1 or darkmode=0. This does not mean accent colors etc are fully supported by the Windows styles. [ChangeLog][QtGui][Windows] Dark mode, both for the window frames and for the palette, is now supported by default. It can be turned off (partially or entirely) by setting the QPA parameter "darkmode=0" (no dark mode support) or "darkmode=1" (darkmode support only for the window frames). Pick-to: 6.4 Fixes: QTBUG-72028 Change-Id: Ia55af101896c106cde21340b306aa81390e608a2 Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowsintegration.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index f1874b37bb..40b264d186 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -188,8 +188,11 @@ static inline unsigned parseOptions(const QStringList ¶mList, options |= QWindowsIntegration::DontUseWMPointer; } else if (param == u"reverse") { options |= QWindowsIntegration::RtlEnabled; + } else if (param == u"darkmode=0") { + *darkModeHandling = {}; } else if (param == u"darkmode=1") { darkModeHandling->setFlag(DarkModeHandlingFlag::DarkModeWindowFrames); + darkModeHandling->setFlag(DarkModeHandlingFlag::DarkModeStyle, false); } else if (param == u"darkmode=2") { darkModeHandling->setFlag(DarkModeHandlingFlag::DarkModeWindowFrames); darkModeHandling->setFlag(DarkModeHandlingFlag::DarkModeStyle); @@ -209,7 +212,8 @@ void QWindowsIntegrationPrivate::parseOptions(QWindowsIntegration *q, const QStr QtWindows::ProcessDpiAwareness dpiAwareness = QtWindows::ProcessPerMonitorV2DpiAware; int tabletAbsoluteRange = -1; - DarkModeHandling darkModeHandling; + DarkModeHandling darkModeHandling = DarkModeHandlingFlag::DarkModeWindowFrames + | DarkModeHandlingFlag::DarkModeStyle; m_options = ::parseOptions(paramList, &tabletAbsoluteRange, &dpiAwareness, &darkModeHandling); q->setDarkModeHandling(darkModeHandling); QWindowsFontDatabase::setFontOptions(m_options); -- cgit v1.2.3