fix(applist): 修复滚动列表时容易触发拖拽问题
This commit is contained in:
parent
0d0916fc34
commit
0b4b6a129c
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue