Skip to content

feat: add card-type plugin support to dock panel #1659

Open
wjyrich wants to merge 2 commits into
linuxdeepin:masterfrom
wjyrich:CardPlugin
Open

feat: add card-type plugin support to dock panel #1659
wjyrich wants to merge 2 commits into
linuxdeepin:masterfrom
wjyrich:CardPlugin

Conversation

@wjyrich

@wjyrich wjyrich commented Jul 6, 2026

Copy link
Copy Markdown
Contributor
  1. Add Card plugin type to TrayPluginType enum in constants.h
  2. Create CardLeftDockArea QML component for displaying card-type
    plugins in a carousel
  3. Integrate card plugin surfaces into DockCompositor lifecycle (add/
    remove/find)
  4. Implement card area with left-side dock placement, using current/
    index navigation
  5. Support hover effects, page indicators, and wheel navigation for
    card area
  6. Replace legacy left plugin area with CardLeftDockArea when card
    plugins exist

Log: Added card-type plugin display area with carousel navigation in
dock

Influence:

  1. Test card plugin registration and display in dock left area
  2. Verify card plugin area visibility only when card plugins exist
  3. Test mouse wheel navigation through card plugin pages
  4. Verify hover effects and page indicator behavior
  5. Test card plugin surface geometry updates on resize
  6. Verify compatibility with existing tray/quick/fixed plugin types
  7. Test card area behavior in both horizontal and vertical dock modes
  8. Verify area width adapts to dock size and card content

feat: 为任务栏添加卡片类型插件支持

  1. 在 constants.h 中添加 Card 插件类型到 TrayPluginType 枚举
  2. 创建 CardLeftDockArea QML 组件,用于以轮播方式显示卡片类型插件
  3. 将卡片插件表面集成到 DockCompositor 的生命周期(添加/移除/查找)
  4. 实现左侧任务栏卡片区域,支持当前索引/导航
  5. 支持悬停效果、页面指示器和鼠标滚轮导航
  6. 当存在卡片插件时,用 CardLeftDockArea 替换传统的左侧插件区域

Log: 新增卡片类型插件显示区域,支持轮播导航

Influence:

  1. 测试卡片插件的注册和在任务栏左侧区域的显示
  2. 验证卡片插件区域仅在存在卡片插件时可见
  3. 测试通过鼠标滚轮在卡片插件页面间导航
  4. 验证悬停效果和页面指示器的行为
  5. 测试卡片插件表面在窗口大小调整时的几何更新
  6. 验证与现有托盘/快捷/固定插件类型的兼容性
  7. 测试卡片区域在任务栏水平和垂直模式下的表现
  8. 验证区域宽度根据任务栏尺寸和卡片内容自适应

wjyrich added 2 commits July 6, 2026 14:40
1. Implement new FashionAlignment enum value (2) for dock item alignment
2. Create FashionDockController QML component to manage fashion dock
layout and appearance
3. Add "Fashion Mode" menu item in dock context menu for easy mode
switching
4. Integrate fashion dock logic into main dock window: adjust width,
anchors, margins, window radius, and blur effects
5. Update showdesktop and taskmanager to be hidden or behave differently
in fashion mode
6. Ensure width animation when entering/exiting fashion mode
7. Add appropriate DTK blur and styling for fashion dock appearance
8. Update string conversion functions to support the new "fashion"
alignment
9. Hide left part and adjust spacing in fashion mode for a compact,
floating design

Log: Added new dock fashion alignment mode with floating UI and compact
layout

Influence:
1. Test switching between Center, Left, and Fashion alignment modes via
context menu
2. Verify fashion mode only enables on Bottom/Top positions and not in
column layout
3. Check that showdesktop widget is hidden in fashion mode
4. Verify dock width and margin adjustments in fashion mode (floating
margin, vertical padding)
5. Test taskmanager behavior in fashion mode (no remaining space
calculation, no text calculator)
6. Verify blur and color blending correctness in fashion mode for both
light and dark themes
7. Test width animation when enabling/disabling fashion mode
8. Verify dock exclusion zone includes floating margin in fashion mode
9. Test on different screen sizes and DPI settings
10. Validate that left part and its items are hidden in fashion mode

feat: 新增时尚模式对齐方式

1. 实现新的时尚模式对齐枚举值 (2),用于 dock 面板的项目对齐
2. 创建 FashionDockController QML 组件,管理时尚模式布局和外观
3. 在 dock 右键菜单中添加 "时尚模式" 菜单项,便于模式切换
4. 将时尚模式逻辑集成到主 dock 窗口中:调整宽度、锚点、边距、窗口圆角和
模糊效果
5. 更新显示桌面和任务管理器,使其在时尚模式下隐藏或改变行为
6. 在进入/退出时尚模式时启用宽度动画
7. 为时尚模式外观添加合适的 DTK 模糊和样式
8. 更新字符串转换函数以支持新的 "fashion" 对齐方式
9. 在时尚模式下隐藏左侧部分并调整间距,实现紧凑浮动设计

Log: 新增时尚模式对齐方式,浮动UI和紧凑布局

Influence:
1. 通过右键菜单测试中心、左对齐和时尚模式之间的切换
2. 验证时尚模式仅在底部/顶部位置且非列布局时启用
3. 检查显示桌面小部件在时尚模式下是否隐藏
4. 验证时尚模式下的 dock 宽度和边距调整(浮动边距、垂直内边距)
5. 测试任务管理器在时尚模式下的行为(无剩余空间计算、无文本计算器)
6. 验证时尚模式下浅色和深色主题的模糊和颜色混合正确性
7. 测试启用/禁用时尚模式时的宽度动画
8. 验证时尚模式下 dock 排除区域包含浮动边距
9. 在不同屏幕尺寸和 DPI 设置下进行测试
10. 验证左侧部分及其项目在时尚模式下是否隐藏
1. Add Card plugin type to TrayPluginType enum in constants.h
2. Create CardLeftDockArea QML component for displaying card-type
plugins in a carousel
3. Integrate card plugin surfaces into DockCompositor lifecycle (add/
remove/find)
4. Implement card area with left-side dock placement, using current/
index navigation
5. Support hover effects, page indicators, and wheel navigation for
card area
6. Replace legacy left plugin area with CardLeftDockArea when card
plugins exist

Log: Added card-type plugin display area with carousel navigation in
dock

Influence:
1. Test card plugin registration and display in dock left area
2. Verify card plugin area visibility only when card plugins exist
3. Test mouse wheel navigation through card plugin pages
4. Verify hover effects and page indicator behavior
5. Test card plugin surface geometry updates on resize
6. Verify compatibility with existing tray/quick/fixed plugin types
7. Test card area behavior in both horizontal and vertical dock modes
8. Verify area width adapts to dock size and card content

feat: 为任务栏添加卡片类型插件支持

1. 在 constants.h 中添加 Card 插件类型到 TrayPluginType 枚举
2. 创建 CardLeftDockArea QML 组件,用于以轮播方式显示卡片类型插件
3. 将卡片插件表面集成到 DockCompositor 的生命周期(添加/移除/查找)
4. 实现左侧任务栏卡片区域,支持当前索引/导航
5. 支持悬停效果、页面指示器和鼠标滚轮导航
6. 当存在卡片插件时,用 CardLeftDockArea 替换传统的左侧插件区域

Log: 新增卡片类型插件显示区域,支持轮播导航

Influence:
1. 测试卡片插件的注册和在任务栏左侧区域的显示
2. 验证卡片插件区域仅在存在卡片插件时可见
3. 测试通过鼠标滚轮在卡片插件页面间导航
4. 验证悬停效果和页面指示器的行为
5. 测试卡片插件表面在窗口大小调整时的几何更新
6. 验证与现有托盘/快捷/固定插件类型的兼容性
7. 测试卡片区域在任务栏水平和垂直模式下的表现
8. 验证区域宽度根据任务栏尺寸和卡片内容自适应

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

Sorry @wjyrich, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 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

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:70分

■ 【总体评价】

代码实现了任务栏时尚模式及卡片插件功能,但存在严重的布局嵌套与Margin冲突导致UI错位溢出
逻辑错误引发空间重复扣除扣15分,代码质量与性能问题扣15分,无安全漏洞保留70分底线

■ 【详细分析】

  • 1.语法逻辑(存在严重错误)✕

main.qml 中,gridLayout 设置了 anchors.fill: parent,同时又设置了 rightMargin: dockRightPart.implicitWidth + Math.ceil(gridLayout.columnSpacing)。由于 dockRightPart 在 DOM 树中与 gridLayout 是平级兄弟节点,这种在子元素内部通过 margin 为外部兄弟节点避让的做法破坏了 fill: parent 的语义,导致 gridLayout 内部可用宽度被异常截断。同时,在 dockRawCenterSpace 计算中,已经减去了 dockRightPart.implicitWidth,却又额外减去了 gridLayout.columnSpacing,而 FashionDockController.contentWidth 计算窗口总宽时也会加上该间距,这种不对称导致中央区域空间计算偏小,引发图标挤压。
潜在问题:右侧插件区域被挤出屏幕外或与中央区域重叠;任务管理器图标被异常截断或挤压
建议:移除 gridLayout 中的 rightMargin 避让逻辑,改由父容器通过 RowLayout 或锚点布局统一管理 gridLayoutdockRightPart 的位置关系;删除 dockRawCenterSpace 中额外扣除 columnSpacing 的错误逻辑

  • 2.代码质量(存在严重问题)✕

main.qmldockCenterPartLayout.leftMargin 绑定了一个极其复杂且难以阅读的单行三元表达式计算公式,且在时尚模式下直接被短路为0,未做函数封装或拆分。CardLeftDockArea.qmlitemGlobalPointitemGlobalPos 两个函数功能高度重叠,且使用 while 循环遍历父节点获取全局坐标,这种硬编码的坐标累加方式在复杂的 QML 渲染树中极其脆弱且难以维护。
潜在问题:复杂表达式的维护成本极高,容易在后续迭代中引入新缺陷;坐标计算函数在缩放或变换场景下容易失效
建议:将 Layout.leftMargin 的复杂计算提取为独立的 C++ 属性或 QML 函数并增加注释;使用 mapToItem(null, x, y) 替代手动 while 循环遍历计算全局坐标

  • 3.代码性能(存在性能问题)✕

CardLeftDockArea.qml 中的 geometryUpdateTimer 在代理项的 onXChangedonYChangedonWidthChangedonHeightChanged 四个属性变化信号中均无条件调用 restart(),在窗口拖拽或动画过程中会导致定时器被极高频率地重置,产生不必要的开销。手动遍历父节点的坐标计算在代理项较多或布局频繁重排时会带来额外的 CPU 损耗。
潜在问题:高频触发的定时器重置和遍历计算可能导致UI微卡顿
建议:合并几何属性的变化信号,或使用 Binding 结合延迟回调优化更新频率;替换为 QML 原生的坐标映射方法

  • 4.代码安全(存在0个安全漏洞)✓

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
本次变更纯属于 QML 界面布局与渲染逻辑调整,不涉及系统命令执行、文件路径遍历、网络请求或敏感数据处理,未发现安全风险

  • 建议:保持现有的纯 UI 逻辑隔离设计

■ 【改进建议代码示例】

// main.qml 修复片段

// 1. 修复 dockRawCenterSpace 重复扣除间距的问题
readonly property int dockRawCenterSpace: {
    if (useColumnLayout) {
        return Screen.height - dockLeftPart.implicitHeight - dockRightPart.implicitHeight;
    } else {
        // 修复:移除错误的双重扣除 columnSpacing 逻辑
        return Math.max(0, Screen.width - dockLeftPart.implicitWidth - dockRightPart.implicitWidth);
    }
}

// 2. 修复 gridLayout 中不合理的 rightMargin 避让逻辑
// 注意:需配合父容器(如使用 RowLayout 包裹 gridLayout 和 dockRightPart)来控制相对位置
GridLayout {
    id: gridLayout
    anchors {
        fill: parent
        // 修复:移除为外部兄弟节点 dockRightPart 强行扣减宽度的错误 margin
        // rightMargin: fashionDock.enabled && dockRightPart.visible
        //     ? dockRightPart.implicitWidth + Math.ceil(gridLayout.columnSpacing)
        //     : 0
    }
    columns: 1
    rows: 1
    flow: useColumnLayout ? GridLayout.LeftToRight : GridLayout.TopToBottom
    columnSpacing: 20
    rowSpacing: 10
    // ... 内部元素保持不变 ...
}

// 3. CardLeftDockArea.qml 修复坐标计算性能与质量问题
function updateSurfaceGeometry() {
    if (!plugin || !visible) {
        return
    }

    // 修复:使用 QML 原生 mapToItem(null, x, y) 替代手动的 while 循环遍历
    var globalPoint = surfaceHost.mapToItem(null, 0, 0)
    var globalPos = Qt.point(Math.round(globalPoint.x), Math.round(globalPoint.y))
    if (surfaceHost.Window.window) {
        globalPos.x += surfaceHost.Window.window.x
        globalPos.y += surfaceHost.Window.window.y
    }

    plugin.updatePluginGeometry(Qt.rect(globalPos.x, globalPos.y, Math.round(width), Math.round(height)))
    plugin.setGlobalPos(Qt.point(globalPos.x, globalPos.y))
    surfaceItem.fixPosition()
}

// 移除冗余的 itemGlobalPoint 和 itemGlobalPos 函数

@18202781743 18202781743 self-requested a review July 6, 2026 06:56

Component {
id: cardLeftPart
CardLeftDockArea {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

这个是不是可以做成一个applet,去给dock加载,

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