mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2025-11-05 11:56:37 +00:00
suggest opening the send to many dialog when adding multiple payments on the send tab
This commit is contained in:
parent
25770c2426
commit
f28e00b97e
5 changed files with 66 additions and 7 deletions
|
|
@ -1422,6 +1422,10 @@ public class AppController implements Initializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendToMany(ActionEvent event) {
|
public void sendToMany(ActionEvent event) {
|
||||||
|
sendToMany(Collections.emptyList());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendToMany(List<Payment> initialPayments) {
|
||||||
if(sendToManyDialog != null) {
|
if(sendToManyDialog != null) {
|
||||||
Stage stage = (Stage)sendToManyDialog.getDialogPane().getScene().getWindow();
|
Stage stage = (Stage)sendToManyDialog.getDialogPane().getScene().getWindow();
|
||||||
stage.setAlwaysOnTop(true);
|
stage.setAlwaysOnTop(true);
|
||||||
|
|
@ -1437,7 +1441,7 @@ public class AppController implements Initializable {
|
||||||
bitcoinUnit = wallet.getAutoUnit();
|
bitcoinUnit = wallet.getAutoUnit();
|
||||||
}
|
}
|
||||||
|
|
||||||
sendToManyDialog = new SendToManyDialog(bitcoinUnit);
|
sendToManyDialog = new SendToManyDialog(bitcoinUnit, initialPayments);
|
||||||
sendToManyDialog.initModality(Modality.NONE);
|
sendToManyDialog.initModality(Modality.NONE);
|
||||||
Optional<List<Payment>> optPayments = sendToManyDialog.showAndWait();
|
Optional<List<Payment>> optPayments = sendToManyDialog.showAndWait();
|
||||||
sendToManyDialog = null;
|
sendToManyDialog = null;
|
||||||
|
|
@ -3107,6 +3111,11 @@ public class AppController implements Initializable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void requestSendToMany(RequestSendToManyEvent event) {
|
||||||
|
sendToMany(event.getPayments());
|
||||||
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void functionAction(FunctionActionEvent event) {
|
public void functionAction(FunctionActionEvent event) {
|
||||||
selectTab(event.getWallet());
|
selectTab(event.getWallet());
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,6 @@ import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import javafx.scene.Node;
|
import javafx.scene.Node;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
import javafx.scene.image.Image;
|
|
||||||
import javafx.scene.image.ImageView;
|
|
||||||
import javafx.scene.input.Clipboard;
|
import javafx.scene.input.Clipboard;
|
||||||
import javafx.scene.layout.StackPane;
|
import javafx.scene.layout.StackPane;
|
||||||
import javafx.stage.FileChooser;
|
import javafx.stage.FileChooser;
|
||||||
|
|
@ -34,7 +32,7 @@ public class SendToManyDialog extends Dialog<List<Payment>> {
|
||||||
private final SpreadsheetView spreadsheetView;
|
private final SpreadsheetView spreadsheetView;
|
||||||
public static final AddressCellType ADDRESS = new AddressCellType();
|
public static final AddressCellType ADDRESS = new AddressCellType();
|
||||||
|
|
||||||
public SendToManyDialog(BitcoinUnit bitcoinUnit) {
|
public SendToManyDialog(BitcoinUnit bitcoinUnit, List<Payment> payments) {
|
||||||
this.bitcoinUnit = bitcoinUnit;
|
this.bitcoinUnit = bitcoinUnit;
|
||||||
|
|
||||||
final DialogPane dialogPane = new SendToManyDialogPane();
|
final DialogPane dialogPane = new SendToManyDialogPane();
|
||||||
|
|
@ -44,7 +42,8 @@ public class SendToManyDialog extends Dialog<List<Payment>> {
|
||||||
dialogPane.setHeaderText("Send to many recipients by specifying addresses and amounts.\nOnly the first row's label is necessary.");
|
dialogPane.setHeaderText("Send to many recipients by specifying addresses and amounts.\nOnly the first row's label is necessary.");
|
||||||
dialogPane.setGraphic(new DialogImage(DialogImage.Type.SPARROW));
|
dialogPane.setGraphic(new DialogImage(DialogImage.Type.SPARROW));
|
||||||
|
|
||||||
List<Payment> initialPayments = IntStream.range(0, 100).mapToObj(i -> new Payment(null, null, -1, false)).collect(Collectors.toList());
|
List<Payment> initialPayments = IntStream.range(0, 100)
|
||||||
|
.mapToObj(i -> i < payments.size() ? payments.get(i) : new Payment(null, null, -1, false)).collect(Collectors.toList());
|
||||||
Grid grid = getGrid(initialPayments);
|
Grid grid = getGrid(initialPayments);
|
||||||
|
|
||||||
spreadsheetView = new SpreadsheetView(grid) {
|
spreadsheetView = new SpreadsheetView(grid) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.sparrowwallet.sparrow.event;
|
||||||
|
|
||||||
|
import com.sparrowwallet.drongo.wallet.Payment;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class RequestSendToManyEvent {
|
||||||
|
private final List<Payment> payments;
|
||||||
|
|
||||||
|
public RequestSendToManyEvent(List<Payment> payments) {
|
||||||
|
this.payments = payments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Payment> getPayments() {
|
||||||
|
return payments;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -53,6 +53,7 @@ public class Config {
|
||||||
private boolean signBsmsExports = false;
|
private boolean signBsmsExports = false;
|
||||||
private boolean preventSleep = false;
|
private boolean preventSleep = false;
|
||||||
private Boolean connectToBroadcast;
|
private Boolean connectToBroadcast;
|
||||||
|
private Boolean suggestSendToMany;
|
||||||
private List<File> recentWalletFiles;
|
private List<File> recentWalletFiles;
|
||||||
private Integer keyDerivationPeriod;
|
private Integer keyDerivationPeriod;
|
||||||
private long dustAttackThreshold = DUST_ATTACK_THRESHOLD_SATS;
|
private long dustAttackThreshold = DUST_ATTACK_THRESHOLD_SATS;
|
||||||
|
|
@ -361,6 +362,15 @@ public class Config {
|
||||||
flush();
|
flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean getSuggestSendToMany() {
|
||||||
|
return suggestSendToMany;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSuggestSendToMany(Boolean suggestSendToMany) {
|
||||||
|
this.suggestSendToMany = suggestSendToMany;
|
||||||
|
flush();
|
||||||
|
}
|
||||||
|
|
||||||
public List<File> getRecentWalletFiles() {
|
public List<File> getRecentWalletFiles() {
|
||||||
return recentWalletFiles;
|
return recentWalletFiles;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -491,11 +491,35 @@ public class SendController extends WalletFormController implements Initializabl
|
||||||
validationSupport.setErrorDecorationEnabled(false);
|
validationSupport.setErrorDecorationEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Tab addPaymentTab() {
|
public void addPaymentTab() {
|
||||||
|
if(Config.get().getSuggestSendToMany() == null && openSendToMany()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Tab tab = getPaymentTab();
|
Tab tab = getPaymentTab();
|
||||||
paymentTabs.getTabs().add(tab);
|
paymentTabs.getTabs().add(tab);
|
||||||
paymentTabs.getSelectionModel().select(tab);
|
paymentTabs.getSelectionModel().select(tab);
|
||||||
return tab;
|
}
|
||||||
|
|
||||||
|
private boolean openSendToMany() {
|
||||||
|
try {
|
||||||
|
List<Payment> payments = getPayments();
|
||||||
|
if(payments.size() == 3) {
|
||||||
|
ConfirmationAlert confirmationAlert = new ConfirmationAlert("Open Send To Many?", "Open the Tools > Send To Many dialog to add multiple payments?", ButtonType.NO, ButtonType.YES);
|
||||||
|
Optional<ButtonType> optType = confirmationAlert.showAndWait();
|
||||||
|
if(confirmationAlert.isDontAskAgain() && optType.isPresent()) {
|
||||||
|
Config.get().setSuggestSendToMany(optType.get() == ButtonType.YES);
|
||||||
|
}
|
||||||
|
if(optType.isPresent() && optType.get() == ButtonType.YES) {
|
||||||
|
Platform.runLater(() -> EventManager.get().post(new RequestSendToManyEvent(payments)));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch(Exception e) {
|
||||||
|
//ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Tab getPaymentTab() {
|
public Tab getPaymentTab() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue