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
@@ -99,32 +99,52 @@ MouseArea {
opacity: root.toolbarOpacity opacity: root.toolbarOpacity
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")
clip: true
font.pixelSize: Appearance.font.pixelSize.small
enabled: !root.context.unlockInProgress
echoMode: TextInput.Password
inputMethodHints: Qt.ImhSensitiveData
onTextChanged: root.context.currentText = this.text
onAccepted: root.context.tryUnlock()
Connections {
target: root.context
function onCurrentTextChanged() {
passwordBox.text = root.context.currentText;
}
}
Keys.onPressed: event => {
root.context.resetClearTimer();
}
// Style // Idk but it work lol
clip: true property bool isShaking: false
font.pixelSize: Appearance.font.pixelSize.small function startShake() {
shakeAnim.running = false; // reset if running
x = 0; // reset position
shakeAnim.running = true;
}
// Password SequentialAnimation {
enabled: !root.context.unlockInProgress id: shakeAnim
echoMode: TextInput.Password running: false
inputMethodHints: Qt.ImhSensitiveData 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 }
}
// Synchronizing (across monitors) and unlocking Connections {
onTextChanged: root.context.currentText = this.text target: GlobalStates
onAccepted: root.context.tryUnlock() function onScreenUnlockFailedChanged() {
Connections { if (GlobalStates.screenUnlockFailed) {
target: root.context passwordBox.startShake();
function onCurrentTextChanged() {
passwordBox.text = root.context.currentText;
}
}
Keys.onPressed: event => {
root.context.resetClearTimer();
} }
} }
}
}
ToolbarButton { ToolbarButton {
id: confirmButton id: confirmButton