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 <oliver.wolff@qt.io>
This commit is contained in:
Wladimir Leuschner 2023-07-13 12:35:30 +02:00
parent 5ececa66d5
commit 07d524aad7

View File

@ -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 <qstylehints.h>
#include <private/qstyleanimation_p.h>
#include <private/qstylehelper_p.h>
#include <qstyleoption.h>
#include <qpainter.h>
#include <qglobal.h>
#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);
}
}