From d05d2988bbba889622f0fe1340349dcee7b70bad Mon Sep 17 00:00:00 2001 From: gongheng Date: Fri, 30 Oct 2026 04:40:31 +0800 Subject: [PATCH] fix: align search count text with content in delegate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Root cause: SearchResDelegate::paint() calculated search count text x-position with a hardcoded -20 right margin, while content text and bottom line used option.rect.right() directly (0px margin) 2. Fix: remove the -20 offset so search count text right edge aligns with content text and bottom line right edge 3. Impact: only affects search result sidebar item rendering; no signature change, no effect on other delegates or widgets Log: fix search count text right margin misalignment in sidebar Influence: 1. Test search result list items show count text aligned with content 2. Test alignment under different window widths 3. Verify no regression in dark/light theme rendering fix: 修复搜索结果侧栏数量文本与内容文本右边界不对齐 1. 根因:SearchResDelegate::paint() 计算搜索数量文本 x 坐标时使用了 硬编码 -20 右边距,而内容文本和底线直接使用 option.rect.right() (0px 右边距),导致不对齐 20px 2. 方案:移除 -20 偏移,使搜索数量文本右边界与内容文本及底线右边界对齐 3. 影响:仅影响搜索结果侧栏列表项渲染,不改变函数签名,不影响其他 delegate 或 widget Log: 修复搜索结果侧栏数量文本右边距不对齐问题 Influence: 1. 测试搜索结果列表项中数量文本与内容文本右边界对齐 2. 测试不同窗口宽度下的对齐表现 3. 验证深色/浅色主题下渲染无回归 PMS: BUG-193245 --- reader/sidebar/SearchResDelegate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reader/sidebar/SearchResDelegate.cpp b/reader/sidebar/SearchResDelegate.cpp index c5171bcef..fc50354a8 100644 --- a/reader/sidebar/SearchResDelegate.cpp +++ b/reader/sidebar/SearchResDelegate.cpp @@ -90,7 +90,7 @@ void SearchResDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt painter->setFont(sfont); const QString &searchCountText = index.data(ImageinfoType_e::IMAGE_SEARCH_COUNT).toString(); int searchCountTextWidth = painter->fontMetrics().horizontalAdvance(searchCountText); - painter->drawText(option.rect.right() - searchCountTextWidth - 20, option.rect.y() + margin, option.rect.width(), pagetextHeight, Qt::AlignVCenter | Qt::AlignLeft, searchCountText); + painter->drawText(option.rect.right() - searchCountTextWidth, option.rect.y() + margin, option.rect.width(), pagetextHeight, Qt::AlignVCenter | Qt::AlignLeft, searchCountText); painter->restore(); //drawPageContenttext