[lookandfeel,sddm-theme] Add rejection animation in response to a wrong password

This is a stripped down version of customizable demo available at my
invent repo[1]. It is optimized for this particular use-case. Animation
honors right-to-left application layout and "instant animation speed"
preference.

[1]: https://invent.kde.org/ratijas/reject-input-animation/
wilder-5.25
ivan tkachenko 4 years ago
parent 2918bc2134
commit 6688c4a513
No known key found for this signature in database
GPG Key ID: AF72731B7C654CB3
  1. 42
      lookandfeel/contents/components/animation/RejectPasswordAnimation.qml
  2. 53
      lookandfeel/contents/components/animation/RejectPasswordPathAnimation.qml
  3. 7
      lookandfeel/contents/lockscreen/LockScreenUi.qml
  4. 7
      sddm-theme/Main.qml

@ -0,0 +1,42 @@
/*
SPDX-FileCopyrightText: 2022 ivan (@ratijas) tkachenko <me@ratijas.tk>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
import QtQuick 2.15
import QtQml 2.15
QtObject {
id: root
property Item target
readonly property Animation __animation: RejectPasswordPathAnimation {
id: animation
target: Item { id: fakeTarget }
}
property Binding __bindEnabled: Binding {
target: root.target
property: "enabled"
value: false
when: animation.running
restoreMode: Binding.RestoreBindingOrValue
}
// real target is getting a Translate object which pulls coordinates from
// a fake Item object
property Binding __bindTransform: Binding {
target: root.target
property: "transform"
value: Translate {
x: fakeTarget.x
}
restoreMode: Binding.RestoreBindingOrValue
}
function start() {
animation.start();
}
}

@ -0,0 +1,53 @@
/*
SPDX-FileCopyrightText: 2022 ivan (@ratijas) tkachenko <me@ratijas.tk>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
import QtQuick 2.15
import QtQml 2.15
import org.kde.plasma.core 2.0 as PlasmaCore
PathAnimation {
id: root
/** The magnitude/distance/offset of the animation, in the usual device-independent pixels. */
property real swing: 15
/**
* In which direction the target starts moving first.
* Must be either Qt.LeftToRight or Qt.RightToLeft.
*
* By default it is opposite to the application's layout direction, to
* make an animation feel more "disturbing".
*/
property int initialDirection: Qt.application.layoutDirection === Qt.RightToLeft ? Qt.LeftToRight : Qt.RightToLeft
alwaysRunToEnd: true
// This animation's speed does not depend on user preferences, except when
// we honor the "reduced animations" special case.
// Animators with a duration of 0 do not fire reliably, which is why duration is at least 1.
// see Bug 357532 and QTBUG-39766
duration: PlasmaCore.Units.longDuration <= 1 ? 1 : 600
easing.type: Easing.OutCubic
path: Path {
PathPolyline {
path: {
const directionFactor = root.initialDirection === Qt.RightToLeft ? -1 : 1;
const extreme = root.swing * directionFactor;
const here = Qt.point(extreme, 0);
const there = Qt.point(-extreme, 0);
return [
Qt.point(0, 0),
here, there,
here, there,
here, there,
Qt.point(0, 0),
];
}
}
}
}

@ -15,6 +15,7 @@ import org.kde.plasma.workspace.components 2.0 as PW
import org.kde.plasma.private.sessions 2.0
import "../components"
import "../components/animation"
PlasmaCore.ColorScope {
@ -34,6 +35,7 @@ PlasmaCore.ColorScope {
root.notification += i18nd("plasma_lookandfeel_org.kde.lookandfeel","Unlocking failed");
graceLockTimer.restart();
notificationRemoveTimer.restart();
rejectPasswordAnimation.start();
}
function onSucceeded() {
@ -95,6 +97,11 @@ PlasmaCore.ColorScope {
visible: false
}
RejectPasswordAnimation {
id: rejectPasswordAnimation
target: mainBlock
}
MouseArea {
id: lockScreenRoot

@ -14,6 +14,7 @@ import org.kde.plasma.components 3.0 as PlasmaComponents3
import org.kde.plasma.extras 2.0 as PlasmaExtras
import "components"
import "components/animation"
// TODO: Once SDDM 0.19 is released and we are setting the font size using the
// SDDM KCM's syncing feature, remove the `config.fontSize` overrides here and
@ -58,6 +59,11 @@ PlasmaCore.ColorScope {
}
}
RejectPasswordAnimation {
id: rejectPasswordAnimation
target: mainStack
}
MouseArea {
id: loginScreenRoot
anchors.fill: parent
@ -587,6 +593,7 @@ PlasmaCore.ColorScope {
footer.enabled = true
mainStack.enabled = true
userListComponent.userList.opacity = 1
rejectPasswordAnimation.start()
}
function onLoginSucceeded() {
//note SDDM will kill the greeter at some random point after this

Loading…
Cancel
Save