Skip to content

fix: disable tray items during collapse animation#1430

Merged
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
wjyrich:fix-bug-342345
Feb 4, 2026
Merged

fix: disable tray items during collapse animation#1430
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
wjyrich:fix-bug-342345

Conversation

@wjyrich
Copy link
Contributor

@wjyrich wjyrich commented Feb 4, 2026

  1. Added enabled: !DDT.TraySortOrderModel.isCollapsing to ActionLegacyTrayPluginDelegate to disable tray items during collapse animation
  2. Updated condition in TrayItemDelegateChooser to use DDT.TraySortOrderModel.isCollapsing instead of DDT.TraySortOrderModel.collapsed for input events
  3. This prevents user interaction with tray items while the collapse animation is in progress
  4. Fixes potential issues where users could click on items that are being animated or in transition state

Log: Fixed tray items remaining interactive during collapse animation

Influence:

  1. Test tray collapse/expand animation to ensure items are disabled during transition
  2. Verify that tray items become interactive again after animation completes
  3. Check that input events are properly blocked during collapse animation
  4. Test with different tray item types (legacy, modern, fixed, collapsable)
  5. Verify that drag operations are not affected by this change

fix: 修复托盘项在折叠动画期间保持交互的问题

  1. 在 ActionLegacyTrayPluginDelegate 中添加 enabled: ! DDT.TraySortOrderModel.isCollapsing,在折叠动画期间禁用托盘项
  2. 更新 TrayItemDelegateChooser 中的条件,使 用 DDT.TraySortOrderModel.isCollapsing 替代
    DDT.TraySortOrderModel.collapsed 来控制输入事件
  3. 防止用户在折叠动画进行期间与托盘项交互
  4. 修复了用户可能点击正在动画或过渡状态中的托盘项的问题

Log: 修复了托盘项在折叠动画期间保持交互的问题

Influence:

  1. 测试托盘折叠/展开动画,确保托盘项在过渡期间被禁用
  2. 验证托盘项在动画完成后重新变为可交互状态
  3. 检查折叠动画期间输入事件是否被正确阻止
  4. 测试不同类型的托盘项(传统、现代、固定、可折叠)
  5. 验证拖拽操作不受此更改影响

PMS: BUG-342345

Summary by Sourcery

Prevent tray items from remaining interactive while the tray is collapsing.

Bug Fixes:

  • Disable legacy tray plugin buttons while the tray collapse animation is in progress to avoid interaction during transition.
  • Block input events for collapsable tray sections based on the tray's collapsing state instead of the collapsed state.

@wjyrich wjyrich requested a review from 18202781743 February 4, 2026 09:11
@sourcery-ai
Copy link

sourcery-ai bot commented Feb 4, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR prevents tray items from remaining interactive while the tray is in its collapse animation by wiring the delegates’ enabled/input handling to TraySortOrderModel.isCollapsing instead of the collapsed state and by disabling the legacy tray plugin delegate during the animation.

Class diagram for tray item delegates and TraySortOrderModel

classDiagram

  class TraySortOrderModel {
    bool collapsed
    bool isCollapsing
  }

  class TrayItemDelegateChooser {
    bool disableInputEvents
    string model_sectionType
    bool inputEventsEnabled
    bool traySurfacePositioner_itemVisible
  }

  class ActionLegacyTrayPluginDelegate {
    bool visible
    bool hoverEnabled
    bool enabled
    bool itemVisible
    bool inputEventsEnabled
    updatePluginMargins()
  }

  TrayItemDelegateChooser --> ActionLegacyTrayPluginDelegate : instantiates_delegate
  TrayItemDelegateChooser --> TraySortOrderModel : uses_isCollapsing_for_inputEvents
  ActionLegacyTrayPluginDelegate --> TraySortOrderModel : uses_isCollapsing_for_enabled
Loading

State diagram for tray collapsing behavior and item interactivity

stateDiagram-v2
  [*] --> Expanded_isCollapsing_false

  Expanded_isCollapsing_false --> Collapsing_isCollapsing_true : user_clicks_collapse
  Collapsing_isCollapsing_true --> Collapsed_isCollapsing_false : collapse_animation_finished
  Collapsed_isCollapsing_false --> Expanding_isCollapsing_true : user_clicks_expand
  Expanding_isCollapsing_true --> Expanded_isCollapsing_false : expand_animation_finished

  state Expanded_isCollapsing_false {
    [*] --> TrayItemsInteractive
  }

  state Collapsing_isCollapsing_true {
    [*] --> TrayItemsDisabled
  }

  state Collapsed_isCollapsing_false {
    [*] --> TrayItemsInteractive
  }

  state Expanding_isCollapsing_true {
    [*] --> TrayItemsDisabled
  }
Loading

File-Level Changes

Change Details Files
Block input on collapsable tray items while the tray is collapsing instead of when fully collapsed.
  • Updated the inputEventsEnabled condition to check TraySortOrderModel.isCollapsing instead of TraySortOrderModel.collapsed for collapsable section types.
  • Kept the existing disableInputEvents flag and sectionType checks intact so only the collapsing state behavior changes.
panels/dock/tray/package/TrayItemDelegateChooser.qml
Disable legacy tray plugin delegate entirely during collapse animation.
  • Bound the delegate’s enabled property to the negation of TraySortOrderModel.isCollapsing so the button cannot be interacted with while collapsing.
  • Left visibility, hover, and drag logic unchanged to minimize behavioral regression outside the animation window.
panels/dock/tray/package/ActionLegacyTrayPluginDelegate.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

@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 found 1 issue, and left some high level feedback:

  • The enabled: !DDT.TraySortOrderModel.isCollapsing binding in ActionLegacyTrayPluginDelegate ignores inputEventsEnabled and sectionType, so the enabled state can get out of sync with hoverEnabled and the chooser’s inputEventsEnabled filter; consider reusing the same composite condition or wiring enabled directly to inputEventsEnabled to keep interaction logic consistent.
  • Using the global DDT.TraySortOrderModel.isCollapsing to drive enabled will disable all legacy tray delegates whenever any collapse animation runs; if that’s not intended, consider scoping the condition by model.sectionType or the specific tray section being animated.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `enabled: !DDT.TraySortOrderModel.isCollapsing` binding in `ActionLegacyTrayPluginDelegate` ignores `inputEventsEnabled` and `sectionType`, so the enabled state can get out of sync with `hoverEnabled` and the chooser’s `inputEventsEnabled` filter; consider reusing the same composite condition or wiring `enabled` directly to `inputEventsEnabled` to keep interaction logic consistent.
- Using the global `DDT.TraySortOrderModel.isCollapsing` to drive `enabled` will disable all legacy tray delegates whenever any collapse animation runs; if that’s not intended, consider scoping the condition by `model.sectionType` or the specific tray section being animated.

## Individual Comments

### Comment 1
<location> `panels/dock/tray/package/ActionLegacyTrayPluginDelegate.qml:34` </location>
<code_context>

     visible: !Drag.active && itemVisible
     hoverEnabled: inputEventsEnabled
+    enabled: !DDT.TraySortOrderModel.isCollapsing

     function updatePluginMargins()
</code_context>

<issue_to_address>
**suggestion (bug_risk):** Consider basing `enabled` on the same condition as `inputEventsEnabled` to avoid inconsistent interaction states.

`hoverEnabled` already uses `inputEventsEnabled`, which incorporates `disableInputEvents` and section type, but `enabled` only checks `!isCollapsing`. This can leave the item logically enabled (e.g., keyboard/a11y activation) while hover/pointer input is blocked. Please align `enabled` with the same gating (e.g. `enabled: inputEventsEnabled` or a shared helper) so all interaction paths use consistent conditions.

Suggested implementation:

