forked from Shinonome/dots-hyprland
lock: simplify shake anim impl
This commit is contained in:
@@ -99,52 +99,47 @@ 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();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Idk but it work lol
|
// Style
|
||||||
property bool isShaking: false
|
clip: true
|
||||||
function startShake() {
|
font.pixelSize: Appearance.font.pixelSize.small
|
||||||
shakeAnim.running = false; // reset if running
|
|
||||||
x = 0; // reset position
|
|
||||||
shakeAnim.running = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
SequentialAnimation {
|
// Password
|
||||||
id: shakeAnim
|
enabled: !root.context.unlockInProgress
|
||||||
running: false
|
echoMode: TextInput.Password
|
||||||
NumberAnimation { target: passwordBox; property: "x"; to: -40; duration: 50 }
|
inputMethodHints: Qt.ImhSensitiveData
|
||||||
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 {
|
// Synchronizing (across monitors) and unlocking
|
||||||
target: GlobalStates
|
onTextChanged: root.context.currentText = this.text
|
||||||
function onScreenUnlockFailedChanged() {
|
onAccepted: root.context.tryUnlock()
|
||||||
if (GlobalStates.screenUnlockFailed) {
|
Connections {
|
||||||
passwordBox.startShake();
|
target: root.context
|
||||||
|
function onCurrentTextChanged() {
|
||||||
|
passwordBox.text = root.context.currentText;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Keys.onPressed: event => {
|
||||||
|
root.context.resetClearTimer();
|
||||||
|
}
|
||||||
|
|
||||||
|
SequentialAnimation {
|
||||||
|
id: wrongPasswordShakeAnim
|
||||||
|
NumberAnimation { target: passwordBox; property: "x"; to: -30; duration: 50 }
|
||||||
|
NumberAnimation { target: passwordBox; property: "x"; to: 30; duration: 50 }
|
||||||
|
NumberAnimation { target: passwordBox; property: "x"; to: -15; duration: 40 }
|
||||||
|
NumberAnimation { target: passwordBox; property: "x"; to: 15; duration: 40 }
|
||||||
|
NumberAnimation { target: passwordBox; property: "x"; to: 0; duration: 30 }
|
||||||
|
}
|
||||||
|
Connections {
|
||||||
|
target: GlobalStates
|
||||||
|
function onScreenUnlockFailedChanged() {
|
||||||
|
if (GlobalStates.screenUnlockFailed) wrongPasswordShakeAnim.restart();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ToolbarButton {
|
ToolbarButton {
|
||||||
id: confirmButton
|
id: confirmButton
|
||||||
|
|||||||
Reference in New Issue
Block a user