1
0

qml: pin lock after inactivity

This commit is contained in:
Sander van Grieken
2022-07-20 09:25:57 +02:00
parent 5faef83874
commit 6aded403b8
2 changed files with 34 additions and 3 deletions

View File

@@ -21,12 +21,15 @@ Dialog {
modal: true
parent: Overlay.overlay
Overlay.modal: Rectangle {
color: "#aa000000"
color: canCancel ? "#aa000000" : "#ff000000"
}
focus: true
standardButtons: Dialog.Cancel
standardButtons: canCancel ? Dialog.Cancel : 0
closePolicy: canCancel ? Popup.CloseOnEscape | Popup.CloseOnPressOutside : Popup.NoAutoClose
property bool canCancel: true
property string mode // [check, enter, change]
property string pincode // old one passed in when change, new one passed out

View File

@@ -275,7 +275,7 @@ ApplicationWindow
}
function handleAuthRequired(qtobject, method) {
console.log('AUTHENTICATING USING METHOD ' + method)
console.log('auth using method ' + method)
if (method == 'wallet') {
if (Daemon.currentWallet.verify_password('')) {
// wallet has no password
@@ -309,6 +309,34 @@ ApplicationWindow
})
dialog.open()
}
} else {
console.log('unknown auth method ' + method)
qtobject.authCancel()
}
}
property var _lastActive: 0 // record time of last activity
property int _maxInactive: 30 // seconds
property bool _lockDialogShown: false
onActiveChanged: {
console.log('active='+active)
if (!active) {
// deactivated
_lastActive = Date.now()
} else {
// activated
if (_lastActive != 0 && Date.now() - _lastActive > _maxInactive * 1000) {
if (_lockDialogShown || Config.pinCode == '')
return
var dialog = app.pinDialog.createObject(app, {mode: 'check', canCancel: false, pincode: Config.pinCode})
dialog.accepted.connect(function() {
dialog.close()
_lockDialogShown = false
})
dialog.open()
_lockDialogShown = true
}
}
}