fix(catalog): 目录页码使用默认文本色 - #348
Conversation
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideRemoves 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 renderingsequenceDiagram
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
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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: 浅色和深色主题下页码均可清晰显示
680a2bb to
7be28c6
Compare
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 本次变更仅删除了设置前景色的两行代码,语法正确,逻辑清晰。移除QBrush前景色设置后,QStandardItem将自动使用默认文本色,符合修复目的。 2. 代码质量 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 变更简洁明了,删除不必要的颜色设置代码使代码更加简洁。保留的qCDebug日志为标准Qt日志机制,符合编码规范。 3. 代码性能 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 移除了对DGuiApplicationHelper::instance()->applicationPalette().textTips().color()的调用,减少了不必要的调色板查询开销,对性能有轻微正面影响。 4. 代码安全 🔒评价: 优秀 ✅ 通过
安全漏洞详情: 建议: 本次变更仅涉及UI颜色设置,不涉及用户输入、认证、敏感数据等安全相关操作,无安全风险。 💡 改进建议代码示例// 暂无代码示例本报告由 AI 代码审查工具自动生成 |
问题
侧边栏目录页码在浅色主题下看不清,对比度不足。
根因
CatalogTreeView::getItemList()中,页码列(column 1)前景色被设为textTips():两个问题:
低对比度:
textTips()是半透明颜色(浅色主题下 alpha 0.6 黑色 ≈#666666),语义为提示/占位文本,不应用于页码这类内容信息。页码比标题列(使用默认不透明文本色)更难看清。不随主题切换:颜色在 item 创建时缓存为静态
QBrush,主题切换后调色板更新但缓存的画笔不刷新,导致页码颜色不响应主题变化。修复
移除
setForeground()调用,页码回退到视图默认调色板文本色——完全不透明、高对比度、绘制时动态解析,随主题切换自动适配。改动
1 个文件,2 行删除,0 行新增。
DTK 规范合规性
TextTips语义为提示性文本,页码是内容信息,语义误用已纠正#include <DGuiApplicationHelper>仍被paintEvent使用,无未使用 include验证
ForegroundRole日志确认 col=1 返回valid=false,视图使用默认不透明文本色PMS: BUG-375491