mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-04 21:36:45 +00:00
set mnemonic enter words button to number of chosen words when dropdown item clicked
This commit is contained in:
parent
ec918b78ed
commit
f1d7fc656c
2 changed files with 12 additions and 4 deletions
|
@ -8,6 +8,8 @@ import com.sparrowwallet.sparrow.EventManager;
|
||||||
import com.sparrowwallet.sparrow.event.KeystoreImportEvent;
|
import com.sparrowwallet.sparrow.event.KeystoreImportEvent;
|
||||||
import com.sparrowwallet.sparrow.glyphfont.FontAwesome5;
|
import com.sparrowwallet.sparrow.glyphfont.FontAwesome5;
|
||||||
import com.sparrowwallet.sparrow.io.*;
|
import com.sparrowwallet.sparrow.io.*;
|
||||||
|
import javafx.beans.property.IntegerProperty;
|
||||||
|
import javafx.beans.property.SimpleIntegerProperty;
|
||||||
import javafx.beans.property.SimpleListProperty;
|
import javafx.beans.property.SimpleListProperty;
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
|
@ -56,6 +58,7 @@ public class MnemonicKeystoreImportPane extends TitledDescriptionPane {
|
||||||
|
|
||||||
private SimpleListProperty<String> wordEntriesProperty;
|
private SimpleListProperty<String> wordEntriesProperty;
|
||||||
private final SimpleStringProperty passphraseProperty = new SimpleStringProperty();
|
private final SimpleStringProperty passphraseProperty = new SimpleStringProperty();
|
||||||
|
private IntegerProperty defaultWordSizeProperty;
|
||||||
|
|
||||||
public MnemonicKeystoreImportPane(Wallet wallet, KeystoreMnemonicImport importer) {
|
public MnemonicKeystoreImportPane(Wallet wallet, KeystoreMnemonicImport importer) {
|
||||||
super(importer.getName(), "Seed import", importer.getKeystoreImportDescription(), "image/" + importer.getWalletModel().getType() + ".png");
|
super(importer.getName(), "Seed import", importer.getKeystoreImportDescription(), "image/" + importer.getWalletModel().getType() + ".png");
|
||||||
|
@ -86,14 +89,19 @@ public class MnemonicKeystoreImportPane extends TitledDescriptionPane {
|
||||||
enterMnemonicButton = new SplitMenuButton();
|
enterMnemonicButton = new SplitMenuButton();
|
||||||
enterMnemonicButton.setAlignment(Pos.CENTER_RIGHT);
|
enterMnemonicButton.setAlignment(Pos.CENTER_RIGHT);
|
||||||
enterMnemonicButton.setText("Enter 24 Words");
|
enterMnemonicButton.setText("Enter 24 Words");
|
||||||
enterMnemonicButton.setOnAction(event -> {
|
defaultWordSizeProperty = new SimpleIntegerProperty(24);
|
||||||
enterMnemonic(24);
|
defaultWordSizeProperty.addListener((observable, oldValue, newValue) -> {
|
||||||
|
enterMnemonicButton.setText("Enter " + newValue + " Words");
|
||||||
});
|
});
|
||||||
int[] numberWords = new int[] {21, 18, 15, 12};
|
enterMnemonicButton.setOnAction(event -> {
|
||||||
|
enterMnemonic(defaultWordSizeProperty.get());
|
||||||
|
});
|
||||||
|
int[] numberWords = new int[] {24, 21, 18, 15, 12};
|
||||||
for(int i = 0; i < numberWords.length; i++) {
|
for(int i = 0; i < numberWords.length; i++) {
|
||||||
MenuItem item = new MenuItem("Enter " + numberWords[i] + " Words");
|
MenuItem item = new MenuItem("Enter " + numberWords[i] + " Words");
|
||||||
final int words = numberWords[i];
|
final int words = numberWords[i];
|
||||||
item.setOnAction(event -> {
|
item.setOnAction(event -> {
|
||||||
|
defaultWordSizeProperty.set(words);
|
||||||
enterMnemonic(words);
|
enterMnemonic(words);
|
||||||
});
|
});
|
||||||
enterMnemonicButton.getItems().add(item);
|
enterMnemonicButton.getItems().add(item);
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class KeystoreImportDialog extends Dialog<Keystore> {
|
||||||
final ButtonType cancelButtonType = new javafx.scene.control.ButtonType("Cancel", ButtonBar.ButtonData.CANCEL_CLOSE);
|
final ButtonType cancelButtonType = new javafx.scene.control.ButtonType("Cancel", ButtonBar.ButtonData.CANCEL_CLOSE);
|
||||||
dialogPane.getButtonTypes().addAll(watchOnlyButtonType, cancelButtonType);
|
dialogPane.getButtonTypes().addAll(watchOnlyButtonType, cancelButtonType);
|
||||||
dialogPane.setPrefWidth(650);
|
dialogPane.setPrefWidth(650);
|
||||||
dialogPane.setPrefHeight(620);
|
dialogPane.setPrefHeight(690);
|
||||||
AppServices.moveToActiveWindowScreen(this);
|
AppServices.moveToActiveWindowScreen(this);
|
||||||
|
|
||||||
setResultConverter(dialogButton -> dialogButton != cancelButtonType ? getWatchOnlyKeystore() : null);
|
setResultConverter(dialogButton -> dialogButton != cancelButtonType ? getWatchOnlyKeystore() : null);
|
||||||
|
|
Loading…
Reference in a new issue