Skip to content

fix: prevent animation glitch during task text width changes#1464

Merged
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
wjyrich:fix-bug-343403
Mar 3, 2026
Merged

fix: prevent animation glitch during task text width changes#1464
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
wjyrich:fix-bug-343403

Conversation

@wjyrich
Copy link
Contributor

@wjyrich wjyrich commented Mar 2, 2026

  1. Fixed animation glitch that occurred when task item text width changed dynamically
  2. Added onOptimalSingleTextWidthChanged handler to temporarily disable and re-enable animations
  3. Created displacedTransition ID for proper animation reference
  4. Used Qt.callLater to ensure smooth transition restoration

Log: Fixed taskbar animation glitches when application names change width

Influence:

  1. Test taskbar behavior when application names change (e.g., language switching)
  2. Verify smooth animations when dragging task items
  3. Check that text width changes don't cause visual artifacts
  4. Test with applications that have varying name lengths
  5. Verify task grouping and overflow functionality remains intact

fix: 修复任务文本宽度变化时的动画故障

  1. 修复了任务项文本宽度动态变化时出现的动画故障
  2. 添加了onOptimalSingleTextWidthChanged处理程序,临时禁用并重新启用动画
  3. 创建了displacedTransition ID以便正确引用动画
  4. 使用Qt.callLater确保平滑恢复过渡效果

Log: 修复了应用程序名称宽度变化时的任务栏动画故障

Influence:

  1. 测试应用程序名称变化时的任务栏行为(如语言切换)
  2. 验证拖动任务项时的平滑动画效果
  3. 检查文本宽度变化不会导致视觉伪影
  4. 测试具有不同名称长度的应用程序
  5. 验证任务分组和溢出功能保持正常

目前需要修复:拆分后,remove的时候动画显示需要进行修复,目前由于卡图标重叠以及图标间距卡顿问题,主要由于X,Y动画卡主引起,从而去除里相应的remove和add的displace的动画。
PMS: BUG-343403

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.

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

Please try again later or upgrade to continue using Sourcery

18202781743
18202781743 previously approved these changes Mar 2, 2026
1. Fixed animation glitch that occurred when task item text width
changed dynamically
2. Added onOptimalSingleTextWidthChanged handler to temporarily disable
and re-enable animations
3. Created displacedTransition ID for proper animation reference
4. Used Qt.callLater to ensure smooth transition restoration

Log: Fixed taskbar animation glitches when application names change
width

Influence:
1. Test taskbar behavior when application names change (e.g., language
switching)
2. Verify smooth animations when dragging task items
3. Check that text width changes don't cause visual artifacts
4. Test with applications that have varying name lengths
5. Verify task grouping and overflow functionality remains intact

fix: 修复任务文本宽度变化时的动画故障

1. 修复了任务项文本宽度动态变化时出现的动画故障
2. 添加了onOptimalSingleTextWidthChanged处理程序,临时禁用并重新启用动画
3. 创建了displacedTransition ID以便正确引用动画
4. 使用Qt.callLater确保平滑恢复过渡效果

Log: 修复了应用程序名称宽度变化时的任务栏动画故障

Influence:
1. 测试应用程序名称变化时的任务栏行为(如语言切换)
2. 验证拖动任务项时的平滑动画效果
3. 检查文本宽度变化不会导致视觉伪影
4. 测试具有不同名称长度的应用程序
5. 验证任务分组和溢出功能保持正常

目前需要修复:拆分后,remove的时候动画显示需要进行修复,目前由于卡图标重叠以及图标间距卡顿问题,主要由于X,Y动画卡主引起,从而去除里相应的remove和add的displace的动画。
@deepin-ci-robot
Copy link

deepin pr auto review

这段代码主要涉及 QML 中 ListView 的动画过渡效果优化,旨在改善任务栏图标在添加、删除或移动时的视觉体验。以下是对这段代码的详细审查和改进建议:

