Skip to content

Commit 4d5aab8

Browse files
committed
fix: fix touchscreen drag interruption issue
1. Replaced DragHandler with MouseArea for drag handling to better support touchscreen interactions 2. Changed visibility control from `visible` to `opacity` to prevent layout reflow during drag operations 3. Updated drag activation logic to use MouseArea's drag state instead of DragHandler's active state 4. Simplified drag initialization by directly setting Drag.imageSource on the root item 5. Fixed drag state synchronization by binding Drag.active to mouseArea.drag.active Log: Fixed touchscreen drag and drop interruption issues Influence: 1. Test touchscreen drag operations on icon items 2. Verify drag visual feedback (opacity changes) during drag operations 3. Test drag and drop functionality with mouse input 4. Verify drag image appears correctly during drag operations 5. Test drag cancellation and completion scenarios 6. Verify no layout shifts occur during drag operations fix: 修复触摸屏拖拽被打断的问题 1. 将 DragHandler 替换为 MouseArea 以更好地支持触摸屏交互 2. 将可见性控制从 `visible` 改为 `opacity`,防止拖拽过程中的布局重排 3. 更新拖拽激活逻辑,使用 MouseArea 的拖拽状态而非 DragHandler 的活动 状态 4. 简化拖拽初始化,直接在根项目上设置 Drag.imageSource 5. 通过将 Drag.active 绑定到 mouseArea.drag.active 来修复拖拽状态同步 问题 Log: 修复触摸屏拖拽被打断的问题 Influence: 1. 测试触摸屏上的图标拖拽操作 2. 验证拖拽过程中的视觉反馈(透明度变化) 3. 测试鼠标输入的拖放功能 4. 验证拖拽过程中拖拽图像正确显示 5. 测试拖拽取消和完成场景 6. 验证拖拽过程中没有布局偏移发生 PMS: BUG-346077
1 parent 0848d6b commit 4d5aab8

1 file changed

Lines changed: 11 additions & 18 deletions

File tree

qml/windowed/IconItemDelegate.qml

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import org.deepin.launchpad 1.0
1212

1313
Control {
1414
id: root
15-
visible: !dragHandler.active
15+
opacity: Drag.active ? 0 : 1
1616

1717
property string text: display.startsWith("internal/category/") ? getCategoryName(display.substring(18)) : display
1818

@@ -25,10 +25,11 @@ Control {
2525
signal menuTriggered()
2626

2727
Drag.dragType: Drag.Automatic
28+
Drag.active: mouseArea.drag.active
2829

2930
states: State {
3031
name: "dragged";
31-
when: dragHandler.active
32+
when: mouseArea.drag.active
3233
// FIXME: When dragging finished, the position of the item is changed for unknown reason,
3334
// so we use the state to reset the x and y here.
3435
PropertyChanges {
@@ -73,25 +74,17 @@ Control {
7374
theme: ApplicationHelper.DarkType
7475
}
7576

76-
DragHandler {
77-
id: dragHandler
78-
target: root
77+
MouseArea {
78+
id: mouseArea
79+
anchors.fill: parent
80+
hoverEnabled: false
7981
acceptedButtons: Qt.LeftButton
8082
enabled: root.dndEnabled
81-
dragThreshold: 1
82-
onActiveChanged: {
83-
if (active) {
84-
// We switch to use the `dndItem` to handle Drag event since that one will always exists.
85-
// If we use the current item, then if the item that provides the drag attached property
86-
// get destoryed (e.g. switch page or folder close caused destory), dropping at that moment
87-
// will cause a crash.
88-
dndItem.Drag.hotSpot = target.Drag.hotSpot
89-
dndItem.Drag.mimeData = target.Drag.mimeData
90-
83+
drag.target: root
84+
onPressed: function (mouse) {
85+
if (mouse.button === Qt.LeftButton && root.dndEnabled) {
9186
appIcon.grabToImage(function(result) {
92-
dndItem.Drag.imageSource = result.url;
93-
dndItem.Drag.active = true
94-
dndItem.Drag.startDrag()
87+
root.Drag.imageSource = result.url;
9588
})
9689
}
9790
}

0 commit comments

Comments
 (0)