From 074a4e16a3899652247714fc18881e97e4fcdaed Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Fri, 9 Dec 2022 14:33:13 +0100 Subject: [PATCH] Windows: Enable dark mode system palette by default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Can be overwritten by setting the "darkmode" parameter of the QPA platform to 0 or 1. The Windows Vista style (which is the default on Windows) will overwrite the platform theme's palette with the light system palette (see a2518b4140ed88a674bf4a4fcf4576e35c698bb9), but styles that support rendering in dark mode will just run with the dark palette. More work needed in qtdeclarative to make the Qt Quick native style for Windows also overwrite the palette, and to handle palette changes in Qt. [ChangeLog][Windows] Qt applications that use a style that supports dark mode rendering (such as the classic Windows or Fusion styles) will respect the dark appearance setting on Windows. Applications that use the Vista style, which doesn't support rendering in dark mode, will use the light system palette. On dark mode systems, the window frame will be dark if the palette is dark. Task-number: QTBUG-72028 Change-Id: I416b4fd59eb3f64701b403984c7ac2359536abbe Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qguiapplication.cpp | 3 +++ src/plugins/platforms/windows/qwindowsintegration.cpp | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index fd7739b06f7..e5144b514ae 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -572,6 +572,9 @@ static QWindowGeometrySpecification windowGeometrySpecification = Q_WINDOW_GEOME experimental pending the introduction of new style that properly adapts to dark mode. + As of Qt 6.5, the default value is 2; to disable dark mode + support, set the value to 0 or 1. + \li \c {dialogs=[xp|none]}, \c xp uses XP-style native dialogs and \c none disables them. diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 1bddcb43638..51f040e719e 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -233,7 +233,8 @@ void QWindowsIntegrationPrivate::parseOptions(QWindowsIntegration *q, const QStr QtWindows::ProcessDpiAwareness dpiAwareness = QtWindows::ProcessPerMonitorV2DpiAware; int tabletAbsoluteRange = -1; - DarkModeHandling darkModeHandling = DarkModeHandlingFlag::DarkModeWindowFrames; + DarkModeHandling darkModeHandling = DarkModeHandlingFlag::DarkModeWindowFrames + | DarkModeHandlingFlag::DarkModeStyle; m_options = ::parseOptions(paramList, &tabletAbsoluteRange, &dpiAwareness, &darkModeHandling); q->setDarkModeHandling(darkModeHandling); QWindowsFontDatabase::setFontOptions(m_options);