From a75b432c8a9d56066071fe7883f5a3e292e94059 Mon Sep 17 00:00:00 2001 From: Marius Kittler Date: Fri, 9 Aug 2024 21:00:52 +0200 Subject: [PATCH] Fix QCommandLinkButton in Windows 11 style when darkmode is used Fix polishing QCommandLinkButton in Windows 11 style: The condition for QCommandLinkButton needs to be checked before the condition for QAbstractButton; otherwise it is never entered and the colors from the Vista style are used breaking darkmode. Pick-to: 6.7 Change-Id: Ie9e1c20b38a52b2d72f28279e38deb533595b974 Reviewed-by: Oliver Wolff Reviewed-by: Wladimir Leuschner (cherry picked from commit a17c34d2b7ef8391e5485d0ba06966ece793d184) Reviewed-by: Qt Cherry-pick Bot --- src/plugins/styles/modernwindows/qwindows11style.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/plugins/styles/modernwindows/qwindows11style.cpp b/src/plugins/styles/modernwindows/qwindows11style.cpp index f18f8295323..ce28f4e40fd 100644 --- a/src/plugins/styles/modernwindows/qwindows11style.cpp +++ b/src/plugins/styles/modernwindows/qwindows11style.cpp @@ -2080,6 +2080,12 @@ 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 (widget->inherits("QAbstractSpinBox")) { const int minWidth = 2 * 24 + 40; const int originalWidth = widget->size().width(); @@ -2115,12 +2121,6 @@ void QWindows11Style::polish(QWidget* widget) pal.setColor(scrollarea->viewport()->backgroundRole(), Qt::transparent); scrollarea->viewport()->setPalette(pal); scrollarea->viewport()->setProperty("_q_original_background_palette", originalPalette); - } 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); } }