diff --git a/main/commons/src/main/java/org/cryptomator/common/settings/Settings.java b/main/commons/src/main/java/org/cryptomator/common/settings/Settings.java index cbe0b4b0d..a419d206a 100644 --- a/main/commons/src/main/java/org/cryptomator/common/settings/Settings.java +++ b/main/commons/src/main/java/org/cryptomator/common/settings/Settings.java @@ -40,7 +40,8 @@ public class Settings { public static final UiTheme DEFAULT_THEME = UiTheme.LIGHT; public static final KeychainBackend DEFAULT_KEYCHAIN_BACKEND = SystemUtils.IS_OS_WINDOWS ? KeychainBackend.WIN_SYSTEM_KEYCHAIN : SystemUtils.IS_OS_MAC ? KeychainBackend.MAC_SYSTEM_KEYCHAIN : KeychainBackend.GNOME; public static final NodeOrientation DEFAULT_USER_INTERFACE_ORIENTATION = NodeOrientation.LEFT_TO_RIGHT; - private static final String DEFAULT_LICENSE_KEY = ""; + public static final String DEFAULT_LICENSE_KEY = ""; + public static final boolean DEFAULT_SHOW_MINIMIZE_BUTTON = false; private final ObservableList directories = FXCollections.observableArrayList(VaultSettings::observables); private final BooleanProperty askedForUpdateCheck = new SimpleBooleanProperty(DEFAULT_ASKED_FOR_UPDATE_CHECK); @@ -55,6 +56,7 @@ public class Settings { private final ObjectProperty keychainBackend = new SimpleObjectProperty<>(DEFAULT_KEYCHAIN_BACKEND); private final ObjectProperty userInterfaceOrientation = new SimpleObjectProperty<>(DEFAULT_USER_INTERFACE_ORIENTATION); private final StringProperty licenseKey = new SimpleStringProperty(DEFAULT_LICENSE_KEY); + private final BooleanProperty showMinimizeButton = new SimpleBooleanProperty(DEFAULT_SHOW_MINIMIZE_BUTTON); private final BooleanProperty showTrayIcon; private Consumer saveCmd; @@ -78,6 +80,7 @@ public class Settings { keychainBackend.addListener(this::somethingChanged); userInterfaceOrientation.addListener(this::somethingChanged); licenseKey.addListener(this::somethingChanged); + showMinimizeButton.addListener(this::somethingChanged); showTrayIcon.addListener(this::somethingChanged); } @@ -147,6 +150,10 @@ public class Settings { return licenseKey; } + public BooleanProperty showMinimizeButton() { + return showMinimizeButton; + } + public BooleanProperty showTrayIcon() { return showTrayIcon; } diff --git a/main/commons/src/main/java/org/cryptomator/common/settings/SettingsJsonAdapter.java b/main/commons/src/main/java/org/cryptomator/common/settings/SettingsJsonAdapter.java index 87a2bd1aa..d22e0867f 100644 --- a/main/commons/src/main/java/org/cryptomator/common/settings/SettingsJsonAdapter.java +++ b/main/commons/src/main/java/org/cryptomator/common/settings/SettingsJsonAdapter.java @@ -50,6 +50,7 @@ public class SettingsJsonAdapter extends TypeAdapter { out.name("uiOrientation").value(value.userInterfaceOrientation().get().name()); out.name("keychainBackend").value(value.keychainBackend().get().name()); out.name("licenseKey").value(value.licenseKey().get()); + out.name("showMinimizeButton").value(value.showMinimizeButton().get()); out.name("showTrayIcon").value(value.showTrayIcon().get()); out.endObject(); } @@ -83,6 +84,7 @@ public class SettingsJsonAdapter extends TypeAdapter { case "uiOrientation" -> settings.userInterfaceOrientation().set(parseUiOrientation(in.nextString())); case "keychainBackend" -> settings.keychainBackend().set(parseKeychainBackend(in.nextString())); case "licenseKey" -> settings.licenseKey().set(in.nextString()); + case "showMinimizeButton" -> settings.showMinimizeButton().set(in.nextBoolean()); case "showTrayIcon" -> settings.showTrayIcon().set(in.nextBoolean()); default -> { LOG.warn("Unsupported vault setting found in JSON: " + name); diff --git a/main/ui/src/main/java/org/cryptomator/ui/mainwindow/MainWindowTitleController.java b/main/ui/src/main/java/org/cryptomator/ui/mainwindow/MainWindowTitleController.java index 15553cb52..a8659de4a 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/mainwindow/MainWindowTitleController.java +++ b/main/ui/src/main/java/org/cryptomator/ui/mainwindow/MainWindowTitleController.java @@ -34,6 +34,7 @@ public class MainWindowTitleController implements FxController { private final BooleanBinding updateAvailable; private final LicenseHolder licenseHolder; private final Settings settings; + private final BooleanBinding showMinimizeButton; private double xOffset; private double yOffset; @@ -49,6 +50,7 @@ public class MainWindowTitleController implements FxController { this.updateAvailable = updateChecker.latestVersionProperty().isNotNull(); this.licenseHolder = licenseHolder; this.settings = settings; + this.showMinimizeButton = Bindings.createBooleanBinding(this::isShowMinimizeButton, settings.showMinimizeButton(), settings.showTrayIcon()); } @FXML @@ -123,4 +125,13 @@ public class MainWindowTitleController implements FxController { public boolean isDebugModeEnabled() { return debugModeEnabledProperty().get(); } + + public BooleanBinding showMinimizeButtonProperty() { + return showMinimizeButton; + } + + public boolean isShowMinimizeButton() { + // always show the minimize button if no tray icon is present OR it is explicitily enabled + return !trayMenuInitialized || settings.showMinimizeButton().get(); + } } diff --git a/main/ui/src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java b/main/ui/src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java index 2588f940c..ea1fbfe3a 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java +++ b/main/ui/src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java @@ -52,6 +52,7 @@ public class GeneralPreferencesController implements FxController { private final ErrorComponent.Builder errorComponent; public ChoiceBox themeChoiceBox; public ChoiceBox keychainBackendChoiceBox; + public CheckBox showMinimizeButtonCheckbox; public CheckBox showTrayIconCheckbox; public CheckBox startHiddenCheckbox; public CheckBox debugModeCheckbox; @@ -86,6 +87,8 @@ public class GeneralPreferencesController implements FxController { themeChoiceBox.valueProperty().bindBidirectional(settings.theme()); themeChoiceBox.setConverter(new UiThemeConverter(resourceBundle)); + showMinimizeButtonCheckbox.selectedProperty().bindBidirectional(settings.showMinimizeButton()); + showTrayIconCheckbox.selectedProperty().bindBidirectional(settings.showTrayIcon()); startHiddenCheckbox.selectedProperty().bindBidirectional(settings.startHidden()); diff --git a/main/ui/src/main/resources/fxml/main_window_title.fxml b/main/ui/src/main/resources/fxml/main_window_title.fxml index 4b83cc650..108c0970e 100644 --- a/main/ui/src/main/resources/fxml/main_window_title.fxml +++ b/main/ui/src/main/resources/fxml/main_window_title.fxml @@ -54,7 +54,7 @@ -