Integrated the tray icon with the hide on close setting
This commit is contained in:
@ -62,6 +62,7 @@ public final class LoginScene {
|
||||
private static final Logger logger = EnvoyLog.getLogger(LoginScene.class);
|
||||
private static final EventBus eventBus = EventBus.getInstance();
|
||||
private static final ClientConfig config = ClientConfig.getInstance();
|
||||
private static final Settings settings = Settings.getInstance();
|
||||
|
||||
@FXML
|
||||
private void initialize() {
|
||||
@ -209,15 +210,22 @@ public final class LoginScene {
|
||||
sceneContext.load(SceneContext.SceneInfo.CHAT_SCENE);
|
||||
sceneContext.<ChatScene>getController().initializeData(sceneContext, localDB, client, writeProxy);
|
||||
|
||||
try {
|
||||
new StatusTrayIcon(sceneContext.getStage()).show();
|
||||
if (StatusTrayIcon.isSupported()) {
|
||||
|
||||
// Configure hide on close
|
||||
sceneContext.getStage().setOnCloseRequest(e -> {
|
||||
sceneContext.getStage().setIconified(true);
|
||||
e.consume();
|
||||
if (settings.isHideOnClose()) {
|
||||
sceneContext.getStage().setIconified(true);
|
||||
e.consume();
|
||||
}
|
||||
});
|
||||
|
||||
// Initialize status tray icon
|
||||
final var trayIcon = new StatusTrayIcon(sceneContext.getStage());
|
||||
settings.getItems().get("hideOnClose").setChangeHandler(c -> {
|
||||
if (((Boolean) c)) trayIcon.show();
|
||||
else trayIcon.hide();
|
||||
});
|
||||
} catch (EnvoyException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user