mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-02 20:36:44 +00:00
make search wallet dialog non-modal, close any non-modal dialogs on application closing
This commit is contained in:
parent
fe7dba6d83
commit
d3752a856b
2 changed files with 37 additions and 9 deletions
|
@ -219,6 +219,8 @@ public class AppController implements Initializable {
|
||||||
|
|
||||||
private Timeline statusTimeline;
|
private Timeline statusTimeline;
|
||||||
|
|
||||||
|
private SearchWalletDialog searchWalletDialog;
|
||||||
|
|
||||||
private SendToManyDialog sendToManyDialog;
|
private SendToManyDialog sendToManyDialog;
|
||||||
|
|
||||||
private DownloadVerifierDialog downloadVerifierDialog;
|
private DownloadVerifierDialog downloadVerifierDialog;
|
||||||
|
@ -280,6 +282,15 @@ public class AppController implements Initializable {
|
||||||
void initializeView() {
|
void initializeView() {
|
||||||
setPlatformApplicationMenu();
|
setPlatformApplicationMenu();
|
||||||
|
|
||||||
|
rootStack.getScene().getWindow().setOnHiding(windowEvent -> {
|
||||||
|
if(searchWalletDialog != null && searchWalletDialog.isShowing()) {
|
||||||
|
searchWalletDialog.close();
|
||||||
|
}
|
||||||
|
if(sendToManyDialog != null && sendToManyDialog.isShowing()) {
|
||||||
|
sendToManyDialog.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
rootStack.setOnDragOver(event -> {
|
rootStack.setOnDragOver(event -> {
|
||||||
if(event.getGestureSource() != rootStack && event.getDragboard().hasFiles()) {
|
if(event.getGestureSource() != rootStack && event.getDragboard().hasFiles()) {
|
||||||
event.acceptTransferModes(TransferMode.LINK);
|
event.acceptTransferModes(TransferMode.LINK);
|
||||||
|
@ -1419,7 +1430,6 @@ public class AppController implements Initializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
sendToManyDialog = new SendToManyDialog(bitcoinUnit);
|
sendToManyDialog = new SendToManyDialog(bitcoinUnit);
|
||||||
sendToManyDialog.initOwner(rootStack.getScene().getWindow());
|
|
||||||
sendToManyDialog.initModality(Modality.NONE);
|
sendToManyDialog.initModality(Modality.NONE);
|
||||||
Optional<List<Payment>> optPayments = sendToManyDialog.showAndWait();
|
Optional<List<Payment>> optPayments = sendToManyDialog.showAndWait();
|
||||||
sendToManyDialog = null;
|
sendToManyDialog = null;
|
||||||
|
@ -1605,14 +1615,28 @@ public class AppController implements Initializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void searchWallets(List<WalletForm> walletForms) {
|
private void searchWallets(List<WalletForm> walletForms) {
|
||||||
SearchWalletDialog searchWalletDialog = new SearchWalletDialog(walletForms);
|
if(searchWalletDialog != null) {
|
||||||
searchWalletDialog.initOwner(rootStack.getScene().getWindow());
|
if(!searchWalletDialog.getWalletForms().equals(walletForms)) {
|
||||||
Optional<Entry> optEntry = searchWalletDialog.showAndWait();
|
searchWalletDialog.close();
|
||||||
if(optEntry.isPresent()) {
|
} else {
|
||||||
Entry entry = optEntry.get();
|
Stage stage = (Stage)searchWalletDialog.getDialogPane().getScene().getWindow();
|
||||||
EventManager.get().post(new FunctionActionEvent(entry.getWalletFunction(), entry.getWallet()));
|
stage.setAlwaysOnTop(true);
|
||||||
Platform.runLater(() -> EventManager.get().post(new SelectEntryEvent(entry)));
|
stage.setAlwaysOnTop(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Platform.runLater(() -> {
|
||||||
|
searchWalletDialog = new SearchWalletDialog(walletForms);
|
||||||
|
searchWalletDialog.initModality(Modality.NONE);
|
||||||
|
Optional<Entry> optEntry = searchWalletDialog.showAndWait();
|
||||||
|
if(optEntry.isPresent()) {
|
||||||
|
Entry entry = optEntry.get();
|
||||||
|
EventManager.get().post(new FunctionActionEvent(entry.getWalletFunction(), entry.getWallet()));
|
||||||
|
Platform.runLater(() -> EventManager.get().post(new SelectEntryEvent(entry)));
|
||||||
|
}
|
||||||
|
searchWalletDialog = null;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showAllWalletsSummary(ActionEvent event) {
|
public void showAllWalletsSummary(ActionEvent event) {
|
||||||
|
|
|
@ -156,6 +156,10 @@ public class SearchWalletDialog extends Dialog<Entry> {
|
||||||
Platform.runLater(search::requestFocus);
|
Platform.runLater(search::requestFocus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<WalletForm> getWalletForms() {
|
||||||
|
return walletForms;
|
||||||
|
}
|
||||||
|
|
||||||
private void searchWallets(String searchPhrase) {
|
private void searchWallets(String searchPhrase) {
|
||||||
Set<Entry> matchingEntries = new LinkedHashSet<>();
|
Set<Entry> matchingEntries = new LinkedHashSet<>();
|
||||||
|
|
||||||
|
@ -276,7 +280,7 @@ public class SearchWalletDialog extends Dialog<Entry> {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String removeOccurrences(String inputString, Collection<String> stringsToRemove) {
|
private String removeOccurrences(String inputString, Collection<String> stringsToRemove) {
|
||||||
for(String str : stringsToRemove) {
|
for(String str : stringsToRemove) {
|
||||||
inputString = inputString.replaceAll("(?i)" + str, "");
|
inputString = inputString.replaceAll("(?i)" + str, "");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue