From eef2b691e77e81fc92348f43e15612101b7a5bd8 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Fri, 3 Apr 2026 18:51:24 +0200 Subject: [PATCH] lock: refactor error shake anim --- .../common/widgets/ErrorShakeAnimation.qml | 16 ++++++++++++++++ .../ii/modules/ii/lock/LockSurface.qml | 8 ++------ 2 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 dots/.config/quickshell/ii/modules/common/widgets/ErrorShakeAnimation.qml diff --git a/dots/.config/quickshell/ii/modules/common/widgets/ErrorShakeAnimation.qml b/dots/.config/quickshell/ii/modules/common/widgets/ErrorShakeAnimation.qml new file mode 100644 index 000000000..dadfe88c3 --- /dev/null +++ b/dots/.config/quickshell/ii/modules/common/widgets/ErrorShakeAnimation.qml @@ -0,0 +1,16 @@ +pragma ComponentBehavior: Bound +import QtQuick +import QtQuick.Layouts + +SequentialAnimation { + id: root + + required property Item target + property real distance: 30 + + NumberAnimation { target: root.target; property: "Layout.leftMargin"; to: -root.distance; duration: 50 } + NumberAnimation { target: root.target; property: "Layout.leftMargin"; to: root.distance; duration: 50 } + NumberAnimation { target: root.target; property: "Layout.leftMargin"; to: -root.distance / 2; duration: 40 } + NumberAnimation { target: root.target; property: "Layout.leftMargin"; to: root.distance / 2; duration: 40 } + NumberAnimation { target: root.target; property: "Layout.leftMargin"; to: 0; duration: 30 } +} diff --git a/dots/.config/quickshell/ii/modules/ii/lock/LockSurface.qml b/dots/.config/quickshell/ii/modules/ii/lock/LockSurface.qml index 82d10260a..4eb709c06 100644 --- a/dots/.config/quickshell/ii/modules/ii/lock/LockSurface.qml +++ b/dots/.config/quickshell/ii/modules/ii/lock/LockSurface.qml @@ -170,13 +170,9 @@ MouseArea { } // Shake when wrong password - SequentialAnimation { + ErrorShakeAnimation { id: wrongPasswordShakeAnim - NumberAnimation { target: passwordBox; property: "Layout.leftMargin"; to: -30; duration: 50 } - NumberAnimation { target: passwordBox; property: "Layout.leftMargin"; to: 30; duration: 50 } - NumberAnimation { target: passwordBox; property: "Layout.leftMargin"; to: -15; duration: 40 } - NumberAnimation { target: passwordBox; property: "Layout.leftMargin"; to: 15; duration: 40 } - NumberAnimation { target: passwordBox; property: "Layout.leftMargin"; to: 0; duration: 30 } + target: passwordBox } Connections { target: GlobalStates