mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-08-01 03:06:14 -04:00
Remove cycle between SystemTray and BitsquareUI
This commit is contained in:
parent
b1a4641139
commit
f278db01ac
2 changed files with 5 additions and 10 deletions
|
@ -109,7 +109,7 @@ public class BitsquareUI extends Application {
|
||||||
|
|
||||||
// configure the system tray
|
// configure the system tray
|
||||||
|
|
||||||
SystemTray systemTray = new SystemTray(primaryStage, this);
|
SystemTray systemTray = new SystemTray(primaryStage, this::stop);
|
||||||
primaryStage.setOnCloseRequest(e -> systemTray.hideStage());
|
primaryStage.setOnCloseRequest(e -> systemTray.hideStage());
|
||||||
scene.setOnKeyReleased(keyEvent -> {
|
scene.setOnKeyReleased(keyEvent -> {
|
||||||
if (new KeyCodeCombination(KeyCode.W, KeyCombination.SHORTCUT_DOWN).match(keyEvent))
|
if (new KeyCodeCombination(KeyCode.W, KeyCombination.SHORTCUT_DOWN).match(keyEvent))
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
package io.bitsquare.gui;
|
package io.bitsquare.gui;
|
||||||
|
|
||||||
import io.bitsquare.BitsquareUI;
|
|
||||||
import io.bitsquare.gui.util.ImageUtil;
|
import io.bitsquare.gui.util.ImageUtil;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
@ -43,13 +42,13 @@ public class SystemTray {
|
||||||
public static final String HIDE_WINDOW_LABEL = "Hide exchange window";
|
public static final String HIDE_WINDOW_LABEL = "Hide exchange window";
|
||||||
|
|
||||||
private final Stage stage;
|
private final Stage stage;
|
||||||
private final BitsquareUI application;
|
private final Runnable onExit;
|
||||||
private final TrayIcon trayIcon = createTrayIcon();
|
private final TrayIcon trayIcon = createTrayIcon();
|
||||||
private final MenuItem toggleShowHideItem = new MenuItem(HIDE_WINDOW_LABEL);
|
private final MenuItem toggleShowHideItem = new MenuItem(HIDE_WINDOW_LABEL);
|
||||||
|
|
||||||
public SystemTray(Stage stage, BitsquareUI application) {
|
public SystemTray(Stage stage, Runnable onExit) {
|
||||||
this.stage = stage;
|
this.stage = stage;
|
||||||
this.application = application;
|
this.onExit = onExit;
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,11 +94,7 @@ public class SystemTray {
|
||||||
|
|
||||||
exitItem.addActionListener(e -> {
|
exitItem.addActionListener(e -> {
|
||||||
self.remove(trayIcon);
|
self.remove(trayIcon);
|
||||||
try {
|
onExit.run();
|
||||||
application.stop();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
log.error("Application failed to shut down properly.", ex);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue