Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: close tooltip when window appears in AppItem #1432

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wjyrich wants to merge 1 commit into linuxdeepin:master
base: master
Choose a base branch
Loading
from wjyrich:fix-bug-342085

Conversation

@wjyrich
Copy link
Contributor

@wjyrich wjyrich commented Feb 4, 2026
edited by sourcery-ai bot
Loading

  1. Added logic to close tooltip when windows become available for an application item
  2. The tooltip now automatically closes when a window appears while the tooltip is visible
  3. This prevents tooltips from staying open when they're no longer relevant
  4. Improves user experience by reducing visual clutter

Log: Fixed tooltip behavior to automatically close when application windows appear

Influence:

  1. Test hovering over app items in dock to show tooltips
  2. Verify tooltips close automatically when application windows open
  3. Test with multiple applications opening while tooltips are visible
  4. Check that tooltip behavior remains normal when no windows are opening

fix: 修复AppItem中窗口出现时关闭工具提示的问题

  1. 添加了当应用程序项有窗口可用时关闭工具提示的逻辑
  2. 当窗口出现且工具提示可见时,工具提示现在会自动关闭
  3. 防止工具提示在不再相关时保持打开状态
  4. 通过减少视觉杂乱改善用户体验

Log: 修复工具提示行为,当应用程序窗口出现时自动关闭

Influence:

  1. 测试悬停在Dock中的应用项上显示工具提示
  2. 验证当应用程序窗口打开时工具提示自动关闭
  3. 测试多个应用程序在工具提示可见时打开的情况
  4. 检查在没有窗口打开时工具提示行为保持正常

PMS: BUG-342085

Summary by Sourcery

Bug Fixes:

  • Close visible app item tooltips automatically when their corresponding application windows appear to avoid stale tooltips.

1. Added logic to close tooltip when windows become available for an
application item
2. The tooltip now automatically closes when a window appears while the
tooltip is visible
3. This prevents tooltips from staying open when they're no longer
relevant
4. Improves user experience by reducing visual clutter
Log: Fixed tooltip behavior to automatically close when application
windows appear
Influence:
1. Test hovering over app items in dock to show tooltips
2. Verify tooltips close automatically when application windows open
3. Test with multiple applications opening while tooltips are visible
4. Check that tooltip behavior remains normal when no windows are
opening
fix: 修复AppItem中窗口出现时关闭工具提示的问题
1. 添加了当应用程序项有窗口可用时关闭工具提示的逻辑
2. 当窗口出现且工具提示可见时,工具提示现在会自动关闭
3. 防止工具提示在不再相关时保持打开状态
4. 通过减少视觉杂乱改善用户体验
Log: 修复工具提示行为,当应用程序窗口出现时自动关闭
Influence:
1. 测试悬停在Dock中的应用项上显示工具提示
2. 验证当应用程序窗口打开时工具提示自动关闭
3. 测试多个应用程序在工具提示可见时打开的情况
4. 检查在没有窗口打开时工具提示行为保持正常
PMS: BUG-342085
Copy link

sourcery-ai bot commented Feb 4, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updates AppItem tooltip behavior so that any visible tooltip automatically closes when application windows become available for that item.

Sequence diagram for tooltip closing when a window appears

sequenceDiagram
 actor User
 participant Dock
 participant AppItem
 participant ToolTip
 participant WindowManager
 User->>Dock: hover over app item
 Dock->>AppItem: hover event
 AppItem->>ToolTip: open()
 ToolTip-->>User: tooltipVisible = true
 User->>Dock: open app
 Dock->>WindowManager: request app window
 WindowManager-->>AppItem: windowsChanged(windows)
 AppItem->>AppItem: onWindowsChanged
 AppItem->>AppItem: updateWindowIconGeometryTimer.start()
 AppItem->>ToolTip: close() (when windows.length > 0 and toolTipVisible)
 ToolTip-->>User: tooltipVisible = false
Loading

File-Level Changes

