Skip to content

Commit bc24f61

Browse files
committed
feat: Add animation for position switching to dock.
as title. pms-bug-271145
1 parent af7d445 commit bc24f61

File tree

1 file changed

+54
-4
lines changed

1 file changed

+54
-4
lines changed

panels/dock/package/main.qml

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,66 @@ Window {
116116
}
117117
}
118118

119+
PropertyAnimation {
120+
id: hideDockAnimation;
121+
target: dockTransform
122+
property: dock.useColumnLayout ? "x" : "y"
123+
from: 0
124+
to: (Panel.position === Dock.Left || Panel.position === Dock.Top) ? -Panel.dockSize : Panel.dockSize
125+
duration: 250
126+
easing.type: Easing.OutCubic
127+
onStarted: {
128+
dock.visible = true
129+
}
130+
onStopped: {
131+
dock.visible = true
132+
}
133+
}
134+
PropertyAnimation {
135+
id: showDockAnimation;
136+
target: dockTransform;
137+
property: dock.useColumnLayout ? "x" : "y";
138+
duration: 250
139+
easing.type: Easing.OutCubic
140+
from: (Panel.position === Dock.Left || Panel.position === Dock.Top) ? -Panel.dockSize : Panel.dockSize
141+
to: 0
142+
onStarted: {
143+
dock.visible = true
144+
}
145+
onStopped: {
146+
dock.visible = true
147+
}
148+
}
149+
119150
component EnumPropertyMenuItem: LP.MenuItem {
120151
required property string name
121152
required property string prop
122153
required property int value
123154
text: name
124155
onTriggered: {
125-
Applet[prop] = value
126-
checked = Qt.binding(function() {
127-
return Applet[prop] === value
128-
})
156+
if (prop === "position") {
157+
// After hide animation completes, change position
158+
hideDockAnimation.onStopped.connect(function() {
159+
// Stop any running animations first --fix bug with do not show dock
160+
hideDockAnimation.stop()
161+
showDockAnimation.stop()
162+
// Reset transform before starting new animation--fix bug with change position,will have a blank area
163+
dockTransform.x = 0
164+
dockTransform.y = 0
165+
166+
Applet[prop] = value
167+
checked = Qt.binding(function() {
168+
return Applet[prop] === value
169+
})
170+
showDockAnimation.start()
171+
})
172+
hideDockAnimation.start()
173+
} else {
174+
Applet[prop] = value
175+
checked = Qt.binding(function() {
176+
return Applet[prop] === value
177+
})
178+
}
129179
}
130180
checked: Applet[prop] === value
131181
}

0 commit comments

Comments
 (0)