mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-04-21 10:06:55 -04:00
No longer using TrayIcon on linux systems
* Reason: TrayIcon not supported well on linux and caused problems * Renamed TrayIconUtil to ExitUtil * fixes #177
This commit is contained in:
@@ -29,5 +29,5 @@ interface CryptomatorComponent {
|
||||
|
||||
Localization localization();
|
||||
|
||||
TrayIconUtil trayIconUtil();
|
||||
ExitUtil exitUtil();
|
||||
}
|
||||
@@ -38,22 +38,41 @@ import javafx.application.Platform;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
@Singleton
|
||||
class TrayIconUtil {
|
||||
class ExitUtil {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(TrayIconUtil.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ExitUtil.class);
|
||||
|
||||
private final Stage mainWindow;
|
||||
private final Localization localization;
|
||||
private final Settings settings;
|
||||
|
||||
@Inject
|
||||
public TrayIconUtil(@Named("mainWindow") Stage mainWindow, Localization localization, Settings settings) {
|
||||
public ExitUtil(@Named("mainWindow") Stage mainWindow, Localization localization, Settings settings) {
|
||||
this.mainWindow = mainWindow;
|
||||
this.localization = localization;
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
public void initTrayIcon(Runnable exitCommand) {
|
||||
public void initExitHandler(Runnable exitCommand) {
|
||||
if (SystemUtils.IS_OS_LINUX) {
|
||||
initMinimizeExitHandler(exitCommand);
|
||||
} else {
|
||||
initTrayIconExitHandler(exitCommand);
|
||||
}
|
||||
}
|
||||
|
||||
private void initMinimizeExitHandler(Runnable exitCommand) {
|
||||
mainWindow.setOnCloseRequest(e -> {
|
||||
if (Platform.isImplicitExit()) {
|
||||
exitCommand.run();
|
||||
} else {
|
||||
mainWindow.setIconified(true);
|
||||
e.consume();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initTrayIconExitHandler(Runnable exitCommand) {
|
||||
final TrayIcon trayIcon = createTrayIcon(exitCommand);
|
||||
try {
|
||||
SystemTray.getSystemTray().add(trayIcon);
|
||||
@@ -67,7 +67,7 @@ public class MainApplication extends Application {
|
||||
// show window and start observing its focus:
|
||||
primaryStage.show();
|
||||
ActiveWindowStyleSupport.startObservingFocus(primaryStage);
|
||||
comp.trayIconUtil().initTrayIcon(this::quit);
|
||||
comp.exitUtil().initExitHandler(this::quit);
|
||||
|
||||
// open files, if requested during startup:
|
||||
for (String arg : getParameters().getUnnamed()) {
|
||||
|
||||
Reference in New Issue
Block a user