Browse Source

qml: pin lock after inactivity

patch-4
Sander van Grieken 3 years ago
parent
commit
6aded403b8
  1. 7
      electrum/gui/qml/components/Pin.qml
  2. 30
      electrum/gui/qml/components/main.qml

7
electrum/gui/qml/components/Pin.qml

@ -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

30
electrum/gui/qml/components/main.qml

@ -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
}
}
}

Loading…
Cancel
Save