diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-12-07 17:39:39 +0100 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-12-08 17:56:48 +0100 |
commit | 13784450d1a192ecef14615318fd5a605ff0323e (patch) | |
tree | 3abc7959f0291ce9efac37f06f61fc49d65eb05a /src/widgets/styles/qwindowsstyle.cpp | |
parent | a2518b4140ed88a674bf4a4fcf4576e35c698bb9 (diff) |
Remove QWindowsStylePrivate:isDarkMode
The only usage of that function is to decide whether we should etch
disabled text. That should depend on the actual palette we are using,
not on a system setting (that might be ignored by an application or
style overwriting the palette).
Since styleHint might be called without option and widget, fall back to
the application default palette if needed.
Change-Id: Icf90eb4198890c613dccea6188733e74995962c5
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/widgets/styles/qwindowsstyle.cpp')
-rw-r--r-- | src/widgets/styles/qwindowsstyle.cpp | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index 63b1e85483..e48e17ed3b 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -93,21 +93,6 @@ qreal QWindowsStylePrivate::appDevicePixelRatio() return qApp->devicePixelRatio(); } -bool QWindowsStylePrivate::isDarkMode() -{ - bool result = false; -#ifdef Q_OS_WIN - using QWindowsApplication = QNativeInterface::Private::QWindowsApplication; - // Windows only: Return whether dark mode style support is desired and - // dark mode is in effect. - if (auto windowsApp = dynamic_cast<QWindowsApplication *>(QGuiApplicationPrivate::platformIntegration())) { - result = windowsApp->isDarkMode() - && windowsApp->darkModeHandling().testFlag(QWindowsApplication::DarkModeStyle); - } -#endif - return result; -} - // Returns \c true if the toplevel parent of \a widget has seen the Alt-key bool QWindowsStylePrivate::hasSeenAlt(const QWidget *widget) const { @@ -514,9 +499,14 @@ int QWindowsStyle::styleHint(StyleHint hint, const QStyleOption *opt, const QWid int ret = 0; switch (hint) { - case SH_EtchDisabledText: - ret = d_func()->isDarkMode() ? 0 : 1; + case SH_EtchDisabledText: { + const QPalette pal = opt ? opt->palette + : widget ? widget->palette() + : QPalette(); + ret = pal.window().color().lightness() > pal.text().color().lightness() + ? 1 : 0; break; + } case SH_Slider_SnapToValue: case SH_PrintDialog_RightAlignButtons: case SH_FontDialog_SelectAssociatedText: |