Skip to content

Conversation

@mhduiy
Copy link
Contributor

@mhduiy mhduiy commented Dec 26, 2025

  1. Replaced manual timer-based animation with a reusable lightSweepAnimation component
  2. Fixed BoxShadow positioning to use anchors instead of manual calculations
  3. Added OpacityMask layers to handle corner radius clipping properly
  4. Restructured gradient animation to use ColorAnimation for smoother transitions
  5. Fixed indeterminate mode animation to respect animationStop control
  6. Improved visual consistency between determinate and indeterminate modes

Log: Improved progress bar visual effects with smoother animations and better corner handling

Influence:

  1. Test progress bar in both determinate and indeterminate modes
  2. Verify smooth gradient animation without visual glitches
  3. Check corner radius rendering at different progress values
  4. Test animation stop/start functionality in indeterminate mode
  5. Verify BoxShadow positioning and visibility at progress boundaries
  6. Test performance with multiple progress bars simultaneously

fix: 重构进度条动画和视觉效果

  1. 将基于定时器的手动动画替换为可复用的 lightSweepAnimation 组件
  2. 修复 BoxShadow 定位,使用锚点替代手动计算
  3. 添加 OpacityMask 层以正确处理圆角裁剪
  4. 重构渐变动画,使用 ColorAnimation 实现更平滑的过渡
  5. 修复不确定模式动画以遵守 animationStop 控制
  6. 改进确定模式和不确定模式之间的视觉一致性

Log: 改进了进度条的视觉效果,动画更平滑,圆角处理更好

Influence:

  1. 测试确定模式和不确定模式下的进度条
  2. 验证平滑的渐变动画,无视觉故障
  3. 检查不同进度值下的圆角渲染
  4. 测试不确定模式下的动画停止/开始功能
  5. 验证进度边界处的 BoxShadow 定位和可见性
  6. 测试同时显示多个进度条时的性能表现

pms: BUG-341547

Summary by Sourcery

Refine the progress bar’s visual behavior by replacing custom timer-driven highlight logic with a reusable animation component and improving clipping and shadow handling for both determinate and indeterminate modes.

New Features:

  • Introduce a reusable light sweep animation component for progress bar highlight effects.

Bug Fixes:

  • Correct BoxShadow positioning by anchoring it to the progress content and adjusting for visualPosition.
  • Ensure indeterminate mode animation respects the animationStop flag when starting or stopping.
  • Fix corner radius clipping issues on the progress fill by applying appropriate opacity mask layers.

Enhancements:

  • Smooth progress bar highlight transitions using color and number animations instead of manual timer updates.
  • Align gradient and highlight behavior between determinate and indeterminate progress bar modes for consistent visuals.

@mhduiy mhduiy requested a review from 18202781743 December 26, 2025 07:22
deepin-ci-robot added a commit to linuxdeepin/dtk6declarative that referenced this pull request Dec 26, 2025
Synchronize source files from linuxdeepin/dtkdeclarative.

Source-pull-request: linuxdeepin/dtkdeclarative#554
@sourcery-ai
Copy link

sourcery-ai bot commented Dec 26, 2025

Reviewer's Guide

Refactors the progress bar’s visual effects by replacing timer-driven light sweep logic with a reusable animation component, fixing shadow anchoring, and improving corner-radius clipping for both determinate and indeterminate modes.

Class diagram for refactored progress bar animation components

classDiagram

class ProgressBarImpl {
}

class ProgressBarVisualArea {
  +BoxShadow boxShadow
  +Item maskedItem
  +Rectangle rect
  +OpacityMask rectMask
}

class DeterminateRect {
  +color gradientColor
  +real lightPosition
  +real width
  +real height
}

class IndeterminateRect {
  +color gradientColor
  +real lightPosition
}

class BoxShadow {
  +real shadowOffsetY
  +real shadowBlur
  +real cornerRadius
  +color shadowColor
  +bool visible
}

class MaskedItem {
  +real x
  +real width
  +real height
}

class OpacityMaskEffect {
}

class LoaderLightAnimDeterminate {
  +Component sourceComponent
}

class LoaderLightAnimIndeterminate {
  +Component sourceComponent
}

class LightSweepAnimationComponent {
}

class LightSweepAnimationInstance {
  +Item targetItem
  +int loops
}

class SequentialAnimation {
  +int loops
}

class ParallelAnimation {
}

class ColorAnimation {
  +Item target
  +string property
  +color from
  +color to
  +int duration
}

class NumberAnimation {
  +Item target
  +string property
  +real from
  +real to
  +int duration
}

class PauseAnimation {
  +int duration
}

ProgressBarImpl *-- ProgressBarVisualArea : contains
ProgressBarVisualArea *-- BoxShadow : contains
ProgressBarVisualArea *-- MaskedItem : contains
MaskedItem *-- DeterminateRect : contains
DeterminateRect *-- OpacityMaskEffect : maskedBy
IndeterminateRect *-- OpacityMaskEffect : maskedBy

ProgressBarImpl *-- DeterminateRect : determinateFill
ProgressBarImpl *-- IndeterminateRect : indeterminateFill

ProgressBarImpl *-- LoaderLightAnimDeterminate : uses
ProgressBarImpl *-- LoaderLightAnimIndeterminate : uses
LoaderLightAnimDeterminate --> LightSweepAnimationComponent : loads
LoaderLightAnimIndeterminate --> LightSweepAnimationComponent : loads
LightSweepAnimationComponent o-- LightSweepAnimationInstance : instantiates

LightSweepAnimationInstance *-- SequentialAnimation : root
SequentialAnimation *-- ParallelAnimation : contains
ParallelAnimation *-- ColorAnimation : drivesGradientColor
ParallelAnimation *-- NumberAnimation : drivesLightPosition
SequentialAnimation *-- PauseAnimation : trailingPause

ColorAnimation --> DeterminateRect : updatesGradientColor
NumberAnimation --> DeterminateRect : updatesLightPosition
ColorAnimation --> IndeterminateRect : updatesGradientColor
NumberAnimation --> IndeterminateRect : updatesLightPosition
Loading

File-Level Changes

Change Details Files
Refactor determinate progress bar fill and highlight to use a reusable light sweep animation with proper corner clipping.
  • Anchor the BoxShadow to its parent and drive its width via right margin based on visualPosition instead of manual x/y/rotation math.
  • Wrap the fill rectangle in an offset container Item to avoid narrow-width corner artifacts and extend its width beyond the bar.
  • Move the light sweep effect from a Timer-based counter to a Loader that instantiates a shared lightSweepAnimation component targeting the fill rectangle.
  • Introduce gradientColor and lightPosition properties on the fill rectangle and drive the gradient stops off these properties.
  • Apply nested OpacityMask layer effects on the fill container and rectangle to ensure correct corner radius clipping at varying progress values.
qt6/src/qml/private/ProgressBarImpl.qml
Unify indeterminate mode highlight behavior with determinate mode using the same animation component and gradient properties.
  • Replace the indeterminate Timer-based gradient update with a Loader that uses the lightSweepAnimation component.
  • Add lightPosition and gradientColor properties on the indeterminate rectangle and bind the gradient stops to them.
  • Control the indeterminate animation’s running state based on progressBar.indeterminate and !control.animationStop to respect stop control.
  • Align gradient stop definitions with determinate mode for visual consistency.
qt6/src/qml/private/ProgressBarImpl.qml
Introduce a reusable lightSweepAnimation component to centralize color and position animation for progress bar highlights.
  • Add a Component lightSweepAnimation containing a SequentialAnimation with an Item-typed targetItem property.
  • Within the component, animate gradientColor via ColorAnimation and lightPosition via NumberAnimation in a ParallelAnimation for synchronized sweep and color change.
  • Configure infinite looping and interleaved PauseAnimations to control sweep cadence and dwell times at endpoints.
  • Reuse this component via Loader instances for both determinate and indeterminate progress bar variants.
qt6/src/qml/private/ProgressBarImpl.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 2 issues, and left some high level feedback:

  • Both Loader instances are declared with the same id: lightAnimLoader in this QML file, which will cause id conflicts; use distinct ids or move the animation loader into a shared component to keep ids unique.
  • The running flag for the lightSweepAnimation is only set imperatively in onLoaded (especially for the indeterminate case), so it won’t react when progressBar.indeterminate or control.animationStop change; consider binding running directly to these properties (e.g. running: progressBar.indeterminate && !control.animationStop) instead.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Both `Loader` instances are declared with the same `id: lightAnimLoader` in this QML file, which will cause id conflicts; use distinct ids or move the animation loader into a shared component to keep ids unique.
- The `running` flag for the `lightSweepAnimation` is only set imperatively in `onLoaded` (especially for the indeterminate case), so it won’t react when `progressBar.indeterminate` or `control.animationStop` change; consider binding `running` directly to these properties (e.g. `running: progressBar.indeterminate && !control.animationStop`) instead.

## Individual Comments

