From cec05e13f9f797bc74e66dd14bcd133a0524e025 Mon Sep 17 00:00:00 2001 From: HenrikJannsen Date: Mon, 10 Apr 2023 14:49:47 +0700 Subject: [PATCH] Add toggle to PreferencesView Add popup when selecting a burningman to ask for enabling processing Signed-off-by: HenrikJannsen --- .../resources/i18n/displayStrings.properties | 6 ++++ .../burnbsq/burningman/BurningManView.java | 27 +++++++++++++++-- .../settings/preferences/PreferencesView.java | 30 +++++++++++++++---- 3 files changed, 56 insertions(+), 7 deletions(-) diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index 8a3e4e280d..2e83b85bd6 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -1399,6 +1399,7 @@ setting.preferences.dao.resyncFromGenesis.popup=A resync from genesis transactio the seed nodes and the BSQ consensus state will be rebuilt from the genesis transaction. setting.preferences.dao.resyncFromGenesis.resync=Resync from genesis and shutdown setting.preferences.dao.isDaoFullNode=Run Bisq as DAO full node +setting.preferences.dao.processBurningManAccountingData=Process Burningman accounting data setting.preferences.dao.fullModeDaoMonitor=Full-mode DAO state monitoring setting.preferences.dao.fullModeDaoMonitor.popup=If full-mode DAO state monitoring is activated the DAO state \ @@ -2355,6 +2356,11 @@ dao.burningman.table.balanceEntry.revenue=Revenue dao.burningman.table.balanceEntry.price=BSQ/BTC price dao.burningman.table.balanceEntry.type=Type +dao.burningman.accounting.popup=To display accounting data of a burningman you need to enable the 'process burningman accounting data' option in settings.\n\ + Do you want to do that now?\n\ + It will require to restart Bisq to apply that change.\n\n\ + If you cancel, the displayed accounting data are not up-to-date. + # From BalanceEntry.Type enum names dao.burningman.balanceEntry.type.UNDEFINED=Undefined dao.burningman.balanceEntry.type.BTC_TRADE_FEE_TX=Trade fee diff --git a/desktop/src/main/java/bisq/desktop/main/dao/burnbsq/burningman/BurningManView.java b/desktop/src/main/java/bisq/desktop/main/dao/burnbsq/burningman/BurningManView.java index 8504f6453b..f9d4a0e08e 100644 --- a/desktop/src/main/java/bisq/desktop/main/dao/burnbsq/burningman/BurningManView.java +++ b/desktop/src/main/java/bisq/desktop/main/dao/burnbsq/burningman/BurningManView.java @@ -17,6 +17,7 @@ package bisq.desktop.main.dao.burnbsq.burningman; +import bisq.desktop.app.BisqApp; import bisq.desktop.common.view.ActivatableView; import bisq.desktop.common.view.FxmlView; import bisq.desktop.components.AutoTooltipButton; @@ -51,11 +52,13 @@ import bisq.core.dao.state.DaoStateListener; import bisq.core.dao.state.model.blockchain.Block; import bisq.core.locale.Res; import bisq.core.monetary.Price; +import bisq.core.user.Preferences; import bisq.core.util.FormattingUtils; import bisq.core.util.ParsingUtils; import bisq.core.util.coin.BsqFormatter; import bisq.core.util.coin.CoinFormatter; +import bisq.common.UserThread; import bisq.common.app.DevEnv; import bisq.common.util.DateUtil; import bisq.common.util.Tuple2; @@ -113,6 +116,7 @@ import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Set; +import java.util.concurrent.TimeUnit; import java.util.function.Predicate; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -187,7 +191,8 @@ public class BurningManView extends ActivatableView implements BsqWalletService bsqWalletService, BsqFormatter bsqFormatter, @Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter btcFormatter, - BsqValidator bsqValidator) { + BsqValidator bsqValidator, + Preferences preferences) { this.daoFacade = daoFacade; this.burningManPresentationService = burningManPresentationService; this.burningManAccountingService = burningManAccountingService; @@ -235,7 +240,25 @@ public class BurningManView extends ActivatableView implements selectedContributorAddressBox.setManaged(isValueSet); selectedContributorAddressBox.setVisible(isValueSet); if (isValueSet) { - onBurningManSelected(newValue); + if (preferences.isProcessBurningManAccountingData()) { + onBurningManSelected(newValue); + } else { + String key = "processBurningManAccountingData"; + if (preferences.showAgain(key)) { + new Popup().information(Res.get("dao.burningman.accounting.popup")) + .actionButtonText(Res.get("shared.applyAndShutDown")) + .onAction(() -> { + preferences.setProcessBurningManAccountingData(true); + UserThread.runAfter(BisqApp.getShutDownHandler(), 500, TimeUnit.MILLISECONDS); + }) + .closeButtonText(Res.get("shared.cancel")) + .onClose(() -> onBurningManSelected(newValue)) + .dontShowAgainId(key) + .show(); + } else { + onBurningManSelected(newValue); + } + } } else { selectedContributorNameField.clear(); selectedContributorTotalRevenueField.clear(); diff --git a/desktop/src/main/java/bisq/desktop/main/settings/preferences/PreferencesView.java b/desktop/src/main/java/bisq/desktop/main/settings/preferences/PreferencesView.java index aee7ced1e7..b3c640df04 100644 --- a/desktop/src/main/java/bisq/desktop/main/settings/preferences/PreferencesView.java +++ b/desktop/src/main/java/bisq/desktop/main/settings/preferences/PreferencesView.java @@ -131,7 +131,7 @@ public class PreferencesView extends ActivatableViewAndModel { + boolean selected = processBurningManAccountingDataToggleButton.isSelected(); + if (selected != preferences.isProcessBurningManAccountingData()) { + new Popup().information(Res.get("settings.net.needRestart")) + .actionButtonText(Res.get("shared.applyAndShutDown")) + .onAction(() -> { + preferences.setProcessBurningManAccountingData(selected); + UserThread.runAfter(BisqApp.getShutDownHandler(), 500, TimeUnit.MILLISECONDS); + }) + .closeButtonText(Res.get("shared.cancel")) + .onClose(() -> processBurningManAccountingDataToggleButton.setSelected(!selected)) + .show(); + } + }); + fullModeDaoMonitorToggleButton.setSelected(preferences.isUseFullModeDaoMonitor()); fullModeDaoMonitorToggleButton.setOnAction(e -> { preferences.setUseFullModeDaoMonitor(fullModeDaoMonitorToggleButton.isSelected()); @@ -1221,7 +1240,7 @@ public class PreferencesView extends ActivatableViewAndModel