forked from Public/monero-gui
Lock wallet on inactivity
This commit is contained in:
39
main.qml
39
main.qml
@@ -75,6 +75,7 @@ ApplicationWindow {
|
||||
property var cameraUi
|
||||
property bool remoteNodeConnected: false
|
||||
property bool androidCloseTapped: false;
|
||||
property int userLastActive; // epoch
|
||||
// Default daemon addresses
|
||||
readonly property string localDaemonAddress : persistentSettings.nettype == NetworkType.MAINNET ? "localhost:18081" : persistentSettings.nettype == NetworkType.TESTNET ? "localhost:28081" : "localhost:38081"
|
||||
property string currentDaemonAddress;
|
||||
@@ -219,6 +220,8 @@ ApplicationWindow {
|
||||
// Local daemon settings
|
||||
walletManager.setDaemonAddress(localDaemonAddress)
|
||||
|
||||
// enable user inactivity timer
|
||||
userInActivityTimer.running = true;
|
||||
|
||||
// wallet already opened with wizard, we just need to initialize it
|
||||
if (typeof wizard.m_wallet !== 'undefined') {
|
||||
@@ -932,6 +935,8 @@ ApplicationWindow {
|
||||
rootItem.state = "wizard"
|
||||
// reset balance
|
||||
leftPanel.balanceText = leftPanel.unlockedBalanceText = walletManager.displayAmount(0);
|
||||
// disable inactivity timer
|
||||
userInActivityTimer.running = false;
|
||||
}
|
||||
|
||||
function hideMenu() {
|
||||
@@ -1041,6 +1046,8 @@ ApplicationWindow {
|
||||
property int segregationHeight: 0
|
||||
property int kdfRounds: 1
|
||||
property bool hideBalance: false
|
||||
property bool lockOnUserInActivity: true
|
||||
property int lockOnUserInActivityInterval: 10 // minutes
|
||||
}
|
||||
|
||||
// Information dialog
|
||||
@@ -1696,6 +1703,12 @@ ApplicationWindow {
|
||||
triggeredOnStart: false
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: userInActivityTimer
|
||||
interval: 2000; running: false; repeat: true
|
||||
onTriggered: checkInUserActivity()
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: statusMessage
|
||||
z: 99
|
||||
@@ -1823,6 +1836,32 @@ ApplicationWindow {
|
||||
leftPanel.balanceLabelText = qsTr("Balance")
|
||||
}
|
||||
|
||||
function userActivity() {
|
||||
// register user activity
|
||||
var epoch = Math.floor((new Date).getTime()/1000);
|
||||
appWindow.userLastActive = epoch;
|
||||
}
|
||||
|
||||
function checkInUserActivity() {
|
||||
if(!persistentSettings.lockOnUserInActivity) return;
|
||||
|
||||
// prompt password after X seconds of inactivity
|
||||
var epoch = Math.floor((new Date).getTime() / 1000);
|
||||
var inactivity = epoch - appWindow.userLastActive;
|
||||
if(inactivity < (persistentSettings.lockOnUserInActivityInterval * 60)) return;
|
||||
|
||||
passwordDialog.onAcceptedCallback = function() {
|
||||
if(walletPassword === passwordDialog.password){
|
||||
passwordDialog.close();
|
||||
} else {
|
||||
passwordDialog.showError(qsTr("Wrong password"));
|
||||
}
|
||||
}
|
||||
|
||||
passwordDialog.onRejectedCallback = function() { appWindow.showWizard(); }
|
||||
passwordDialog.open();
|
||||
}
|
||||
|
||||
// Daemon console
|
||||
DaemonConsole {
|
||||
id: daemonConsolePopup
|
||||
|
||||
Reference in New Issue
Block a user