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