From 775e8d7b938f13692dbb04c59d6341dc404c4150 Mon Sep 17 00:00:00 2001 From: Ivy233 Date: Thu, 19 Mar 2026 20:11:46 +0800 Subject: [PATCH] fix: clip item background painting to prevent border overflow in high DPI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When using fractional scaling (e.g. 125%), DStyle's PE_ItemBackground drawing could overflow the item rect boundary into the gap area between items, leaving a visible blue line artifact on the top edge of the middle item during hover state transitions. Added painter->setClipRect(boption.rect) to constrain the background drawing within the adjusted item rect, preventing border overflow into the spacing gap between items. fix: 修复高DPI下列表项背景绘制边框溢出问题 在使用非整数缩放(如125%)时,DStyle绘制PE_ItemBackground时边框会 溢出到列表项之间的间隙区域,导致鼠标从上往下滑过中间项时,其上边缘 出现蓝色残留线条。 通过在绘制前设置painter->setClipRect(boption.rect),将背景绘制限制 在调整后的项矩形范围内,防止边框溢出到项间距区域。 PMS: BUG-336463 --- plugins/dde-dock/common/pluginitemdelegate.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/dde-dock/common/pluginitemdelegate.cpp b/plugins/dde-dock/common/pluginitemdelegate.cpp index bf0f005fa..d1ec91338 100644 --- a/plugins/dde-dock/common/pluginitemdelegate.cpp +++ b/plugins/dde-dock/common/pluginitemdelegate.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2016 - 2023 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2016 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: LGPL-3.0-or-later @@ -68,7 +68,11 @@ void PluginItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op boption.dpalette.setBrush(DPalette::ItemBackground, bgColor); boption.directions = Qt::Vertical; boption.position = DStyleOptionBackgroundGroup::ItemBackgroundPosition(itemSpacing.viewItemPosition); + // 限制绘制范围,防止高DPI下DStyle绘制ItemBackground边框溢出到gap区域 + painter->save(); + painter->setClipRect(boption.rect, Qt::IntersectClip); m_view->style()->drawPrimitive(static_cast(DStyle::PE_ItemBackground), &boption, painter, option.widget); + painter->restore(); } }