diff options
author | Santhosh Kumar <santhosh.kumar.selvaraj@qt.io> | 2023-01-24 10:49:53 +0100 |
---|---|---|
committer | Santhosh Kumar <santhosh.kumar.selvaraj@qt.io> | 2023-02-02 14:57:18 +0100 |
commit | 9a1b7c7fa59a5033344dd0b67b28de3531c92d69 (patch) | |
tree | e692be497b3fc271879af019447e3b5a0762b54b /src/plugins/styles | |
parent | 0b20f243f7efbd612d41bab8c2000e6c9fcb13e9 (diff) |
Reset dark palettes for widgets to light in windows style
Windows theme in dark mode set dark palettes for checkbox,
radiobutton, menu, menubar explicitly. The fix added as part of
a2518b4140ed88a674bf4a4fcf4576e35c698bb9 (to use light palette for
windows style) overrides only system palette and widget specific
palettes are still with dark palettes.
In this patch, the windows style overwrite dark with light palette
for widgets that are explicitly set with dark palette in windows
theme.
Fixes: QTBUG-110432
Pick-to: 6.5
Change-Id: I2af0e517d62981f062244eeab8f1b5e5442cc451
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/plugins/styles')
-rw-r--r-- | src/plugins/styles/windowsvista/qwindowsvistastyle.cpp | 35 | ||||
-rw-r--r-- | src/plugins/styles/windowsvista/qwindowsvistastyle_p.h | 1 |
2 files changed, 36 insertions, 0 deletions
diff --git a/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp b/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp index fc612c82e5..f884afc5b4 100644 --- a/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp +++ b/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp @@ -4814,6 +4814,41 @@ void QWindowsVistaStyle::polish(QPalette &pal) /*! \internal */ +void QWindowsVistaStyle::polish(QApplication *app) +{ + // Override windows theme palettes to light + if (qApp->styleHints()->appearance() == Qt::Appearance::Dark) { + static const char* themedWidgets[] = { + "QToolButton", + "QAbstractButton", + "QCheckBox", + "QRadioButton", + "QHeaderView", + "QAbstractItemView", + "QMessageBoxLabel", + "QTabBar", + "QLabel", + "QGroupBox", + "QMenu", + "QMenuBar", + "QTextEdit", + "QTextControl", + "QLineEdit" + }; + for (const auto& themedWidget : std::as_const(themedWidgets)) { + auto defaultResolveMask = QApplication::palette().resolveMask(); + auto widgetResolveMask = QApplication::palette(themedWidget).resolveMask(); + if (widgetResolveMask != defaultResolveMask) + QApplication::setPalette(QApplication::palette(), themedWidget); + } + } + + QWindowsStyle::polish(app); +} + +/*! + \internal + */ QPixmap QWindowsVistaStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *option, const QWidget *widget) const { diff --git a/src/plugins/styles/windowsvista/qwindowsvistastyle_p.h b/src/plugins/styles/windowsvista/qwindowsvistastyle_p.h index b600491248..c437b3e434 100644 --- a/src/plugins/styles/windowsvista/qwindowsvistastyle_p.h +++ b/src/plugins/styles/windowsvista/qwindowsvistastyle_p.h @@ -58,6 +58,7 @@ public: void polish(QWidget *widget) override; void unpolish(QWidget *widget) override; void polish(QPalette &pal) override; + void polish(QApplication *app) override; private: Q_DISABLE_COPY_MOVE(QWindowsVistaStyle) |