From 07d524aad74fcc13cc5dfe47559c71c8b4e3a25f Mon Sep 17 00:00:00 2001 From: Wladimir Leuschner Date: Thu, 13 Jul 2023 12:35:30 +0200 Subject: [PATCH] Introduce Rounded ScrollAreas in QWindows11Style Introduce a rounded frame around the viewport of a QAbstractScrollArea. This change affects the appearance of QTextEdit, QTreeView, QListView, QTableView and QColumnView. Change-Id: I5fc94ea17415903d74c469f9777a932ca62742d0 Reviewed-by: Oliver Wolff --- .../styles/modernwindows/qwindows11style.cpp | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/plugins/styles/modernwindows/qwindows11style.cpp b/src/plugins/styles/modernwindows/qwindows11style.cpp index f3aa0bcdb0..cd92fb1463 100644 --- a/src/plugins/styles/modernwindows/qwindows11style.cpp +++ b/src/plugins/styles/modernwindows/qwindows11style.cpp @@ -2,6 +2,13 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qwindows11style_p.h" +#include +#include +#include +#include +#include +#include +#include "qdrawutil.h" QT_BEGIN_NAMESPACE @@ -174,8 +181,15 @@ void QWindows11Style::drawPrimitive(PrimitiveElement element, const QStyleOption painter->drawLine(option->rect.bottomLeft() + QPoint(2,1), option->rect.bottomRight() + QPoint(-2,1)); } break; + case PE_Frame: { + QRect rect = option->rect.adjusted(2,2,-2,-2); + painter->setBrush(option->palette.base()); + painter->setPen(QPen(frameColorLight)); + painter->drawRoundedRect(rect, secondLevelRoundingRadius, secondLevelRoundingRadius); + break; + } default: - QWindowsVistaStyle::drawPrimitive(element, option, painter, widget);; + QWindowsVistaStyle::drawPrimitive(element, option, painter, widget); } painter->restore(); } @@ -199,6 +213,11 @@ void QWindows11Style::polish(QWidget* widget) pal.setColor(QPalette::Base, pal.window().color()); widget->setPalette(pal); } + if (widget->objectName() == QStringLiteral("qt_scrollarea_viewport")) { + QPalette pal = widget->palette(); + pal.setColor(widget->backgroundRole(), Qt::transparent); + widget->setPalette(pal); + } }