Immediately hide tray icon

This commit is contained in:
crschnick 2023-08-20 19:09:59 +00:00
parent 80f44608a1
commit b9dff411fb

View file

@ -20,7 +20,7 @@ public class AppTray {
private static AppTray INSTANCE;
private final FXTrayIcon icon;
private final ErrorHandler errorHandler;
private final TrayIcon privateTrayIcon;
private TrayIcon privateTrayIcon = null;
@SneakyThrows
private AppTray() {
@ -33,6 +33,8 @@ public class AppTray {
var builder = new FXTrayIcon.Builder(App.getApp().getStage(), url)
.menuItem(AppI18n.get("open"), e -> {
var tray = SystemTray.getSystemTray();
tray.remove(privateTrayIcon);
OperationMode.switchToAsync(OperationMode.GUI);
});
if (AppProperties.get().isDeveloperMode()) {
@ -82,6 +84,8 @@ public class AppTray {
}
privateTrayIcon.addActionListener(e -> {
if (OsType.getLocal() != OsType.MACOS) {
var tray = SystemTray.getSystemTray();
tray.remove(privateTrayIcon);
OperationMode.switchToAsync(OperationMode.GUI);
}
});