Skip to content

feat: add attention animation toggle for taskmanager#1558

Merged
mhduiy merged 1 commit into
linuxdeepin:masterfrom
mhduiy:attentionAnimation
Apr 16, 2026
Merged

feat: add attention animation toggle for taskmanager#1558
mhduiy merged 1 commit into
linuxdeepin:masterfrom
mhduiy:attentionAnimation

Conversation

@mhduiy

@mhduiy mhduiy commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Added a new configuration option to control the display of attention animation for applications in the dock task manager. The animation shows a ripple effect when applications have new notifications. This feature includes DConfig settings, QML property binding, and C++ backend implementation to allow users to enable/disable the animation based on their preference.

Log: Added toggle for attention animation in dock task manager settings

feat: 为任务管理器添加消息通知动画开关

新增配置选项用于控制任务管理器中的应用消息通知动画显示。当应用有新消息
时,会显示水波纹动画效果。此功能包含 DConfig 设置、QML 属性绑定和 C++ 后
端实现,允许用户根据个人偏好启用或禁用该动画。

Log: 在任务管理器设置中添加了消息通知动画开关

Summary by Sourcery

Add a configurable toggle to control attention notification animations for dock task manager items.

New Features:

  • Introduce a task manager setting and QML property to enable or disable attention animations for dock applications.

Enhancements:

  • Expose the attention animation setting through the TaskManager API and wire it to DConfig with change notifications.

@sourcery-ai

sourcery-ai Bot commented Apr 16, 2026

Copy link
Copy Markdown

Reviewer's Guide

Implements a new task manager setting that controls whether the dock shows the ripple-style attention animation for apps with notifications, wiring it through DConfig, C++ settings/backend, and QML so the animation can be toggled on/off from configuration.

Sequence diagram for attention animation toggle propagation

sequenceDiagram
    participant User
    participant SettingsUI
    participant TaskManagerSettings
    participant DConfig
    participant TaskManager
    participant QML_AppItem as AppItem_qml

    User->>SettingsUI: Toggle showAttentionAnimation
    SettingsUI->>TaskManagerSettings: setShowAttentionAnimation(show bool)
    TaskManagerSettings->>TaskManagerSettings: m_showAttentionAnimation = show
    TaskManagerSettings->>DConfig: setValue(TASKMANAGER_SHOW_ATTENTION_ANIMATION_KEY, show)
    TaskManagerSettings-->>TaskManager: showAttentionAnimationChanged()
    TaskManager-->>QML_AppItem: showAttentionAnimation property changed
    QML_AppItem->>QML_AppItem: animationRoot.active = root.attention && !Panel.rootObject.isDragging && TaskManager.showAttentionAnimation
Loading

Class diagram for new attention animation toggle in task manager

classDiagram
    class DConfig {
        +value(key QString, defaultValue QVariant) QVariant
        +setValue(key QString, value QVariant) void
    }

    class TaskManagerSettings {
        -DConfig* m_taskManagerDconfig
        -bool m_allowForceQuit
        -bool m_showAttentionAnimation
        -bool m_windowSplit
        -bool m_cgroupsBasedGrouping
        -QStringList m_dockedElements
        -QStringList m_dockedItems
        +TaskManagerSettings(parent QObject)
        +bool isAllowedForceQuit()
        +void setAllowedForceQuit(allowed bool)
        +bool showAttentionAnimation() const
        +void setShowAttentionAnimation(show bool)
        +bool isWindowSplit()
        +void setWindowSplit(split bool)
        +bool isCgroupsBasedGrouping()
        +void setCgroupsBasedGrouping(enabled bool)
        +QStringList dockedElements() const
        +void setDockedElements(elements QStringList)
        +QStringList dockedItems() const
        +void setDockedItems(items QStringList)
        +void sync()
        +void reload()
        +void init()
        <<signals>> allowedForceQuitChanged()
        <<signals>> showAttentionAnimationChanged()
        <<signals>> windowSplitChanged()
        <<signals>> dockedItemsChanged()
        <<signals>> dockedElementsChanged()
    }

    class AbstractTaskManager {
        <<interface>>
        +void requestActivate(index QModelIndex) const
        +void requestNewInstance(index QModelIndex, action QString) const
    }

    class DContainment {
    }

    class TaskManager {
        Q_PROPERTY bool windowSplit
        Q_PROPERTY bool windowFullscreen
        Q_PROPERTY bool allowForceQuit
        Q_PROPERTY bool showAttentionAnimation
        +TaskManager(parent QObject)
        +bool windowSplit()
        +bool windowFullscreen()
        +bool allowForceQuit()
        +bool showAttentionAnimation()
        +void requestActivate(index QModelIndex) const
        +void requestNewInstance(index QModelIndex, action QString) const
        <<signals>> windowSplitChanged()
        <<signals>> windowFullscreenChanged(fullscreen bool)
        <<signals>> allowedForceQuitChanged()
        <<signals>> showAttentionAnimationChanged()
        -void handleWindowAdded(window QPointer_AbstractWindow)
    }

    DContainment <|-- TaskManager
    AbstractTaskManager <|.. TaskManager
    TaskManagerSettings --> DConfig : uses
    TaskManager --> TaskManagerSettings : uses
Loading

File-Level Changes

Change Details Files
Add persistent DConfig-backed setting for toggling attention animation in the task manager
  • Introduce TASKMANAGER_SHOW_ATTENTION_ANIMATION_KEY constant for the new setting key
  • Load m_showAttentionAnimation from DConfig on TaskManagerSettings construction with a default of true
  • Handle DConfig valueChanged signals for the new key and emit a dedicated showAttentionAnimationChanged() signal
  • Expose getter/setter methods for the new showAttentionAnimation flag and store updates back to DConfig
  • Extend TaskManagerSettings private state with the m_showAttentionAnimation member
panels/dock/taskmanager/globals.h
panels/dock/taskmanager/taskmanagersettings.h
panels/dock/taskmanager/taskmanagersettings.cpp
panels/dock/taskmanager/dconfig/org.deepin.ds.dock.taskmanager.json
Expose the attention animation setting to the task manager backend and QML
  • Add a Q_PROPERTY showAttentionAnimation to TaskManager that reads from TaskManagerSettings and notifies on showAttentionAnimationChanged
  • Connect TaskManagerSettings::showAttentionAnimationChanged to TaskManager::showAttentionAnimationChanged in the TaskManager constructor
  • Implement TaskManager::showAttentionAnimation() forwarding to Settings->showAttentionAnimation()
  • Gate the AppItem attention ripple animation with TaskManager.showAttentionAnimation so it only runs when enabled
panels/dock/taskmanager/taskmanager.h
panels/dock/taskmanager/taskmanager.cpp
panels/dock/taskmanager/package/AppItem.qml
Update file copyright year ranges
  • Adjust SPDX-FileCopyrightText headers to use year range 2023 - 2026 in touched C++ header/source files
panels/dock/taskmanager/taskmanagersettings.cpp
panels/dock/taskmanager/taskmanagersettings.h
panels/dock/taskmanager/taskmanager.cpp
panels/dock/taskmanager/globals.h
panels/dock/taskmanager/taskmanager.h

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

Added a new configuration option to control the display of attention
animation for applications in the dock task manager. The animation
shows a ripple effect when applications have new notifications. This
feature includes DConfig settings, QML property binding, and C++ backend
implementation to allow users to enable/disable the animation based on
their preference.

Log: Added toggle for attention animation in dock task manager settings

feat: 为任务管理器添加消息通知动画开关

新增配置选项用于控制任务管理器中的应用消息通知动画显示。当应用有新消息
时,会显示水波纹动画效果。此功能包含 DConfig 设置、QML 属性绑定和 C++ 后
端实现,允许用户根据个人偏好启用或禁用该动画。

Log: 在任务管理器设置中添加了消息通知动画开关
BLumia
BLumia previously approved these changes Apr 16, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

这段代码的主要目的是在任务栏的任务管理器中添加一个可配置的"显示消息通知动画"(水波纹动画)的功能。整体来看,代码逻辑清晰,遵循了项目的现有架构和命名规范。以下是对语法逻辑、代码质量、代码性能和代码安全的详细审查意见:

1. 语法与逻辑

  • 文件头版权年份更新

    • globals.h, taskmanagersettings.cpp, taskmanagersettings.h 中的版权年份从 2023 更新为 2023 - 2026
    • 意见:这是合理的,表明该文件在未来几年内仍会维护。请确保在 2026 年后再次更新或进行代码审查。
  • 配置键定义与使用

    • globals.h 中定义了 TASKMANAGER_SHOW_ATTENTION_ANIMATION_KEY,与 JSON 文件中的键名 showAttentionAnimation 对应。
    • 意见:命名规范一致,符合项目要求。
  • 信号与槽连接

    • taskmanager.cpp 中连接了 Settings 的信号 showAttentionAnimationChangedTaskManager 的同名信号。
    • 意见:逻辑正确。当设置改变时,能够正确通知 QML 层。
  • QML 绑定

    • AppItem.qmlanimationRoot.active 的绑定条件增加了 TaskManager.showAttentionAnimation
    • 意见:逻辑正确,只有当应用需要关注(root.attention)、不在拖拽中(!Panel.rootObject.isDragging)且开启了设置(TaskManager.showAttentionAnimation)时才激活动画。

2. 代码质量

  • 一致性

    • 新增的 showAttentionAnimation 相关代码(成员变量、方法、信号)与现有的 allowForceQuitwindowSplit 等功能的实现模式保持高度一致。
    • 意见:这非常好,保持了代码库的统一风格,降低了维护成本。
  • 注释与文档

    • JSON 文件中提供了中英文的 namedescription,这有助于用户和开发者理解配置项。
    • 意见:文档齐全,质量很好。
  • 命名规范

    • 变量名 m_showAttentionAnimation、方法名 showAttentionAnimation 均符合驼峰命名法和 Qt 的 m_ 前缀成员变量惯例。
    • 意见:命名规范。

3. 代码性能

  • 默认值处理

    • taskmanagersettings.cpp 中,读取配置时使用了 .value(TASKMANAGER_SHOW_ATTENTION_ANIMATION_KEY, true),设置了默认值为 true
    • 意见:这是很好的做法。如果配置文件缺失或损坏,系统能回退到默认行为(显示动画),保证用户体验。
  • QML 绑定性能

    • AppItem.qml 中的属性绑定是响应式的。
    • 意见:由于 TaskManager.showAttentionAnimation 是一个简单的布尔值,读取开销极小,不会造成性能问题。

4. 代码安全

  • 类型安全

    • 使用了 .toBool() 进行类型转换。
    • 意见:虽然 Qt 的 toBool() 对非布尔类型(如字符串 "true"/"false")有较好的容错性,但 DConfig 的 JSON 定义中 value 明确为 true (boolean),所以类型是安全的。
  • 权限设置

    • JSON 配置中 "permissions": "readwrite"
    • 意见:既然这是一个用户可配置的开关,读写权限是合适的。
  • 潜在风险

    • 空指针检查:在 taskmanager.cpp 的构造函数中直接连接了 Settings 的信号。虽然在这个上下文中 Settings 通常已经初始化,但作为最佳实践,如果 Settings 有可能为空,建议添加断言或空指针检查。不过,鉴于现有代码(如 allowedForceQuitChanged)也是这样写的,保持现状是可以接受的,但值得注意。

5. 改进建议

  1. 拼写检查

    • globals.h 中,常量 TASKMANAGER_ALLOWFOCEQUIT_KEY 似乎存在拼写错误("FOCE" 应为 "FORCE")。虽然这不是本次修改引入的,但既然你在审查这个文件,值得记录下来以便后续修正。
    • 本次新增的 TASKMANAGER_SHOW_ATTENTION_ANIMATION_KEY 拼写正确。
  2. 初始化列表(C++ 最佳实践):

    • TaskManagerSettings 的构造函数中,成员变量 m_showAttentionAnimation 是在构造函数体中赋值的。
    • 建议:如果 TaskManagerSettings 类有其他构造函数或成员变量较多,建议使用 C++ 的成员初始化列表来初始化 m_showAttentionAnimation,这通常比在构造函数体内赋值效率略高。不过,考虑到这里需要先调用 m_taskManagerDconfig->value(...),当前的写法也是必要的。
  3. 信号命名一致性

    • TaskManager 类中,属性 allowForceQuit 对应的信号是 allowedForceQuitChanged(注意是 allowed,不是 allow)。
    • 新增的属性 showAttentionAnimation 对应的信号是 showAttentionAnimationChanged
    • 观察allowForceQuit 的信号命名与属性名略有差异(形容词 vs 动词原形),而 showAttentionAnimation 则完全一致。建议统一风格。考虑到 Qt 的属性系统通常推荐 PropertyChanged 的形式,showAttentionAnimationChanged 是更标准的写法。如果以后重构,可以考虑修正 allowForceQuit 相关的命名,但在本次变更中保持现状即可。

总结

这段代码实现了一个新的功能开关,代码质量高,逻辑清晰,且完美融入了现有代码库。没有发现明显的安全隐患或性能瓶颈。代码可以合并。

@mhduiy mhduiy requested review from 18202781743 and BLumia April 16, 2026 05:12
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: BLumia, 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 8247a0a into linuxdeepin:master Apr 16, 2026
11 of 12 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