Skip to content

Commit 22a5abb

Browse files
committed
fix(style): fix visual artifacts after deselecting list items at high DPI
Use setClipRect to limit drawing area and prevent antialiasing artifacts from extending beyond item boundaries. 使用setClipRect限制绘制区域,防止反锯齿伪影超出item边界。 Log: 修复高DPI缩放下列表项取消选中后的视觉残留问题 PMS: BUG-332513 Influence: 修复后在125%及更高DPI缩放下,列表项取消选中后不再出现视觉残留横线,同时保持圆角平滑效果,不影响其他项的正常显示。
1 parent 15a1f5d commit 22a5abb

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

styleplugins/chameleon/chameleonstyle.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2017 - 2024 UnionTech Software Technology Co., Ltd.
2+
* SPDX-FileCopyrightText: 2017 - 2026 UnionTech Software Technology Co., Ltd.
33
* SPDX-License-Identifier: LGPL-3.0-or-later
44
*/
55
#include "chameleonstyle.h"
@@ -352,17 +352,20 @@ void ChameleonStyle::drawPrimitive(QStyle::PrimitiveElement pe, const QStyleOpti
352352
int frame_radius = DStyle::pixelMetric(PM_FrameRadius, opt, w);
353353

354354
if (vopt->state & QStyle::State_Selected) {
355-
QRect select_rect = opt->rect;
355+
QRect select_rect = opt->rect;
356356

357-
if (!vopt->showDecorationSelected) {
358-
select_rect = proxy()->subElementRect(QStyle::SE_ItemViewItemText, opt, w);
359-
}
357+
if (!vopt->showDecorationSelected) {
358+
select_rect = proxy()->subElementRect(QStyle::SE_ItemViewItemText, opt, w);
359+
}
360360

361-
p->setPen(Qt::NoPen);
362-
p->setBrush(getColor(opt, QPalette::Highlight));
363-
p->setRenderHint(QPainter::Antialiasing);
364-
p->drawRoundedRect(select_rect, frame_radius, frame_radius);
365-
return;
361+
p->save();
362+
p->setPen(Qt::NoPen);
363+
p->setClipRect(opt->rect);
364+
p->setBrush(getColor(opt, QPalette::Highlight));
365+
p->setRenderHint(QPainter::Antialiasing);
366+
p->drawRoundedRect(select_rect, frame_radius, frame_radius);
367+
p->restore();
368+
return;
366369
} else {
367370
if (vopt->backgroundBrush.style() != Qt::NoBrush) {
368371
p->save();

0 commit comments

Comments
 (0)