From 6fbd332b4d55c12785768e28f45c5cc8802619b1 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Wed, 17 Mar 2021 11:59:58 +0200 Subject: [PATCH] add preference option to load recent wallets --- .../java/com/sparrowwallet/sparrow/AppServices.java | 2 +- src/main/java/com/sparrowwallet/sparrow/io/Config.java | 10 ++++++++++ .../preferences/GeneralPreferencesController.java | 9 +++++++++ .../sparrow/preferences/PreferencesDialog.java | 2 +- .../com/sparrowwallet/sparrow/preferences/general.fxml | 4 ++++ 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/AppServices.java b/src/main/java/com/sparrowwallet/sparrow/AppServices.java index 0f7114a6..aee9cb47 100644 --- a/src/main/java/com/sparrowwallet/sparrow/AppServices.java +++ b/src/main/java/com/sparrowwallet/sparrow/AppServices.java @@ -540,7 +540,7 @@ public class AppServices { Platform.runLater(() -> { if(!Window.getWindows().isEmpty()) { List walletFiles = allWallets.stream().map(walletTabData -> walletTabData.getStorage().getWalletFile()).collect(Collectors.toList()); - Config.get().setRecentWalletFiles(walletFiles); + Config.get().setRecentWalletFiles(Config.get().isLoadRecentWallets() ? walletFiles : Collections.emptyList()); } }); diff --git a/src/main/java/com/sparrowwallet/sparrow/io/Config.java b/src/main/java/com/sparrowwallet/sparrow/io/Config.java index f6a316e1..b4f7a52d 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/Config.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/Config.java @@ -25,6 +25,7 @@ public class Config { private FeeRatesSelection feeRatesSelection; private Currency fiatCurrency; private ExchangeSource exchangeSource; + private boolean loadRecentWallets = true; private boolean validateDerivationPaths = true; private boolean groupByAddress = true; private boolean includeMempoolChange = true; @@ -155,6 +156,15 @@ public class Config { flush(); } + public boolean isLoadRecentWallets() { + return loadRecentWallets; + } + + public void setLoadRecentWallets(boolean loadRecentWallets) { + this.loadRecentWallets = loadRecentWallets; + flush(); + } + public boolean isValidateDerivationPaths() { return validateDerivationPaths; } diff --git a/src/main/java/com/sparrowwallet/sparrow/preferences/GeneralPreferencesController.java b/src/main/java/com/sparrowwallet/sparrow/preferences/GeneralPreferencesController.java index ee5975ec..b68adf1b 100644 --- a/src/main/java/com/sparrowwallet/sparrow/preferences/GeneralPreferencesController.java +++ b/src/main/java/com/sparrowwallet/sparrow/preferences/GeneralPreferencesController.java @@ -33,6 +33,9 @@ public class GeneralPreferencesController extends PreferencesDetailController { @FXML private ComboBox exchangeSource; + @FXML + private UnlabeledToggleSwitch loadRecentWallets; + @FXML private UnlabeledToggleSwitch validateDerivationPaths; @@ -97,6 +100,12 @@ public class GeneralPreferencesController extends PreferencesDetailController { updateCurrencies(exchangeSource.getSelectionModel().getSelectedItem()); + loadRecentWallets.setSelected(config.isLoadRecentWallets()); + loadRecentWallets.selectedProperty().addListener((observableValue, oldValue, newValue) -> { + config.setLoadRecentWallets(newValue); + EventManager.get().post(new RequestOpenWalletsEvent()); + }); + validateDerivationPaths.setSelected(config.isValidateDerivationPaths()); validateDerivationPaths.selectedProperty().addListener((observableValue, oldValue, newValue) -> { config.setValidateDerivationPaths(newValue); diff --git a/src/main/java/com/sparrowwallet/sparrow/preferences/PreferencesDialog.java b/src/main/java/com/sparrowwallet/sparrow/preferences/PreferencesDialog.java index b12149fb..27b3def6 100644 --- a/src/main/java/com/sparrowwallet/sparrow/preferences/PreferencesDialog.java +++ b/src/main/java/com/sparrowwallet/sparrow/preferences/PreferencesDialog.java @@ -47,7 +47,7 @@ public class PreferencesDialog extends Dialog { } dialogPane.setPrefWidth(750); - dialogPane.setPrefHeight(600); + dialogPane.setPrefHeight(630); preferencesController.reconnectOnClosingProperty().set(AppServices.isConnecting() || AppServices.isConnected()); setOnCloseRequest(event -> { diff --git a/src/main/resources/com/sparrowwallet/sparrow/preferences/general.fxml b/src/main/resources/com/sparrowwallet/sparrow/preferences/general.fxml index 6a8906b6..87a5cc5a 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/preferences/general.fxml +++ b/src/main/resources/com/sparrowwallet/sparrow/preferences/general.fxml @@ -72,6 +72,10 @@
+ + + +