Skip to content

Conversation

@mhduiy
Copy link
Contributor

@mhduiy mhduiy commented Nov 10, 2025

  1. Removed custom state-based removal animations from NormalNotify and OverlapNotify components
  2. Added sophisticated ListView transitions for add/remove operations with smooth animations
  3. Implemented indexInGroup property to track notification position within groups
  4. Added panelShown property to control animation activation only when panel is visible
  5. Enhanced OverlapIndicator with staggered fade-in animations for better visual experience
  6. Fixed text width calculation in NotifyItemContent to prevent layout issues during animations
  7. Added proper z-index management for notification items to ensure correct layering

Log: Improved notification panel animations with smoother transitions and better visual effects

Influence:

  1. Test notification panel opening and closing animations
  2. Verify smooth add/remove transitions for individual notifications
  3. Check group notification animations and overlap indicator effects
  4. Test notification content display with various text lengths and icons
  5. Verify animation performance with multiple notifications
  6. Test notification interactions (remove, dismiss, action invoke) during animations

feat: 增强通知动画和视觉效果

  1. 从 NormalNotify 和 OverlapNotify 组件中移除基于自定义状态的删除动画
  2. 为添加/删除操作添加复杂的 ListView 过渡动画,实现平滑的动画效果
  3. 实现 indexInGroup 属性来跟踪通知在组内的位置
  4. 添加 panelShown 属性控制动画仅在面板可见时激活
  5. 增强 OverlapIndicator,添加错开的淡入动画以获得更好的视觉体验
  6. 修复 NotifyItemContent 中的文本宽度计算,防止动画期间的布局问题
  7. 添加适当的 z-index 管理确保通知项的正确层级

Log: 改进了通知面板动画,提供更平滑的过渡和更好的视觉效果

Influence:

  1. 测试通知面板打开和关闭动画
  2. 验证单个通知的平滑添加/删除过渡效果
  3. 检查组通知动画和重叠指示器效果
  4. 测试不同文本长度和图标的通知内容显示
  5. 验证多通知情况下的动画性能
  6. 测试动画期间的通知交互(删除、关闭、操作调用)

pms: BUG-338883# 请为您的变更输入提交说明。以 '#' 开始的行将被忽略,而一个空的提交

Summary by Sourcery

Enhance the notification panel with smooth, configurable animations for adding and removing items, introduce indexInGroup and panelShown properties to control behavior, improve overlap indicator effects and layering, and fix content layout calculation

New Features:

  • Add indexInGroup property in NotifyItem and model to track each notification’s position within its group

Bug Fixes:

  • Fix text width calculation in NotifyItemContent to prevent layout issues during animations

Enhancements:

  • Replace legacy state-based removal animations with sophisticated ListView transitions for add, remove, and displacement operations, gated by a new panelShown flag
  • Enhance OverlapIndicator with staggered fade-in animations for improved visual experience
  • Bind z-index of notification delegates to their list index to ensure correct stacking order

Chores:

  • Remove outdated custom state-based removal animations from NormalNotify and OverlapNotify components

@sourcery-ai
Copy link

sourcery-ai bot commented Nov 10, 2025

Reviewer's Guide

Enhances notification panel animations by replacing legacy state-based transitions with ListView-based transitions gated by panel visibility, introduces indexInGroup and panelShown properties for grouping and visibility control, improves overlap indicator effects, corrects layout calculations and adds z-index management for proper layering.

Sequence diagram for notification add/remove animations with ListView transitions

sequenceDiagram
participant User
participant NotificationPanel
participant ListView
participant NotificationItem
User->>NotificationPanel: Open panel
NotificationPanel->>ListView: Set panelShown = true
ListView->>NotificationItem: Add notification (with indexInGroup)
ListView->>NotificationItem: Animate add (if panelShown)
User->>NotificationPanel: Remove notification
NotificationPanel->>ListView: Remove notification
ListView->>NotificationItem: Animate remove (if panelShown)
Loading

Entity relationship diagram for notification item grouping and index tracking

erDiagram
    NOTIFY_MODEL ||--o{ APP_NOTIFY_ITEM : contains
    APP_NOTIFY_ITEM {
      int indexInGroup
      bool pinned
      bool strongInteractive
    }
    NOTIFY_MODEL {
      int NotifyIndexInGroup
    }
Loading

Class diagram for updated notification item and model structure

classDiagram
class NotifyModel {
  +open()
  +close()
  +expandApp(row)
  +data(index, role)
  +roleNames()
  NotifyIndexInGroup
}
class AppNotifyItem {
  +int indexInGroup
  +void setIndexInGroup(int)
  +int indexInGroup() const
  +bool pinned()
  +bool strongInteractive()
}
NotifyModel "1" -- "*" AppNotifyItem : contains
Loading

Class diagram for QML notification item properties and transitions

classDiagram
class NotifyItem {
  +int indexInGroup
  +signal remove()
  +signal dismiss()
  +signal actionInvoked(actionId)
}
class NotifyView {
  +bool panelShown
  +Transition add
  +Transition remove
  +Transition addDisplaced
  +Transition removeDisplaced
}
class OverlapIndicator {
  +bool enableAnimation
}
NotifyView "1" -- "*" NotifyItem : displays
NotifyItem "1" -- "1" OverlapIndicator : uses
Loading

File-Level Changes

Change Details Files
Replace custom removal animations with ListView transitions and panel visibility gating
  • Removed legacy state-based removal transitions from NormalNotify and OverlapNotify
  • Added sophisticated add/remove/addDisplaced/removeDisplaced Transitions in NotifyView conditional on panelShown
  • Exposed panelShown via viewPanelShown alias and toggled it on window visibility change
NotifyView.qml
NormalNotify.qml
OverlapNotify.qml
panels/notification/center/package/main.qml
NotifyCenter.qml
Introduce indexInGroup property for notification grouping
  • Added indexInGroup property in NotifyItem and model roles
  • Set indexInGroup in NotifyModel.expandApp and exposed it via roleNames/data
  • Propagated indexInGroup to QML delegates and used it in animation logic
notifymodel.cpp
notifymodel.h
notifyitem.h
NotifyItem.qml
NotifyViewDelegate.qml
NormalNotify.qml
OverlapNotify.qml
Enhance OverlapIndicator with staggered fade-in animations
  • Introduced enableAnimation flag and Sequenced fade-in animations in OverlapIndicator
  • Controlled indicator animation trigger based on panelShown in OverlapNotify
OverlapIndicator.qml
OverlapNotify.qml
Fix text width calculation in notification content
  • Replaced Layout.fillWidth with manual Layout.preferredWidth computation in NotifyItemContent
  • Calculated width against icon size, margins, spacing and content loader presence
NotifyItemContent.qml
Manage z-index on notification delegates for proper stacking
  • Assigned z property to each delegate in NotifyViewDelegate based on model index
NotifyViewDelegate.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

@mhduiy mhduiy requested a review from 18202781743 November 10, 2025 09:45
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 - here's some feedback:

  • Relying on DS.singleShot with a fixed 100 ms delay to set panelShown may be brittle; consider using QML state changes or built-in visibility signals to toggle animations in sync with the panel lifecycle.
  • There are a lot of hard-coded magic values (animation durations, offsets like 24px, z-indices, and the manual text width calculation); extracting these into named constants or helper bindings will improve readability and maintainability.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Relying on DS.singleShot with a fixed 100 ms delay to set panelShown may be brittle; consider using QML state changes or built-in visibility signals to toggle animations in sync with the panel lifecycle.
- There are a lot of hard-coded magic values (animation durations, offsets like 24px, z-indices, and the manual text width calculation); extracting these into named constants or helper bindings will improve readability and maintainability.

## Individual Comments

### Comment 1
<location> `panels/notification/plugin/NotifyItemContent.qml:212-216` </location>
<code_context>
                         Layout.alignment: Qt.AlignLeft | Qt.AlignTop
-                        Layout.fillWidth: true
+                        // text 宽度若让Layout通过implicitWidth计算会导致ListView的add动画出现位置错误,故这里手动计算Text的宽度
+                        Layout.preferredWidth: NotifyStyle.contentItem.width - appIcon.width
+                            - appIcon.Layout.leftMargin - appIcon.Layout.rightMargin
+                            - contentLayout.Layout.rightMargin - contentLayout.Layout.leftMargin 
+                            - (contentIconLoader.active ? (contentIconLoader.width + 1) : 0)
+                            - bodyRow.spacing * bodyRow.children.length - 1
                         visible: text !== ""
                         text: root.content
</code_context>

<issue_to_address>
**issue:** Manual width calculation for bodyText may be fragile if layout changes.

This calculation depends on several component properties, making it prone to errors if any layout details change. To mitigate future issues, either document these dependencies clearly or encapsulate the logic in a dedicated function.
</issue_to_address>

### Comment 2
<location> `panels/notification/plugin/OverlapIndicator.qml:44-46` </location>
<code_context>
                         topMargin: revert ? undefined : -(height - overlapHeight)
                         bottomMargin: revert ? -(height - overlapHeight) : undefined
                     }
+                    opacity: 0
+
+                    Component.onCompleted: {
+                        if (root.enableAnimation) {
+                            fadeInAnimation.start()
</code_context>

<issue_to_address>
**issue:** Animation logic for opacity may not handle repeated show/hide cycles correctly.

Currently, fade-in only occurs on initial completion. To support repeated show/hide cycles and changes to enableAnimation, consider updating the logic to respond to property changes or use a state-driven approach.
</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-bot
Copy link

deepin-bot bot commented Nov 13, 2025

TAG Bot

New tag: 2.0.18
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #1349

@deepin-ci-robot
Copy link

[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.

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. Removed custom state-based removal animations from NormalNotify and
OverlapNotify components
2. Added sophisticated ListView transitions for add/remove operations
with smooth animations
3. Implemented indexInGroup property to track notification position
within groups
4. Added panelShown property to control animation activation only when
panel is visible
5. Enhanced OverlapIndicator with staggered fade-in animations for
better visual experience
6. Fixed text width calculation in NotifyItemContent to prevent layout
issues during animations
7. Added proper z-index management for notification items to ensure
correct layering

Log: Improved notification panel animations with smoother transitions
and better visual effects

Influence:
1. Test notification panel opening and closing animations
2. Verify smooth add/remove transitions for individual notifications
3. Check group notification animations and overlap indicator effects
4. Test notification content display with various text lengths and icons
5. Verify animation performance with multiple notifications
6. Test notification interactions (remove, dismiss, action invoke)
during animations

feat: 增强通知动画和视觉效果

1. 从 NormalNotify 和 OverlapNotify 组件中移除基于自定义状态的删除动画
2. 为添加/删除操作添加复杂的 ListView 过渡动画,实现平滑的动画效果
3. 实现 indexInGroup 属性来跟踪通知在组内的位置
4. 添加 panelShown 属性控制动画仅在面板可见时激活
5. 增强 OverlapIndicator,添加错开的淡入动画以获得更好的视觉体验
6. 修复 NotifyItemContent 中的文本宽度计算,防止动画期间的布局问题
7. 添加适当的 z-index 管理确保通知项的正确层级

Log: 改进了通知面板动画,提供更平滑的过渡和更好的视觉效果

Influence:
1. 测试通知面板打开和关闭动画
2. 验证单个通知的平滑添加/删除过渡效果
3. 检查组通知动画和重叠指示器效果
4. 测试不同文本长度和图标的通知内容显示
5. 验证多通知情况下的动画性能
6. 测试动画期间的通知交互(删除、关闭、操作调用)

pms: BUG-338883
@mhduiy
Copy link
Contributor Author

mhduiy commented Nov 14, 2025

/forcemerge

@deepin-bot
Copy link

deepin-bot bot commented Nov 14, 2025

This pr force merged! (status: blocked)

@deepin-ci-robot
Copy link

deepin pr auto review

我来对这个diff进行审查:

  1. 代码逻辑和架构改进:
  • 移除了NormalNotify.qml和OverlapNotify.qml中的removedCallback属性和相关状态转换逻辑,简化了代码结构
  • 新增了indexInGroup属性来处理通知项的组内位置,这是一个更好的设计
  • 将动画逻辑从单个组件移到了ListView层面,这是更合理的架构
  1. 动画效果改进:
  • 新增了add、remove、addDisplaced和removeDisplaced等过渡动画
  • 根据indexInGroup和objectName来区分不同类型的通知项,实现不同的动画效果
  • 增加了渐入渐出效果,提升了用户体验
  1. 性能优化建议:
  • 在NotifyItemContent.qml中,手动计算Text的宽度而不是让Layout自动计算,这可以避免ListView的add动画出现位置错误
  • 使用DS.singleShot延迟设置viewPanelShown,确保动画的平滑性
  1. 安全性考虑:
  • 代码中没有发现明显的安全隐患
  • 建议在NotifyModel::expandApp中添加边界检查,防止数组越界
  1. 其他建议:
  • 在OverlapIndicator.qml中新增的enableAnimation属性很好,可以让动画更可控
  • 建议为动画时长和效果参数提取为可配置项,便于后续调整
  • 可以考虑为复杂的动画逻辑添加注释,提高代码可维护性

总体来说,这次改动主要优化了通知中心的动画效果和代码结构,改动是积极的。代码质量良好,逻辑清晰,没有明显的性能或安全问题。建议在后续版本中持续观察动画效果的实际表现,并根据用户反馈进行微调。

@deepin-bot deepin-bot bot merged commit e33ac81 into linuxdeepin:master Nov 14, 2025
7 of 11 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