Change Details Files
Ensure AppItem tooltip closes automatically when windows appear for that app.
  • Extend onWindowsChanged handler to start the existing window icon geometry update timer and then conditionally close the tooltip
  • Add a guard that checks for presence of windows and current tooltip visibility before closing the tooltip to avoid unnecessary calls
panels/dock/taskmanager/package/AppItem.qml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

deepin pr auto review

这段,针对这段代码的审查意见如下:

1. 语法逻辑

  • 状态判断逻辑:windows.length > 0 && toolTip.toolTipVisible 的逻辑是明确的,即当有窗口存在且工具提示当前可见时,关闭工具提示。这在逻辑上是合理的,通常用于防止新窗口出现时工具提示遮挡或干扰用户操作。
  • 触发时机:代码放在 onWindowsChanged 信号处理中,这意味着只要窗口列表发生变化(增加或减少)都会触发。结合 if 判断,它只会在窗口增加且工具提示打开时执行,符合预期。

2. 代码质量

  • 注释:添加了 // Close tooltip when window appears 注释,这很好,有助于后续维护者理解该操作的意图。
  • 代码位置:该逻辑紧跟在 updateWindowIconGeometryTimer.start() 之后,表明它与窗口几何位置更新有关联。如果关闭工具提示是为了配合几何位置更新,那么这个位置是合适的。如果两者没有强关联,建议将逻辑分离或添加更详细的注释说明关系。

3. 代码性能

  • 无性能问题:这段代码仅涉及简单的属性检查和函数调用,没有循环或复杂计算,对性能影响极小。
  • 潜在冗余检查:toolTip.toolTipVisible 可能是一个绑定属性,频繁检查可能会产生微小的开销,但在 onWindowsChanged 这种低频事件中可以忽略不计。

4. 代码安全

  • 空指针风险:代码假设 toolTip 对象始终存在。如果 toolTip 有可能为 null 或未定义,建议增加空值检查:
    if (windows.length > 0 && toolTip && toolTip.toolTipVisible) {
     toolTip.close()
    }
  • 异常处理:如果 toolTip.close() 可能抛出异常(例如在 QML 中不太常见,但需考虑底层实现),建议使用 try-catch 块包裹(如果 QML 环境支持)。

改进建议

  1. 增强健壮性:添加 toolTip 对象的空值检查,避免潜在的运行时错误。
  2. 明确意图:如果关闭工具提示不仅是为了窗口出现时,还包括窗口消失时,建议调整注释或条件判断以更准确地反映意图。
  3. 考虑边界情况:如果 windows.length 从 0 变为 1(窗口打开)或从 1 变为 0(窗口关闭),行为是否符合预期?当前代码只在 windows.length > 0 时触发,因此窗口关闭时不会关闭工具提示。如果这也是预期行为,则无需修改;否则,可能需要调整条件。

改进后的代码示例

onWindowsChanged: {
 updateWindowIconGeometryTimer.start()
 // Close tooltip when window list changes and tooltip is visible
 if (toolTip && toolTip.toolTipVisible) {
 toolTip.close()
 }
}

总结

这段代码整体质量良好,逻辑清晰,但可以通过增加空值检查和更明确的注释来提高健壮性和可维护性。性能和安全方面没有明显问题。

Copy link

@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.

Hey - I've left some high level feedback:

  • Consider guarding the new logic with a check that toolTip is defined to avoid potential runtime errors if toolTip is ever missing or refactored away.
  • You might want to trigger the close only when transitioning from no windows to at least one (e.g., tracking previous windows.length) so that tooltip behavior isn’t affected by subsequent window list changes while windows are already present.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider guarding the new logic with a check that `toolTip` is defined to avoid potential runtime errors if `toolTip` is ever missing or refactored away.
- You might want to trigger the close only when transitioning from no windows to at least one (e.g., tracking previous `windows.length`) so that tooltip behavior isn’t affected by subsequent window list changes while windows are already present.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

Reviewers

@sourcery-ai sourcery-ai[bot] sourcery-ai[bot] left review comments

@18202781743 18202781743 18202781743 approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /