From 27ffb0f7a0e032c5fa852ab7de4dc657811217a9 Mon Sep 17 00:00:00 2001 From: reionwong Date: Mon, 8 Nov 2021 23:44:15 +0800 Subject: [PATCH] Drop item add delay --- qml/AppItem.qml | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/qml/AppItem.qml b/qml/AppItem.qml index e6c75a2..878f58e 100644 --- a/qml/AppItem.qml +++ b/qml/AppItem.qml @@ -26,6 +26,7 @@ DockItem { id: appItem property var windowCount: model.windowCount + property var dragSource: null iconName: model.iconName ? model.iconName : "application-x-desktop" isActive: model.isActive @@ -61,10 +62,13 @@ DockItem { } dropArea.onEntered: { - if (drag.source) - appModel.move(drag.source.dragItemIndex, appItem.dragItemIndex) - else - appModel.raiseWindow(model.appId) + appItem.dragSource = drag.source + dropTimer.restart() + } + + dropArea.onExited: { + appItem.dragSource = null + dropTimer.stop() } dropArea.onDropped: { @@ -72,6 +76,18 @@ DockItem { updateGeometry() } + Timer { + id: dropTimer + interval: 300 + onTriggered: { + if (appItem.dragSource) + appModel.move(appItem.dragSource.dragItemIndex, + appItem.dragItemIndex) + else + appModel.raiseWindow(model.appId) + } + } + FishUI.DesktopMenu { id: contextMenu