From 4dec0e8c1d5d6ae05e49562cf91ea6b8375e5aad Mon Sep 17 00:00:00 2001 From: "Florian RICHER (aka MrDev023)" Date: Sat, 14 Jun 2025 23:45:00 +0200 Subject: [PATCH] lockscreen: Add feedback when lockscreen action is not held MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- .../contents/lockscreen/QuickActionButton.qml | 43 ++++++++++++++++++- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/shell/contents/lockscreen/QuickActionButton.qml b/shell/contents/lockscreen/QuickActionButton.qml index 6932fff7..2b961dc3 100644 --- a/shell/contents/lockscreen/QuickActionButton.qml +++ b/shell/contents/lockscreen/QuickActionButton.qml @@ -17,6 +17,7 @@ AbstractButton { property bool buttonHeld: false property double scale: pressed ? (buttonHeld ? 1.7 : 1.5) : 1 + property real fillAmount: 0.0 Behavior on scale { NumberAnimation { @@ -41,7 +42,15 @@ AbstractButton { background: Rectangle { 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 { @@ -66,8 +75,22 @@ AbstractButton { if (pressed) { pressedTimer.restart(); 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(); + + // 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; } } + + 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 + } }