Skip to content

Conversation

@BLumia
Copy link
Member

@BLumia BLumia commented Dec 12, 2025

由于 QTBUG-133953, 任务栏添加 icon 时新元素的加入动画一定会导致其
布局计算得到的位置是一个错误的位置.原本的修复是通过延时强制重新触发
布局实现的,但延时重新触发不一定可靠,导致仍可能概率性发生. 尽管
QTBUG-133953 并未得以解决,此处通过将动画时机进行调整,使相关位置计算
问题不再发生.

Summary by Sourcery

Adjust task manager task list animations and layout sizing to avoid incorrect icon positioning when new items are added.

Bug Fixes:

  • Prevent newly added taskbar icons from being laid out in incorrect positions by changing when and how the add animation is applied.

Enhancements:

  • Simplify task manager layout sizing by removing the force relayout workaround and relying on direct implicit size calculations for the app container.
  • Move the task list add animation from the ListView transition to a per-delegate add handler for more reliable behavior.

由于 QTBUG-133953, 任务栏添加 icon 时新元素的加入动画一定会导致其
布局计算得到的位置是一个错误的位置.原本的修复是通过延时强制重新触发
布局实现的,但延时重新触发不一定可靠,导致仍可能概率性发生. 尽管
QTBUG-133953 并未得以解决,此处通过将动画时机进行调整,使相关位置计算
问题不再发生.

PMS: BUG-308927
Log:
@sourcery-ai
Copy link

sourcery-ai bot commented Dec 12, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Refactors the TaskManager QML taskbar layout workaround by removing the force-relayout timer hack and moving the add animation to a per-delegate ListView.onAdd animation, ensuring correct layout calculation while keeping add/remove animations.

Sequence diagram for new ListView.onAdd animation and layout calculation

sequenceDiagram
    participant PanelRoot as PanelRootObject
    participant TaskManager as TaskManager
    participant Overflow as OverflowContainer
    participant ListView as AppsListView
    participant Delegate as AppDelegate

    PanelRoot->>TaskManager: dockItemMaxSize changes / new app added
    TaskManager->>Overflow: visualModel updated
    Overflow->>ListView: count changes
    ListView->>ListView: onCountChanged
    ListView->>TaskManager: DS.singleShot(300, updateDynamicCharLimits)

    Note over ListView,Delegate: New delegate is created and positioned using correct layout

    ListView->>Delegate: ListView.onAdd triggered
    Delegate->>Delegate: NumberAnimation(scale, opacity, 0 -> 1, 200ms)

    Note over TaskManager: No forceRelayoutWorkaround timer or property
    Note over TaskManager: implicitWidth/implicitHeight use appContainer.implicitWidth/Height directly
Loading

Class diagram for updated TaskManager QML structure and properties

classDiagram
    class ContainmentItem {
    }

    class TaskManager {
        <<QML Item>>
        bool useColumnLayout
        int dockOrder
        int remainingSpacesForTaskManager
        int remainingSpacesForSplitWindow
        int appContainerWidth
        int appContainerHeight
        var dynamicCharLimits
        int implicitWidth
        int implicitHeight
        findAppIndex(appId)
        updateDynamicCharLimits()
    }

    class OverflowContainer {
        <<QML Item>>
        bool useColumnLayout
        real spacing
    }

    class AppsListView {
        <<QML ListView>>
        int count
        real cellWidth
        onCountChanged()
    }

    class AppDelegate {
        <<QML Item>>
        ListView.onAdd()
    }

    ContainmentItem *-- TaskManager : rootItem
    TaskManager *-- OverflowContainer : overflowContainer
    OverflowContainer *-- AppsListView : appsListView
    AppsListView *-- AppDelegate : delegate

    %% Removed elements (for context)
    class RemovedTimer {
        <<QML Timer>>
        int interval
        bool repeat
        onTriggered()
    }

    TaskManager .. RemovedTimer : removed

    class RemovedProperty {
        <<property>>
        int forceRelayoutWorkaround
    }

    TaskManager .. RemovedProperty : removed

    class RemovedAddTransition {
        <<Transition>>
        addAnimation(scale, opacity, 0 -> 1, 200ms)
    }

    OverflowContainer .. RemovedAddTransition : removed add transition
Loading

File-Level Changes

Change Details Files
Remove the force relayout workaround based on a timer and dummy property used to perturb layout calculations.
  • Delete forceRelayoutWorkaround property used to adjust implicit sizes and trigger relayouts.
  • Remove relayoutWorkaroundTimer Timer object and its onTriggered handler that mutated forceRelayoutWorkaround.
  • Stop mutating forceRelayoutWorkaround in the updateDynamicCharLimitsSingleShot timer.
