@@ -17,7 +17,8 @@ import org.deepin.dtk.style 1.0 as DStyle
1717
1818Window {
1919 id: dock
20- property bool useColumnLayout: Applet .position % 2
20+ property int positionForAnimation: Panel .position
21+ property bool useColumnLayout: positionForAnimation % 2
2122 // TODO: 临时溢出逻辑,待后面修改
2223 property int dockLeftSpaceForCenter: useColumnLayout ?
2324 (Screen .height - dockLeftPart .implicitHeight - dockRightPart .implicitHeight ) :
@@ -43,8 +44,8 @@ Window {
4344 property real dockItemIconSize: dockItemMaxSize * 9 / 14
4445
4546 // NOTE: -1 means not set its size, follow the platform size
46- width: Panel . position === Dock .Top || Panel . position === Dock .Bottom ? - 1 : dockSize
47- height: Panel . position === Dock .Left || Panel . position === Dock .Right ? - 1 : dockSize
47+ width: positionForAnimation === Dock .Top || positionForAnimation === Dock .Bottom ? - 1 : dockSize
48+ height: positionForAnimation === Dock .Left || positionForAnimation === Dock .Right ? - 1 : dockSize
4849 color: " transparent"
4950 flags: Qt .WindowDoesNotAcceptFocus
5051
@@ -55,7 +56,7 @@ Window {
5556 return appearance .opacity
5657 }
5758
58- DLayerShellWindow .anchors : position2Anchors (Applet . position )
59+ DLayerShellWindow .anchors : position2Anchors (positionForAnimation )
5960 DLayerShellWindow .layer : DLayerShellWindow .LayerTop
6061 DLayerShellWindow .exclusionZone : Panel .hideMode === Dock .KeepShowing ? Applet .dockSize : 0
6162 DLayerShellWindow .scope : " dde-shell/dock"
@@ -102,7 +103,7 @@ Window {
102103 return dock .useColumnLayout ? " width" : " height" ;
103104 }
104105 to: {
105- if (useTransformBasedAnimation) return Panel .hideState !== Dock .Hide ? 0 : ((Panel . position === Dock .Left || Panel . position === Dock .Top ) ? - Panel .dockSize : Panel .dockSize );
106+ if (useTransformBasedAnimation) return Panel .hideState !== Dock .Hide ? 0 : ((dock . positionForAnimation === Dock .Left || dock . positionForAnimation === Dock .Top ) ? - Panel .dockSize : Panel .dockSize );
106107 return Panel .hideState !== Dock .Hide ? Panel .dockSize : 1 ;
107108 }
108109 duration: 500
@@ -168,6 +169,7 @@ Window {
168169 id: dockAnimation
169170 property bool useTransformBasedAnimation: Qt .platform .pluginName === " xcb"
170171 property bool isShowing: false
172+ property bool isPositionChanging: false
171173 property var target: useTransformBasedAnimation ? dockTransform : dock
172174 property string animProperty: {
173175 if (useTransformBasedAnimation) return dock .useColumnLayout ? " x" : " y" ;
@@ -179,13 +181,29 @@ Window {
179181 start ();
180182 }
181183
184+ function setTransformToHiddenPosition () {
185+ if (useTransformBasedAnimation) {
186+ var hideOffset = (Panel .position === Dock .Left || Panel .position === Dock .Top ) ? - Panel .dockSize : Panel .dockSize ;
187+ if (dock .useColumnLayout ) {
188+ dockTransform .x = hideOffset;
189+ dockTransform .y = 0 ;
190+ } else {
191+ dockTransform .x = 0 ;
192+ dockTransform .y = hideOffset;
193+ }
194+ } else {
195+ dockTransform .x = 0 ;
196+ dockTransform .y = 0 ;
197+ }
198+ }
199+
182200 PropertyAnimation {
183201 target: dockAnimation .target
184202 property: dockAnimation .animProperty
185203 from: {
186204 if (dockAnimation .isShowing ) {
187205 if (dockAnimation .useTransformBasedAnimation ) {
188- return (Panel . position === Dock .Left || Panel . position === Dock .Top ) ? - Panel .dockSize : Panel .dockSize ;
206+ return (dock . positionForAnimation === Dock .Left || dock . positionForAnimation === Dock .Top ) ? - Panel .dockSize : Panel .dockSize ;
189207 }
190208 return 1 ;
191209 }
@@ -196,7 +214,7 @@ Window {
196214 return 0 ;
197215 } else {
198216 if (dockAnimation .useTransformBasedAnimation ) {
199- return (Panel . position === Dock .Left || Panel . position === Dock .Top ) ? - Panel .dockSize : Panel .dockSize ;
217+ return (dock . positionForAnimation === Dock .Left || dock . positionForAnimation === Dock .Top ) ? - Panel .dockSize : Panel .dockSize ;
200218 }
201219 return 1 ;
202220 }
@@ -215,6 +233,28 @@ Window {
215233 } else {
216234 dock .visible = ((dock .useColumnLayout ? dock .width : dock .height ) !== 1 );
217235 }
236+
237+ // If this was a hide animation during position change, prepare for show animation
238+ if (isPositionChanging && ! isShowing) {
239+ isPositionChanging = false ;
240+
241+ // Update position for animation to new position for show animation
242+ dock .positionForAnimation = Panel .position ;
243+
244+ // Set transform to hidden position before showing
245+ setTransformToHiddenPosition ();
246+
247+ startAnimation (true );
248+ } else if (isShowing) {
249+ // After show animation completes, check if we need to auto-hide
250+ // For KeepHidden and SmartHide modes, trigger hide check immediately
251+ if (Panel .hideMode === Dock .KeepHidden || Panel .hideMode === Dock .SmartHide ) {
252+ hideTimer .running = true ;
253+ } else if (Panel .hideState === Dock .Hide ) {
254+ // For other cases, if hideState is already Hide, trigger hide animation
255+ hideTimer .running = true ;
256+ }
257+ }
218258 }
219259 }
220260
@@ -224,31 +264,9 @@ Window {
224264 required property int value
225265 text: name
226266
227- property var positionChangeCallback : function () {
228- // Disconnect any existing callback first
229- dockAnimation .onStopped .disconnect (positionChangeCallback);
230- // Stop any running animations first --fix bug with do not show dock
231- dockAnimation .stop ();
232- // Reset transform before starting new animation--fix bug with change position,will have a blank area
233- dockTransform .x = 0 ;
234- dockTransform .y = 0 ;
235-
236- Applet[prop] = value;
237- checked = Qt .binding (function () {
238- return Applet[prop] === value;
239- });
240- dockAnimation .startAnimation (true );
241- }
242267 onTriggered: {
243- if (prop === " position" ) {
244- // Connect the callback and start the hide animation
245- dockAnimation .onStopped .connect (positionChangeCallback);
246- dockAnimation .startAnimation (false );
247- } else {
268+ if (Applet[prop] !== value) {
248269 Applet[prop] = value
249- checked = Qt .binding (function () {
250- return Applet[prop] === value
251- })
252270 }
253271 }
254272 checked: Applet[prop] === value
@@ -648,7 +666,7 @@ Window {
648666 }
649667
650668 function changeDragAreaAnchor () {
651- switch (Panel . position ) {
669+ switch (dock . positionForAnimation ) {
652670 case Dock .Top : {
653671 dragArea .anchorToTop ()
654672 return
@@ -669,9 +687,42 @@ Window {
669687 }
670688
671689 Connections {
690+ function onBeforePositionChanged (beforePosition ) {
691+ // Stop any running animations first
692+ dockAnimation .stop ();
693+ hideShowAnimation .stop ();
694+
695+ // Set the position for animation to old position for hide animation
696+ dock .positionForAnimation = beforePosition;
697+
698+ // Mark that we're changing position
699+ dockAnimation .isPositionChanging = true ;
700+
701+ // Check if dock is currently hidden
702+ if (Panel .hideState === Dock .Hide && ! dock .visible ) {
703+ // Dock is already hidden, no need for hide animation
704+ // Wait for onPositionChanged to get the new position, then show
705+ dockAnimation .isPositionChanging = false ;
706+ } else {
707+ // Start hide animation at old position
708+ // When animation completes, onStopped will handle show animation
709+ dockAnimation .startAnimation (false );
710+ }
711+ }
712+
672713 function onPositionChanged () {
673714 changeDragAreaAnchor ()
674715 Panel .requestClosePopup ()
716+
717+ // If dock was hidden when position change started, show it now at new position
718+ if (! dockAnimation .isPositionChanging && ! dock .visible ) {
719+ dock .positionForAnimation = Panel .position ;
720+
721+ // Set transform to hidden position before showing
722+ dockAnimation .setTransformToHiddenPosition ();
723+
724+ dockAnimation .startAnimation (true );
725+ }
675726 }
676727 function onDockSizeChanged () {
677728 dock .dockSize = Panel .dockSize
@@ -681,7 +732,10 @@ Window {
681732 if (Panel .hideState === Dock .Hide ) {
682733 hideTimer .running = true
683734 } else {
684- hideShowAnimation .restart ()
735+ // Only restart animation if not already running or if visible state doesn't match
736+ if (! hideShowAnimation .running || ! dock .visible ) {
737+ hideShowAnimation .restart ()
738+ }
685739 }
686740 }
687741 function onRequestClosePopup () {
@@ -734,7 +788,7 @@ Window {
734788 })
735789
736790 DockCompositor .dockPosition = Qt .binding (function (){
737- return Panel . position
791+ return dock . positionForAnimation
738792 })
739793
740794 DockCompositor .dockSize = Qt .binding (function (){
0 commit comments