fix(applist): 修复滚动列表时容易触发拖拽问题

This commit is contained in:
hewenfei 2024-04-23 19:10:19 +08:00
parent 0d0916fc34
commit 0b4b6a129c
1 changed files with 17 additions and 7 deletions

View File

@ -61,14 +61,15 @@ AppListView {
height: appListView.itemHeight
anchors.centerIn: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
drag.target: appItem
Drag.hotSpot.x: 48 / 2
Drag.hotSpot.y: 48 / 2
Drag.supportedActions: Qt.CopyAction
Drag.dragType: Drag.Automatic
Drag.active: appItem.drag.active
Drag.mimeData: {"id": id, "favorite": favorite}
Drag.onDragFinished: function (dropAction) {
appItem.Drag.active = false;
}
onClicked: {
if (mouse.button === Qt.RightButton) {
@ -80,19 +81,28 @@ AppListView {
return;
}
}
onPressed: {
normalUI.focus = false;
//
grabImage();
}
onPressAndHold: {
//
Drag.active = true;
}
}
function grabImage() {
var icon = mouseGrabImage.createObject(appItem, {width: 48, height: 48, source: model.icon})
icon.grabToImage(function(result) {
appItem.Drag.imageSource = result.url
return result;
});
icon.opacity = 0;
if (icon !== null) {
icon.grabToImage(function(result) {
appItem.Drag.imageSource = result.url
icon.destroy();
});
icon.visible = false;
}
}
Component {