Skip to content

Commit 8b1fbf6

Browse files
committed
feat: add split window background support for dock app items
1. Created new AppBackground.qml component to handle split window background rendering 2. Added splitBackgroundVisible property to control split background display 3. Enhanced AppletItemBackground.qml with drawDefaultBackground property for conditional rendering 4. Modified AppItem.qml to use AppBackground instead of AppletItemBackground 5. Updated text calculation logic to remove extra spacing between icon and title 6. Added windowSplit property propagation through components 7. Improved title text color handling based on active state and theme Log: Added split window background visualization for dock app items Influence: 1. Test dock app items with multiple windows open in split mode 2. Verify background colors change correctly in light and dark themes 3. Check hover and active states for split window backgrounds 4. Test title text color changes when app is active 5. Verify spacing between icon and title in split mode 6. Test transition animations when switching between split and non- split modes feat: 为任务栏应用项添加分屏窗口背景支持 1. 创建新的 AppBackground.qml 组件处理分屏窗口背景渲染 2. 添加 splitBackgroundVisible 属性控制分屏背景显示 3. 增强 AppletItemBackground.qml 添加 drawDefaultBackground 属性用于条件 渲染 4. 修改 AppItem.qml 使用 AppBackground 替代 AppletItemBackground 5. 更新文本计算逻辑,移除图标和标题之间的额外间距 6. 添加 windowSplit 属性在组件间传递 7. 改进标题文本颜色处理,基于激活状态和主题 Log: 新增任务栏应用项分屏窗口背景可视化功能 Influence: 1. 测试分屏模式下打开多个窗口的任务栏应用项 2. 验证浅色和深色主题下背景颜色正确变化 3. 检查分屏窗口背景的悬停和激活状态 4. 测试应用激活时标题文本颜色变化 5. 验证分屏模式下图标和标题之间的间距 6. 测试分屏和非分屏模式切换时的过渡动画
1 parent 79ee98f commit 8b1fbf6

7 files changed

Lines changed: 173 additions & 46 deletions

File tree

panels/dock/AppletItemBackground.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
1+
// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
22
//
33
// SPDX-License-Identifier: GPL-3.0-or-later
44

panels/dock/taskmanager/package/AppItem.qml

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,9 @@ Item {
3838
Drag.mimeData: { "text/x-dde-dock-dnd-appid": itemId, "text/x-dde-dock-dnd-source": "taskbar", "text/x-dde-dock-dnd-winid": windows.length > 0 ? windows[0] : ""}
3939

4040
property bool useColumnLayout: Panel.rootObject.useColumnLayout
41-
property int statusIndicatorSize: useColumnLayout ? root.width * 0.72 : root.height * 0.72
4241
property int iconSize: Panel.rootObject.dockItemMaxSize * 9 / 14
4342
property bool enableTitle: false
4443
property bool titleActive: enableTitle && titleLoader.active
45-
property int appTitleSpacing: 0
4644
property var iconGlobalPoint: {
4745
var a = icon
4846
var x = 0, y = 0
@@ -79,16 +77,15 @@ Item {
7977
Control {
8078
anchors.fill: parent
8179
id: appItem
82-
implicitWidth: root.titleActive ? (iconContainer.width + 4 + titleLoader.width + root.appTitleSpacing) : iconContainer.width + root.appTitleSpacing
80+
implicitWidth: root.titleActive ? (root.iconSize + hoverBackground.horizontalSpacing + titleLoader.width) : iconContainer.width
8381
visible: !root.Drag.active // When in dragging, hide app item
84-
background: AppletItemBackground {
82+
background: AppItemBackground {
8583
id: hoverBackground
8684

8785
readonly property int verticalSpacing: Math.round(root.iconSize / 8) + 1
8886
readonly property int horizontalSpacing: Math.round(root.iconSize / 8)
8987
readonly property int nonSplitHeight: root.iconSize + verticalSpacing * 2
90-
readonly property int hoverPadding: Math.round((Panel.rootObject.dockItemMaxSize * 0.8 - root.iconSize) / 2)
91-
readonly property int splitWidth: Math.round(icon.width + titleLoader.width + hoverPadding * 2)
88+
readonly property int splitWidth: Math.round(root.iconSize + titleLoader.width + horizontalSpacing * 3)
9289
readonly property int nonSplitWidth: Math.round(root.iconSize + horizontalSpacing * 2)
9390

9491
enabled: false
@@ -98,10 +95,8 @@ Item {
9895
radius: height / 5
9996
anchors.centerIn: parent
10097
isActive: root.active
101-
opacity: (hoverHandler.hovered || (root.active && root.windows.length > 0)) ? 1.0 : 0.0
102-
Behavior on opacity {
103-
NumberAnimation { duration: 150 }
104-
}
98+
windowCount: root.windows.length
99+
displayMode: root.displayMode
105100
}
106101
Item {
107102
id: iconContainer
@@ -118,10 +113,6 @@ Item {
118113
anchors.left: parent.left
119114
anchors.horizontalCenter: undefined
120115
}
121-
PropertyChanges {
122-
target: iconContainer
123-
anchors.leftMargin: hoverBackground.horizontalSpacing
124-
}
125116
},
126117
State {
127118
name: "nonTitleActive"
@@ -134,13 +125,12 @@ Item {
134125
}
135126
}
136127
]
137-
StatusIndicator {
138-
id: statusIndicator
139-
palette: itemPalette
140-
width: root.statusIndicatorSize
141-
height: root.statusIndicatorSize
142-
anchors.centerIn: iconContainer
143-
visible: root.displayMode === Dock.Efficient && root.windows.length > 0
128+
129+
Connections {
130+
function onDisplayModeChanged() {
131+
windowIndicator.updateIndicatorAnchors()
132+
}
133+
target: root
144134
}
145135

146136
Connections {
@@ -215,28 +205,30 @@ Item {
215205
windowIndicator.anchors.horizontalCenter = undefined
216206
windowIndicator.anchors.verticalCenter = undefined
217207

208+
const anchorTarget = root.displayMode === Dock.Efficient ? appItem : hoverBackground
209+
218210
switch(Panel.position) {
219211
case Dock.Top: {
220212
windowIndicator.anchors.horizontalCenter = iconContainer.horizontalCenter
221-
windowIndicator.anchors.top = hoverBackground.top
213+
windowIndicator.anchors.top = anchorTarget.top
222214
windowIndicator.anchors.topMargin = 1
223215
return
224216
}
225217
case Dock.Bottom: {
226218
windowIndicator.anchors.horizontalCenter = iconContainer.horizontalCenter
227-
windowIndicator.anchors.bottom = hoverBackground.bottom
219+
windowIndicator.anchors.bottom = anchorTarget.bottom
228220
windowIndicator.anchors.bottomMargin = 1
229221
return
230222
}
231223
case Dock.Left: {
232224
windowIndicator.anchors.verticalCenter = parent.verticalCenter
233-
windowIndicator.anchors.left = hoverBackground.left
225+
windowIndicator.anchors.left = anchorTarget.left
234226
windowIndicator.anchors.leftMargin = 1
235227
return
236228
}
237229
case Dock.Right:{
238230
windowIndicator.anchors.verticalCenter = parent.verticalCenter
239-
windowIndicator.anchors.right = hoverBackground.right
231+
windowIndicator.anchors.right = anchorTarget.right
240232
windowIndicator.anchors.rightMargin = 1
241233
return
242234
}
@@ -251,13 +243,18 @@ Item {
251243
AppItemTitle {
252244
id: titleLoader
253245
anchors.left: iconContainer.right
254-
anchors.leftMargin: 4
246+
anchors.leftMargin: Math.round(root.iconSize / 8)
255247
anchors.verticalCenter: parent.verticalCenter
256248
enabled: root.enableTitle && root.windows.length > 0
257249
text: root.title
250+
textColor: {
251+
if (root.displayMode === Dock.Efficient && root.active) {
252+
return "#000000"
253+
}
254+
return D.DTK.themeType === D.ApplicationHelper.DarkType ? "#FFFFFF" : "#000000"
255+
}
258256
}
259257

260-
// TODO: value can set during debugPanel
261258
Loader {
262259
id: animationRoot
263260
anchors.fill: parent
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
// SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd.
2+
//
3+
// SPDX-License-Identifier: GPL-3.0-or-later
4+
5+
import QtQuick
6+
import QtQuick.Controls
7+
8+
import org.deepin.ds.dock 1.0
9+
import org.deepin.dtk
10+
11+
AppletItemBackground {
12+
id: control
13+
property int windowCount: 0
14+
property int displayMode: Dock.Efficient
15+
property Palette minDockEffectActive: Palette {
16+
normal {
17+
crystal: Qt.rgba(1.0, 1.0, 1.0, 0.8)
18+
}
19+
normalDark {
20+
crystal: Qt.rgba(1.0, 1.0, 1.0, 0.6)
21+
}
22+
hovered {
23+
crystal: Qt.rgba(1.0, 1.0, 1.0, 0.9)
24+
}
25+
hoveredDark {
26+
crystal: Qt.rgba(1.0, 1.0, 1.0, 0.7)
27+
}
28+
}
29+
property Palette normalDockEffectActive: Palette {
30+
normal {
31+
crystal: ("transparent")
32+
}
33+
normalDark: normal
34+
hovered {
35+
crystal: Qt.rgba(1.0, 1.0, 1.0, 0.15)
36+
}
37+
hoveredDark: hovered
38+
}
39+
backgroundColor: Palette {
40+
normal {
41+
crystal: if (displayMode === Dock.Efficient && control.windowCount > 0) {
42+
return Qt.rgba(1.0, 1.0, 1.0, 0.35)
43+
} else {
44+
return ("transparent")
45+
}
46+
}
47+
normalDark: {
48+
crystal: if (displayMode === Dock.Efficient && control.windowCount > 0) {
49+
return Qt.rgba(1.0, 1.0, 1.0, 0.1)
50+
} else {
51+
return ("transparent")
52+
}
53+
}
54+
hovered {
55+
crystal: Qt.rgba(1.0, 1.0, 1.0, 0.15)
56+
}
57+
hoveredDark {
58+
crystal: Qt.rgba(1.0, 1.0, 1.0, 0.15)
59+
}
60+
pressed {
61+
crystal: Qt.rgba(1.0, 1.0, 1.0, 0.25)
62+
}
63+
pressedDark {
64+
crystal: Qt.rgba(1.0, 1.0, 1.0, 0.25)
65+
}
66+
}
67+
activeBackgroundColor: displayMode === Dock.Efficient ? minDockEffectActive : normalDockEffectActive
68+
insideBorderColor: Palette {
69+
normal {
70+
crystal: if (displayMode === Dock.Efficient && control.windowCount > 0) {
71+
return Qt.rgba(1.0, 1.0, 1.0, 0.05)
72+
} else {
73+
return ("transparent")
74+
}
75+
}
76+
normalDark: normal
77+
hovered {
78+
crystal: Qt.rgba(0, 0, 0, 0.05)
79+
}
80+
hoveredDark: hovered
81+
pressed: hovered
82+
pressedDark: pressed
83+
}
84+
85+
activeInsideBorderColor: Palette {
86+
normal {
87+
crystal: if (displayMode === Dock.Efficient) {
88+
return Qt.rgba(0, 0, 0, 0.1)
89+
} else {
90+
return ("transparent")
91+
}
92+
}
93+
normalDark: {
94+
crystal: if (displayMode === Dock.Efficient) {
95+
return Qt.rgba(1.0, 1.0, 1.0, 0.1)
96+
} else {
97+
return ("transparent")
98+
}
99+
}
100+
hovered {
101+
crystal: Qt.rgba(1.0, 1.0, 1.0, 0.1)
102+
}
103+
hoveredDark: hovered
104+
pressed: hovered
105+
pressedDark: pressed
106+
}
107+
outsideBorderColor: Palette {
108+
normal: {
109+
crystal: ("transparent")
110+
}
111+
normalDark: normal
112+
hovered : normal
113+
hoveredDark: hovered
114+
pressed: hovered
115+
pressedDark: pressed
116+
}
117+
activeOutsideBorderColor: Palette {
118+
normal {
119+
crystal: if (displayMode === Dock.Efficient) {
120+
return Qt.rgba(0, 0, 0, 0.1)
121+
} else {
122+
return ("transparent")
123+
}
124+
}
125+
normalDark {
126+
crystal: if (displayMode === Dock.Efficient) {
127+
return Qt.rgba(0, 0, 0, 0.05)
128+
} else {
129+
return ("transparent")
130+
}
131+
}
132+
hovered {
133+
crystal: Qt.rgba(0.0, 0.0, 0.0, 0.10)
134+
}
135+
hoveredDark: hovered
136+
pressed {
137+
crystal: Qt.rgba(0.0, 0.0, 0.0, 0.10)
138+
}
139+
pressedDark {
140+
crystal: Qt.rgba(0.0, 0.0, 0.0, 0.05)
141+
}
142+
}
143+
}

panels/dock/taskmanager/package/AppItemTitle.qml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Item {
1414

1515
property bool active: titleLoader.active
1616
property string text: ""
17+
property color textColor: D.DTK.themeType === D.ApplicationHelper.DarkType ? "#FFFFFF" : "#000000"
1718

1819
implicitWidth: titleLoader.width
1920
implicitHeight: titleLoader.height
@@ -28,7 +29,7 @@ Item {
2829

2930
text: root.TextCalculator.elidedText
3031

31-
color: D.DTK.themeType === D.ApplicationHelper.DarkType ? "#FFFFFF" : "#000000"
32+
color: root.textColor
3233
font: root.TextCalculator.calculator.font
3334
verticalAlignment: Text.AlignVCenter
3435

panels/dock/taskmanager/package/StatusIndicator.qml

Lines changed: 0 additions & 12 deletions
This file was deleted.

panels/dock/taskmanager/package/TaskManager.qml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ ContainmentItem {
6464
iconSize: Panel.rootObject.dockItemMaxSize * 9 / 14
6565
spacing: appContainer.spacing
6666
cellSize: visualModel.cellWidth
67-
itemPadding: 4
67+
itemPadding: taskmanager.appTitleSpacing
6868
remainingSpace: taskmanager.remainingSpacesForSplitWindow
6969
font.family: D.DTK.fontManager.t6.family
7070
font.pixelSize: Math.max(10, Math.min(20, Math.round(textCalculator.iconSize * 0.35)))
@@ -74,7 +74,7 @@ ContainmentItem {
7474
id: appContainer
7575
anchors.fill: parent
7676
useColumnLayout: taskmanager.useColumnLayout
77-
spacing: 0
77+
spacing: taskmanager.appTitleSpacing
7878
remove: Transition {
7979
NumberAnimation {
8080
properties: "scale,opacity"
@@ -191,7 +191,6 @@ ContainmentItem {
191191
blendOpacity: taskmanager.blendOpacity
192192
title: delegateRoot.title
193193
enableTitle: textCalculator.enabled
194-
appTitleSpacing: taskmanager.appTitleSpacing
195194
ListView.delayRemove: Drag.active
196195
Component.onCompleted: {
197196
dropFilesOnItem.connect(taskmanager.Applet.dropFilesOnItem)

panels/dock/taskmanager/textcalculator.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,7 @@ void TextCalculator::calculateOptimalTextWidth()
277277
qreal textWidth = calculateElidedTextWidth(title, baselineWidth);
278278
// Only add spacing between icon and text when text is present
279279
if (textWidth > 0.0) {
280-
qreal appTitleSpacing = qMax(10.0, m_iconSize / 3.0);
281-
itemWidth = m_iconSize + m_itemPadding + textWidth + appTitleSpacing;
280+
itemWidth = m_iconSize + m_itemPadding + textWidth;
282281
} else {
283282
itemWidth = m_cellSize;
284283
}

0 commit comments

Comments
 (0)