From 3fe5fd89c466cc2ce6753a60f870eed7a401a2e7 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Wed, 14 Apr 2021 10:20:23 +0200 Subject: [PATCH] fix qr display dialog sizing --- .../sparrow/control/QRDisplayDialog.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/control/QRDisplayDialog.java b/src/main/java/com/sparrowwallet/sparrow/control/QRDisplayDialog.java index 69feff22..371f961a 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/QRDisplayDialog.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/QRDisplayDialog.java @@ -37,6 +37,9 @@ public class QRDisplayDialog extends Dialog { private static final int ANIMATION_PERIOD_MILLIS = 400; + private static final int QR_WIDTH = 480; + private static final int QR_HEIGHT = 480; + private final UR ur; private final UREncoder encoder; @@ -91,8 +94,8 @@ public class QRDisplayDialog extends Dialog { dialogPane.getButtonTypes().add(legacyEncodingButtonType); } - dialogPane.setPrefWidth(500); - dialogPane.setPrefHeight(550); + dialogPane.setPrefWidth(40 + QR_WIDTH + 40); + dialogPane.setPrefHeight(40 + QR_HEIGHT + 85); setResultConverter(dialogButton -> dialogButton != cancelButtonType ? ur : null); } @@ -113,8 +116,8 @@ public class QRDisplayDialog extends Dialog { final ButtonType cancelButtonType = new javafx.scene.control.ButtonType("Cancel", ButtonBar.ButtonData.CANCEL_CLOSE); dialogPane.getButtonTypes().addAll(cancelButtonType); - dialogPane.setPrefWidth(500); - dialogPane.setPrefHeight(550); + dialogPane.setPrefWidth(40 + QR_WIDTH + 40); + dialogPane.setPrefHeight(40 + QR_HEIGHT + 85); setResultConverter(dialogButton -> dialogButton != cancelButtonType ? ur : null); } @@ -135,7 +138,7 @@ public class QRDisplayDialog extends Dialog { private Image getQrCode(String fragment) { try { QRCodeWriter qrCodeWriter = new QRCodeWriter(); - BitMatrix qrMatrix = qrCodeWriter.encode(fragment, BarcodeFormat.QR_CODE, 480, 480); + BitMatrix qrMatrix = qrCodeWriter.encode(fragment, BarcodeFormat.QR_CODE, QR_WIDTH, QR_HEIGHT); ByteArrayOutputStream baos = new ByteArrayOutputStream(); MatrixToImageWriter.writeToStream(qrMatrix, "PNG", baos, new MatrixToImageConfig());