mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-08-01 03:06:14 -04:00
Add comment for each major step in BitsquareUI#start
This commit is contained in:
parent
78819d7e13
commit
2af861a776
1 changed files with 27 additions and 22 deletions
|
@ -67,8 +67,14 @@ public class BitsquareUI extends Application {
|
||||||
public void start(Stage primaryStage) {
|
public void start(Stage primaryStage) {
|
||||||
BitsquareUI.primaryStage = primaryStage;
|
BitsquareUI.primaryStage = primaryStage;
|
||||||
|
|
||||||
Thread.currentThread().setUncaughtExceptionHandler((thread, throwable) -> Popups.handleUncaughtExceptions
|
|
||||||
(Throwables.getRootCause(throwable)));
|
// route uncaught exceptions to a user-facing dialog
|
||||||
|
|
||||||
|
Thread.currentThread().setUncaughtExceptionHandler((thread, throwable) ->
|
||||||
|
Popups.handleUncaughtExceptions(Throwables.getRootCause(throwable)));
|
||||||
|
|
||||||
|
|
||||||
|
// configure the Bitsquare application data directory
|
||||||
|
|
||||||
try {
|
try {
|
||||||
AppDirectory.initAppDir(Bitsquare.getAppName());
|
AppDirectory.initAppDir(Bitsquare.getAppName());
|
||||||
|
@ -77,10 +83,8 @@ public class BitsquareUI extends Application {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// currently there is not SystemTray support for java fx (planned for version 3) so we use the old AWT
|
// load and apply any stored settings
|
||||||
AWTSystemTray.createSystemTray(primaryStage, injector.getInstance(ActorSystem.class), this);
|
|
||||||
|
|
||||||
// apply stored data
|
|
||||||
User user = injector.getInstance(User.class);
|
User user = injector.getInstance(User.class);
|
||||||
Settings settings = injector.getInstance(Settings.class);
|
Settings settings = injector.getInstance(Settings.class);
|
||||||
Persistence persistence = injector.getInstance(Persistence.class);
|
Persistence persistence = injector.getInstance(Persistence.class);
|
||||||
|
@ -91,16 +95,10 @@ public class BitsquareUI extends Application {
|
||||||
|
|
||||||
settings.applyPersistedSettings((Settings) persistence.read(settings.getClass().getName()));
|
settings.applyPersistedSettings((Settings) persistence.read(settings.getClass().getName()));
|
||||||
|
|
||||||
primaryStage.setTitle("Bitsquare (" + Bitsquare.getAppName() + ")");
|
|
||||||
|
|
||||||
// sometimes there is a rendering bug, see https://github.com/bitsquare/bitsquare/issues/160
|
// load the main view and create the main scene
|
||||||
if (ImageUtil.isRetina())
|
|
||||||
primaryStage.getIcons().add(new Image(getClass().getResourceAsStream("/images/window_icon@2x.png")));
|
|
||||||
else
|
|
||||||
primaryStage.getIcons().add(new Image(getClass().getResourceAsStream("/images/window_icon.png")));
|
|
||||||
|
|
||||||
ViewLoader.setInjector(injector);
|
ViewLoader.setInjector(injector);
|
||||||
|
|
||||||
ViewLoader loader = new ViewLoader(Navigation.Item.MAIN, false);
|
ViewLoader loader = new ViewLoader(Navigation.Item.MAIN, false);
|
||||||
Parent view = loader.load();
|
Parent view = loader.load();
|
||||||
|
|
||||||
|
@ -109,24 +107,31 @@ public class BitsquareUI extends Application {
|
||||||
"/io/bitsquare/gui/bitsquare.css",
|
"/io/bitsquare/gui/bitsquare.css",
|
||||||
"/io/bitsquare/gui/images.css");
|
"/io/bitsquare/gui/images.css");
|
||||||
|
|
||||||
setupCloseHandlers(primaryStage, scene);
|
|
||||||
|
|
||||||
primaryStage.setScene(scene);
|
// configure the system tray
|
||||||
|
|
||||||
primaryStage.setMinWidth(75);
|
AWTSystemTray.createSystemTray(primaryStage, injector.getInstance(ActorSystem.class), this);
|
||||||
primaryStage.setMinHeight(50);
|
|
||||||
|
|
||||||
primaryStage.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupCloseHandlers(Stage primaryStage, Scene scene) {
|
|
||||||
primaryStage.setOnCloseRequest(e -> AWTSystemTray.setStageHidden());
|
primaryStage.setOnCloseRequest(e -> AWTSystemTray.setStageHidden());
|
||||||
|
|
||||||
KeyCodeCombination keyCodeCombination = new KeyCodeCombination(KeyCode.W, KeyCombination.SHORTCUT_DOWN);
|
KeyCodeCombination keyCodeCombination = new KeyCodeCombination(KeyCode.W, KeyCombination.SHORTCUT_DOWN);
|
||||||
scene.setOnKeyReleased(keyEvent -> {
|
scene.setOnKeyReleased(keyEvent -> {
|
||||||
if (keyCodeCombination.match(keyEvent))
|
if (keyCodeCombination.match(keyEvent))
|
||||||
AWTSystemTray.setStageHidden();
|
AWTSystemTray.setStageHidden();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// configure the primary stage
|
||||||
|
|
||||||
|
primaryStage.setTitle("Bitsquare (" + Bitsquare.getAppName() + ")");
|
||||||
|
primaryStage.setScene(scene);
|
||||||
|
primaryStage.setMinWidth(75);
|
||||||
|
primaryStage.setMinHeight(50);
|
||||||
|
primaryStage.getIcons().add(new Image(getClass().getResourceAsStream(
|
||||||
|
ImageUtil.isRetina() ? "/images/window_icon@2x.png" : "/images/window_icon.png")));
|
||||||
|
|
||||||
|
|
||||||
|
// make the UI visible
|
||||||
|
|
||||||
|
primaryStage.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue