From 6e8b6250e73c90d1e37a8ae65ad22bc4143f6b85 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Fri, 28 Feb 2025 22:02:36 +0100 Subject: [PATCH] Windows11Style: Don't modify palette for QCommandLinkButton in polish() The windows vista style modifies the palette for a QCommandLinkButton to match the vista style. For windows11 we simply use the same color as for a normal button so no need to modify the palette is needed. Since the vista style does not reset the palette on style change, the wrong color is still used in the widgetsgallery example when switching from vista to win11 (or fusion). Pick-to: 6.9 6.8 Task-number: QTBUG-130480 Change-Id: I963215295ee1d2e483b5b58045752474c920c64b Reviewed-by: Oliver Wolff Reviewed-by: Wladimir Leuschner --- src/plugins/styles/modernwindows/qwindows11style.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/plugins/styles/modernwindows/qwindows11style.cpp b/src/plugins/styles/modernwindows/qwindows11style.cpp index 53848f1698a..b5a82e4dc47 100644 --- a/src/plugins/styles/modernwindows/qwindows11style.cpp +++ b/src/plugins/styles/modernwindows/qwindows11style.cpp @@ -2186,7 +2186,8 @@ int QWindows11Style::pixelMetric(PixelMetric metric, const QStyleOption *option, void QWindows11Style::polish(QWidget* widget) { - QWindowsVistaStyle::polish(widget); + if (!qobject_cast(widget)) + QWindowsVistaStyle::polish(widget); const bool isScrollBar = qobject_cast(widget); if (isScrollBar || qobject_cast(widget) || widget->inherits("QComboBoxPrivateContainer")) { bool wasCreated = widget->testAttribute(Qt::WA_WState_Created); @@ -2214,12 +2215,6 @@ void QWindows11Style::polish(QWidget* widget) QLineEdit *le = cb->lineEdit(); le->setFrame(false); } - } else if (qobject_cast(widget)) { - widget->setProperty("_qt_usingVistaStyle",false); - QPalette pal = widget->palette(); - pal.setColor(QPalette::ButtonText, pal.text().color()); - pal.setColor(QPalette::BrightText, pal.text().color()); - widget->setPalette(pal); } else if (qobject_cast(widget) && !qobject_cast(widget)) { QPalette pal = widget->palette(); pal.setColor(QPalette::Base, pal.window().color()); @@ -2242,7 +2237,8 @@ void QWindows11Style::polish(QWidget* widget) void QWindows11Style::unpolish(QWidget *widget) { - QWindowsVistaStyle::unpolish(widget); + if (!qobject_cast(widget)) + QWindowsVistaStyle::unpolish(widget); if (const auto *scrollarea = qobject_cast(widget); scrollarea #if QT_CONFIG(mdiarea)