Skip to content

fix: tray tooltip position incorrect for stashed area on treeland#1623

Open
BLumia wants to merge 1 commit into
linuxdeepin:masterfrom
BLumia:pms-bug-339313
Open

fix: tray tooltip position incorrect for stashed area on treeland#1623
BLumia wants to merge 1 commit into
linuxdeepin:masterfrom
BLumia:pms-bug-339313

Conversation

@BLumia
Copy link
Copy Markdown
Member

@BLumia BLumia commented Jun 8, 2026

修正 treeland 会话下,向上收起的托盘区域中的图标 tooltip 位置不正确.

PMS: BUG-339313

@BLumia BLumia requested review from 18202781743 and tsic404 June 8, 2026 07:31
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Sorry @BLumia, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@deepin-ci-robot
Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@BLumia BLumia marked this pull request as ready for review June 8, 2026 07:31
Comment thread panels/dock/tray/SurfacePopup.qml Outdated
修正 treeland 会话下,向上收起的托盘区域中的图标 tooltip 位置不正确.

PMS: BUG-339313
Log:
@BLumia BLumia requested a review from 18202781743 June 8, 2026 07:56
@deepin-ci-robot
Copy link
Copy Markdown

deepin pr auto review

我来对这段代码进行审查,从语法逻辑、代码质量、性能和安全性几个方面进行分析:

语法逻辑

  1. 代码整体逻辑清晰,主要处理系统托盘弹出窗口的工具提示和菜单显示
  2. 修改后的代码将工具提示窗口的逻辑从外部移到了内部,提高了组件的内聚性
  3. 使用信号处理机制来管理窗口的显示和隐藏,逻辑合理

代码质量

  1. 改进点:

    • 移除了独立的 PanelToolTipWindow 组件,直接在 PanelToolTip 内部处理工具提示可见性,提高了代码的内聚性
    • 使用 toolTipVisible 属性替代了原来的 toolTipWindow 引用,减少了组件间的耦合
    • 修复了版权年份从 2024 扩展到 2026,符合规范
  2. 潜在问题:

    • onUpdateGeometryFinished 信号处理函数没有参数,但使用了 function () 语法,可以简化为箭头函数
    • toolTipXtoolTipY 的绑定计算中增加了 Panel.popupWindow 的偏移量,但未对 Panel.popupWindow 是否存在进行空值检查

性能

  1. 优化点:

    • 移除了独立的 WaylandOutput 组件,减少了组件数量,可能略微提高性能
    • 将工具提示窗口逻辑内聚,减少了组件间的通信开销
  2. 潜在问题:

    • toolTipXtoolTipY 的绑定中使用了 Qt.binding,每次相关属性变化都会重新计算,如果频繁变化可能影响性能
    • 没有看到对 toolTipVOffset 的使用优化,如果这个值经常变化,可能会影响性能

安全性

  1. 改进点:

    • 通过信号处理机制确保工具提示和菜单不会同时显示,避免了界面混乱
    • 使用属性绑定确保位置计算的准确性
  2. 潜在问题:

    • toolTip.shellSurface 的赋值没有进行空值检查,如果 popupSurface 为 null 可能导致问题
    • menu.shellSurface 的检查只在 onUpdateGeometryFinished 中,没有在初始化时进行检查

改进建议

  1. 代码质量:
// 简化信号处理
onUpdateGeometryFinished: {
    if (!menu.shellSurface)
        return
    // 其他逻辑
}
  1. 安全性:
// 添加空值检查
toolTip.shellSurface = popupSurface || null
  1. 性能优化:
// 考虑使用缓存机制优化位置计算
property real cachedX: 0
property real cachedY: 0

onPopupSurfaceChanged: {
    if (popupSurface) {
        cachedX = Panel.popupWindow.xOffset + popupSurface.x - toolTip.width / 2
        cachedY = Panel.popupWindow.yOffset + popupSurface.y - toolTip.height - toolTipVOffset
    }
}
  1. 可读性:
// 添加注释说明位置计算逻辑
// 计算工具提示位置,考虑弹出窗口偏移和表面位置
toolTip.toolTipX = Qt.binding(function () {
    return Panel.popupWindow.xOffset + toolTip.shellSurface.x - toolTip.width / 2
})

总体而言,这次修改提高了代码的内聚性和可维护性,但在性能优化和错误处理方面还有改进空间。建议在实际使用中关注这些潜在问题,并根据实际运行情况进行调整。

@deepin-ci-robot
Copy link
Copy Markdown

[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

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