Skip to content
Merged
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
21 changes: 19 additions & 2 deletions panels/dock/tray/package/TrayContainer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,15 @@ Item {
id: dropArea
anchors.fill: parent
keys: ["text/x-dde-shell-tray-dnd-surfaceId"]
property bool isDropped: false
property bool dragExited: false
property string source: ""
property string surfaceId: ""
Copy link
Contributor

Choose a reason for hiding this comment

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

这几个变量的值,是不是需要在拖拽完成后重置下,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

拖拽的时候,先触发的onEnter,会初始化这些值

onEntered: function (dragEvent) {
let surfaceId = dragEvent.getDataAsString("text/x-dde-shell-tray-dnd-surfaceId")
let source = dragEvent.getDataAsString("text/x-dde-shell-tray-dnd-source")
dragExited = false
isDropped = false
surfaceId = dragEvent.getDataAsString("text/x-dde-shell-tray-dnd-surfaceId")
source = dragEvent.getDataAsString("text/x-dde-shell-tray-dnd-source")
console.log(surfaceId, source)
if (source !== "" && DDT.TraySortOrderModel.isDisplayedSurface(surfaceId)) {
dragEvent.accepted = false
Expand All @@ -164,6 +170,7 @@ Item {
if (!isStash) {
if (dropHoverIndex !== 0) {
dropTrayTimer.handleDrop = function() {
if (isDropped || dragExited) return
DDT.TraySortOrderModel.dropToDockTray(surfaceId, Math.floor(currentItemIndex), isBefore)
}
dropTrayTimer.start()
Expand All @@ -173,6 +180,7 @@ Item {
}
}
onDropped: function (dropEvent) {
isDropped = true
let surfaceId = dropEvent.getDataAsString("text/x-dde-shell-tray-dnd-surfaceId")
let dropIdx = DDT.TrayItemPositionManager.itemIndexByPoint(Qt.point(drag.x, drag.y))
let currentItemIndex = dropIdx.index
Expand All @@ -182,6 +190,15 @@ Item {
DDT.TraySortOrderModel.actionsAlwaysVisible = false
}

onExited: function () {
dragExited = true
// dragging from quickPanel, entered trayContainer, but not dropped in this area
if (source !== "" && !isDropped) {
dropTrayTimer.stop()
DDT.TraySortOrderModel.setSurfaceVisible(surfaceId, false)
}
}

Timer {
id: dropTrayTimer
interval: 50
Expand Down
Loading