mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
lockscreen: Add feedback when lockscreen action is not held
Final result:  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:
parent
e4919690b4
commit
4dec0e8c1d
1 changed files with 41 additions and 2 deletions
|
|
@ -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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue