From 3a0695fe67353aa0337e93453c349bfb2727b735 Mon Sep 17 00:00:00 2001 From: wjyrich Date: Thu, 2 Jul 2026 19:59:14 +0800 Subject: [PATCH 1/2] feat: add FashionAlignment mode for dock panel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. 验证左侧部分及其项目在时尚模式下是否隐藏 --- panels/dock/constants.h | 3 +- panels/dock/docksettings.cpp | 4 + panels/dock/package/FashionDockController.qml | 65 ++++++++++++++++ panels/dock/package/main.qml | 78 +++++++++++++++---- .../dock/showdesktop/package/showdesktop.qml | 10 ++- .../dock/taskmanager/package/TaskManager.qml | 10 ++- 6 files changed, 150 insertions(+), 20 deletions(-) create mode 100644 panels/dock/package/FashionDockController.qml diff --git a/panels/dock/constants.h b/panels/dock/constants.h index bf3cb9372..69fc3823b 100644 --- a/panels/dock/constants.h +++ b/panels/dock/constants.h @@ -1,6 +1,6 @@ // Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd. // SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd. -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: LGPL-3.0-or-later @@ -36,6 +36,7 @@ enum IndicatorStyle { enum ItemAlignment { CenterAlignment = 0, LeftAlignment = 1, + FashionAlignment = 2, }; enum ColorTheme { diff --git a/panels/dock/docksettings.cpp b/panels/dock/docksettings.cpp index ac78af46f..575b60ccf 100644 --- a/panels/dock/docksettings.cpp +++ b/panels/dock/docksettings.cpp @@ -85,6 +85,8 @@ static QString itemAlignment2String(const ItemAlignment& alignment) return "left"; case ItemAlignment::CenterAlignment: return "center"; + case ItemAlignment::FashionAlignment: + return "fashion"; } return "center"; @@ -111,6 +113,8 @@ static ItemAlignment string2ItenAlignment(const QString& alignmentStr) return ItemAlignment::LeftAlignment; else if (alignmentStr == "center") return ItemAlignment::CenterAlignment; + else if (alignmentStr == "fashion") + return ItemAlignment::FashionAlignment; return ItemAlignment::CenterAlignment; } diff --git a/panels/dock/package/FashionDockController.qml b/panels/dock/package/FashionDockController.qml new file mode 100644 index 000000000..d6e80a810 --- /dev/null +++ b/panels/dock/package/FashionDockController.qml @@ -0,0 +1,65 @@ +// SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later + +import QtQuick 2.15 + +import org.deepin.ds 1.0 +import org.deepin.ds.dock 1.0 +import org.deepin.dtk.style 1.0 as DStyle + +QtObject { + id: root + + property bool useColumnLayout: false + property int itemAlignment: Dock.CenterAlignment + property int position: Dock.Bottom + property int hideState: Dock.Show + property real dockSize: 0 + property real dockItemIconSize: 0 + property real devicePixelRatio: 1 + property int screenWidth: 0 + property int colorTheme: Dock.Light + property bool dragging: false + property var gridLayout: null + property var rightPart: null + + readonly property bool enabled: !useColumnLayout + && itemAlignment === Dock.FashionAlignment + && (position === Dock.Bottom || position === Dock.Top) + readonly property bool topMode: enabled && position === Dock.Top + readonly property bool bottomMode: enabled && position === Dock.Bottom + readonly property int floatingMargin: 8 + readonly property int verticalPadding: Math.max(6, Math.round(dockSize * 0.16)) + readonly property int surfaceThickness: useColumnLayout ? dockSize : dockSize + verticalPadding * 2 + readonly property int backgroundRadius: Math.round(surfaceThickness / 4) + readonly property real gridDisplayedWidth: enabled && gridLayout + ? gridLayout.implicitWidth + : 0 + readonly property real gridDisplayedHeight: enabled && gridLayout + ? gridLayout.implicitHeight + : 0 + readonly property real contentWidth: { + if (!enabled) { + return 0 + } + + let width = gridDisplayedWidth + if (rightPart && rightPart.visible) { + if (width > 0) { + width += gridLayout.columnSpacing + } + width += rightPart.implicitWidth + } + return width + } + readonly property bool widthAnimationEnabled: enabled && !dragging + + function effectiveShellWidth() { + if (!enabled) { + return 0 + } + + return Math.min(contentWidth, screenWidth) + } +} diff --git a/panels/dock/package/main.qml b/panels/dock/package/main.qml index 68e8931e6..98f7a915c 100644 --- a/panels/dock/package/main.qml +++ b/panels/dock/package/main.qml @@ -13,19 +13,42 @@ import Qt.labs.platform as LP import org.deepin.ds 1.0 import org.deepin.ds.dock 1.0 import org.deepin.dtk 1.0 as D -import org.deepin.dtk.style 1.0 as DStyle Window { id: dock property int positionForAnimation: Panel.position property bool useColumnLayout: positionForAnimation % 2 + + FashionDockController { + id: fashionDockController + useColumnLayout: dock.useColumnLayout + itemAlignment: Panel.itemAlignment + position: dock.positionForAnimation + hideState: Panel.hideState + dockSize: dock.dockSize + dockItemIconSize: dock.dockItemIconSize + devicePixelRatio: Panel.devicePixelRatio > 0 ? Panel.devicePixelRatio : Screen.devicePixelRatio + screenWidth: Screen.width + colorTheme: Panel.colorTheme + dragging: dock.isDragging + gridLayout: gridLayout + rightPart: dockRightPart + } + + property alias fashionDock: fashionDockController property int dockCenterPartCount: dockCenterPartModel.count readonly property int dockRawCenterSpace: { if (useColumnLayout) { return Screen.height - dockLeftPart.implicitHeight - dockRightPart.implicitHeight; } else { - return Screen.width - dockLeftPart.implicitWidth - dockRightPart.implicitWidth; + let space = Screen.width - dockLeftPart.implicitWidth - dockRightPart.implicitWidth; + if (fashionDock.enabled && gridLayout) { + // 时尚模式下,dockRightPart 在 gridLayout 右侧,之间需要扣除 dockSpacing + // 这是为了确保 gridLayout 的宽度 + dockSpacing + rightPart 宽度 <= screenWidth + space -= Math.ceil(gridLayout.columnSpacing); + } + return Math.max(0, space); } } @@ -45,7 +68,13 @@ Window { property real dockItemIconSize: dockItemMaxSize * 9 / 14 // NOTE: -1 means not set its size, follow the platform size - width: positionForAnimation === Dock.Top || positionForAnimation === Dock.Bottom ? -1 : dockSize + width: { + if (fashionDock.enabled) { + return Math.max(1, fashionDock.effectiveShellWidth()) + } + + return positionForAnimation === Dock.Top || positionForAnimation === Dock.Bottom ? -1 : dockSize + } height: positionForAnimation === Dock.Left || positionForAnimation === Dock.Right ? -1 : dockSize color: "transparent" flags: Qt.WindowDoesNotAcceptFocus @@ -65,14 +94,21 @@ Window { MenuHelper.openMenu(dockMenuLoader.item) } - DLayerShellWindow.anchors: position2Anchors(positionForAnimation) + DLayerShellWindow.anchors: fashionDock.enabled + ? (fashionDock.topMode ? DLayerShellWindow.AnchorTop : DLayerShellWindow.AnchorBottom) + : position2Anchors(positionForAnimation) + DLayerShellWindow.topMargin: fashionDock.topMode ? fashionDock.floatingMargin : 0 + + DLayerShellWindow.bottomMargin: fashionDock.bottomMode ? fashionDock.floatingMargin : 0 DLayerShellWindow.layer: DLayerShellWindow.LayerTop - DLayerShellWindow.exclusionZone: Panel.hideMode === Dock.KeepShowing ? Applet.dockSize : 0 + DLayerShellWindow.exclusionZone: Panel.hideMode === Dock.KeepShowing + ? Applet.dockSize + (fashionDock.enabled ? fashionDock.floatingMargin : 0) + : 0 DLayerShellWindow.scope: "dde-shell/dock" DLayerShellWindow.keyboardInteractivity: DLayerShellWindow.KeyboardInteractivityOnDemand D.DWindow.enabled: true - D.DWindow.windowRadius: 0 + D.DWindow.windowRadius: fashionDock.enabled ? fashionDock.backgroundRadius : 0 //TODO:由于windoweffect处理有BUG,导致动画结束后一致保持无阴影,无borderwidth状态。 无法恢复到最初的阴影和边框 //D.DWindow.windowEffect: hideShowAnimation.running ? D.PlatformHandle.EffectNoShadow | D.PlatformHandle.EffectNoBorder : 0 @@ -89,12 +125,21 @@ Window { D.ColorSelector.family: D.Palette.CrystalColor onDockSizeChanged: { - if (dock.dockSize === Dock.MIN_DOCK_SIZE) { + if (fashionDock.enabled) { + Panel.indicatorStyle = Dock.Fashion + } else if (dock.dockSize === Dock.MIN_DOCK_SIZE) { Panel.indicatorStyle = Dock.Efficient } else { Panel.indicatorStyle = Dock.Fashion } } + Behavior on width { + enabled: fashionDock.widthAnimationEnabled + NumberAnimation { + duration: 200 + easing.type: Easing.OutQuad + } + } Binding on itemIconSizeBase { when: !isDragging @@ -326,6 +371,11 @@ Window { prop: "itemAlignment" value: Dock.CenterAlignment } + EnumPropertyMenuItem { + name: qsTr("Fashion Mode") + prop: "itemAlignment" + value: Dock.FashionAlignment + } } MutuallyExclusiveMenu { title: qsTr("Position") @@ -402,7 +452,7 @@ Window { D.StyledBehindWindowBlur { control: parent anchors.fill: parent - cornerRadius: 0 + cornerRadius: fashionDock.enabled ? fashionDock.backgroundRadius : 0 blendColor: { if (valid) { return DStyle.Style.control.selectColor(undefined, @@ -485,7 +535,7 @@ Window { //此处为边距区域的点击实践特殊处理。 MouseArea { id: leftMarginArea - width: useColumnLayout ? parent.width : gridLayout.columnSpacing + width: useColumnLayout ? parent.width : (fashionDock.enabled ? 0 : gridLayout.columnSpacing) height: useColumnLayout ? gridLayout.rowSpacing : parent.height anchors.left: parent.left anchors.top: parent.top @@ -514,13 +564,14 @@ Window { Item { id: leftMargin + visible: !fashionDock.enabled implicitWidth: 0 implicitHeight: 0 } Item { id: dockLeftPart - visible: dockLeftPartModel.count > 0 + visible: !fashionDock.enabled && dockLeftPartModel.count > 0 implicitWidth: leftLoader.implicitWidth implicitHeight: leftLoader.implicitHeight OverflowContainer { @@ -543,7 +594,7 @@ Window { Layout.maximumHeight: useColumnLayout ? dockRawCenterSpace : -1 onXChanged: dockCenterPartPosChanged() onYChanged: dockCenterPartPosChanged() - Layout.leftMargin: !useColumnLayout && Panel.itemAlignment === Dock.CenterAlignment ? + Layout.leftMargin: !useColumnLayout && !fashionDock.enabled && Panel.itemAlignment === Dock.CenterAlignment ? Math.max(0, (dock.width - dockCenterPart.implicitWidth) / 2 - (dockLeftPart.implicitWidth + 20) + Math.min((dock.width - dockCenterPart.implicitWidth) / 2 - (dockRightPart.implicitWidth + 20), 0)) : 0 Layout.topMargin: useColumnLayout && Panel.itemAlignment === Dock.CenterAlignment ? Math.max(0, (dock.height - dockCenterPart.implicitHeight) / 2 - (dockLeftPart.implicitHeight + 20) + Math.min((dock.height - dockCenterPart.implicitHeight) / 2 - (dockRightPart.implicitHeight + 20), 0)) : 0 @@ -578,8 +629,9 @@ Window { } Item { - Layout.fillWidth: true - Layout.fillHeight: true + Layout.fillWidth: !fashionDock.enabled + Layout.fillHeight: !fashionDock.enabled + visible: !fashionDock.enabled } } diff --git a/panels/dock/showdesktop/package/showdesktop.qml b/panels/dock/showdesktop/package/showdesktop.qml index cd3b18932..e0230b7ba 100644 --- a/panels/dock/showdesktop/package/showdesktop.qml +++ b/panels/dock/showdesktop/package/showdesktop.qml @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -13,11 +13,13 @@ AppletItem { id: showdesktop readonly property int showDesktopWidth: 10 property bool useColumnLayout: Panel.position % 2 + readonly property bool fashionMode: Panel.rootObject && Panel.rootObject.fashionDock && Panel.rootObject.fashionDock.enabled property int dockSize: Panel.rootObject.dockItemMaxSize property int dockOrder: 30 - property bool shouldVisible: Applet.visible - implicitWidth: useColumnLayout ? Panel.rootObject.dockSize : showDesktopWidth - implicitHeight: useColumnLayout ? showDesktopWidth : Panel.rootObject.dockSize + property bool shouldVisible: Applet.visible && !fashionMode + visible: shouldVisible + implicitWidth: shouldVisible ? (useColumnLayout ? Panel.rootObject.dockSize : showDesktopWidth) : 0 + implicitHeight: shouldVisible ? (useColumnLayout ? showDesktopWidth : Panel.rootObject.dockSize) : 0 PanelToolTip { id: toolTip diff --git a/panels/dock/taskmanager/package/TaskManager.qml b/panels/dock/taskmanager/package/TaskManager.qml index 130bbc1be..30e30d4e3 100644 --- a/panels/dock/taskmanager/package/TaskManager.qml +++ b/panels/dock/taskmanager/package/TaskManager.qml @@ -14,6 +14,8 @@ ContainmentItem { id: taskmanager property bool useColumnLayout: Panel.rootObject.useColumnLayout property int dockOrder: 16 + readonly property bool fashionMode: Panel.rootObject && Panel.rootObject.fashionDock && Panel.rootObject.fashionDock.enabled + readonly property bool horizontalFashionMode: fashionMode && !useColumnLayout function calcRemainingSpace(baseSize) { const otherCount = Panel.rootObject.dockCenterPartCount - 1; @@ -21,7 +23,9 @@ ContainmentItem { return Panel.rootObject.dockRawCenterSpace - otherOccupied; } - readonly property real remainingSpacesForTaskManager: calcRemainingSpace(Panel.rootObject.dockItemMaxSize) + property real remainingSpacesForTaskManager: fashionMode + ? 0 + : calcRemainingSpace(Panel.rootObject.dockItemMaxSize) readonly property int appTitleSpacing: Math.max(10, Math.round(Panel.rootObject.dockItemMaxSize * 9 / 14) / 3) // Start padding for the app container so that the visual gap // (multitask icon right edge → first app icon left edge) = appTitleSpacing. @@ -37,12 +41,14 @@ ContainmentItem { readonly property real startPadding: Math.max(0, appTitleSpacing - (Panel.rootObject.dockItemMaxSize * (multitaskViewIconRatio - iconWidthToMaxSizeRatio) / 2)) implicitWidth: { + if (horizontalFashionMode) return appContainer.implicitWidth + (useColumnLayout ? 0 : startPadding) let extra = useColumnLayout ? 0 : startPadding let w = appContainer.implicitWidth + extra let maxW = Panel.itemAlignment === Dock.LeftAlignment ? Math.max(remainingSpacesForTaskManager, w) : Math.min(remainingSpacesForTaskManager, w) return useColumnLayout ? Panel.rootObject.dockSize : maxW } implicitHeight: { + if (fashionMode && useColumnLayout) return appContainer.implicitHeight + (useColumnLayout ? startPadding : 0) let extra = useColumnLayout ? startPadding : 0 let h = appContainer.implicitHeight + extra let maxH = Panel.itemAlignment === Dock.LeftAlignment ? Math.max(remainingSpacesForTaskManager, h) : Math.min(remainingSpacesForTaskManager, h) @@ -81,7 +87,7 @@ ContainmentItem { TextCalculator { id: textCalculator - enabled: taskmanager.Applet.windowSplit && (Panel.position == Dock.Bottom || Panel.position == Dock.Top) + enabled: !fashionMode && taskmanager.Applet.windowSplit && (Panel.position == Dock.Bottom || Panel.position == Dock.Top) dataModel: taskmanager.Applet.dataModel iconSize: Panel.rootObject.dockSize * 9 / 14 spacing: Math.max(10, Math.round(textCalculator.iconSize) / 3) From d316c4ec099eb623d64f4ba6bf0c714ed15d706b Mon Sep 17 00:00:00 2001 From: wjyrich Date: Mon, 6 Jul 2026 14:41:54 +0800 Subject: [PATCH 2/2] feat: add card-type plugin support to dock panel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. 验证区域宽度根据任务栏尺寸和卡片内容自适应 --- panels/dock/CMakeLists.txt | 1 + panels/dock/DockCompositor.qml | 6 + panels/dock/cardleft/CMakeLists.txt | 5 + .../cardleft/package/CardLeftDockArea.qml | 254 ++++++++++++++++++ .../cardleft/package/CardLeftDockSwitcher.qml | 37 +++ panels/dock/cardleft/package/metadata.json | 8 + panels/dock/constants.h | 1 + panels/dock/package/main.qml | 17 +- .../dock/showdesktop/package/showdesktop.qml | 3 +- .../dock/taskmanager/package/TaskManager.qml | 2 +- 10 files changed, 326 insertions(+), 8 deletions(-) create mode 100644 panels/dock/cardleft/CMakeLists.txt create mode 100644 panels/dock/cardleft/package/CardLeftDockArea.qml create mode 100644 panels/dock/cardleft/package/CardLeftDockSwitcher.qml create mode 100644 panels/dock/cardleft/package/metadata.json diff --git a/panels/dock/CMakeLists.txt b/panels/dock/CMakeLists.txt index 16d6aa5e0..809c21ff5 100644 --- a/panels/dock/CMakeLists.txt +++ b/panels/dock/CMakeLists.txt @@ -97,6 +97,7 @@ ds_install_package(PACKAGE org.deepin.ds.dock TARGET dockpanel) ds_handle_package_translation(PACKAGE org.deepin.ds.dock) # sub plugins +add_subdirectory(cardleft) add_subdirectory(showdesktop) add_subdirectory(taskmanager) add_subdirectory(tray) diff --git a/panels/dock/DockCompositor.qml b/panels/dock/DockCompositor.qml index e206ee7a4..9d58d5b18 100644 --- a/panels/dock/DockCompositor.qml +++ b/panels/dock/DockCompositor.qml @@ -30,6 +30,7 @@ Item { property ListModel trayPluginSurfaces: ListModel {} property ListModel quickPluginSurfaces: ListModel {} property ListModel fixedPluginSurfaces: ListModel {} + property ListModel cardPluginSurfaces: ListModel {} property var compositor: waylandCompositor property var panelScale: 1.0 @@ -62,6 +63,7 @@ Item { let ret = findSurfaceFromModel(trayPluginSurfaces, surfaceId) if (ret === null) ret = findSurfaceFromModel(quickPluginSurfaces, surfaceId) if (ret === null) ret = findSurfaceFromModel(fixedPluginSurfaces, surfaceId) + if (ret === null) ret = findSurfaceFromModel(cardPluginSurfaces, surfaceId) return ret } @@ -92,6 +94,8 @@ Item { quickPluginSurfaces.append({shellSurface: dockPluginSurface}) } else if (dockPluginSurface.pluginType === Dock.Fixed) { fixedPluginSurfaces.append({shellSurface: dockPluginSurface}) + } else if (dockPluginSurface.pluginType === Dock.Card) { + cardPluginSurfaces.append({shellSurface: dockPluginSurface}) } dockCompositor.pluginSurfacesUpdated() } @@ -104,6 +108,8 @@ Item { removeDockPluginSurface(quickPluginSurfaces, dockPluginSurface) } else if (dockPluginSurface.pluginType === Dock.Fixed) { removeDockPluginSurface(fixedPluginSurfaces, dockPluginSurface) + } else if (dockPluginSurface.pluginType === Dock.Card) { + removeDockPluginSurface(cardPluginSurfaces, dockPluginSurface) } dockCompositor.pluginSurfacesUpdated() } diff --git a/panels/dock/cardleft/CMakeLists.txt b/panels/dock/cardleft/CMakeLists.txt new file mode 100644 index 000000000..a049b858f --- /dev/null +++ b/panels/dock/cardleft/CMakeLists.txt @@ -0,0 +1,5 @@ +# SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd. +# +# SPDX-License-Identifier: GPL-3.0-or-later + +ds_install_package(PACKAGE org.deepin.ds.dock.cardleft) diff --git a/panels/dock/cardleft/package/CardLeftDockArea.qml b/panels/dock/cardleft/package/CardLeftDockArea.qml new file mode 100644 index 000000000..6fc0119f2 --- /dev/null +++ b/panels/dock/cardleft/package/CardLeftDockArea.qml @@ -0,0 +1,254 @@ +// SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later + +import QtQuick 2.15 +import QtQuick.Window 2.15 + +import org.deepin.ds 1.0 +import org.deepin.ds.dock 1.0 +import org.deepin.ds.dock.tray 1.0 as DDT +import org.deepin.dtk 1.0 as D + +AppletItem { + id: root + + readonly property bool fashionMode: Panel.rootObject.fashionDock.enabled + readonly property int dockSize: Panel.rootObject.dockSize + readonly property int hoverInset: 5 + readonly property real taskbarRadius: Panel.rootObject.fashionDock.backgroundRadius + readonly property real hoverBackgroundRadius: Math.max(0, taskbarRadius - hoverInset) + readonly property int hoverFadeDuration: 150 + readonly property int taskbarWidth: Panel.rootObject.adaptiveCardLeftWidth + readonly property int rightContentPadding: Math.max(10, Math.round(taskbarWidth * 0.07)) + readonly property int verticalInset: Math.max(5, Math.round(dockSize * 0.16)) + readonly property int pageContentHeight: Math.max(24, dockSize - verticalInset * 2) + readonly property int pageIndicatorRightInset: Math.max(4, hoverInset + 3) + + readonly property color primaryTextColor: Panel.colorTheme === Dock.Dark + ? Qt.rgba(1, 1, 1, 0.96) + : Qt.rgba(0, 0, 0, 0.92) + + property int dockOrder: 5 + property bool shouldVisible: fashionMode && pageCount > 0 + property int currentIndex: 0 + property int previousIndex: -1 + property int switchDirection: 1 + property real pageTransitionProgress: 1 + readonly property int pageCount: DockCompositor.cardPluginSurfaces.count + property bool contentHovered: false + readonly property bool pageTransitioning: pageTransitionAnimation.running || pageTransitionProgress < 1 + readonly property bool effectiveHovered: rootHoverHandler.hovered || contentHovered + + visible: shouldVisible + implicitWidth: taskbarWidth + implicitHeight: dockSize + clip: true + + function normalizeIndex() { + if (pageCount <= 0) { + previousIndex = -1 + pageTransitionProgress = 1 + currentIndex = 0 + return + } + + if (currentIndex >= pageCount) { + previousIndex = -1 + pageTransitionProgress = 1 + currentIndex = pageCount - 1 + } else if (currentIndex < 0) { + previousIndex = -1 + pageTransitionProgress = 1 + currentIndex = 0 + } + } + + function step(delta) { + if (pageCount <= 1) { + return + } + + const nextIndex = (currentIndex + delta + pageCount) % pageCount + if (nextIndex === currentIndex) { + return + } + + pageTransitionAnimation.stop() + previousIndex = currentIndex + switchDirection = delta > 0 ? 1 : -1 + pageTransitionProgress = 0 + currentIndex = nextIndex + pageTransitionAnimation.restart() + } + + function updateContentHovered() { + const item = pluginRepeater.itemAt(currentIndex) + contentHovered = !!item && item.visible && item.surfaceHovered + } + + onCurrentIndexChanged: updateContentHovered() + onPageCountChanged: { + normalizeIndex() + updateContentHovered() + } + + NumberAnimation { + id: pageTransitionAnimation + + target: root + property: "pageTransitionProgress" + from: 0 + to: 1 + duration: 180 + easing.type: Easing.OutCubic + onStopped: { + root.pageTransitionProgress = 1 + root.previousIndex = -1 + root.updateContentHovered() + } + } + + HoverHandler { + id: rootHoverHandler + acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad | PointerDevice.Stylus + } + + AppletItemBackground { + x: root.hoverInset + y: root.hoverInset + width: Math.max(0, parent.width - root.hoverInset) + height: Math.max(0, parent.height - root.hoverInset * 2) + radius: root.hoverBackgroundRadius + enabled: false + opacity: root.effectiveHovered ? 1 : 0 + D.ColorSelector.hovered: root.effectiveHovered + + Behavior on opacity { + NumberAnimation { + duration: root.hoverFadeDuration + easing.type: Easing.OutCubic + } + } + } + + CardLeftDockSwitcher { + anchors.right: parent.right + anchors.rightMargin: root.pageIndicatorRightInset + anchors.verticalCenter: parent.verticalCenter + visible: root.effectiveHovered && root.pageCount > 1 + itemCount: root.pageCount + currentIndex: root.currentIndex + indicatorSize: 2 + indicatorSpacing: 4 + indicatorColor: root.primaryTextColor + } + + Item { + anchors.left: parent.left + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + anchors.leftMargin: 13 + anchors.rightMargin: root.rightContentPadding + height: root.pageContentHeight + clip: true + + Repeater { + id: pluginRepeater + model: DockCompositor.cardPluginSurfaces + + delegate: Item { + id: surfaceHost + + property var plugin: model.shellSurface + readonly property bool surfaceHovered: visible && surfaceItem.hovered + function itemGlobalPoint() { + var item = surfaceHost + var x = 0 + var y = 0 + while (item) { + x += item.x + y += item.y + item = item.parent + } + return Qt.point(x, y) + } + function itemGlobalPos() { + var point = itemGlobalPoint() + if (surfaceHost.Window.window) { + point.x += surfaceHost.Window.window.x + point.y += surfaceHost.Window.window.y + } + return point + } + + y: { + if (index === root.currentIndex) { + return (1 - root.pageTransitionProgress) * root.switchDirection * height + } + + if (index === root.previousIndex && root.pageTransitioning) { + return -root.pageTransitionProgress * root.switchDirection * height + } + + return 0 + } + width: parent.width + height: parent.height + visible: !!plugin && (index === root.currentIndex || (root.pageTransitioning && index === root.previousIndex)) + + DDT.ShellSurfaceItemProxy { + id: surfaceItem + anchors.fill: parent + shellSurface: surfaceHost.plugin + } + + function updateSurfaceGeometry() { + if (!plugin || !visible) { + return + } + + const globalPoint = itemGlobalPoint() + const globalPos = itemGlobalPos() + plugin.updatePluginGeometry(Qt.rect(Math.round(globalPoint.x), + Math.round(globalPoint.y), + Math.round(width), + Math.round(height))) + plugin.setGlobalPos(Qt.point(Math.round(globalPos.x), + Math.round(globalPos.y))) + surfaceItem.fixPosition() + } + + Component.onCompleted: updateSurfaceGeometry() + onYChanged: geometryUpdateTimer.restart() + onWidthChanged: geometryUpdateTimer.restart() + onHeightChanged: geometryUpdateTimer.restart() + onVisibleChanged: { + geometryUpdateTimer.restart() + root.updateContentHovered() + } + onSurfaceHoveredChanged: root.updateContentHovered() + + Timer { + id: geometryUpdateTimer + interval: 50 + repeat: false + onTriggered: surfaceHost.updateSurfaceGeometry() + } + } + } + } + + MouseArea { + anchors.fill: parent + enabled: root.pageCount > 1 + acceptedButtons: Qt.NoButton + onWheel: function(wheel) { + const deltaY = wheel.angleDelta.y !== 0 ? wheel.angleDelta.y : wheel.pixelDelta.y + if (deltaY !== 0) { + root.step(deltaY < 0 ? 1 : -1) + wheel.accepted = true + } + } + } +} diff --git a/panels/dock/cardleft/package/CardLeftDockSwitcher.qml b/panels/dock/cardleft/package/CardLeftDockSwitcher.qml new file mode 100644 index 000000000..d72571b1d --- /dev/null +++ b/panels/dock/cardleft/package/CardLeftDockSwitcher.qml @@ -0,0 +1,37 @@ +// SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later + +import QtQuick 2.15 + +Item { + id: root + + required property int itemCount + property int currentIndex: 0 + property int indicatorSize: 2 + property int indicatorSpacing: 4 + property color indicatorColor: Qt.rgba(1, 1, 1, 0.96) + + visible: itemCount > 1 + implicitWidth: indicatorColumn.implicitWidth + implicitHeight: indicatorColumn.implicitHeight + + Column { + id: indicatorColumn + + spacing: root.indicatorSpacing + + Repeater { + model: root.itemCount + + Rectangle { + width: root.indicatorSize + height: root.indicatorSize + radius: width / 2 + color: root.indicatorColor + opacity: index === root.currentIndex ? 1 : 0.35 + } + } + } +} diff --git a/panels/dock/cardleft/package/metadata.json b/panels/dock/cardleft/package/metadata.json new file mode 100644 index 000000000..b18a9e068 --- /dev/null +++ b/panels/dock/cardleft/package/metadata.json @@ -0,0 +1,8 @@ +{ + "Plugin": { + "Version": "1.0", + "Id": "org.deepin.ds.dock.cardleft", + "Url": "CardLeftDockArea.qml", + "Parent": "org.deepin.ds.dock" + } +} diff --git a/panels/dock/constants.h b/panels/dock/constants.h index 69fc3823b..7a91c210d 100644 --- a/panels/dock/constants.h +++ b/panels/dock/constants.h @@ -80,6 +80,7 @@ enum TrayPluginType { Tray = 1, Fixed, Quick, + Card, }; enum TrayPluginSizePolicy { diff --git a/panels/dock/package/main.qml b/panels/dock/package/main.qml index 98f7a915c..8260bf400 100644 --- a/panels/dock/package/main.qml +++ b/panels/dock/package/main.qml @@ -18,6 +18,7 @@ Window { id: dock property int positionForAnimation: Panel.position property bool useColumnLayout: positionForAnimation % 2 + readonly property int adaptiveCardLeftWidth: 150 + Math.max(0, dockSize - Dock.DEFAULT_DOCK_SIZE) FashionDockController { id: fashionDockController @@ -554,7 +555,12 @@ Window { // TODO: remove GridLayout and use delegatechosser manager all items GridLayout { id: gridLayout - anchors.fill: parent + anchors { + fill: parent + rightMargin: fashionDock.enabled && dockRightPart.visible + ? dockRightPart.implicitWidth + Math.ceil(gridLayout.columnSpacing) + : 0 + } columns: 1 rows: 1 flow: useColumnLayout ? GridLayout.LeftToRight : GridLayout.TopToBottom @@ -571,11 +577,12 @@ Window { Item { id: dockLeftPart - visible: !fashionDock.enabled && dockLeftPartModel.count > 0 - implicitWidth: leftLoader.implicitWidth - implicitHeight: leftLoader.implicitHeight + visible: dockLeftPartModel.count > 0 + implicitWidth: leftContainer.implicitWidth + implicitHeight: leftContainer.implicitHeight + OverflowContainer { - id: leftLoader + id: leftContainer anchors.fill: parent useColumnLayout: dock.useColumnLayout model: DockPartAppletModel { diff --git a/panels/dock/showdesktop/package/showdesktop.qml b/panels/dock/showdesktop/package/showdesktop.qml index e0230b7ba..998970737 100644 --- a/panels/dock/showdesktop/package/showdesktop.qml +++ b/panels/dock/showdesktop/package/showdesktop.qml @@ -13,8 +13,7 @@ AppletItem { id: showdesktop readonly property int showDesktopWidth: 10 property bool useColumnLayout: Panel.position % 2 - readonly property bool fashionMode: Panel.rootObject && Panel.rootObject.fashionDock && Panel.rootObject.fashionDock.enabled - property int dockSize: Panel.rootObject.dockItemMaxSize + readonly property bool fashionMode: Panel.rootObject.fashionDock.enabled property int dockOrder: 30 property bool shouldVisible: Applet.visible && !fashionMode visible: shouldVisible diff --git a/panels/dock/taskmanager/package/TaskManager.qml b/panels/dock/taskmanager/package/TaskManager.qml index 30e30d4e3..b53d6f176 100644 --- a/panels/dock/taskmanager/package/TaskManager.qml +++ b/panels/dock/taskmanager/package/TaskManager.qml @@ -14,7 +14,7 @@ ContainmentItem { id: taskmanager property bool useColumnLayout: Panel.rootObject.useColumnLayout property int dockOrder: 16 - readonly property bool fashionMode: Panel.rootObject && Panel.rootObject.fashionDock && Panel.rootObject.fashionDock.enabled + readonly property bool fashionMode: Panel.rootObject.fashionDock.enabled readonly property bool horizontalFashionMode: fashionMode && !useColumnLayout function calcRemainingSpace(baseSize) {