```
    visible: !Drag.active && itemVisible
    hoverEnabled: inputEventsEnabled
    enabled: inputEventsEnabled

    function updatePluginMargins()
    {

```

If there are other properties or handlers in this component (e.g. `onClicked`, `Keys.onReturnPressed`) that manually check `DDT.TraySortOrderModel.isCollapsing`, consider refactoring them to use `inputEventsEnabled` as well to keep all interaction paths consistent.
</issue_to_address>

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.

@deepin-ci-robot
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

1. Added `enabled: !DDT.TraySortOrderModel.isCollapsing` to
ActionLegacyTrayPluginDelegate to disable tray items during collapse
animation
2. Updated condition in TrayItemDelegateChooser to
use `DDT.TraySortOrderModel.isCollapsing` instead of
`DDT.TraySortOrderModel.collapsed` for input events
3. This prevents user interaction with tray items while the collapse
animation is in progress
4. Fixes potential issues where users could click on items that are
being animated or in transition state

Log: Fixed tray items remaining interactive during collapse animation

Influence:
1. Test tray collapse/expand animation to ensure items are disabled
during transition
2. Verify that tray items become interactive again after animation
completes
3. Check that input events are properly blocked during collapse
animation
4. Test with different tray item types (legacy, modern, fixed,
collapsable)
5. Verify that drag operations are not affected by this change

fix: 修复托盘项在折叠动画期间保持交互的问题

1. 在 ActionLegacyTrayPluginDelegate 中添加 `enabled: !
DDT.TraySortOrderModel.isCollapsing`,在折叠动画期间禁用托盘项
2. 更新 TrayItemDelegateChooser 中的条件,使
用 `DDT.TraySortOrderModel.isCollapsing` 替代
`DDT.TraySortOrderModel.collapsed` 来控制输入事件
3. 防止用户在折叠动画进行期间与托盘项交互
4. 修复了用户可能点击正在动画或过渡状态中的托盘项的问题

Log: 修复了托盘项在折叠动画期间保持交互的问题

Influence:
1. 测试托盘折叠/展开动画,确保托盘项在过渡期间被禁用
2. 验证托盘项在动画完成后重新变为可交互状态
3. 检查折叠动画期间输入事件是否被正确阻止
4. 测试不同类型的托盘项(传统、现代、固定、可折叠)
5. 验证拖拽操作不受此更改影响

PMS: BUG-342345
@wjyrich
Copy link
Contributor Author

wjyrich commented Feb 4, 2026

/forcemerge

@deepin-bot
Copy link

deepin-bot bot commented Feb 4, 2026

This pr force merged! (status: blocked)

@deepin-bot deepin-bot bot merged commit 381b9c1 into linuxdeepin:master Feb 4, 2026
7 of 11 checks passed
@deepin-ci-robot
Copy link

deepin pr auto review

这段代码是对 Qt/QML 中托盘区域(Tray)相关组件的修改,主要目的是在折叠动画或状态改变期间禁用用户交互,以防止动画冲突或状态不一致。

以下是对该 diff 的详细审查意见,包括语法逻辑、代码质量、性能和安全性方面的分析与建议:

