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(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; }