refactor: migrate icons to theme-based system with DTK#311
Conversation
1. Replace hardcoded SVG icons with DTK theme-based icon system using QIcon::fromTheme() 2. Remove deprecated light/dark icon variants and manual theme suffix handling 3. Move icons to new theme directory structure under builtin/texts/ and builtin/icons/ 4. Reduce SWITCHWIDGETICONSIZE from 36 to 24 pixels for better visual consistency 5. Update CMakeLists.txt to reference new resource.qrc location 6. Simplify icon loading logic in BestMatchWidget, ScopeWidget, PlanWidget and ConfigWidget 7. Remove fixed icon label size constraint in SwitchWidget for flexible sizing Log: Migrated search configuration icons to DTK theme system with standardized 24px sizing Influence: 1. Verify all search configuration icons display correctly in both light and dark themes 2. Test icon appearance in BestMatchWidget, ScopeWidget, PlanWidget sections 3. Confirm window icon loads properly in ConfigWidget titlebar 4. Check icon sizing consistency across different DPI settings 5. Validate theme switching updates icons without restart 6. Ensure no broken image references in search settings UI refactor: 迁移图标至基于 DTK 主题的图标系统 1. 使用 QIcon::fromTheme() 替换硬编码的 SVG 图标,采用 DTK 主题图标系统 2. 移除废弃的浅色/深色图标变体及手动主题后缀处理逻辑 3. 将图标移至新的主题目录结构,位于 builtin/texts/ 和 builtin/icons/ 下 4. 将 SWITCHWIDGETICONSIZE 从 36 减小至 24 像素,提升视觉一致性 5. 更新 CMakeLists.txt 以引用新的 resource.qrc 位置 6. 简化 BestMatchWidget、ScopeWidget、PlanWidget 和 ConfigWidget 中的图 标加载逻辑 7. 移除 SwitchWidget 中固定的图标标签尺寸约束,实现灵活 sizing Log: 搜索配置图标已迁移至 DTK 主题系统,采用标准化的 24px 尺寸 Influence: 1. 验证所有搜索配置图标在浅色和深色主题下均能正确显示 2. 测试 BestMatchWidget、ScopeWidget、PlanWidget 区域中的图标外观 3. 确认 ConfigWidget 标题栏中的窗口图标正常加载 4. 检查不同 DPI 设置下图标尺寸的一致性 5. 验证主题切换无需重启即可更新图标 6. 确保搜索设置 UI 中没有损坏的图片引用 BUG: https://pms.uniontech.com/bug-view-361095.html
deepin pr auto review你好!我是CodeGeeX。我已经仔细审查了你提供的Git Diff。这次代码变更的核心是将图标加载方式从硬编码的资源文件路径(区分明暗主题)迁移到了系统主题图标机制( 总体来说,这是一次非常优秀且符合Qt/Deepin平台最佳实践的重构。以下是针对语法逻辑、代码质量、性能和安全方面的详细审查意见及改进建议: 一、 语法与逻辑1. const auto &icon = QIcon::fromTheme(iconName);问题: const QIcon icon = QIcon::fromTheme(iconName);
// 或者更简洁:
// const auto icon = QIcon::fromTheme(iconName);2. // 以 configwidget.cpp 为例
QIcon tmpIcon = QIcon::fromTheme("dde-grand-search-setting", QIcon(":/icons/deepin/builtin/icons/dde-grand-search-setting_32px.svg"));这样即使系统主题缺失,也能从内置资源中加载图标。 二、 代码质量1. 布局伸展因子修正(优秀) - m_mainLayout->addLayout(labelLayout, 0);
+ m_mainLayout->addLayout(labelLayout, 1);评价:这是一个很好的修复!将 2. 图标尺寸与固定大小约束的解耦(优秀) -#define ICONLABELSIZE 36
m_iconLabel->setFixedSize(ICONLABELSIZE, ICONLABELSIZE); // 被移除同时 3. 资源文件前缀的规范化(优秀) - <qresource prefix="/">
+ <qresource prefix="/icons/deepin">评价:将资源前缀从根目录 三、 代码性能1. 减少磁盘I/O和内存占用(提升) 四、 代码安全1. 路径注入风险消除(提升) 综合修改建议代码示例针对上述审查意见,建议对代码进行如下微调: 1. bestmatchwidget.cpp / planwidget.cpp / scopewidget.cpp // 修改前:
const auto &icon = QIcon::fromTheme(iconName);
// 修改后:去掉引用,使用值语义;并视情况增加 fallback(可选)
const QIcon icon = QIcon::fromTheme(iconName);2. configwidget.cpp // 修改前:
QIcon tmpIcon = QIcon::fromTheme("dde-grand-search-setting");
// 修改后:增加 fallback 保证极端情况下的显示
QIcon tmpIcon = QIcon::fromTheme("dde-grand-search-setting", QIcon(":/icons/deepin/builtin/icons/dde-grand-search-setting_32px.svg"));总结:这次重构方向非常正确,显著提升了代码的维护性、性能和安全性,且更加贴合系统原生风格。只需注意 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Johnson-zs, Kakueeen 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 |
|
/forcemerge |
QIcon::fromTheme()
handling
builtin/icons/
consistency
PlanWidget and ConfigWidget
sizing
Log: Migrated search configuration icons to DTK theme system with
standardized 24px sizing
Influence:
and dark themes
sections
refactor: 迁移图标至基于 DTK 主题的图标系统
标加载逻辑
Log: 搜索配置图标已迁移至 DTK 主题系统,采用标准化的 24px 尺寸
Influence:
BUG: https://pms.uniontech.com/bug-view-361095.html