Skip to content

Commit b887499

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

1 file changed

Lines changed: 83 additions & 4 deletions

File tree

panels/dock/package/main.qml

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

119+
PropertyAnimation {
120+
id: hideDockAnimation;
121+
property bool useTransformBasedAnimation: Qt.platform.pluginName === "xcb"
122+
target: useTransformBasedAnimation ? dockTransform : dock
123+
property: {
124+
if (useTransformBasedAnimation) return dock.useColumnLayout ? "x" : "y";
125+
return dock.useColumnLayout ? "width" : "height";
126+
}
127+
from: 0
128+
to: {
129+
if (useTransformBasedAnimation) {
130+
return (Panel.position === Dock.Left || Panel.position === Dock.Top) ? -Panel.dockSize : Panel.dockSize;
131+
}
132+
return 1;
133+
}
134+
duration: 250
135+
easing.type: Easing.OutCubic
136+
onStarted: {
137+
dock.visible = true
138+
}
139+
onStopped: {
140+
if (useTransformBasedAnimation) {
141+
dock.visible = true
142+
} else {
143+
dock.visible = ((dock.useColumnLayout ? dock.width : dock.height) != 1)
144+
}
145+
}
146+
}
147+
PropertyAnimation {
148+
id: showDockAnimation;
149+
property bool useTransformBasedAnimation: Qt.platform.pluginName === "xcb"
150+
target: useTransformBasedAnimation ? dockTransform : dock
151+
property: {
152+
if (useTransformBasedAnimation) return dock.useColumnLayout ? "x" : "y";
153+
return dock.useColumnLayout ? "width" : "height";
154+
}
155+
duration: 250
156+
easing.type: Easing.OutCubic
157+
from: {
158+
if (useTransformBasedAnimation) {
159+
return (Panel.position === Dock.Left || Panel.position === Dock.Top) ? -Panel.dockSize : Panel.dockSize;
160+
}
161+
return 1;
162+
}
163+
to: {
164+
if (useTransformBasedAnimation) return 0;
165+
return Panel.dockSize;
166+
}
167+
onStarted: {
168+
dock.visible = true
169+
}
170+
onStopped: {
171+
if (useTransformBasedAnimation) {
172+
dock.visible = true
173+
} else {
174+
dock.visible = ((dock.useColumnLayout ? dock.width : dock.height) != 1)
175+
}
176+
}
177+
}
178+
119179
component EnumPropertyMenuItem: LP.MenuItem {
120180
required property string name
121181
required property string prop
122182
required property int value
123183
text: name
124184
onTriggered: {
125-
Applet[prop] = value
126-
checked = Qt.binding(function() {
127-
return Applet[prop] === value
128-
})
185+
if (prop === "position") {
186+
// After hide animation completes, change position
187+
hideDockAnimation.onStopped.connect(function() {
188+
// Stop any running animations first --fix bug with do not show dock
189+
hideDockAnimation.stop()
190+
showDockAnimation.stop()
191+
// Reset transform before starting new animation--fix bug with change position,will have a blank area
192+
dockTransform.x = 0
193+
dockTransform.y = 0
194+
195+
Applet[prop] = value
196+
checked = Qt.binding(function() {
197+
return Applet[prop] === value
198+
})
199+
showDockAnimation.start()
200+
})
201+
hideDockAnimation.start()
202+
} else {
203+
Applet[prop] = value
204+
checked = Qt.binding(function() {
205+
return Applet[prop] === value
206+
})
207+
}
129208
}
130209
checked: Applet[prop] === value
131210
}

0 commit comments

Comments
 (0)