1. 语法逻辑审查

  • 版权年份更新SPDX-FileCopyrightText: 2023-2026
    • 意见:将版权年份更新为未来年份(如2026)通常是为了覆盖未来的维护期。这在逻辑上是合法的,但建议只在确定该项目会持续维护到该年份时才使用,否则通常使用 "2023, 2024" 或 "2023-present"。
  • 属性别名暴露
    • OverflowContainer.qml 中新增了 addDisplaced, removeDisplaced, moveDisplaced 的别名。
    • 意见:逻辑正确。这使得父组件能够控制 ListView 内部委托的位移过渡动画。
  • 动画重置机制
    • TaskManager.qml 中,使用 onOptimalSingleTextWidthChanged 信号处理器来重置并重新设置 appContainer 的过渡动画。
    • 意见:这里的逻辑意图是强制 ListView 刷新其过渡效果。在 QML 中,有时直接修改 Transition 对象的属性不会立即触发重新评估,通过先设为 null 再利用 Qt.callLater 恢复,是一种强制刷新绑定和状态的技巧。逻辑上是为了解决潜在的动画卡顿或不更新问题。

2. 代码质量

  • 代码格式与缩进
    • onOptimalSingleTextWidthChanged 块内的代码缩进和空格存在不一致,且行尾有多余空格(如 appContainer.addDisplaced = null 后)。
    • 改进建议:统一缩进风格(通常为4空格),并删除行尾多余空格,保持代码整洁。
  • 代码重复
    • addDisplacedremoveDisplaced 的 Transition 定义完全一致。
    • 改进建议:虽然 QML 中 Transition 不支持像普通组件那样直接复用实例(因为它们绑定到了特定的属性),但可以通过定义一个 Component 并利用 Loader 来复用逻辑,或者如果未来动画逻辑不同,保持现状以便独立调整。目前考虑到代码量不大,保持现状可读性尚可。
  • 命名清晰度
    • addDisplacedTransitionremoveDisplacedTransition ID 命名清晰,易于理解。

3. 代码性能

  • Qt.callLater 的使用
    • 使用 Qt.callLater 将赋值操作推迟到事件队列中处理,避免了在同一堆栈帧中连续修改属性可能导致的冲突或未定义行为。
    • 评价:这是处理 QML 属性连续修改的一种良好实践,有助于性能稳定。
  • 动画属性
    • 动画同时修改了 x, y, scale, opacity
    • 评价:在大多数现代设备上,这些属性通常能由 GPU 加速(特别是 opacityscale,如果 x/y 导致的是位移而非布局重排)。性能影响可控。
  • 频繁触发
    • onOptimalSingleTextWidthChanged 可能在窗口调整大小、DPI变化或字体变化时频繁触发。
    • 潜在风险:每次触发都会销毁并重建 Transition 对象(虽然开销不大),但频繁操作可能会造成微小的性能抖动。
    • 改进建议:确认 optimalSingleTextWidth 是否会在短时间内剧烈波动。如果会,可以考虑增加防抖逻辑,但鉴于目前代码逻辑是强制刷新动画,这可能是有意为之。

4. 代码安全

  • 空值检查
    • 代码将属性设为 null,QML 的属性系统对此处理良好,不会导致崩溃。
  • 动态属性修改
    • 动态修改 addDisplaced 等属性依赖于 appContainer(即 OverflowContainer)的生命周期和状态。
    • 意见:只要 appContainerTaskManager 销毁前始终有效,就是安全的。目前的层级结构保证了这一点。

5. 具体的改进代码示例

针对代码格式和逻辑清晰度,建议对 TaskManager.qml 进行如下微调:

// ... 其他代码保持不变 ...

        onOptimalSingleTextWidthChanged: {
            // 临时禁用过渡以强制刷新状态
            appContainer.addDisplaced = null
            appContainer.removeDisplaced = null
            
            // 使用 Qt.callLater 确保在下一帧恢复过渡,避免属性绑定冲突
            Qt.callLater(function() {
                appContainer.addDisplaced = addDisplacedTransition
                appContainer.removeDisplaced = removeDisplacedTransition
            })
        }

// ... 其他代码保持不变 ...

总结

这段代码的主要目的是优化 ListView 的视觉反馈,通过分离 addDisplacedremoveDisplacedmoveDisplaced 动画,并增加强制刷新机制,解决了潜在的动画状态不同步问题。

总体评价:代码逻辑正确,能够达到预期效果。主要改进点在于清理代码格式(去除多余空格),并确认频繁重置 Transition 是否存在性能瓶颈。从安全角度看,没有明显风险。

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: BLumia, 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

@wjyrich
Copy link
Contributor Author

wjyrich commented Mar 3, 2026

/forcemerge

@deepin-bot
Copy link

deepin-bot bot commented Mar 3, 2026

This pr force merged! (status: behind)

@deepin-bot deepin-bot bot merged commit 2704112 into linuxdeepin:master Mar 3, 2026
14 of 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.

4 participants