From e41f971254fbdb497a004c46141c2f56b2969625 Mon Sep 17 00:00:00 2001 From: qiqi49 Date: Mon, 26 Feb 2024 14:24:30 +0800 Subject: [PATCH] =?UTF-8?q?fix(qml):=E8=A7=A3=E5=86=B3=E6=8B=96=E6=8B=BD?= =?UTF-8?q?=E5=90=8E=E4=BD=8D=E7=BD=AE=E5=87=BA=E7=8E=B0=E5=81=8F=E7=A7=BB?= =?UTF-8?q?=E3=80=81=E9=BC=A0=E6=A0=87=E9=99=84=E7=9D=80=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E4=B8=8D=E5=B1=85=E4=B8=AD=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- qml/AppUI/AppList.qml | 21 +++++++++++++-------- qml/AppUI/FullScreenAppList.qml | 18 +++++++++--------- 2 files changed, 22 insertions(+), 17 deletions(-) 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 {