fix(tray): use positionForAnimation to prevent layout direction abrup…#1505
Conversation
…t change When dock position changes from bottom to right/left, the tray layout direction should transition smoothly with animation instead of changing abruptly. This fix binds useColumnLayout to positionForAnimation instead of Panel.position, ensuring the layout direction updates after the position animation completes. 修复任务栏位置切换时系统托盘布局方向突变的问题。将托盘的布局方向 绑定到 positionForAnimation,使其与 dock 主面板保持同步,在位置动画 完成后才改变布局方向,避免切换过程中的视觉突变。 PMS: BUG-353295
Reviewer's guide (collapsed on small PRs)Reviewer's GuideBinds the tray’s column/row layout decision to the animated dock position (positionForAnimation) instead of the raw Panel.position so the tray layout direction flips only after the dock position animation completes, avoiding abrupt layout changes when moving the dock between edges. Sequence diagram for tray layout update using positionForAnimationsequenceDiagram
actor User
participant DockUI
participant Panel
participant RootObject
participant TrayApplet
User->>DockUI: Change dock position (bottom -> left/right)
DockUI->>Panel: Update position
Panel->>RootObject: Start positionForAnimation transition
loop During animation
RootObject-->>TrayApplet: positionForAnimation changes gradually
TrayApplet-->>TrayApplet: useColumnLayout = positionForAnimation % 2
Note over TrayApplet: Layout direction kept consistent until edge flip
end
RootObject->>TrayApplet: Final positionForAnimation value
TrayApplet-->>TrayApplet: useColumnLayout updates after animation completes
Class diagram for tray.qml layout direction binding changeclassDiagram
class Panel {
int position
}
class RootObject {
int positionForAnimation
}
class TrayApplet {
int nextAppletSpacing
bool useColumnLayout
int dockOrder
string quickpanelTrayItemPluginId
var filterTrayPlugins
}
Panel o-- RootObject : rootObject
RootObject o-- TrayApplet : controlsLayout
class TrayApplet {
+bool getUseColumnLayout()
}
TrayApplet : +getUseColumnLayout() = RootObject.positionForAnimation % 2
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Using
Panel.rootObject.positionForAnimationassumesrootObjectis always available when this QML is instantiated; consider guarding against a nullrootObjector documenting the expected initialization order to avoid potential runtime errors. - If
positionForAnimationcan take intermediate values during animation (e.g., non-integers), confirm that using% 2still yields the intended boolean layout state, or consider normalizing/rounding the value before applying the modulo.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Using `Panel.rootObject.positionForAnimation` assumes `rootObject` is always available when this QML is instantiated; consider guarding against a null `rootObject` or documenting the expected initialization order to avoid potential runtime errors.
- If `positionForAnimation` can take intermediate values during animation (e.g., non-integers), confirm that using `% 2` still yields the intended boolean layout state, or consider normalizing/rounding the value before applying the modulo.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
deepin pr auto review这份代码修改涉及 QML 文件 1. 语法逻辑审查
2. 代码质量审查
3. 代码性能审查
4. 代码安全审查
5. 改进建议建议 1:明确意图并解耦(推荐) // 假设 Panel 暴露了更清晰的接口
property bool useColumnLayout: Panel.isVertical或者如果必须使用奇偶判断: property bool useColumnLayout: Panel.dockPosition === Dock.Left || Panel.dockPosition === Dock.Right建议 2:防御性编程(如果必须使用当前逻辑) // 注意:使用 positionForAnimation 可能导致动画期间频繁触发布局更新
property bool useColumnLayout: Panel.rootObject ? (Panel.rootObject.positionForAnimation % 2 !== 0) : false建议 3:性能优化
总结不建议直接合并当前的修改。 建议方案:除非有特殊的动画效果需求(即布局需要随着位置动画实时变化),否则应回退到使用 |
|
/forcemerge |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, BLumia, Ivy233 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
This pr force merged! (status: blocked) |
…t change
When dock position changes from bottom to right/left, the tray layout direction should transition smoothly with animation instead of changing abruptly. This fix binds useColumnLayout to positionForAnimation instead of Panel.position, ensuring the layout direction updates after the position animation completes.
修复任务栏位置切换时系统托盘布局方向突变的问题。将托盘的布局方向
绑定到 positionForAnimation,使其与 dock 主面板保持同步,在位置动画
完成后才改变布局方向,避免切换过程中的视觉突变。
PMS: BUG-353295
Summary by Sourcery
Bug Fixes: