diff --git a/qml/AppUI/AppList.qml b/qml/AppUI/AppList.qml index 662bfad..f519a35 100644 --- a/qml/AppUI/AppList.qml +++ b/qml/AppUI/AppList.qml @@ -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) { diff --git a/qml/AppUI/FullScreenAppList.qml b/qml/AppUI/FullScreenAppList.qml index 47cb514..9e3c8fb 100644 --- a/qml/AppUI/FullScreenAppList.qml +++ b/qml/AppUI/FullScreenAppList.qml @@ -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 {