lock: key presses also reset inactivity timer

This commit is contained in:
end-4 2025-09-06 08:44:25 +02:00
parent f593ad0f2c
commit c86dbeb2b3
2 changed files with 26 additions and 15 deletions

View file

@ -15,6 +15,10 @@ Scope {
property bool unlockInProgress: false
property bool showFailure: false
function resetClearTimer() {
passwordClearTimer.restart();
}
Timer {
id: passwordClearTimer
interval: 10000

View file

@ -14,17 +14,26 @@ MouseArea {
property bool active: false
property bool showInputField: active || context.currentText.length > 0
// Force focus on entry
function forceFieldFocus() {
passwordBox.forceActiveFocus();
}
Connections {
target: context
function onShouldReFocus() {
forceFieldFocus();
}
}
hoverEnabled: true
acceptedButtons: Qt.LeftButton
onPressed: mouse => {
forceFieldFocus();
}
onPositionChanged: mouse => {
forceFieldFocus();
}
// Toolbar appearing animation
property real toolbarScale: 0.9
property real toolbarOpacity: 0
Behavior on toolbarScale {
@ -38,30 +47,22 @@ MouseArea {
animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this)
}
// Init
Component.onCompleted: {
forceFieldFocus();
toolbarScale = 1;
toolbarOpacity = 1;
}
Keys.onPressed: event => { // Esc to clear
if (event.key === Qt.Key_Escape) {
// Key presses
Keys.onPressed: event => {
root.context.resetClearTimer();
if (event.key === Qt.Key_Escape) { // Esc to clear
root.context.currentText = "";
}
forceFieldFocus();
}
hoverEnabled: true
acceptedButtons: Qt.LeftButton
onPressed: mouse => {
forceFieldFocus();
}
onPositionChanged: mouse => {
forceFieldFocus();
}
anchors.fill: parent
// RippleButton {
// anchors {
// top: parent.top
@ -77,7 +78,7 @@ MouseArea {
// }
// }
// Controls
// Main toolbar: password box
Toolbar {
id: mainIsland
anchors {
@ -114,6 +115,10 @@ MouseArea {
passwordBox.text = root.context.currentText;
}
}
Keys.onPressed: event => {
root.context.resetClearTimer();
}
}
ToolbarButton {
@ -136,6 +141,7 @@ MouseArea {
}
}
// Left toolbar
Toolbar {
id: leftIsland
anchors {
@ -207,6 +213,7 @@ MouseArea {
}
}
// Right toolbar
Toolbar {
id: rightIsland
anchors {