qml: pin lock after inactivity
This commit is contained in:
@@ -21,12 +21,15 @@ Dialog {
|
|||||||
modal: true
|
modal: true
|
||||||
parent: Overlay.overlay
|
parent: Overlay.overlay
|
||||||
Overlay.modal: Rectangle {
|
Overlay.modal: Rectangle {
|
||||||
color: "#aa000000"
|
color: canCancel ? "#aa000000" : "#ff000000"
|
||||||
}
|
}
|
||||||
|
|
||||||
focus: true
|
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 mode // [check, enter, change]
|
||||||
property string pincode // old one passed in when change, new one passed out
|
property string pincode // old one passed in when change, new one passed out
|
||||||
|
|||||||
@@ -275,7 +275,7 @@ ApplicationWindow
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleAuthRequired(qtobject, method) {
|
function handleAuthRequired(qtobject, method) {
|
||||||
console.log('AUTHENTICATING USING METHOD ' + method)
|
console.log('auth using method ' + method)
|
||||||
if (method == 'wallet') {
|
if (method == 'wallet') {
|
||||||
if (Daemon.currentWallet.verify_password('')) {
|
if (Daemon.currentWallet.verify_password('')) {
|
||||||
// wallet has no password
|
// wallet has no password
|
||||||
@@ -309,6 +309,34 @@ ApplicationWindow
|
|||||||
})
|
})
|
||||||
dialog.open()
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user