Skip to content

Conversation

@wjyrich
Copy link
Contributor

@wjyrich wjyrich commented Feb 6, 2026

Added AppletItemBackground component to AppItem for better visual feedback during hover and active states. The background features dynamic sizing based on title visibility with smooth opacity transitions. Updated window indicator positioning to align with the new background dimensions instead of icon size, ensuring consistent spacing. Modified TaskManager spacing to zero to accommodate new background layout.

Log: Improved dock app item visual feedback with hover background and adjusted window indicator positioning

Influence:

  1. Test hover effects on dock app items in both normal and dark themes
  2. Verify window indicator positioning at all dock edges (top, bottom, left, right)
  3. Check active state visual feedback for running applications
  4. Test background appearance with and without title display
  5. Verify smooth opacity transitions during hover state changes
  6. Test layout consistency when dock items are rearranged or dragged

feat: 添加悬停背景并调整窗口指示器位置

为AppItem添加AppletItemBackground组件,提供悬停和激活状态下的视觉反
馈。背景根据标题可见性动态调整尺寸,具有平滑的透明度过渡效果。更新窗
口指示器定位,使其与新的背景尺寸对齐而非图标尺寸,确保间距一致性。修改
TaskManager间距为零以适应新的背景布局。

Log: 改进任务栏应用项视觉反馈,添加悬停背景并调整窗口指示器定位

Influence:

  1. 在正常和深色主题下测试任务栏应用项的悬停效果
  2. 验证窗口指示器在所有任务栏边缘(顶部、底部、左侧、右侧)的定位
  3. 检查运行中应用的激活状态视觉反馈
  4. 测试带标题和不带标题显示时的背景外观
  5. 验证悬停状态变化时的平滑透明度过渡
  6. 测试任务栏项目重新排列或拖动时的布局一致性

PMS: BUG-345931

Summary by Sourcery

Improve dock app item visual feedback with a dynamic hover background and align window indicators with the new background layout.

New Features:

  • Add a dedicated hover/active background component to dock app items that adapts to icon/title configurations and supports theme-aware styling.

Enhancements:

  • Adjust window indicator positioning to align with the hover background dimensions for consistent spacing across dock edges.
  • Set task manager app item spacing to zero to better integrate the new background layout.

@sourcery-ai
Copy link

sourcery-ai bot commented Feb 6, 2026

Reviewer's Guide

Introduces an AppletItemBackground hover/active background for dock app items, aligns the window indicator margins to this new background size across all dock edges, and removes inter-item spacing in the TaskManager layout to accommodate the new visual design.

Sequence diagram for hover-triggered AppletItemBackground behavior

sequenceDiagram
  actor User
  participant HoverHandler as hoverHandler
  participant AppItem as appItem
  participant AppletItemBackground as hoverBackground
  participant WindowIndicator as windowIndicator

  User->>HoverHandler: move_pointer_over_app_item
  HoverHandler->>AppItem: hovered_changed_true
  AppItem->>hoverBackground: set_hovered_true
  hoverBackground->>hoverBackground: compute_width_height_based_on_title_and_icon
  hoverBackground->>hoverBackground: set_opacity_1_with_NumberAnimation_150ms
  hoverBackground->>hoverBackground: update_palette_for_hovered_state

  User->>HoverHandler: move_pointer_away
  HoverHandler->>AppItem: hovered_changed_false
  AppItem->>hoverBackground: set_hovered_false
  hoverBackground->>hoverBackground: set_opacity_0_with_NumberAnimation_150ms

  AppItem->>windowIndicator: update_margins_using_hoverBackground_nonSplitHeight_and_nonSplitWidth
  windowIndicator->>windowIndicator: align_to_dock_edge_with_consistent_spacing
Loading

Class diagram for AppItem, AppletItemBackground, WindowIndicator, and TaskManager changes

classDiagram
  class AppItem {
    int iconSize
    bool titleActive
    bool active
    var windows
    AppletItemBackground hoverBackground
    Item iconContainer
    void updateWindowIndicatorAnchors(DockEdge edge)
  }

  class AppletItemBackground {
    int verticalSpacing
    int horizontalSpacing
    int nonSplitHeight
    int hoverPadding
    int splitWidth
    int nonSplitWidth
    bool enabled
    int z
    int width
    int height
    int radius
    real opacity
    bool visible
    bool isActive
    DPalette backgroundColor
    DPalette insideBorderColor
    DPalette outsideBorderColor
    void animateOpacity(NumberAnimation animation)
  }

  class WindowIndicator {
    AnchorGroup anchors
    void setTopMargin(int margin)
    void setBottomMargin(int margin)
    void setLeftMargin(int margin)
    void setRightMargin(int margin)
  }

  class TaskManager {
    bool useColumnLayout
    int appItemSpacing
  }

  class AppContainer {
    bool useColumnLayout
    int spacing
  }

  AppItem --> AppletItemBackground : owns_hoverBackground
  AppItem --> WindowIndicator : positions
  AppItem --> AppContainer : contained_in
  TaskManager --> AppContainer : configures_useColumnLayout_and_spacing

  class DPalette {
    color normal_common
    color normal_crystal
    color normalDark_crystal
    color hovered_crystal
    color hoveredDark_crystal
    color pressed_crystal
    color pressedDark_crystal
  }
Loading

File-Level Changes

Change Details Files
Add AppletItemBackground hover/active background behind each app item with theme-aware colors and animated opacity.
  • Wrap AppItem content with an AppletItemBackground assigned to the delegate's background property.
  • Compute dynamic background dimensions based on icon size, title visibility, and dock item maximum size.
  • Drive visibility and opacity from hover and active state, with a short NumberAnimation for opacity transitions.
  • Configure light/dark theme palettes for background and border colors, and bind hovered/pressed states to existing handlers.
panels/dock/taskmanager/package/AppItem.qml
Retarget window indicator positioning to the new hover background dimensions instead of icon metrics.
  • Replace top/bottom indicator margins with bindings based on the non-split hover background height.
  • Replace left/right indicator margins with bindings based on the non-split hover background width.
  • Keep edge-specific anchoring (top, bottom, left, right) but ensure consistent spacing around the new background.
panels/dock/taskmanager/package/AppItem.qml
Tighten TaskManager layout by eliminating inter-item spacing.
  • Set app container spacing to zero, overriding the previous taskmanager.appItemSpacing value so items visually align with the new background sizing.
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

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 1 issue, and left some high level feedback:

  • The AppletItemBackground only has anchors.verticalCenter set and its x binding is commented out, so it will default to x: 0; consider restoring or simplifying the horizontal positioning binding so the background is centered/aligned with the icon as intended.
  • The windowIndicator margin bindings now duplicate similar expressions for each dock edge using hoverBackground.nonSplitHeight/nonSplitWidth; consider extracting this into a small helper or shared binding to avoid subtle inconsistencies between edges when tweaking the layout in the future.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `AppletItemBackground` only has `anchors.verticalCenter` set and its `x` binding is commented out, so it will default to `x: 0`; consider restoring or simplifying the horizontal positioning binding so the background is centered/aligned with the icon as intended.
- The `windowIndicator` margin bindings now duplicate similar expressions for each dock edge using `hoverBackground.nonSplitHeight/nonSplitWidth`; consider extracting this into a small helper or shared binding to avoid subtle inconsistencies between edges when tweaking the layout in the future.

## Individual Comments

### Comment 1
<location> `panels/dock/taskmanager/package/AppItem.qml:145-151` </location>
<code_context>
+                    common: ("transparent")
+                    crystal: Qt.rgba(1.0, 1.0, 1.0, 0.20)
+                }
+                normalDark: {
+                    crystal: Qt.rgba(1.0, 1.0, 1.0, 0.05)
+                }
+                hovered: normal
+                hoveredDark: normalDark
+                pressed: hovered
+                pressedDark: normalDark
+            }
+            outsideBorderColor: D.Palette {
</code_context>

<issue_to_address>
**issue (bug_risk):** The `normalDark:` syntax here likely breaks QML object syntax for the palette group.

Other `D.Palette` groups use `stateName { ... }` without a colon. `normalDark: { ... }` is not valid QML object syntax and may fail to parse or be ignored, which also makes `hoveredDark: normalDark` and `pressedDark: normalDark` unreliable. This should be `normalDark { ... }` to match the other palette groups and ensure these bindings work correctly.
</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.

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 pull request adds visual feedback improvements to dock app items by introducing a hover/active background component and adjusting window indicator positioning to align with the new background layout.

Changes:

  • Added AppletItemBackground component to AppItem with dynamic sizing based on title visibility and smooth opacity transitions
  • Updated window indicator positioning formulas to align with hover background dimensions instead of icon size
  • Modified TaskManager spacing from calculated value to zero to accommodate the new background-based layout

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
panels/dock/taskmanager/package/TaskManager.qml Changed app container spacing from taskmanager.appItemSpacing to 0 to accommodate new background layout
panels/dock/taskmanager/package/AppItem.qml Added AppletItemBackground component with dynamic sizing and updated window indicator positioning to align with background dimensions

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

@wjyrich wjyrich force-pushed the fix-bug-345931 branch 2 times, most recently from afe4c43 to 2c2646d Compare February 6, 2026 09:41
anchors.fill: parent
id: appItem
implicitWidth: root.titleActive ? (iconContainer.width + titleLoader.width + root.appTitleSpacing) : iconContainer.width
implicitWidth: root.titleActive ? (iconContainer.width + titleLoader.width + root.appTitleSpacing) : iconContainer.width + root.appTitleSpacing
Copy link
Contributor

Choose a reason for hiding this comment

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

把textcalcator这个计算方式也同步一下呀,

Added AppletItemBackground component to AppItem for better visual
feedback during hover and active states. The background features dynamic
sizing based on title visibility with smooth opacity transitions.
Updated window indicator positioning to align with the new background
dimensions instead of icon size, ensuring consistent spacing. Modified
TaskManager spacing to zero to accommodate new background layout.

Log: Improved dock app item visual feedback with hover background and
adjusted window indicator positioning

Influence:
1. Test hover effects on dock app items in both normal and dark themes
2. Verify window indicator positioning at all dock edges (top, bottom,
left, right)
3. Check active state visual feedback for running applications
4. Test background appearance with and without title display
5. Verify smooth opacity transitions during hover state changes
6. Test layout consistency when dock items are rearranged or dragged

feat: 添加悬停背景并调整窗口指示器位置

为AppItem添加AppletItemBackground组件,提供悬停和激活状态下的视觉反
馈。背景根据标题可见性动态调整尺寸,具有平滑的透明度过渡效果。更新窗
口指示器定位,使其与新的背景尺寸对齐而非图标尺寸,确保间距一致性。修改
TaskManager间距为零以适应新的背景布局。

Log: 改进任务栏应用项视觉反馈,添加悬停背景并调整窗口指示器定位

Influence:
1. 在正常和深色主题下测试任务栏应用项的悬停效果
2. 验证窗口指示器在所有任务栏边缘(顶部、底部、左侧、右侧)的定位
3. 检查运行中应用的激活状态视觉反馈
4. 测试带标题和不带标题显示时的背景外观
5. 验证悬停状态变化时的平滑透明度过渡
6. 测试任务栏项目重新排列或拖动时的布局一致性

PMS: BUG-345931
@deepin-ci-robot
Copy link

deepin pr auto review

这份代码diff主要涉及了Dock任务栏中应用图标项(AppItem)的布局、背景显示和间距计算的调整。以下是对语法逻辑、代码质量、代码性能和代码安全的详细审查意见:

1. 语法逻辑

AppItem.qml:

  • 背景与内容重叠问题

    • appItem (Control) 的 implicitWidth 计算逻辑是:iconContainer.width + 4 + titleLoader.width + root.appTitleSpacing
    • 新增的 hoverBackground (AppletItemBackground) 的宽度计算逻辑是:Math.round(icon.width + titleLoader.width + hoverPadding * 2)
    • 问题hoverBackground 被设置为 anchors.centerIn: parent。这意味着背景是基于 appItem 的尺寸居中的。然而,appItemimplicitWidth 决定了其自身尺寸。如果 hoverBackground 的宽度计算结果与 appItem 的宽度不一致,或者 hoverBackgroundhoverPaddingappItem 内部布局的 horizontalSpacing 不匹配,会导致背景与内容(图标和文字)在视觉上不对齐(例如背景比内容宽或窄,或者文字没有在背景内居中)。
    • 建议:统一 appItem 的尺寸计算逻辑与 hoverBackground 的尺寸计算逻辑。建议让 appItem 的尺寸完全由 hoverBackground 的尺寸驱动,或者确保两者的计算公式在数学上是等价的。例如,appItemimplicitWidth 应该等于 hoverBackground.width
  • 图标容器 (iconContainer) 布局逻辑

    • 使用了 State 来切换 root.titleActive 状态下的锚点。
    • 问题:在 titleActive 状态下,iconContaineranchors.leftMargin 被设置为 hoverBackground.horizontalSpacing。而在 nonTitleActive 状态下,它被居中。这看起来是合理的,但需要确保 titleLoader 的锚点也正确设置,否则图标和文字之间的间距会不一致。
    • 注意:代码中未显示 titleLoader 的完整定义,但从逻辑推断,titleLoader 应该锚定在 iconContainer 的右侧,并加上适当的间距。如果 titleLoader 没有相应的状态调整,布局可能会错乱。

TaskManager.qml:

  • 间距计算变更

    • appContainer.spacingtaskmanager.appItemSpacing 改为 0
    • 问题:原来的 appItemSpacing 计算较为复杂,考虑了图标大小和单元格宽度的关系。直接改为 0 意味着应用项之间不再有间距,或者间距完全由 appItem 自身的 implicitWidthhoverBackground 的宽度决定。这是一个重大的布局逻辑变更,需要确认这是否是预期行为(例如,是否改用背景的 padding 来模拟间距)。
    • 建议:如果意图是让应用项紧贴,则此改动是正确的。如果意图是保持间距但改变计算方式,则需要确保 appItemimplicitWidthhoverBackground 的宽度包含了所需的间距。
  • 剩余空间计算变更

    • remainingSpacesForSplitWindow 计算中的 appContainer.spacing 替换为 appTitleSpacing
    • 问题appTitleSpacing 定义为 Math.max(10, Math.round(Panel.rootObject.dockItemMaxSize * 9 / 14) / 3),这看起来是图标和标题之间的间距。将其用于计算剩余空间似乎不太合理,因为剩余空间通常取决于应用项之间的总间距(即 appContainer.spacing * 数量)。
    • 建议:仔细检查 remainingSpacesForSplitWindow 的用途。如果它是用于计算分割窗口时的可用空间,那么应该使用应用项之间的实际间距,而不是图标和标题之间的间距。

textcalculator.cpp:

  • 文本宽度计算
    • 新增了 appTitleSpacing 的计算,并将其加到 itemWidth 中。
    • 问题:这里的 appTitleSpacing 计算公式与 TaskManager.qml 中的定义一致,这很好。但是,m_itemPadding 的作用是什么?它是否与 appTitleSpacing 重复?
    • 建议:明确 m_itemPaddingappTitleSpacing 的语义。如果 m_itemPadding 是用于其他用途(例如背景内边距),则保留;如果它也是用于图标和文字之间的间距,则应该合并或明确区分。

2. 代码质量

  • 魔法数字

    • AppItem.qml 中出现了多个魔法数字,如 410.81/5 等。
    • 建议:将这些数字定义为命名常量,例如 ICON_TITLE_PADDINGHOVER_MARGINBACKGROUND_RADIUS_RATIO 等,以提高代码的可读性和可维护性。
    • 例如:
      readonly property int iconTitleExtraPadding: 4
      readonly property real backgroundRadiusRatio: 0.2 // 1/5
  • 代码重复

    • appTitleSpacing 的计算逻辑在 TaskManager.qmltextcalculator.cpp 中重复出现。
    • 建议:如果可能,将这种共享逻辑提取到一个公共的地方(例如 C++ 模型或 QML 单例),以确保一致性并减少维护成本。
  • 状态管理

    • AppItem.qml 中使用 State 来管理布局是一个好的做法,因为它使代码结构清晰。
    • 建议:确保所有受状态影响的属性都在 State 中明确声明,以避免隐式依赖。

3. 代码性能

  • 绑定循环风险

    • AppItem.qmlhoverBackgroundwidth 依赖于 icon.widthtitleLoader.width,而 iconContainer 的宽度又依赖于 root.iconSize
    • 问题:如果 titleLoader.width 依赖于 appItem 的宽度(例如,通过文本自动换行),则可能存在绑定循环。
    • 建议:确保布局依赖关系是单向的,不形成闭环。titleLoader 的宽度应该仅由文本内容和字体决定,而不应受父容器宽度的反向影响(除非使用了 elide,但 elide 不会改变布局流)。
  • 不必要的绑定

    • AppItem.qmlhoverBackgroundopacity 绑定包含了 root.windows.length > 0 的检查。
    • 建议:如果 root.windows 是一个模型,频繁访问其 length 属性可能会有轻微的性能开销。可以考虑在 root 中添加一个 hasWindows 布尔属性,并在窗口列表变化时更新它。

4. 代码安全

  • 除零风险

    • textcalculator.cpp 中的 qMax(10.0, m_iconSize / 3.0) 是安全的,因为除数是常量。
    • 建议:虽然这里没有问题,但在其他地方进行除法运算时,始终检查除数是否为零。
  • 类型安全

    • TaskManager.qml 中的 appTitleSpacing 计算涉及整数和浮点数的混合运算。
    • 建议:明确类型转换。例如,Math.round(...) 返回整数,但 / 3 可能产生浮点数。确保最终结果的类型符合预期(例如,间距通常是整数像素)。

总结与改进建议

  1. 统一布局逻辑:确保 appItemhoverBackgroundiconContainer 的尺寸和间距计算逻辑完全一致,避免视觉错位。
  2. 消除魔法数字:将所有硬编码的数字替换为具有描述性名称的常量。
  3. 明确间距语义:区分并明确 appItemSpacing(应用项之间)、appTitleSpacing(图标和标题之间)和 horizontalSpacing/verticalSpacing(背景内边距)的用途和计算方式。
  4. 审查剩余空间计算:确保 remainingSpacesForSplitWindow 使用正确的间距值。
  5. 性能优化:检查是否存在不必要的属性绑定或重复计算。

示例改进代码 (AppItem.qml 片段)

// 定义常量
readonly property int iconTitleExtraPadding: 4
readonly property real backgroundRadiusRatio: 0.2 // 1/5
readonly property int hoverMargin: 1

Control {
    id: appItem
    // 统一宽度计算,确保与 hoverBackground 一致
    implicitWidth: root.titleActive 
        ? (root.iconSize + iconTitleExtraPadding + titleLoader.width + root.appTitleSpacing + hoverBackground.horizontalSpacing * 2) 
        : (root.iconSize + hoverBackground.horizontalSpacing * 2)
    
    // ... 其他属性 ...

    background: AppletItemBackground {
        id: hoverBackground
        
        // 使用常量
        readonly property int verticalSpacing: Math.round(root.iconSize / 8) + 1
        readonly property int horizontalSpacing: Math.round(root.iconSize / 8)
        
        // ... 其他属性 ...
        
        // 确保宽度计算与 appItem.implicitWidth 一致
        width: root.titleActive 
            ? Math.round(root.iconSize + titleLoader.width + horizontalSpacing * 2)
            : Math.round(root.iconSize + horizontalSpacing * 2)
            
        // ... 其他属性 ...
    }
    
    // ... 其他代码 ...
}

通过以上改进,代码的可读性、可维护性和健壮性都将得到提升。

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

@wjyrich
Copy link
Contributor Author

wjyrich commented Feb 9, 2026

/forcemerge

@deepin-bot
Copy link

deepin-bot bot commented Feb 9, 2026

This pr force merged! (status: behind)

@deepin-bot deepin-bot bot merged commit c50c790 into linuxdeepin:master Feb 9, 2026
10 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