Skip to content

cherry-pick commits of v20#350

Merged
18202781743 merged 2 commits intolinuxdeepin:masterfrom
18202781743:cpv20
Nov 6, 2025
Merged

cherry-pick commits of v20#350
18202781743 merged 2 commits intolinuxdeepin:masterfrom
18202781743:cpv20

Conversation

@18202781743
Copy link
Contributor

  • fix: 修复DTK搜索框图标颜色不跟随主题变化
  • fix: 没有匹配最佳尺寸的图标

@18202781743 18202781743 requested review from BLumia and mhduiy October 17, 2025 07:36
deepin-ci-robot added a commit to linuxdeepin/dtk6gui that referenced this pull request Oct 17, 2025
Synchronize source files from linuxdeepin/dtkgui.

Source-pull-request: linuxdeepin/dtkgui#350
mhduiy
mhduiy previously approved these changes Oct 17, 2025
BLumia
BLumia previously approved these changes Oct 17, 2025
@18202781743
Copy link
Contributor Author

/topic dtk-cpv20

@deepin-ci-robot
Copy link
Contributor

Add topic: dtk-cpv20 successed.

@18202781743 18202781743 dismissed stale reviews from BLumia and mhduiy via da74c05 October 20, 2025 02:40
deepin-ci-robot added a commit to linuxdeepin/dtk6gui that referenced this pull request Oct 20, 2025
Synchronize source files from linuxdeepin/dtkgui.

Source-pull-request: linuxdeepin/dtkgui#350
@deepin-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, BLumia

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

from gerrit/develop/eagle in qt5integration.
466143d3a4cf40b0e95d4d1adf988a8b9c44eddd
9d60ce5c90cc7a7131434adb0a2bcc048f4e9515
2d88e02dfefcfc0b9e112e528d7586656923ba37

fix: 修复DTK搜索框图标颜色不跟随主题变化

图标引擎修改,在绘制pixmap前先填充颜色

Log: 修复DTK搜索框图标颜色不跟随主题变化
Bug: https://pms.uniontech.com/bug-view-200405.html
     https://pms.uniontech.com/bug-view-231425.html
Influence: DTK内置图标绘制
Change-Id: Ib6869cdb331005794661dbd076c60cd5ae0f41df
3b5ab7a: fix: 没有匹配最佳尺寸的图标

原因:存在同名不同尺寸svg图标时,Scalable类型的图标会使用maxSize和minSize去找合适的图标
,找到的不一定是最佳尺寸,绘图的时候会进行缩放,导致图标线条变粗/变细
解决方案:在使用entryForSize查找图标之前,先找一下是否有尺寸完全匹配的图标

Log:
Influence: dtk内建图标(所有使用dtk内建图标的都会有影响)
Change-Id: I158283516b067cc0a81654dee8c6657f54b9a56f
deepin-ci-robot added a commit to linuxdeepin/dtk6gui that referenced this pull request Nov 6, 2025
Synchronize source files from linuxdeepin/dtkgui.

Source-pull-request: linuxdeepin/dtkgui#350
@deepin-ci-robot
Copy link
Contributor

deepin pr auto review

我来对这段代码进行审查:

  1. 代码逻辑审查:
  • 新增的 compositedPixmap 函数很好地封装了图标合成逻辑,提高了代码复用性
  • perfectEntryForSize 函数的添加优化了图标尺寸匹配逻辑,先尝试精确匹配再回退到普通匹配
  • paintvirtual_hook 中都正确使用了新的合成逻辑
  1. 代码质量改进建议:
  • compositedPixmap 函数中的 pm 参数建议使用 const 引用:const QPixmap &pm,因为函数内部不会修改原始 pixmap
  • perfectEntryForSize 函数中的 scale 参数默认值 1.0 应该显式写出:qreal scale = 1.0
  • 建议在 compositedPixmap 函数开始处添加空指针检查:if (!entry) return pm;
  1. 性能优化建议:
  • perfectEntryForSize 函数可以缓存结果,避免重复计算
  • compositedPixmap 中的 QPainter pa(&pm) 创建可能带来性能开销,考虑复用 painter 参数(如果存在)
  1. 安全性改进:
  • static_cast<ImageEntry *>(entry) 的强制类型转换存在风险,建议添加类型检查:
auto* imageEntry = dynamic_cast<ImageEntry*>(entry);
if (!imageEntry) return pm;
  1. 代码规范建议:
  • 函数命名遵循驼峰命名法,但 compositedPixmap 建议改为 compositePixmap 更符合 Qt 命名风格
  • 建议为新增函数添加详细的文档注释,说明参数含义和返回值
  1. 其他建议:
  • paint 函数中,背景图绘制逻辑可以考虑也封装成独立函数,提高代码可维护性
  • 建议添加单元测试用例,特别是针对新增的 perfectEntryForSizecompositedPixmap 函数

总体来说,这次改动提高了代码的复用性和可维护性,但还有上述几点可以进一步改进。

@18202781743 18202781743 merged commit 58f423a into linuxdeepin:master Nov 6, 2025
21 of 23 checks passed
@github-project-automation github-project-automation bot moved this to Done in dtk-cpv20 Nov 6, 2025
18202781743 pushed a commit to linuxdeepin/dtk6gui that referenced this pull request Nov 6, 2025
Synchronize source files from linuxdeepin/dtkgui.

Source-pull-request: linuxdeepin/dtkgui#350
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants