Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions panels/dock/tray/package/ActionShowStashDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,15 @@ AppletItemButton {

Timer {
id: closeStashPopupTimer
running: !isDropHover && !stashedPopup.dropHover && !stashedPopup.stashItemDragging
running: !isDropHover && !stashedPopup.dropHover && !stashedPopup.stashItemDragging && !Panel.contextDragging
interval: 300
repeat: false
onTriggered: {
stashedPopup.close()
// 只在“拖拽前面板未打开”且“拖拽未成功移入 stash”时才关闭
if (!stashedPopup.wasOpenBeforeDrag
&& !stashedPopup.stashDropSucceeded) {
stashedPopup.close()
}
}
}

Expand All @@ -101,6 +105,8 @@ AppletItemButton {
stashedPopup.close()
} else {
stashedPopup.open()
// 用户主动点击打开:后续拖拽结束不应自动关闭面板
stashedPopup.wasOpenBeforeDrag = true
}
if (toolTipShowTimer.running) {
toolTipShowTimer.stop()
Expand Down
10 changes: 8 additions & 2 deletions panels/dock/tray/package/StashContainer.qml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand Down Expand Up @@ -33,6 +33,8 @@ Item {
readonly property int rowCount: Math.round(Math.sqrt(model.count))
property bool dropHover: false
property bool stashItemDragging: false
// 拖拽成功移入 stash 时的回调,由 tray.qml 传入
property var onStashDropSucceeded: null

function isStashPopup(surfaceId)
{
Expand Down Expand Up @@ -94,14 +96,18 @@ Item {
}
onExited: function (dragEvent) {
dropHover = false
stashItemDragging = false
}
onPositionChanged: function (dragEvent) {
let surfaceId = dragEvent.getDataAsString("text/x-dde-shell-tray-dnd-surfaceId")
console.log("dragging", surfaceId)
}
onDropped: function (dropEvent) {
let surfaceId = dropEvent.getDataAsString("text/x-dde-shell-tray-dnd-surfaceId")
DDT.TraySortOrderModel.dropToStashTray(surfaceId, 0, false);
let success = DDT.TraySortOrderModel.dropToStashTray(surfaceId, 0, false);
if (success && onStashDropSucceeded) {
onStashDropSucceeded()
}
}
}

Expand Down
13 changes: 12 additions & 1 deletion panels/dock/tray/package/TrayContainer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ Item {
property int dropHoverIndex: -1
required property var surfaceAcceptor
readonly property bool isDropping: dropArea.containsDrag
// 拖拽成功移入 stash 时的回调(命中 action-show-stash),由 tray.qml 传入
property var onStashDropSucceeded: null

onIsDraggingChanged: {
animationEnable = !isDragging
Expand Down Expand Up @@ -220,8 +222,17 @@ Item {
if (isStash || source === "quickPanel") {
DDT.TraySortOrderModel.commitStagedDrop()
} else {
// 检查是否放到了展开按钮上(命中 action-show-stash 分支,图标移入 stash)
// 在 dropToDockTray 之前检查,避免模型变更后索引失效
let modelIndex = DDT.TraySortOrderModel.getModelIndexByVisualIndex(Math.floor(currentItemIndex))
let dropOnSurfaceId = root.model.data(modelIndex, DDT.TraySortOrderModel.SurfaceIdRole)
let isDroppedOnStashButton = (dropOnSurfaceId === "internal/action-show-stash")

// 托盘内部拖拽直接提交
DDT.TraySortOrderModel.dropToDockTray(surfaceId, Math.floor(currentItemIndex), isBefore);
let success = DDT.TraySortOrderModel.dropToDockTray(surfaceId, Math.floor(currentItemIndex), isBefore);
if (isDroppedOnStashButton && success && onStashDropSucceeded) {
onStashDropSucceeded()
}
}
DDT.TraySortOrderModel.actionsAlwaysVisible = false
}
Expand Down
32 changes: 31 additions & 1 deletion panels/dock/tray/package/tray.qml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ AppletItem {
property alias dropHover: stashContainer.dropHover
property alias stashItemDragging: stashContainer.stashItemDragging

property bool wasOpenBeforeDrag: false
// 拖拽成功标记(图标是否成功移入 stash),由放下的回调根据返回值设置
property bool stashDropSucceeded: false

popupX: DockPanelPositioner.x
popupY: DockPanelPositioner.y

Expand Down Expand Up @@ -72,6 +76,10 @@ AppletItem {
stashedPopup.close()
}
}
// 拖拽成功移入 stash 时由 StashContainer 回调
onStashDropSucceeded: function() {
stashedPopup.stashDropSucceeded = true
}
}
}

Expand All @@ -96,12 +104,30 @@ AppletItem {
interval: 10
repeat: false
onTriggered: {
if (!Panel.contextDragging && !stashedPopup.dropHover) {
// 拖拽仍在进行中时,绝不关闭(可能正要拖入面板)
if (Panel.contextDragging)
return
// 只在“拖拽前面板未打开”且“拖拽未成功移入 stash”时才关闭
if (!stashedPopup.dropHover
&& !stashedPopup.wasOpenBeforeDrag
&& !stashedPopup.stashDropSucceeded) {
stashedPopup.close()
}
}
}

Connections {
target: Panel
function onContextDraggingChanged() {
// 拖拽开始时记录面板状态,拖拽结束后据此决定是否自动关闭
if (Panel.contextDragging) {
stashedPopup.wasOpenBeforeDrag = stashedPopup.popupVisible
stashedPopup.stashDropSucceeded = false
}
}
}


TrayContainer {
id: trayContainter
isHorizontal: !tray.useColumnLayout
Expand All @@ -113,6 +139,10 @@ AppletItem {
Component.onCompleted: {
DDT.TrayItemPositionManager.layoutHealthCheck(1500)
}
// 拖拽成功移入 stash 时由 TrayContainer 回调(命中 action-show-stash)
onStashDropSucceeded: function() {
stashedPopup.stashDropSucceeded = true
}
}

function isTrayPluginPopup(surfaceId) {
Expand Down
Loading