preserve check menu item state across windows

This commit is contained in:
Craig Raw 2021-10-05 16:38:56 +02:00
parent 8c0a1932cf
commit 3b730a1711
2 changed files with 26 additions and 9 deletions

View file

@ -35,6 +35,8 @@ import de.codecentric.centerdevice.MenuToolkit;
import javafx.animation.*; import javafx.animation.*;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.beans.binding.Bindings; import javafx.beans.binding.Bindings;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.value.ChangeListener; import javafx.beans.value.ChangeListener;
import javafx.beans.value.WeakChangeListener; import javafx.beans.value.WeakChangeListener;
import javafx.collections.ListChangeListener; import javafx.collections.ListChangeListener;
@ -118,21 +120,27 @@ public class AppController implements Initializable {
@FXML @FXML
private CheckMenuItem openWalletsInNewWindows; private CheckMenuItem openWalletsInNewWindows;
private static final BooleanProperty openWalletsInNewWindowsProperty = new SimpleBooleanProperty();
@FXML @FXML
private CheckMenuItem hideEmptyUsedAddresses; private CheckMenuItem hideEmptyUsedAddresses;
private static final BooleanProperty hideEmptyUsedAddressesProperty = new SimpleBooleanProperty();
@FXML @FXML
private CheckMenuItem useHdCameraResolution; private CheckMenuItem useHdCameraResolution;
private static final BooleanProperty useHdCameraResolutionProperty = new SimpleBooleanProperty();
@FXML @FXML
private CheckMenuItem showLoadingLog; private CheckMenuItem showLoadingLog;
private static final BooleanProperty showLoadingLogProperty = new SimpleBooleanProperty();
@FXML @FXML
private CheckMenuItem showUtxosChart; private CheckMenuItem showUtxosChart;
private static final BooleanProperty showUtxosChartProperty = new SimpleBooleanProperty();
@FXML @FXML
private CheckMenuItem showTxHex; private CheckMenuItem showTxHex;
private static final BooleanProperty showTxHexProperty = new SimpleBooleanProperty();
@FXML @FXML
private MenuItem minimizeToTray; private MenuItem minimizeToTray;
@ -148,6 +156,7 @@ public class AppController implements Initializable {
@FXML @FXML
private CheckMenuItem preventSleep; private CheckMenuItem preventSleep;
private static final BooleanProperty preventSleepProperty = new SimpleBooleanProperty();
@FXML @FXML
private StackPane rootStack; private StackPane rootStack;
@ -279,12 +288,21 @@ public class AppController implements Initializable {
selectedThemeToggle.ifPresent(toggle -> theme.selectToggle(toggle)); selectedThemeToggle.ifPresent(toggle -> theme.selectToggle(toggle));
setTheme(null); setTheme(null);
openWalletsInNewWindows.setSelected(Config.get().isOpenWalletsInNewWindows()); openWalletsInNewWindowsProperty.set(Config.get().isOpenWalletsInNewWindows());
hideEmptyUsedAddresses.setSelected(Config.get().isHideEmptyUsedAddresses()); openWalletsInNewWindows.selectedProperty().bindBidirectional(openWalletsInNewWindowsProperty);
useHdCameraResolution.setSelected(Config.get().isHdCapture()); hideEmptyUsedAddressesProperty.set(Config.get().isHideEmptyUsedAddresses());
showTxHex.setSelected(Config.get().isShowTransactionHex()); hideEmptyUsedAddresses.selectedProperty().bindBidirectional(hideEmptyUsedAddressesProperty);
showLoadingLog.setSelected(Config.get().isShowLoadingLog()); useHdCameraResolutionProperty.set(Config.get().isHdCapture());
showUtxosChart.setSelected(Config.get().isShowUtxosChart()); useHdCameraResolution.selectedProperty().bindBidirectional(useHdCameraResolutionProperty);
showTxHexProperty.set(Config.get().isShowTransactionHex());
showTxHex.selectedProperty().bindBidirectional(showTxHexProperty);
showLoadingLogProperty.set(Config.get().isShowLoadingLog());
showLoadingLog.selectedProperty().bindBidirectional(showLoadingLogProperty);
showUtxosChartProperty.set(Config.get().isShowUtxosChart());
showUtxosChart.selectedProperty().bindBidirectional(showUtxosChartProperty);
preventSleepProperty.set(Config.get().isPreventSleep());
preventSleep.selectedProperty().bindBidirectional(preventSleepProperty);
saveTransaction.setDisable(true); saveTransaction.setDisable(true);
savePSBT.visibleProperty().bind(saveTransaction.visibleProperty().not()); savePSBT.visibleProperty().bind(saveTransaction.visibleProperty().not());
savePSBTBinary.disableProperty().bind(saveTransaction.visibleProperty()); savePSBTBinary.disableProperty().bind(saveTransaction.visibleProperty());
@ -292,7 +310,6 @@ public class AppController implements Initializable {
lockWallet.setDisable(true); lockWallet.setDisable(true);
refreshWallet.disableProperty().bind(Bindings.or(exportWallet.disableProperty(), Bindings.or(serverToggle.disableProperty(), AppServices.onlineProperty().not()))); refreshWallet.disableProperty().bind(Bindings.or(exportWallet.disableProperty(), Bindings.or(serverToggle.disableProperty(), AppServices.onlineProperty().not())));
sendToMany.disableProperty().bind(exportWallet.disableProperty()); sendToMany.disableProperty().bind(exportWallet.disableProperty());
preventSleep.setSelected(Config.get().isPreventSleep());
setServerType(Config.get().getServerType()); setServerType(Config.get().getServerType());
serverToggle.setSelected(isConnected()); serverToggle.setSelected(isConnected());

View file

@ -38,13 +38,13 @@
.wallet-subtabs > .tab-header-area .tab { .wallet-subtabs > .tab-header-area .tab {
-fx-pref-height: 50; -fx-pref-height: 50;
-fx-pref-width: 80; -fx-pref-width: 90;
-fx-alignment: CENTER; -fx-alignment: CENTER;
} }
.wallet-subtabs > .tab-header-area .tab-label { .wallet-subtabs > .tab-header-area .tab-label {
-fx-pref-height: 50; -fx-pref-height: 50;
-fx-pref-width: 80; -fx-pref-width: 90;
-fx-alignment: CENTER; -fx-alignment: CENTER;
-fx-translate-x: -6; -fx-translate-x: -6;
} }