Skip to content

Commit 9fc7ca4

Browse files
committed
feat: add taskbar click handler for locked state
1. Implement handleDragAreaClick function to activate applications when taskbar is locked 2. Add coordinate mapping logic to convert drag area clicks to app container positions 3. Support all dock positions (bottom, top, left, right) with appropriate coordinate adjustments 4. Connect click handler to drag area onClicked event when Panel.locked is true 5. Expose appContainer property in TaskManager for external access feat: 为锁定状态添加任务栏点击处理功能 1. 实现 handleDragAreaClick 函数,在任务栏锁定时激活应用程序 2. 添加坐标映射逻辑,将拖拽区域点击转换为应用容器位置 3. 支持所有停靠位置(底部、顶部、左侧、右侧)并相应调整坐标 4. 当 Panel.locked 为 true 时,将点击处理程序连接到拖拽区域的 onClicked 事件 5. 在 TaskManager 中暴露 appContainer 属性以供外部访问 PMS: TASK-383127
1 parent 8dcf20e commit 9fc7ca4

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

panels/dock/package/main.qml

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,49 @@ Window {
263263
dockRightPartModel.update()
264264
}
265265

266+
// 在任务栏锁定状态下,点击任务栏相应位置的应用
267+
function handleDragAreaClick(x, y) {
268+
if (!Panel.locked) return false
269+
270+
let taskmanager = DS.applet("org.deepin.ds.dock.taskmanager")
271+
if (!taskmanager || !taskmanager.rootObject) return false
272+
273+
let dataModel = taskmanager.dataModel
274+
if (!dataModel) return false
275+
276+
let appContainer = taskmanager.rootObject.appContainer
277+
if (!appContainer) return false
278+
279+
// 将dragArea的点击坐标映射到应用容器
280+
let dragAreaPos = dragArea.mapToItem(appContainer, x, y)
281+
282+
// 根据dock位置调整坐标映射逻辑
283+
let targetPos = Qt.point(0, 0)
284+
if (Panel.position === Dock.Bottom) {
285+
targetPos.x = dragAreaPos.x
286+
targetPos.y = appContainer.height / 2
287+
} else if (Panel.position === Dock.Top) {
288+
targetPos.x = dragAreaPos.x
289+
targetPos.y = appContainer.height / 2
290+
} else if (Panel.position === Dock.Left) {
291+
targetPos.x = appContainer.width / 2
292+
targetPos.y = dragAreaPos.y
293+
} else if (Panel.position === Dock.Right) {
294+
targetPos.x = appContainer.width / 2
295+
targetPos.y = dragAreaPos.y
296+
}
297+
298+
// 计算点击的应用索引
299+
let clickedIndex = appContainer.indexAt(targetPos.x, targetPos.y)
300+
301+
if (clickedIndex >= 0 && clickedIndex < dataModel.rowCount()) {
302+
let modelIndex = dataModel.index(clickedIndex, 0)
303+
taskmanager.requestActivate(modelIndex)
304+
return true
305+
}
306+
return false
307+
}
308+
266309
Loader {
267310
id: dockMenuLoader
268311
active: false
@@ -561,7 +604,12 @@ Window {
561604
}
562605

563606
// this used for blocking MouseEvent sent to bottom MouseArea
564-
onClicked: {}
607+
onClicked: function(mouse) {
608+
// 在锁定状态下,点击dragArea启动相应位置的应用
609+
if (Panel.locked) {
610+
handleDragAreaClick(mouse.x, mouse.y)
611+
}
612+
}
565613

566614
onPositionChanged: function(mouse) {
567615
if (Panel.locked || !dock.isDragging) return

panels/dock/taskmanager/package/TaskManager.qml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ ContainmentItem {
1515
property int dockOrder: 16
1616
property int remainingSpacesForTaskManager: Panel.itemAlignment === Dock.LeftAlignment ? Panel.rootObject.dockLeftSpaceForCenter : Panel.rootObject.dockRemainingSpaceForCenter
1717
property int forceRelayoutWorkaround: 0
18+
property alias appContainer: appContainer
1819

1920
// 用于居中计算的实际应用区域尺寸
2021
property int appContainerWidth: useColumnLayout ? Panel.rootObject.dockSize : (appContainer.implicitWidth + forceRelayoutWorkaround)

0 commit comments

Comments
 (0)