diff --git a/applets/systemtray/package/contents/ui/PlasmoidPopupsContainer.qml b/applets/systemtray/package/contents/ui/PlasmoidPopupsContainer.qml index bae4c1053..48b4b89c7 100644 --- a/applets/systemtray/package/contents/ui/PlasmoidPopupsContainer.qml +++ b/applets/systemtray/package/contents/ui/PlasmoidPopupsContainer.qml @@ -85,15 +85,25 @@ StackView { } delegate: StackViewDelegate { + id: transitioner function transitionFinished(properties) { properties.exitItem.opacity = 1 } + property bool goingLeft: { + const unFlipped = systemTrayState.oldVisualIndex < systemTrayState.newVisualIndex + + if (Qt.application.layoutDirection == Qt.LeftToRight) { + return unFlipped + } else { + return !unFlipped + } + } replaceTransition: StackViewTransition { ParallelAnimation { PropertyAnimation { target: enterItem property: "x" - from: enterItem.width + from: transitioner.goingLeft ? enterItem.width : -enterItem.width to: 0 easing.type: Easing.InOutQuad duration: PlasmaCore.Units.shortDuration @@ -112,9 +122,9 @@ StackView { target: exitItem property: "x" from: 0 - to: -exitItem.width + to: transitioner.goingLeft ? -exitItem.width : exitItem.width easing.type: Easing.InOutQuad - duration: PlasmaCore.Units.shortDuration + duration: units.longDuration } PropertyAnimation { target: exitItem diff --git a/applets/systemtray/package/contents/ui/SystemTrayState.qml b/applets/systemtray/package/contents/ui/SystemTrayState.qml index 6134b63aa..edf9ca396 100644 --- a/applets/systemtray/package/contents/ui/SystemTrayState.qml +++ b/applets/systemtray/package/contents/ui/SystemTrayState.qml @@ -34,7 +34,21 @@ QtObject { //this is to suppress expanded state change during Plasma startup property bool acceptExpandedChange: false - function setActiveApplet(applet) { + // These properties allow us to keep track of where the expanded applet + // was and is on the panel, allowing PlasmoidPopupContainer.qml to animate + // depending on their locations. + property int oldVisualIndex: -1 + property int newVisualIndex: -1 + + function setActiveApplet(applet, visualIndex) { + if (visualIndex === undefined) { + oldVisualIndex = -1 + newVisualIndex = -1 + } else { + oldVisualIndex = newVisualIndex + newVisualIndex = visualIndex + } + const oldApplet = activeApplet activeApplet = applet if (oldApplet && oldApplet !== applet) { diff --git a/applets/systemtray/package/contents/ui/items/PlasmoidItem.qml b/applets/systemtray/package/contents/ui/items/PlasmoidItem.qml index b773ba51b..5592e5783 100644 --- a/applets/systemtray/package/contents/ui/items/PlasmoidItem.qml +++ b/applets/systemtray/package/contents/ui/items/PlasmoidItem.qml @@ -121,7 +121,7 @@ AbstractItem { function onExpandedChanged(expanded) { if (expanded) { - systemTrayState.setActiveApplet(applet) + systemTrayState.setActiveApplet(applet, model.row) plasmoidContainer.activated() } }