|
@@ -1,6 +1,7 @@
|
|
|
package org.cryptomator.ui.traymenu;
|
|
|
|
|
|
import javafx.beans.Observable;
|
|
|
+import org.apache.commons.lang3.SystemUtils;
|
|
|
import org.cryptomator.common.settings.Settings;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -9,10 +10,13 @@ import javax.inject.Inject;
|
|
|
import java.awt.AWTException;
|
|
|
import java.awt.SystemTray;
|
|
|
import java.awt.TrayIcon;
|
|
|
+import java.awt.event.ActionEvent;
|
|
|
+import java.awt.event.MouseAdapter;
|
|
|
+import java.awt.event.MouseEvent;
|
|
|
|
|
|
@TrayMenuScoped
|
|
|
public class TrayIconController {
|
|
|
-
|
|
|
+
|
|
|
private static final Logger LOG = LoggerFactory.getLogger(TrayIconController.class);
|
|
|
|
|
|
private final Settings settings;
|
|
@@ -27,17 +31,22 @@ public class TrayIconController {
|
|
|
this.imageFactory = imageFactory;
|
|
|
this.trayIcon = new TrayIcon(imageFactory.loadImage(), "Cryptomator", trayMenuController.getMenu());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void initializeTrayIcon() {
|
|
|
settings.theme().addListener(this::themeChanged);
|
|
|
|
|
|
+ if (SystemUtils.IS_OS_WINDOWS) {
|
|
|
+ // TODO: test on windows: is this a double click?
|
|
|
+ trayIcon.addActionListener(trayMenuController::showMainWindow);
|
|
|
+ }
|
|
|
+
|
|
|
try {
|
|
|
SystemTray.getSystemTray().add(trayIcon);
|
|
|
LOG.debug("initialized tray icon");
|
|
|
} catch (AWTException e) {
|
|
|
LOG.error("Error adding tray icon", e);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
trayMenuController.initTrayMenu();
|
|
|
}
|
|
|
|
|
@@ -45,5 +54,4 @@ public class TrayIconController {
|
|
|
trayIcon.setImage(imageFactory.loadImage());
|
|
|
}
|
|
|
|
|
|
-
|
|
|
}
|