From c3d2a4972ca6bec5bfe9dbe989e2dc6e347f02c1 Mon Sep 17 00:00:00 2001 From: Wladimir Leuschner Date: Mon, 10 Feb 2025 11:18:40 +0100 Subject: [PATCH] QWindows11Style: Use Highlight color for ItemView with alternating rows When using alternating rows in ItemViews, the currently selected item is hard to distinguish from the background colors. This patch uses for ItemViews with alternating row colors the highlight color for the selected and hovered item. Fixes: QTBUG-133118 Pick-to: 6.9 6.8 Change-Id: Ib5dbe0f58d5970c41cc9d14cf2188a7e5b1abd1a Reviewed-by: Oliver Wolff Reviewed-by: Christian Ehrlicher --- src/plugins/styles/modernwindows/qwindows11style.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugins/styles/modernwindows/qwindows11style.cpp b/src/plugins/styles/modernwindows/qwindows11style.cpp index 24e462c54d7..748f8fa5e33 100644 --- a/src/plugins/styles/modernwindows/qwindows11style.cpp +++ b/src/plugins/styles/modernwindows/qwindows11style.cpp @@ -1032,7 +1032,8 @@ void QWindows11Style::drawPrimitive(PrimitiveElement element, const QStyleOption isLast = !isLast; } - painter->setBrush(WINUI3Colors[colorSchemeIndex][subtleHighlightColor]); + const QAbstractItemView *view = qobject_cast(widget); + painter->setBrush(view->alternatingRowColors() ? vopt->palette.highlight() : WINUI3Colors[colorSchemeIndex][subtleHighlightColor]); painter->setPen(Qt::NoPen); if (isFirst) { painter->save(); @@ -1718,7 +1719,8 @@ void QWindows11Style::drawControl(ControlElement element, const QStyleOption *op } if (vopt->state.testAnyFlags(State_Selected | State_MouseOver)) { - painter->setBrush(WINUI3Colors[colorSchemeIndex][subtleHighlightColor]); + const QAbstractItemView *view = qobject_cast(widget); + painter->setBrush(view->alternatingRowColors() ? vopt->palette.highlight() : WINUI3Colors[colorSchemeIndex][subtleHighlightColor]); QWidget *editorWidget = view ? view->indexWidget(view->currentIndex()) : nullptr; if (editorWidget) { QPalette pal = editorWidget->palette();