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.8
Task-number: QTBUG-130480
Change-Id: I963215295ee1d2e483b5b58045752474c920c64b
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
(cherry picked from commit 6e8b6250e73c90d1e37a8ae65ad22bc4143f6b85)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Christian Ehrlicher 2025-02-28 22:02:36 +01:00 committed by Qt Cherry-pick Bot
parent f06b8f1779
commit 1b0b5c3280

View File

@ -2186,7 +2186,8 @@ int QWindows11Style::pixelMetric(PixelMetric metric, const QStyleOption *option,
void QWindows11Style::polish(QWidget* widget)
{
QWindowsVistaStyle::polish(widget);
if (!qobject_cast<QCommandLinkButton *>(widget))
QWindowsVistaStyle::polish(widget);
const bool isScrollBar = qobject_cast<QScrollBar *>(widget);
if (isScrollBar || qobject_cast<QMenu *>(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<QCommandLinkButton *>(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<QGraphicsView *>(widget) && !qobject_cast<QTextEdit *>(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<QCommandLinkButton *>(widget))
QWindowsVistaStyle::unpolish(widget);
if (const auto *scrollarea = qobject_cast<QAbstractScrollArea *>(widget);
scrollarea
#if QT_CONFIG(mdiarea)