lock: simplify shake anim impl

This commit is contained in:
end-4
2025-10-30 09:58:52 +01:00
parent 3faa20a29b
commit 06514ed7b7
@@ -101,11 +101,17 @@ MouseArea {
ToolbarTextField { ToolbarTextField {
id: passwordBox id: passwordBox
placeholderText: GlobalStates.screenUnlockFailed ? Translation.tr("Incorrect password") : Translation.tr("Enter password") placeholderText: GlobalStates.screenUnlockFailed ? Translation.tr("Incorrect password") : Translation.tr("Enter password")
// Style
clip: true clip: true
font.pixelSize: Appearance.font.pixelSize.small font.pixelSize: Appearance.font.pixelSize.small
// Password
enabled: !root.context.unlockInProgress enabled: !root.context.unlockInProgress
echoMode: TextInput.Password echoMode: TextInput.Password
inputMethodHints: Qt.ImhSensitiveData inputMethodHints: Qt.ImhSensitiveData
// Synchronizing (across monitors) and unlocking
onTextChanged: root.context.currentText = this.text onTextChanged: root.context.currentText = this.text
onAccepted: root.context.tryUnlock() onAccepted: root.context.tryUnlock()
Connections { Connections {
@@ -114,34 +120,23 @@ MouseArea {
passwordBox.text = root.context.currentText; passwordBox.text = root.context.currentText;
} }
} }
Keys.onPressed: event => { Keys.onPressed: event => {
root.context.resetClearTimer(); root.context.resetClearTimer();
} }
// Idk but it work lol
property bool isShaking: false
function startShake() {
shakeAnim.running = false; // reset if running
x = 0; // reset position
shakeAnim.running = true;
}
SequentialAnimation { SequentialAnimation {
id: shakeAnim id: wrongPasswordShakeAnim
running: false NumberAnimation { target: passwordBox; property: "x"; to: -30; duration: 50 }
NumberAnimation { target: passwordBox; property: "x"; to: -40; duration: 50 } NumberAnimation { target: passwordBox; property: "x"; to: 30; duration: 50 }
NumberAnimation { target: passwordBox; property: "x"; to: 40; duration: 50 } NumberAnimation { target: passwordBox; property: "x"; to: -15; duration: 40 }
NumberAnimation { target: passwordBox; property: "x"; to: -20; duration: 40 } NumberAnimation { target: passwordBox; property: "x"; to: 15; duration: 40 }
NumberAnimation { target: passwordBox; property: "x"; to: 20; duration: 40 }
NumberAnimation { target: passwordBox; property: "x"; to: 0; duration: 30 } NumberAnimation { target: passwordBox; property: "x"; to: 0; duration: 30 }
} }
Connections { Connections {
target: GlobalStates target: GlobalStates
function onScreenUnlockFailedChanged() { function onScreenUnlockFailedChanged() {
if (GlobalStates.screenUnlockFailed) { if (GlobalStates.screenUnlockFailed) wrongPasswordShakeAnim.restart();
passwordBox.startShake();
}
} }
} }
} }