mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-04 21:36:45 +00:00
add button to display seedqr on seed display dialog after warning
This commit is contained in:
parent
10a796098b
commit
3c631fa653
2 changed files with 24 additions and 2 deletions
2
drongo
2
drongo
|
@ -1 +1 @@
|
||||||
Subproject commit 9872c6b6ecfa6f5d14cd2edcb5605b76e9cb7396
|
Subproject commit b128bb895d43dfb97ddb4625425b975182753e5d
|
|
@ -1,12 +1,16 @@
|
||||||
package com.sparrowwallet.sparrow.control;
|
package com.sparrowwallet.sparrow.control;
|
||||||
|
|
||||||
import com.sparrowwallet.drongo.wallet.Keystore;
|
import com.sparrowwallet.drongo.wallet.Keystore;
|
||||||
|
import com.sparrowwallet.drongo.wallet.SeedQR;
|
||||||
import com.sparrowwallet.sparrow.AppServices;
|
import com.sparrowwallet.sparrow.AppServices;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
|
import javafx.event.ActionEvent;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
import javafx.scene.layout.StackPane;
|
import javafx.scene.layout.StackPane;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
public class SeedDisplayDialog extends Dialog<Void> {
|
public class SeedDisplayDialog extends Dialog<Void> {
|
||||||
public SeedDisplayDialog(Keystore decryptedKeystore) {
|
public SeedDisplayDialog(Keystore decryptedKeystore) {
|
||||||
final DialogPane dialogPane = getDialogPane();
|
final DialogPane dialogPane = getDialogPane();
|
||||||
|
@ -39,8 +43,15 @@ public class SeedDisplayDialog extends Dialog<Void> {
|
||||||
|
|
||||||
stackPane.getChildren().addAll(anchorPane);
|
stackPane.getChildren().addAll(anchorPane);
|
||||||
|
|
||||||
|
final ButtonType seedQRButtonType = new javafx.scene.control.ButtonType("Show SeedQR", ButtonBar.ButtonData.LEFT);
|
||||||
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(cancelButtonType);
|
dialogPane.getButtonTypes().addAll(seedQRButtonType, cancelButtonType);
|
||||||
|
|
||||||
|
Button seedQRButton = (Button)dialogPane.lookupButton(seedQRButtonType);
|
||||||
|
seedQRButton.addEventFilter(ActionEvent.ACTION, event -> {
|
||||||
|
event.consume();
|
||||||
|
showSeedQR(decryptedKeystore);
|
||||||
|
});
|
||||||
|
|
||||||
dialogPane.setPrefWidth(500);
|
dialogPane.setPrefWidth(500);
|
||||||
dialogPane.setPrefHeight(150 + height);
|
dialogPane.setPrefHeight(150 + height);
|
||||||
|
@ -48,4 +59,15 @@ public class SeedDisplayDialog extends Dialog<Void> {
|
||||||
|
|
||||||
Platform.runLater(() -> keystoreAccordion.setExpandedPane(keystorePane));
|
Platform.runLater(() -> keystoreAccordion.setExpandedPane(keystorePane));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showSeedQR(Keystore decryptedKeystore) {
|
||||||
|
Optional<ButtonType> optButtonType = AppServices.showWarningDialog("Sensitive QR", "The following QR contains these seed words. " +
|
||||||
|
"Be careful before displaying or digitally recording it.\n\nAre you sure you want to continue?", ButtonType.YES, ButtonType.NO);
|
||||||
|
if(optButtonType.isPresent() && optButtonType.get() == ButtonType.YES) {
|
||||||
|
String seedQR = SeedQR.getSeedQR(decryptedKeystore.getSeed());
|
||||||
|
QRDisplayDialog qrDisplayDialog = new QRDisplayDialog(seedQR);
|
||||||
|
qrDisplayDialog.initOwner(getDialogPane().getScene().getWindow());
|
||||||
|
qrDisplayDialog.showAndWait();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue