Small animation for quickshell lock

This commit is contained in:
Trung Coder
2025-10-26 21:22:08 +07:00
committed by GitHub
parent 57a2e5aba4
commit 3faa20a29b
@@ -101,17 +101,11 @@ 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 {
@@ -120,12 +114,38 @@ 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 {
id: shakeAnim
running: false
NumberAnimation { target: passwordBox; property: "x"; to: -40; duration: 50 }
NumberAnimation { target: passwordBox; property: "x"; to: 40; duration: 50 }
NumberAnimation { target: passwordBox; property: "x"; to: -20; duration: 40 }
NumberAnimation { target: passwordBox; property: "x"; to: 20; duration: 40 }
NumberAnimation { target: passwordBox; property: "x"; to: 0; duration: 30 }
}
Connections {
target: GlobalStates
function onScreenUnlockFailedChanged() {
if (GlobalStates.screenUnlockFailed) {
passwordBox.startShake();
}
}
}
}
ToolbarButton { ToolbarButton {
id: confirmButton id: confirmButton
implicitWidth: height implicitWidth: height