1. 语法逻辑

  • 变量命名一致性

    • 问题:代码将 DDT.TraySortOrderModel.collapsed 修改为了 DDT.TraySortOrderModel.isCollapsing
    • 分析:这是一个重大的语义变更。collapsed 通常表示“已折叠”的静态状态,而 isCollapsing 通常表示“正在折叠”的动态过程。
    • 建议:请务必确认后端 C++ 模型 (TraySortOrderModel) 的逻辑。
      • 如果目的是在折叠动画进行中禁用交互,使用 isCollapsing 是正确的。
      • 如果目的是在托盘处于折叠状态时禁用交互,应该保留 collapsed
      • ActionLegacyTrayPluginDelegate.qml 中新增的 enabled: !DDT.TraySortOrderModel.isCollapsing 来看,推测意图是前者(在动画过程中禁用),但这会导致在折叠完成后,托盘图标依然可以交互。如果这是预期行为(折叠后图标虽然隐藏但在逻辑上仍可接收事件),则逻辑成立;否则可能需要结合两者(例如:!DDT.TraySortOrderModel.collapsed && !DDT.TraySortOrderModel.isCollapsing)。
  • 属性绑定逻辑

    • ActionLegacyTrayPluginDelegate.qml 中新增了 enabled: !DDT.TraySortOrderModel.isCollapsing
    • TrayItemDelegateChooser.qml 中修改了 inputEventsEnabled 的绑定条件。
    • 分析enabled 是 QML Item 的基础属性,设为 false 会完全禁用该控件(鼠标变灰、不响应点击)。inputEventsEnabled 看起来是自定义属性,用于控制是否处理输入事件。
    • 潜在冗余:如果 inputEventsEnabled 最终会控制 MouseAreaenabled 或类似属性,那么外层的 enabled 属性可能已经足够。同时设置两者通常是为了保险,但需要确认 inputEventsEnabled 的内部实现是否会与外层 enabled 冲突或造成双重处理。如果 inputEventsEnabled 为 false 时,外层 enabled 的变化是否会被覆盖?

2. 代码质量

  • 魔法字符串

    • 代码中使用了字符串字面量 "collapsable""fixed"
    • 建议:建议将这些字符串定义为枚举类型或常量,例如 DDT.TrayModel.SectionType.Collapsable。这样可以避免拼写错误,提高代码的可维护性和可读性。
  • 硬编码的模型引用

    • 直接在 QML 中通过单例路径 DDT.TraySortOrderModel 访问模型。
    • 建议:虽然这在 QML 中很常见,但为了解耦,建议通过属性注入的方式传递该模型的状态,或者确保 DDT.TraySortOrderModel 是一个设计良好的全局单例。

3. 代码性能

  • 属性绑定频率
    • isCollapsing 状态通常在动画期间会频繁变化。
    • 分析:每次 isCollapsing 变化都会触发 enabledinputEventsEnabled 的重新求值。这在逻辑上是必要的,因为需要实时响应用户的交互能力。
    • 建议:虽然性能开销通常可以忽略不计,但如果 TrayItemDelegateChooser 中的 delegate 数量非常多,且 inputEventsEnabled 的计算逻辑非常复杂,可能会有轻微影响。目前的逻辑非常简单(布尔运算),性能没有问题。

4. 代码安全

  • 空指针/未定义检查
    • 代码直接访问 DDT.TraySortOrderModel.isCollapsing
    • 建议:虽然不太可能,但为了健壮性,可以确认 DDT.TraySortOrderModel 是否可能为 null 或未初始化。如果存在这种极端情况,应该添加守卫:enabled: DDT.TraySortOrderModel ? !DDT.TraySortOrderModel.isCollapsing : false

5. 综合改进建议

如果确认需求是“在折叠动画进行时禁用交互,折叠完成后允许交互(或根据折叠状态决定)”,建议对代码进行如下微调:

ActionLegacyTrayPluginDelegate.qml:

// 建议明确注释意图,并确保模型引用安全
// 在折叠动画期间禁用整个控件
enabled: DDT.TraySortOrderModel ? !DDT.TraySortOrderModel.isCollapsing : true

TrayItemDelegateChooser.qml:

// 建议使用常量替代魔法字符串
inputEventsEnabled: !disableInputEvents && 
                    (model.sectionType !== DDT.TrayModel.SectionType.Collapsable || 
                     !DDT.TraySortOrderModel.isCollapsing)

总结

这段代码的主要改动是合理的,旨在通过引入 isCollapsing 状态来控制 UI 的交互性,防止动画期间的误操作。主要的关注点在于确认 isCollapsing 的语义是否符合业务需求(是动画中还是折叠状态),以及统一属性控制逻辑enabledinputEventsEnabled 的关系)。

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