Skip to content

fix(catalog): 目录页码使用默认文本色 - #348

Open
F-windy wants to merge 1 commit into
linuxdeepin:masterfrom
F-windy:fix/catalog-page-number-color
Open

fix(catalog): 目录页码使用默认文本色#348
F-windy wants to merge 1 commit into
linuxdeepin:masterfrom
F-windy:fix/catalog-page-number-color

Conversation

@F-windy

@F-windy F-windy commented Aug 28, 2026

Copy link
Copy Markdown

问题

侧边栏目录页码在浅色主题下看不清,对比度不足。

根因

CatalogTreeView::getItemList() 中,页码列(column 1)前景色被设为 textTips()

QColor color = Dtk::Gui::DGuiApplicationHelper::instance()->applicationPalette().textTips().color();
item1->setForeground(QBrush(color));

两个问题:

  1. 低对比度textTips() 是半透明颜色(浅色主题下 alpha 0.6 黑色 ≈ #666666),语义为提示/占位文本,不应用于页码这类内容信息。页码比标题列(使用默认不透明文本色)更难看清。

  2. 不随主题切换:颜色在 item 创建时缓存为静态 QBrush,主题切换后调色板更新但缓存的画笔不刷新,导致页码颜色不响应主题变化。

修复

移除 setForeground() 调用,页码回退到视图默认调色板文本色——完全不透明、高对比度、绘制时动态解析,随主题切换自动适配。

改动

1 个文件,2 行删除,0 行新增。

  item1->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
- QColor color = Dtk::Gui::DGuiApplicationHelper::instance()->applicationPalette().textTips().color();
- item1->setForeground(QBrush(color));
  qCDebug(appLog) << "CatalogTreeView::getItemList() - Returning item list";

DTK 规范合规性

  • TextTips 语义为提示性文本,页码是内容信息,语义误用已纠正
  • 移除静态颜色缓存,改为绘制时动态解析调色板,符合主题切换规范
  • #include <DGuiApplicationHelper> 仍被 paintEvent 使用,无未使用 include

验证

  • 构建成功
  • 运行时 ForegroundRole 日志确认 col=1 返回 valid=false,视图使用默认不透明文本色
  • 目录树正确填充 200+ 条目

PMS: BUG-375491

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: F-windy

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai

sourcery-ai Bot commented Aug 28, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Removes the cached textTips() foreground brush from catalog page numbers so they use the tree view’s fully opaque, theme-adaptive default text color, improving readability in light and dark themes.

Sequence diagram for theme-adaptive catalog page number rendering

sequenceDiagram
    participant CatalogTreeView
    participant QStandardItemModel
    participant QTreeView
    participant Palette

    CatalogTreeView->>QStandardItemModel: getItemList(title, page)
    CatalogTreeView->>QStandardItemModel: setTextAlignment(AlignRight | AlignVCenter)
    QTreeView->>QStandardItemModel: data(ForegroundRole)
    QStandardItemModel-->>QTreeView: invalid ForegroundRole
    QTreeView->>Palette: text()
    Palette-->>QTreeView: theme-adaptive default text color
    QTreeView-->>CatalogTreeView: render page number
Loading

File-Level Changes

Change Details Files
Restore palette-driven rendering for catalog page numbers by removing the explicit hint-text foreground override.
  • Stop assigning the semi-transparent textTips() color to page-number items.
  • Allow the tree view to use its default palette text color, including theme updates.
reader/sidebar/CatalogTreeView.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

1. Page number items used textTips() color, a semi-transparent low-contrast hint color
2. The color was cached as a static QBrush at creation and never updated on theme switch
3. Remove setForeground() so page numbers fall back to the view default opaque text color
4. Page numbers now follow the standard content text color and adapt to theme changes

Log: Remove textTips() foreground from catalog page numbers
Influence: Page numbers now readable in light and dark themes

fix(catalog): 目录页码使用默认文本色

1. 目录页码项使用 textTips() 颜色,为半透明低对比度的提示色
2. 该颜色在创建时缓存为静态 QBrush,主题切换后不更新
3. 移除 setForeground() 调用,页码改用视图默认不透明文本色
4. 页码现跟随标准内容文本色,随主题切换自动适配

Log: 移除目录页码的 textTips 前景色设置
PMS: BUG-375491
Influence: 浅色和深色主题下页码均可清晰显示
@F-windy
F-windy force-pushed the fix/catalog-page-number-color branch from 680a2bb to 7be28c6 Compare August 28, 2026 07:47
@F-windy F-windy changed the title fix(catalog): use default text color for page numbers fix(catalog): 目录页码使用默认文本色 Aug 28, 2026
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 100 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次提交修复了目录页码颜色问题,移除了将页码前景色设置为textTips颜色(灰色提示色)的代码,使页码使用默认文本色。变更简洁明确,无安全漏洞,无语法逻辑错误,代码质量良好。

🔍 详细分析

1. 语法逻辑 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 本次变更仅删除了设置前景色的两行代码,语法正确,逻辑清晰。移除QBrush前景色设置后,QStandardItem将自动使用默认文本色,符合修复目的。


2. 代码质量 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 变更简洁明了,删除不必要的颜色设置代码使代码更加简洁。保留的qCDebug日志为标准Qt日志机制,符合编码规范。


3. 代码性能 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 移除了对DGuiApplicationHelper::instance()->applicationPalette().textTips().color()的调用,减少了不必要的调色板查询开销,对性能有轻微正面影响。


4. 代码安全 🔒

评价: 优秀 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: 本次变更仅涉及UI颜色设置,不涉及用户输入、认证、敏感数据等安全相关操作,无安全风险。


💡 改进建议代码示例

// 暂无代码示例

本报告由 AI 代码审查工具自动生成

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants