-
Notifications
You must be signed in to change notification settings - Fork 59
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
Conversation
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
Reviewer's guide (collapsed on small PRs)Reviewer's GuideUpdates 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 appearssequenceDiagram
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
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin-ci-robot
commented
Feb 4, 2026
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 环境支持)。
改进建议
- 增强健壮性:添加
toolTip对象的空值检查,避免潜在的运行时错误。 - 明确意图:如果关闭工具提示不仅是为了窗口出现时,还包括窗口消失时,建议调整注释或条件判断以更准确地反映意图。
- 考虑边界情况:如果
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() } }
总结
这段代码整体质量良好,逻辑清晰,但可以通过增加空值检查和更明确的注释来提高健壮性和可维护性。性能和安全方面没有明显问题。
There was a problem hiding this 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
toolTipis defined to avoid potential runtime errors iftoolTipis 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.
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
deepin-ci-robot
commented
Feb 4, 2026
[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
Uh oh!
There was an error while loading. Please reload this page.
Log: Fixed tooltip behavior to automatically close when application windows appear
Influence:
fix: 修复AppItem中窗口出现时关闭工具提示的问题
Log: 修复工具提示行为,当应用程序窗口出现时自动关闭
Influence:
PMS: BUG-342085
Summary by Sourcery
Bug Fixes: