From 823e707868f5f00e98cabe03de69637b3c99719f Mon Sep 17 00:00:00 2001 From: Ivy233 Date: Fri, 16 Jan 2026 09:32:01 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E6=A0=8F=E4=BD=8D=E7=BD=AE=E5=88=87=E6=8D=A2=E6=97=B6=E7=9A=84?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 通过改进位置切换逻辑,实现平滑的过渡动画: 1. 在切换位置时,先保存新位置并临时恢复到旧位置 2. 在旧位置播放隐藏动画 3. 切换到新位置后,从隐藏状态播放显示动画 4. 使用状态标志精确控制动画流程,避免闪烁和显示异常 这样可以确保任务栏在位置切换时不会出现空白区域、内容溢出或突然跳变的问题。 Log: 修复任务栏位置切换时的显示异常 PMS: BUG-346777 --- panels/dock/package/main.qml | 113 ++++++++++++++++++++++++++++------- 1 file changed, 90 insertions(+), 23 deletions(-) diff --git a/panels/dock/package/main.qml b/panels/dock/package/main.qml index 49a935a6d..ec07c3b2f 100644 --- a/panels/dock/package/main.qml +++ b/panels/dock/package/main.qml @@ -165,6 +165,7 @@ Window { id: dockAnimation property bool useTransformBasedAnimation: Qt.platform.pluginName === "xcb" property bool isShowing: false + property bool isPositionChanging: false property var target: useTransformBasedAnimation ? dockTransform : dock property string animProperty: { if (useTransformBasedAnimation) return dock.useColumnLayout ? "x" : "y"; @@ -212,6 +213,17 @@ Window { } else { dock.visible = ((dock.useColumnLayout ? dock.width : dock.height) !== 1); } + + // If this was a hide animation during position change, handle the position change now + if (isPositionChanging && !isShowing) { + isPositionChanging = false; + positionChangeConnections.handlePositionChangeAfterHide(); + } else { + // If this was a show animation and dock should be hidden, trigger auto-hide + if (isShowing && Panel.hideState === Dock.Hide) { + hideTimer.running = true; + } + } } } @@ -221,34 +233,20 @@ Window { required property int value text: name - property var positionChangeCallback: function() { - // Disconnect any existing callback first - dockAnimation.onStopped.disconnect(positionChangeCallback); - // Stop any running animations first --fix bug with do not show dock - dockAnimation.stop(); - // Reset transform before starting new animation--fix bug with change position,will have a blank area - dockTransform.x = 0; - dockTransform.y = 0; + onTriggered: { + if (Applet[prop] === value) { + // Manually restore checked state since Qt already toggled it + checked = true; + return; + } + Applet[prop] = value + } - Applet[prop] = value; + Component.onCompleted: { checked = Qt.binding(function() { return Applet[prop] === value; }); - dockAnimation.startAnimation(true); - } - onTriggered: { - if (prop === "position") { - // Connect the callback and start the hide animation - dockAnimation.onStopped.connect(positionChangeCallback); - dockAnimation.startAnimation(false); - } else { - Applet[prop] = value - checked = Qt.binding(function() { - return Applet[prop] === value - }) - } } - checked: Applet[prop] === value } component MutuallyExclusiveMenu: LP.Menu { id: menu @@ -665,9 +663,78 @@ Window { } Connections { + id: positionChangeConnections + property int previousPosition: Panel.position + property int savedNewPosition: -1 + property bool isRestoringPosition: false + function onPositionChanged() { + // Ignore position changes triggered by our own restore operation + if (isRestoringPosition) { + return; + } + + // Save the new position + savedNewPosition = Panel.position; + + // Set flag to ignore the next position change + isRestoringPosition = true; + + // Temporarily restore to previous position for hide animation + Applet.position = previousPosition; + + // Clear the flag after restore + isRestoringPosition = false; + + // Stop any running animations first + dockAnimation.stop(); + hideShowAnimation.stop(); + + // Mark that we're changing position + dockAnimation.isPositionChanging = true; + + // Check if dock is currently hidden + if (Panel.hideState === Dock.Hide && !dock.visible) { + // Directly handle position change without animation + dockAnimation.isPositionChanging = false; + handlePositionChangeAfterHide(); + } else { + // Start hide animation at old position + dockAnimation.startAnimation(false); + } + } + + function handlePositionChangeAfterHide() { + if (savedNewPosition === -1) return; + + // Apply position change + previousPosition = savedNewPosition; + Applet.position = savedNewPosition; + savedNewPosition = -1; + changeDragAreaAnchor() Panel.requestClosePopup() + + // Set transform to hidden position before showing + if (dockAnimation.useTransformBasedAnimation) { + var hideOffset = (Applet.position === Dock.Left || Applet.position === Dock.Top) ? -Panel.dockSize : Panel.dockSize; + if (dock.useColumnLayout) { + dockTransform.x = hideOffset; + dockTransform.y = 0; + } else { + dockTransform.x = 0; + dockTransform.y = hideOffset; + } + } else { + dockTransform.x = 0; + dockTransform.y = 0; + } + + dockAnimation.startAnimation(true); + } + + Component.onCompleted: { + previousPosition = Panel.position } function onDockSizeChanged() { dock.dockSize = Panel.dockSize