diff options
author | Volker Hilsheimer <[email protected]> | 2022-12-07 17:39:39 +0100 |
---|---|---|
committer | Volker Hilsheimer <[email protected]> | 2022-12-08 17:56:48 +0100 |
commit | 13784450d1a192ecef14615318fd5a605ff0323e (patch) | |
tree | 3abc7959f0291ce9efac37f06f61fc49d65eb05a | |
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ø <[email protected]>
-rw-r--r-- | src/widgets/styles/qwindowsstyle.cpp | 24 | ||||
-rw-r--r-- | src/widgets/styles/qwindowsstyle_p_p.h | 1 |
2 files changed, 7 insertions, 18 deletions
diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index 63b1e854835..e48e17ed3b9 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: diff --git a/src/widgets/styles/qwindowsstyle_p_p.h b/src/widgets/styles/qwindowsstyle_p_p.h index 7d6eb2963e6..0c0350c3d22 100644 --- a/src/widgets/styles/qwindowsstyle_p_p.h +++ b/src/widgets/styles/qwindowsstyle_p_p.h @@ -38,7 +38,6 @@ public: static qreal devicePixelRatio(const QWidget *widget = nullptr) { return widget ? widget->devicePixelRatio() : QWindowsStylePrivate::appDevicePixelRatio(); } static qreal nativeMetricScaleFactor(const QWidget *widget = nullptr); - static bool isDarkMode(); bool hasSeenAlt(const QWidget *widget) const; bool altDown() const { return alt_down; } |