lockscreen: Add feedback when lockscreen action is not held

Final result: ![Enregistrement_d_écran_20250612_172825](/uploads/5714e5003c4252d22f0e2671dbd3523d/Enregistrement_d_écran_20250612_172825.webm)

I use a fill animation finally  (filling, unfilling) [See comments](https://invent.kde.org/plasma/plasma-mobile/-/merge_requests/731#note_1237874)
This commit is contained in:
Florian RICHER (aka MrDev023) 2025-06-14 23:45:00 +02:00 committed by Devin Lin
parent e4919690b4
commit 4dec0e8c1d

View file

@ -17,6 +17,7 @@ AbstractButton {
property bool buttonHeld: false property bool buttonHeld: false
property double scale: pressed ? (buttonHeld ? 1.7 : 1.5) : 1 property double scale: pressed ? (buttonHeld ? 1.7 : 1.5) : 1
property real fillAmount: 0.0
Behavior on scale { Behavior on scale {
NumberAnimation { NumberAnimation {
@ -41,7 +42,15 @@ AbstractButton {
background: Rectangle { background: Rectangle {
radius: width radius: width
color: Qt.rgba(255, 255, 255, pressed ? (buttonHeld ? 0.7 : 0.5) : 0.2) color: Qt.rgba(255, 255, 255, 0.2)
Rectangle {
anchors.centerIn: parent
width: parent.width * root.fillAmount
height: parent.height * root.fillAmount
radius: Math.min(width, height)
color: Qt.rgba(255, 255, 255, 0.2) // Use the same background rectangle color
}
} }
contentItem: Item { contentItem: Item {
@ -66,8 +75,22 @@ AbstractButton {
if (pressed) { if (pressed) {
pressedTimer.restart(); pressedTimer.restart();
buttonHeld = false; buttonHeld = false;
} else{
// Ensure emptyAnimation is not running
// And fillAnimation use current fillAmount state before start
// To avoid "reset" glitch
emptyAnimation.stop();
fillAnimation.from = root.fillAmount;
fillAnimation.start();
} else {
pressedTimer.stop(); pressedTimer.stop();
// Ensure fillAnimation is not running
// And emptyAnimation use current fillAmount state before start
// To avoid "reset" glitch
fillAnimation.stop();
emptyAnimation.from = root.fillAmount;
emptyAnimation.start();
} }
} }
@ -95,4 +118,20 @@ AbstractButton {
buttonHeld = true; buttonHeld = true;
} }
} }
PropertyAnimation {
id: fillAnimation
target: root
property: "fillAmount"
duration: Kirigami.Units.longDuration
to: 1.0
}
PropertyAnimation {
id: emptyAnimation
target: root
property: "fillAmount"
duration: Kirigami.Units.longDuration
to: 0.0
}
} }