Browse Source

add link to server preferences in status bar on connection failure

terminal
Craig Raw 3 years ago
parent
commit
4e4fd7501c
  1. 13
      src/main/java/com/sparrowwallet/sparrow/AppController.java
  2. 18
      src/main/java/com/sparrowwallet/sparrow/event/StatusEvent.java
  3. 8
      src/main/resources/com/sparrowwallet/sparrow/app.css

13
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();
}

18
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;
}

8
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;

Loading…
Cancel
Save