WindowsQPA: Respect ENV and cmdline darkmode overrides
Currently the commandline and environment parameters (windows:darkmode) for setting the darkmode handling are ignored when the application starts. This patch adds a condition to QWindowsTheme::effectiveColorScheme that checks whether darkmode handling was explicitly overridden and initializes in the constructor the m_colorScheme with the result of passing Qt::ColorScheme::Unknown toeffectiveColorScheme. Fixes: QTBUG-127135 Change-Id: I365d26c66fdb3a754832cb7c579aeebecab093fd Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> (cherry picked from commit 2ced94b4100c03c5feb7d5b1c0006c9fc451e944) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
b33e0eac97
commit
31367fd2c8
@ -483,7 +483,8 @@ QWindowsTheme *QWindowsTheme::m_instance = nullptr;
|
||||
QWindowsTheme::QWindowsTheme()
|
||||
{
|
||||
m_instance = this;
|
||||
s_colorScheme = QWindowsTheme::queryColorScheme();
|
||||
s_colorScheme = Qt::ColorScheme::Unknown;
|
||||
s_colorScheme = QWindowsTheme::effectiveColorScheme();
|
||||
std::fill(m_fonts, m_fonts + NFonts, nullptr);
|
||||
std::fill(m_palettes, m_palettes + NPalettes, nullptr);
|
||||
refresh();
|
||||
@ -578,12 +579,15 @@ Qt::ColorScheme QWindowsTheme::colorScheme() const
|
||||
|
||||
Qt::ColorScheme QWindowsTheme::effectiveColorScheme()
|
||||
{
|
||||
auto integration = QWindowsIntegration::instance();
|
||||
if (queryHighContrast())
|
||||
return Qt::ColorScheme::Unknown;
|
||||
if (s_colorSchemeOverride != Qt::ColorScheme::Unknown)
|
||||
return s_colorSchemeOverride;
|
||||
if (s_colorScheme != Qt::ColorScheme::Unknown)
|
||||
return s_colorScheme;
|
||||
if (!integration->darkModeHandling().testFlag(QWindowsApplication::DarkModeStyle))
|
||||
return Qt::ColorScheme::Light;
|
||||
return queryColorScheme();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user