panels/dock/taskmanager/package/TaskManager.qml
Simplify implicit size calculations to no longer depend on the relayout workaround property.
  • Update appContainerWidth/appContainerHeight to be plain implicitWidth/implicitHeight without adding the workaround offset.
  • Change implicitWidth/implicitHeight bindings to use only remainingSpacesForTaskManager and appContainer.implicitWidth/implicitHeight.
panels/dock/taskmanager/package/TaskManager.qml
Move the add animation from the ListView.add Transition to a delegate-level ListView.onAdd animation to avoid layout issues tied to QTBUG-133953.
  • Remove ListView add Transition that animated scale and opacity for newly added items.
  • Add ListView.onAdd NumberAnimation inside the delegate to animate delegateRoot scale and opacity on insertion.
  • Keep the existing remove Transition for delete animations unchanged, only decoupling add animation from the ListView layout pipeline.
  • Stop starting the relayout workaround timer from the visualModel onCountChanged handler, leaving only the dynamic char limit update singleShot.
panels/dock/taskmanager/package/TaskManager.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

@deepin-ci-robot
Copy link

deepin pr auto review

我来对这个diff进行仔细的审查:

  1. 代码逻辑改进:
  • 移除了forceRelayoutWorkaround属性和相关的relayoutWorkaroundTimer定时器,这是一个很好的改进。原来的workaround方案不够优雅,使用定时器来强制重新布局可能会导致性能问题。
  • 将原来在add Transition中的动画移到了ListView.onAdd中,这样更符合QML的最佳实践,因为这是处理单个项目添加的标准方式。
  1. 性能优化:
  • 移除了不必要的定时器操作,减少了系统资源的占用。
  • 简化了appContainerWidthappContainerHeight的计算逻辑,去除了forceRelayoutWorkaround的影响,使计算更加直接和高效。
  • 简化了implicitWidthimplicitHeight的计算,减少了不必要的加法运算。
  1. 代码质量提升:
  • 代码更加简洁和清晰,移除了临时解决方案(workaround),使代码更容易维护。
  • 动画处理更加规范,使用ListView.onAdd替代了全局的add Transition,这样更符合QML的组件化思想。
  1. 安全性考虑:
  • 移除了定时器相关的代码,减少了可能的内存泄漏风险。
  • 代码逻辑更加直接,减少了复杂的workaround可能带来的潜在bug。

建议:

  1. 这个改动整体上是很好的,但建议在移除workaround后进行充分的测试,确保没有引入新的布局问题。
  2. 可以考虑添加一些注释,说明为什么选择使用ListView.onAdd而不是原来的add Transition,这样可以帮助其他开发者更好地理解这个改动。
  3. 建议对动画效果进行测试,确保新的动画实现与原来的效果保持一致。

总的来说,这是一个很好的代码改进,提高了代码的可维护性和性能,同时保持了原有的功能。

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 there - I've reviewed your changes and they look great!


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.

return false
}

ListView.onAdd: NumberAnimation {
Copy link
Contributor

Choose a reason for hiding this comment

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

add是附加属性的信号,这里是响应信号的槽函数么,这样写是什么意思呀?

Copy link
Member Author

Choose a reason for hiding this comment

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

就是在 onAdd 信号触发的时候触发动画。

(p.s. 这是 QTBUG-133953 里给我的建议修改方式)

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses an issue where taskbar icons get stuck together due to a ListView add animation causing incorrect layout positioning. The fix removes a timer-based workaround and attempts to move the add animation from the ListView transition level to individual delegate items.

Key Changes:

  • Removed forceRelayoutWorkaround property and related timer-based workaround logic
  • Removed ListView add transition and replaced with per-delegate ListView.onAdd handler
  • Simplified implicit width/height calculations by removing workaround references

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +291 to +298
ListView.onAdd: NumberAnimation {
target: delegateRoot
properties: "scale,opacity"
from: 0
to: 1
duration: 200
}

Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

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

The syntax ListView.onAdd: NumberAnimation { ... } appears non-standard. In QML, ListView.onAdd is an attached signal handler that typically expects JavaScript code, not a direct Animation assignment. The standard approach would be to define the animation separately and start it within the signal handler, or use the ListView's add transition (the original approach). This may not execute as intended. Additionally, this approach could conflict with the existing state-based PropertyChanges (lines 299-310) and Behaviors (lines 312-313) that also control the opacity and scale properties.

Suggested change
ListView.onAdd: NumberAnimation {
target: delegateRoot
properties: "scale,opacity"
from: 0
to: 1
duration: 200
}

Copilot uses AI. Check for mistakes.
@deepin-ci-robot
Copy link

[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

@BLumia BLumia merged commit 8d2b9c4 into linuxdeepin:master Dec 15, 2025
16 of 17 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.

3 participants