Add toggle to PreferencesView

Add popup when selecting a burningman to ask for enabling processing

Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
This commit is contained in:
HenrikJannsen 2023-04-10 14:49:47 +07:00
parent fb5b56d03c
commit cec05e13f9
No known key found for this signature in database
GPG Key ID: 02AA2BAE387C8307
3 changed files with 56 additions and 7 deletions

View File

@ -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

View File

@ -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<ScrollPane, Void> 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<ScrollPane, Void> 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();

View File

@ -131,7 +131,7 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
private ToggleButton showOwnOffersInOfferBook, useAnimations, useDarkMode, sortMarketCurrenciesNumerically,
avoidStandbyMode, useCustomFee, autoConfirmXmrToggle, hideNonAccountPaymentMethodsToggle, denyApiTakerToggle,
notifyOnPreReleaseToggle, isDaoFullNodeToggleButton,
fullModeDaoMonitorToggleButton, useBitcoinUrisToggle, tradeLimitToggle;
fullModeDaoMonitorToggleButton, useBitcoinUrisToggle, tradeLimitToggle, processBurningManAccountingDataToggleButton;
private int gridRow = 0;
private int displayCurrenciesGridRowIndex = 0;
private InputTextField transactionFeeInputTextField, ignoreTradersListInputTextField, ignoreDustThresholdInputTextField,
@ -676,11 +676,14 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
}
private void initializeDaoOptions() {
int rowSpan = 5;
int rowSpan = 6;
daoOptionsTitledGroupBg = addTitledGroupBg(root, ++gridRow, rowSpan,
Res.get("setting.preferences.daoOptions"), Layout.GROUP_DISTANCE);
fullModeDaoMonitorToggleButton = addSlideToggleButton(root, gridRow,
Res.get("setting.preferences.dao.fullModeDaoMonitor"), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
processBurningManAccountingDataToggleButton = addSlideToggleButton(root, gridRow, Res.get("setting.preferences.dao.processBurningManAccountingData"), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
fullModeDaoMonitorToggleButton = addSlideToggleButton(root, ++gridRow,
Res.get("setting.preferences.dao.fullModeDaoMonitor"));
resyncDaoFromResourcesButton = addButton(root, ++gridRow, Res.get("setting.preferences.dao.resyncFromResources.label"));
resyncDaoFromResourcesButton.setMaxWidth(Double.MAX_VALUE);
@ -1099,6 +1102,22 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
}
private void activateDaoPreferences() {
processBurningManAccountingDataToggleButton.setSelected(preferences.isProcessBurningManAccountingData());
processBurningManAccountingDataToggleButton.setOnAction(e -> {
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<GridPane, Preferenc
private void updateDaoFields() {
boolean isDaoFullNode = isDaoFullNodeToggleButton.isSelected();
GridPane.setRowSpan(daoOptionsTitledGroupBg, isDaoFullNode ? 8 : 5);
GridPane.setRowSpan(daoOptionsTitledGroupBg, isDaoFullNode ? 9 : 6);
rpcUserTextField.setVisible(isDaoFullNode);
rpcUserTextField.setManaged(isDaoFullNode);
rpcPwTextField.setVisible(isDaoFullNode);
@ -1284,6 +1303,7 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
}
private void deactivateDaoPreferences() {
processBurningManAccountingDataToggleButton.setOnAction(null);
fullModeDaoMonitorToggleButton.setOnAction(null);
resyncDaoFromResourcesButton.setOnAction(null);
resyncDaoFromGenesisButton.setOnAction(null);