From 4e4fd7501c5b4026db9df5b9dd091d916b4287ce Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Mon, 7 Feb 2022 14:08:06 +0200 Subject: [PATCH] add link to server preferences in status bar on connection failure --- .../sparrowwallet/sparrow/AppController.java | 13 ++++++++++++- .../sparrow/event/StatusEvent.java | 18 +++++++++++++++++- .../com/sparrowwallet/sparrow/app.css | 8 ++++++-- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/AppController.java b/src/main/java/com/sparrowwallet/sparrow/AppController.java index 7a37bc6b..a4dcfc77 100644 --- a/src/main/java/com/sparrowwallet/sparrow/AppController.java +++ b/src/main/java/com/sparrowwallet/sparrow/AppController.java @@ -1213,6 +1213,11 @@ public class AppController implements Initializable { preferencesDialog.showAndWait(); } + public void openServerPreferences(ActionEvent event) { + PreferencesDialog preferencesDialog = new PreferencesDialog(PreferenceGroup.SERVER); + preferencesDialog.showAndWait(); + } + public void signVerifyMessage(ActionEvent event) { MessageSignDialog messageSignDialog = null; WalletForm selectedWalletForm = getSelectedWalletForm(); @@ -2096,6 +2101,7 @@ public class AppController implements Initializable { @Subscribe public void statusUpdated(StatusEvent event) { statusBar.setText(event.getStatus()); + statusBar.setGraphic(event.getGraphic()); if(wait != null && wait.getStatus() == Animation.Status.RUNNING) { wait.stop(); @@ -2104,6 +2110,7 @@ public class AppController implements Initializable { wait.setOnFinished((e) -> { if(statusBar.getText().equals(event.getStatus())) { statusBar.setText(""); + statusBar.setGraphic(null); } }); wait.play(); @@ -2133,6 +2140,7 @@ public class AppController implements Initializable { @Subscribe public void timedWorker(TimedEvent event) { + statusBar.setGraphic(null); if(event.getTimeMills() == 0) { if(statusTimeline != null && statusTimeline.getStatus() == Animation.Status.RUNNING) { statusTimeline.stop(); @@ -2148,6 +2156,7 @@ public class AppController implements Initializable { new KeyFrame(Duration.ZERO, new KeyValue(statusBar.progressProperty(), 0)), new KeyFrame(Duration.millis(event.getTimeMills()), e -> { statusBar.setText(""); + statusBar.setGraphic(null); statusBar.setProgress(0); }, new KeyValue(statusBar.progressProperty(), 1)) ); @@ -2192,7 +2201,9 @@ public class AppController implements Initializable { @Subscribe public void connectionFailed(ConnectionFailedEvent event) { String status = CONNECTION_FAILED_PREFIX + event.getMessage(); - statusUpdated(new StatusEvent(status)); + Hyperlink hyperlink = new Hyperlink("Server Preferences"); + hyperlink.setOnAction(this::openServerPreferences); + statusUpdated(new StatusEvent(status, hyperlink)); serverToggleStopAnimation(); setTorIcon(); } diff --git a/src/main/java/com/sparrowwallet/sparrow/event/StatusEvent.java b/src/main/java/com/sparrowwallet/sparrow/event/StatusEvent.java index 8e3ee41b..7ea69cb8 100644 --- a/src/main/java/com/sparrowwallet/sparrow/event/StatusEvent.java +++ b/src/main/java/com/sparrowwallet/sparrow/event/StatusEvent.java @@ -1,17 +1,29 @@ package com.sparrowwallet.sparrow.event; +import javafx.scene.Node; + public class StatusEvent { public static final int DEFAULT_SHOW_DURATION_SECS = 20; private final String status; + private final Node graphic; private final int showDuration; public StatusEvent(String status) { - this(status, DEFAULT_SHOW_DURATION_SECS); + this(status, null, DEFAULT_SHOW_DURATION_SECS); + } + + public StatusEvent(String status, Node graphic) { + this(status, graphic, DEFAULT_SHOW_DURATION_SECS); } public StatusEvent(String status, int showDuration) { + this(status, null, showDuration); + } + + public StatusEvent(String status, Node graphic, int showDuration) { this.status = status; + this.graphic = graphic; this.showDuration = showDuration; } @@ -19,6 +31,10 @@ public class StatusEvent { return status; } + public Node getGraphic() { + return graphic; + } + public int getShowDuration() { return showDuration; } diff --git a/src/main/resources/com/sparrowwallet/sparrow/app.css b/src/main/resources/com/sparrowwallet/sparrow/app.css index 84a91981..71da8533 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/app.css +++ b/src/main/resources/com/sparrowwallet/sparrow/app.css @@ -59,15 +59,19 @@ -fx-spacing: 10; } -.version-hyperlink { +.version-hyperlink, .status-bar .status-label .hyperlink { -fx-border-color: transparent; -fx-text-fill: #1e88cf; } -.version-hyperlink:visited { +.version-hyperlink:visited, .status-bar .status-label .hyperlink { -fx-underline: false; } +.status-bar .status-label { + -fx-content-display: RIGHT; +} + .core-server.toggle-switch:selected .thumb-area { -fx-background-color: linear-gradient(to bottom, derive(-fx-text-box-border, -20%), derive(-fx-text-box-border, -30%)), linear-gradient(to bottom, derive(#50a14f, 30%), #50a14f); -fx-background-insets: 0, 1;