From 14536db7d43ecb7081c873f8c9ad8b834268323f Mon Sep 17 00:00:00 2001 From: gongheng Date: Wed, 28 Oct 2026 05:10:55 +0800 Subject: [PATCH] fix(reader): align search result content with count text MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. drawPageContenttext used option.rect.right() as right boundary while drawSearchCount used option.rect.right() - 20, causing a 20px misalignment 2. Adjust contentSize width to use option.rect.right() - textStartX - 20 3. Adjust drawBottomLine endpoint to use option.rect.right() - 20 4. Update SPDX-FileCopyrightText year from 2023 to 2023-2026 Log: Search result content text now right-aligns with search count text in sidebar Influence: 1. Verify search result count text and content text are right-aligned 2. Verify bottom separator line length matches content text width 3. Test with different window widths and search result counts fix(reader): 搜索结果内容文字与数量文字右对齐 1. drawPageContenttext 使用 option.rect.right() 作为右边界,而 drawSearchCount 使用 option.rect.right() - 20,导致两者相差 20px 未居右对齐 2. 将 contentSize 宽度调整为 option.rect.right() - textStartX - 20 3. 将 drawBottomLine 终点调整为 option.rect.right() - 20 4. 更新 SPDX-FileCopyrightText 版权年份从 2023 为 2023-2026 Log: 搜索结果内容文字与搜索数量文字在侧边栏中右对齐 Influence: 1. 验证搜索结果数量文字与内容文字右边界对齐 2. 验证底部分割线长度与内容文字宽度一致 3. 测试不同窗口宽度和搜索结果数量下的对齐效果 PMS: BUG-193245 --- reader/sidebar/SearchResDelegate.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/reader/sidebar/SearchResDelegate.cpp b/reader/sidebar/SearchResDelegate.cpp index 395db985b..b91f312d9 100644 --- a/reader/sidebar/SearchResDelegate.cpp +++ b/reader/sidebar/SearchResDelegate.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023-2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -94,7 +94,7 @@ void SearchResDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt contentOption.setAlignment(Qt::AlignTop | Qt::AlignLeft); contentOption.setWrapMode(QTextOption::WrapAnywhere); - QSize contentSize(option.rect.right() - textStartX, option.rect.height() - pagetextHeight - 2 * margin); + QSize contentSize(option.rect.right() - textStartX - 20, option.rect.height() - pagetextHeight - 2 * margin); const QString &elidedContentText = Utils::getElidedText(painter->fontMetrics(), contentSize, contentText, contentOption.alignment()); painter->drawText(QRect(textStartX, option.rect.y() + margin + pagetextHeight, contentSize.width(), contentSize.height()), elidedContentText, contentOption); painter->restore(); @@ -103,7 +103,7 @@ void SearchResDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt painter->save(); int bottomlineHeight = 1; painter->setPen(QPen(DTK_NAMESPACE::Gui::DGuiApplicationHelper::instance()->applicationPalette().frameBorder().color(), bottomlineHeight)); - painter->drawLine(textStartX, option.rect.bottom() - bottomlineHeight, option.rect.right(), option.rect.bottom() - bottomlineHeight); + painter->drawLine(textStartX, option.rect.bottom() - bottomlineHeight, option.rect.right() - 20, option.rect.bottom() - bottomlineHeight); painter->restore(); } }