From 1ccfc3c042422d0543e3635c6a8df3612ddb868a Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Thu, 28 Apr 2022 12:28:58 +0200 Subject: [PATCH] disable lock all wallets menu item when all wallets are locked --- .../com/sparrowwallet/sparrow/AppController.java | 16 ++++++++++++++++ .../resources/com/sparrowwallet/sparrow/app.fxml | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/AppController.java b/src/main/java/com/sparrowwallet/sparrow/AppController.java index aa001d6c..d55a8060 100644 --- a/src/main/java/com/sparrowwallet/sparrow/AppController.java +++ b/src/main/java/com/sparrowwallet/sparrow/AppController.java @@ -156,6 +156,9 @@ public class AppController implements Initializable { @FXML private MenuItem lockWallet; + @FXML + private MenuItem lockAllWallets; + @FXML private MenuItem searchWallet; @@ -1382,6 +1385,17 @@ public class AppController implements Initializable { } } + private boolean allWalletsLocked(Wallet lockingWallet) { + for(Tab tab : tabs.getTabs()) { + TabData tabData = (TabData)tab.getUserData(); + if(tabData instanceof WalletTabData walletTabData && walletTabData.getWallet() != lockingWallet && !walletTabData.getWalletForm().isLocked()) { + return false; + } + } + + return true; + } + public void searchWallet(ActionEvent event) { Tab selectedTab = tabs.getSelectionModel().getSelectedItem(); if(selectedTab != null) { @@ -2557,6 +2571,7 @@ public class AppController implements Initializable { if(selectedWalletForm != null && selectedWalletForm.getMasterWallet().equals(event.getWallet())) { lockWallet.setDisable(true); exportWallet.setDisable(true); + lockAllWallets.setDisable(allWalletsLocked(event.getWallet())); } } @@ -2566,6 +2581,7 @@ public class AppController implements Initializable { if(selectedWalletForm != null && selectedWalletForm.getMasterWallet().equals(event.getWallet())) { lockWallet.setDisable(false); exportWallet.setDisable(!event.getWallet().isValid()); + lockAllWallets.setDisable(false); } } } diff --git a/src/main/resources/com/sparrowwallet/sparrow/app.fxml b/src/main/resources/com/sparrowwallet/sparrow/app.fxml index 90c62039..d24de4d9 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/app.fxml +++ b/src/main/resources/com/sparrowwallet/sparrow/app.fxml @@ -102,7 +102,7 @@ - +