fix(qml):解决拖拽后位置出现偏移、鼠标附着图片不居中的问题
This commit is contained in:
parent
f46521509b
commit
e41f971254
|
@ -59,8 +59,17 @@ AppListView {
|
|||
focus: true
|
||||
width: appListView.view ? appListView.view.width : 0
|
||||
height: appListView.itemHeight
|
||||
anchors.centerIn: parent
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||
drag.target: appItemBase
|
||||
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}
|
||||
|
||||
onClicked: {
|
||||
if (mouse.button === Qt.RightButton) {
|
||||
appListView.model.openMenu(index, MenuInfo.AppList);
|
||||
|
@ -71,13 +80,13 @@ AppListView {
|
|||
return;
|
||||
}
|
||||
}
|
||||
onPressed: parent.grabImage();
|
||||
onPressed: grabImage();
|
||||
}
|
||||
|
||||
function grabImage() {
|
||||
var icon = mouseGrabImage.createObject(appItemBase, { width: 48, height: 48, source: model.icon})
|
||||
var icon = mouseGrabImage.createObject(appItem, {width: 48, height: 48, source: model.icon})
|
||||
icon.grabToImage(function(result) {
|
||||
appItemBase.Drag.imageSource = result.url
|
||||
appItem.Drag.imageSource = result.url
|
||||
return result;
|
||||
});
|
||||
icon.opacity = 0;
|
||||
|
@ -88,10 +97,6 @@ AppListView {
|
|||
UkuiItems.Icon { }
|
||||
}
|
||||
|
||||
Drag.supportedActions: Qt.CopyAction
|
||||
Drag.dragType: Drag.Automatic
|
||||
Drag.active: appItem.drag.active
|
||||
Drag.mimeData: {"id": id, "favorite": favorite}
|
||||
|
||||
Keys.onPressed: {
|
||||
if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) {
|
||||
|
|
|
@ -98,17 +98,17 @@ ListView {
|
|||
}
|
||||
}
|
||||
|
||||
drag.target: parent
|
||||
onPressed: parent.grabToImage(function(result) {
|
||||
parent.Drag.imageSource = result.url
|
||||
drag.target: appItem
|
||||
onPressed: grabToImage(function(result) {
|
||||
Drag.imageSource = result.url
|
||||
})
|
||||
Drag.supportedActions: Qt.CopyAction
|
||||
Drag.dragType: Drag.Automatic
|
||||
Drag.active: appItem.drag.active
|
||||
Drag.hotSpot.x: width / 2
|
||||
Drag.hotSpot.y: height / 2
|
||||
Drag.mimeData: {"id": model.id, "favorite": model.favorite > 0}
|
||||
}
|
||||
Drag.supportedActions: Qt.CopyAction
|
||||
Drag.dragType: Drag.Automatic
|
||||
Drag.active: appItem.drag.active
|
||||
Drag.hotSpot.x: width / 2
|
||||
Drag.hotSpot.y: height / 2
|
||||
Drag.mimeData: {"id": model.id, "favorite": model.favorite > 0}
|
||||
|
||||
// 收藏按钮
|
||||
Loader {
|
||||
|
|
Loading…
Reference in New Issue