Skip to content

Conversation

@JWWTSL
Copy link

@JWWTSL JWWTSL commented Oct 24, 2025

log: Optimise cursor display

log: Optimise cursor display
@deepin-ci-robot
Copy link
Contributor

deepin pr auto review

我来对这个代码变更进行审查:

  1. 代码质量改进:
  • 原代码使用drawLine()绘制光标,新代码改用fillRect(),这是一个很好的改进,因为:
    • 避免了抗锯齿导致的模糊边缘
    • 确保了光标线条的精确像素对齐
    • 提供了更好的视觉一致性
  1. 性能优化:
  • 使用toAlignedRect()将浮点坐标转换为整数坐标,避免了浮点运算
  • 关闭了不必要的抗锯齿渲染(QPainter::Antialiasing),提升了绘制性能
  • 使用fillRect()替代drawLine(),减少了绘制调用次数
  1. 安全性改进:
  • 增加了painter.save()和painter.restore()来保护绘制状态,避免影响后续绘制
  • 对thickness进行了边界检查(qMin(4, intRect.height())),防止可能的溢出
  1. 代码可读性:
  • 代码结构更清晰,使用了合理的变量命名
  • 增加了注释说明改动原因
  • 统一了代码缩进和格式
  1. 建议的进一步改进:
  • 可以考虑将光标颜色逻辑提取为一个单独的函数,避免重复代码
  • thickness的值(4)可以定义为常量,便于统一修改
  • 对于IBeamCursor,可以考虑添加最小高度限制,避免在极小窗口时光标不可见

总体来说,这是一个很好的代码改进,提升了光标绘制的质量和性能,同时保持了代码的可维护性。改动合理且安全,建议合并。

@deepin-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: JWWTSL, lzwind

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

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

@JWWTSL
Copy link
Author

JWWTSL commented Oct 30, 2025

/forcemerge

@deepin-bot deepin-bot bot merged commit b1218e9 into linuxdeepin:develop/snipe Oct 30, 2025
15 checks passed
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.

3 participants