### Comment 1
<location> `qt6/src/qml/private/ProgressBarImpl.qml:58-59` </location>
<code_context>
-                                moveTimer.interval = 2000
-                                return;
+
+                    Loader {
+                        id: lightAnimLoader
+                        sourceComponent: lightSweepAnimation
+                        onLoaded: {
</code_context>

<issue_to_address>
**issue (bug_risk):** Duplicate `id: lightAnimLoader` in the same QML document will cause an id collision.

There are two `Loader` elements in this file using `id: lightAnimLoader` (one in the determinate section and one in the indeterminate section). Since QML ids must be unique within a document, this can cause load failures or incorrect bindings. Please either rename one of the ids or refactor to share a single loader/component if that’s the intended behavior.
</issue_to_address>

### Comment 2
<location> `qt6/src/qml/private/ProgressBarImpl.qml:61-70` </location>
<code_context>
+                    Loader {
+                        id: lightAnimLoader
+                        sourceComponent: lightSweepAnimation
+                        onLoaded: {
+                            lightAnimLoader.item.targetItem = rect
+                            lightAnimLoader.item.running = true
</code_context>

<issue_to_address>
**issue (bug_risk):** `running` is set only once on load, so the animation won't respond to later state changes.

Because `running` is only set in `onLoaded`, changes to `progressBar.indeterminate` or `control.animationStop` later won’t start/stop the animation. Consider binding `running` to a property that reflects these conditions, or adding handlers that update `running` whenever those properties change so the animation state stays in sync.
</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 added a commit to linuxdeepin/dtk6declarative that referenced this pull request Dec 26, 2025
Synchronize source files from linuxdeepin/dtkdeclarative.

Source-pull-request: linuxdeepin/dtkdeclarative#554
@deepin-ci-robot
Copy link
Contributor

deepin pr auto review

我来分析一下这个 QML 代码的改进:

  1. 代码结构和逻辑改进:
  • 将原来的 Timer 实现的动画替换为更优雅的 LightSweepAnimation 组件,提高了代码的可维护性和复用性
  • 使用 SequentialAnimation 和 ParallelAnimation 组合实现了更流畅的动画效果
  • 通过组件化方式将动画逻辑封装,减少了代码重复
  1. 性能优化:
  • 使用 anchors 替代手动计算位置,提高了布局效率
  • 移除了不必要的 rotation 属性,减少了渲染开销
  • 通过 layer.enabled 和 OpacityMask 的组合使用,优化了渲染性能
  1. 安全性改进:
  • 添加了 animationStop 控制标志,可以在不需要时停止动画,节省资源
  • 使用 property 替代直接访问,提高了代码的安全性
  1. 视觉效果改进:
  • 优化了进度条圆角的显示方式,通过 x: -height 的偏移避免了窄宽度时的显示问题
  • 改进了阴影效果,使用 anchors.rightMargin 实现更自然的阴影过渡
  • 使用 Gradient.Horizontal 明确指定渐变方向,提高了代码可读性
  1. 建议进一步改进:
  • 考虑将动画持续时间、延迟时间等参数提取为可配置属性
  • 可以添加动画状态变化时的回调函数,便于外部监听
  • 建议为 LightSweepAnimation 组件添加更多的错误处理和边界条件检查
  1. 代码质量:
  • 代码结构更清晰,通过组件化提高了可维护性
  • 动画实现更加统一和规范
  • 减少了代码重复,提高了代码复用性

这些改进使得代码更加健壮、高效,同时提供了更好的视觉效果和用户体验。

1. Replaced manual timer-based animation with a reusable
lightSweepAnimation component
2. Fixed BoxShadow positioning to use anchors instead of manual
calculations
3. Added OpacityMask layers to handle corner radius clipping properly
4. Restructured gradient animation to use ColorAnimation for smoother
transitions
5. Fixed indeterminate mode animation to respect animationStop control
6. Improved visual consistency between determinate and indeterminate
modes

Log: Improved progress bar visual effects with smoother animations and
better corner handling

Influence:
1. Test progress bar in both determinate and indeterminate modes
2. Verify smooth gradient animation without visual glitches
3. Check corner radius rendering at different progress values
4. Test animation stop/start functionality in indeterminate mode
5. Verify BoxShadow positioning and visibility at progress boundaries
6. Test performance with multiple progress bars simultaneously

fix: 重构进度条动画和视觉效果

1. 将基于定时器的手动动画替换为可复用的 lightSweepAnimation 组件
2. 修复 BoxShadow 定位,使用锚点替代手动计算
3. 添加 OpacityMask 层以正确处理圆角裁剪
4. 重构渐变动画,使用 ColorAnimation 实现更平滑的过渡
5. 修复不确定模式动画以遵守 animationStop 控制
6. 改进确定模式和不确定模式之间的视觉一致性

Log: 改进了进度条的视觉效果,动画更平滑,圆角处理更好

Influence:
1. 测试确定模式和不确定模式下的进度条
2. 验证平滑的渐变动画,无视觉故障
3. 检查不同进度值下的圆角渲染
4. 测试不确定模式下的动画停止/开始功能
5. 验证进度边界处的 BoxShadow 定位和可见性
6. 测试同时显示多个进度条时的性能表现

pms: BUG-341547
deepin-ci-robot added a commit to linuxdeepin/dtk6declarative that referenced this pull request Dec 26, 2025
Synchronize source files from linuxdeepin/dtkdeclarative.

Source-pull-request: linuxdeepin/dtkdeclarative#554
@deepin-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, mhduiy

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

@mhduiy mhduiy merged commit 2e80224 into linuxdeepin:master Dec 29, 2025
20 of 21 checks passed
mhduiy pushed a commit to linuxdeepin/dtk6declarative that referenced this pull request Dec 29, 2025
Synchronize source files from linuxdeepin/dtkdeclarative.

Source-pull-request: linuxdeepin/dtkdeclarative#554
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