From a41b386651c14f6f83139b0e7a82c0ba568a22ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20B=C3=BCchi?= Date: Thu, 1 Aug 2024 16:30:23 +0000 Subject: [PATCH] fix task scrub icon list sometimes being off center also fix animation duration and easing type not being in sync with task preview list. fixes https://invent.kde.org/plasma/plasma-mobile/-/issues/392 --- kwin/mobiletaskswitcher/qml/TaskSwitcher.qml | 16 +++++++--------- .../qml/TaskSwitcherHelpers.qml | 11 ++++++++--- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/kwin/mobiletaskswitcher/qml/TaskSwitcher.qml b/kwin/mobiletaskswitcher/qml/TaskSwitcher.qml index 127a571e..5dd3cdef 100644 --- a/kwin/mobiletaskswitcher/qml/TaskSwitcher.qml +++ b/kwin/mobiletaskswitcher/qml/TaskSwitcher.qml @@ -445,20 +445,18 @@ FocusScope { Behavior on opacity { NumberAnimation { duration: Kirigami.Units.longDuration } } anchors.bottom: parent.bottom - anchors.horizontalCenter: parent.horizontalCenter + anchors.right: parent.horizontalCenter anchors.bottomMargin: taskSwitcherHelpers.openedYPosition * 5 / 8 - anchors.horizontalCenterOffset: { + anchors.rightMargin: { let size = Kirigami.Units.iconSizes.large + Kirigami.Units.largeSpacing * 2; - let offset = (root.state.currentTaskIndex - 0.5) * size; - return offset; + let offset = (root.state.currentTaskIndex + 0.5) * size; + return -offset; } - Behavior on anchors.horizontalCenterOffset { + Behavior on anchors.rightMargin { NumberAnimation { - // TODO: this duration should track the duration of xAnim but that is variable through function parameter - // how do we make sure this is always the same duration? - duration: Kirigami.Units.longDuration * 2; - easing.type: Easing.OutBack; + duration: taskSwitcherHelpers.xAnimDuration; + easing.type: taskSwitcherHelpers.xAnimEasingType; } } diff --git a/kwin/mobiletaskswitcher/qml/TaskSwitcherHelpers.qml b/kwin/mobiletaskswitcher/qml/TaskSwitcherHelpers.qml index 3bf1c6d2..b63d7b0f 100644 --- a/kwin/mobiletaskswitcher/qml/TaskSwitcherHelpers.qml +++ b/kwin/mobiletaskswitcher/qml/TaskSwitcherHelpers.qml @@ -37,6 +37,10 @@ QtObject { // we don't want to continuously send haptics, just once is enough property bool hasVibrated: false + // made as variables to keep x anim in task list and task scrub icon list in sync + property int xAnimDuration: Kirigami.Units.longDuration * 2 + property int xAnimEasingType: Easing.OutExpo + // ~~ measurement constants ~~ // dimensions of a real window on the screen @@ -161,9 +165,9 @@ QtObject { // go to the task index, animated function animateGoToTaskIndex(index, duration = Kirigami.Units.longDuration * 2, easing = Easing.OutExpo) { - xAnim.duration = duration; + xAnimDuration = duration; + xAnimEasingType = easing; xAnim.to = xPositionFromTaskIndex(index); - xAnim.easing.type = easing; xAnim.restart(); } @@ -219,7 +223,8 @@ QtObject { property var xAnim: NumberAnimation { target: root.state property: "xPosition" - easing.type: Easing.OutBack + duration: xAnimDuration + easing.type: xAnimEasingType } property var openAnim: NumberAnimation {