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
Change-Id: I2af0e517d62981f062244eeab8f1b5e5442cc451
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 9a1b7c7fa59a5033344dd0b67b28de3531c92d69)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Santhosh Kumar 2023-01-24 10:49:53 +01:00 committed by Qt Cherry-pick Bot
parent a70ebbc670
commit 451995ba5e
2 changed files with 36 additions and 0 deletions

View File

@ -4819,6 +4819,41 @@ void QWindowsVistaStyle::polish(QPalette &pal)
pal.setBrush(QPalette::AlternateBase, pal.base().color().darker(104));
}
/*!
\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
*/

View File

@ -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)