From 6ea3b2a8309efebb8db64a5fb6d62d43c94cfbd4 Mon Sep 17 00:00:00 2001 From: Wang Zichong Date: Thu, 12 Mar 2026 20:35:38 +0800 Subject: [PATCH] fix: avoid icon overlap caused by ListView move and displace animation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 避免由于 ListView 动画时机问题导致图标相互遮挡的问题. 这个问题是 QTBUG-133953 导致的,官方提供的绕过方案实际不能解决我们场景 所对应的问题(只能解决或者说绕过添加时位置不对的情况). 此修复方式尽可能 规避使用 displaced 动画来对未被移除的图标展示位置变化动画,以使ListView 自身完全不需要关心自身内容的坐标动画(ListView只负责显示被移除元素的消 失动画,即scale缩小并淡出. PMS: BUG-351826, BUG-308927 Log: --- .../dock/taskmanager/package/TaskManager.qml | 103 +++++++++--------- 1 file changed, 50 insertions(+), 53 deletions(-) diff --git a/panels/dock/taskmanager/package/TaskManager.qml b/panels/dock/taskmanager/package/TaskManager.qml index 80ae95e64..ee3cbaca5 100644 --- a/panels/dock/taskmanager/package/TaskManager.qml +++ b/panels/dock/taskmanager/package/TaskManager.qml @@ -68,14 +68,6 @@ ContainmentItem { remainingSpace: taskmanager.remainingSpacesForSplitWindow font.family: D.DTK.fontManager.t6.family font.pixelSize: Math.max(10, Math.min(20, Math.round(textCalculator.iconSize * 0.35))) - onOptimalSingleTextWidthChanged: { - appContainer.addDisplaced = null - appContainer.removeDisplaced = null - Qt.callLater(function() { - appContainer.addDisplaced = addDisplacedTransition - appContainer.removeDisplaced = removeDisplacedTransition - }) - } } OverflowContainer { @@ -91,27 +83,6 @@ ContainmentItem { duration: 200 } } - moveDisplaced: Transition { - NumberAnimation { - properties: "x,y" - easing.type: Easing.OutQuad - } - } - addDisplaced: Transition { - id: addDisplacedTransition - NumberAnimation { - properties: "x,y" - easing.type: Easing.OutQuad - } - } - removeDisplaced: Transition { - id: removeDisplacedTransition - NumberAnimation { - properties: "x,y" - easing.type: Easing.OutQuad - } - } - move: moveDisplaced model: DelegateModel { id: visualModel model: taskmanager.Applet.dataModel @@ -168,31 +139,56 @@ ContainmentItem { property int visualIndex: DelegateModel.itemsIndex property var modelIndex: visualModel.modelIndex(index) - AppItem { - id: appItem - anchors.fill: parent // This is mandatory for draggable item center in drop area - - displayMode: Panel.indicatorStyle - colorTheme: Panel.colorTheme - active: delegateRoot.active - attention: delegateRoot.attention - itemId: delegateRoot.itemId - name: delegateRoot.name - iconName: delegateRoot.iconName - menus: delegateRoot.menus - windows: delegateRoot.windows - visualIndex: delegateRoot.visualIndex - modelIndex: delegateRoot.modelIndex - blendOpacity: taskmanager.blendOpacity - title: delegateRoot.title - enableTitle: textCalculator.enabled - appTitleSpacing: taskmanager.appTitleSpacing - ListView.delayRemove: Drag.active - Component.onCompleted: { - dropFilesOnItem.connect(taskmanager.Applet.dropFilesOnItem) + Rectangle { + // kept for debug purpose + // border.color: "red" + // border.width: 1 + color: "transparent" + parent: appContainer + x: delegateRoot.x + y: delegateRoot.y + width: delegateRoot.width + height: delegateRoot.height + scale: delegateRoot.scale + Behavior on x { + NumberAnimation { + duration: 200 + easing.type: Easing.OutCubic + } } - onDragFinished: function() { - launcherDndDropArea.resetDndState() + Behavior on y { + NumberAnimation { + duration: 200 + easing.type: Easing.OutCubic + } + } + + AppItem { + id: appItem + anchors.fill: parent // This is mandatory for draggable item center in drop area + + displayMode: Panel.indicatorStyle + colorTheme: Panel.colorTheme + active: delegateRoot.active + attention: delegateRoot.attention + itemId: delegateRoot.itemId + name: delegateRoot.name + iconName: delegateRoot.iconName + menus: delegateRoot.menus + windows: delegateRoot.windows + visualIndex: delegateRoot.visualIndex + modelIndex: delegateRoot.modelIndex + blendOpacity: taskmanager.blendOpacity + title: delegateRoot.title + enableTitle: textCalculator.enabled + appTitleSpacing: taskmanager.appTitleSpacing + ListView.delayRemove: Drag.active + Component.onCompleted: { + dropFilesOnItem.connect(taskmanager.Applet.dropFilesOnItem) + } + onDragFinished: function() { + launcherDndDropArea.resetDndState() + } } } } @@ -201,6 +197,7 @@ ContainmentItem { DropArea { id: launcherDndDropArea anchors.fill: parent + z: 3 keys: ["text/x-dde-dock-dnd-appid"] property string launcherDndDesktopId: "" property string launcherDndDragSource: ""