From d186d34d9aa1d7b32a685073bc190aefa9c33ee6 Mon Sep 17 00:00:00 2001 From: yeshanshan Date: Thu, 5 Mar 2026 10:19:27 +0800 Subject: [PATCH] fix: fix touchscreen drag interruption issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- qml/windowed/IconItemDelegate.qml | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/qml/windowed/IconItemDelegate.qml b/qml/windowed/IconItemDelegate.qml index 22ce41f6..c4133d0c 100644 --- a/qml/windowed/IconItemDelegate.qml +++ b/qml/windowed/IconItemDelegate.qml @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -12,7 +12,7 @@ import org.deepin.launchpad 1.0 Control { id: root - visible: !dragHandler.active + opacity: Drag.active ? 0 : 1 property string text: display.startsWith("internal/category/") ? getCategoryName(display.substring(18)) : display @@ -25,10 +25,11 @@ Control { signal menuTriggered() Drag.dragType: Drag.Automatic + Drag.active: mouseArea.drag.active states: State { name: "dragged"; - when: dragHandler.active + when: mouseArea.drag.active // FIXME: When dragging finished, the position of the item is changed for unknown reason, // so we use the state to reset the x and y here. PropertyChanges { @@ -73,25 +74,17 @@ Control { theme: ApplicationHelper.DarkType } - DragHandler { - id: dragHandler - target: root + MouseArea { + id: mouseArea + anchors.fill: parent + hoverEnabled: false acceptedButtons: Qt.LeftButton enabled: root.dndEnabled - dragThreshold: 1 - onActiveChanged: { - if (active) { - // We switch to use the `dndItem` to handle Drag event since that one will always exists. - // If we use the current item, then if the item that provides the drag attached property - // get destoryed (e.g. switch page or folder close caused destory), dropping at that moment - // will cause a crash. - dndItem.Drag.hotSpot = target.Drag.hotSpot - dndItem.Drag.mimeData = target.Drag.mimeData - + drag.target: root + onPressed: function (mouse) { + if (mouse.button === Qt.LeftButton && root.dndEnabled) { appIcon.grabToImage(function(result) { - dndItem.Drag.imageSource = result.url; - dndItem.Drag.active = true - dndItem.Drag.startDrag() + root.Drag.imageSource = result.url; }) } }