소스 검색

Add option to show minimize button despite tray icon being present
fixes #1179

Sebastian Stenzel 4 년 전
부모
커밋
1eeee61572

+ 8 - 1
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<VaultSettings> 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> keychainBackend = new SimpleObjectProperty<>(DEFAULT_KEYCHAIN_BACKEND);
 	private final ObjectProperty<NodeOrientation> 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<Settings> 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;
 	}

+ 2 - 0
main/commons/src/main/java/org/cryptomator/common/settings/SettingsJsonAdapter.java

@@ -50,6 +50,7 @@ public class SettingsJsonAdapter extends TypeAdapter<Settings> {
 		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<Settings> {
 				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);

+ 11 - 0
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();
+	}
 }

+ 3 - 0
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<UiTheme> themeChoiceBox;
 	public ChoiceBox<KeychainBackend> 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());

+ 1 - 1
main/ui/src/main/resources/fxml/main_window_title.fxml

@@ -54,7 +54,7 @@
 				<Tooltip text="%main.preferencesBtn.tooltip"/>
 			</tooltip>
 		</Button>
-		<Button contentDisplay="GRAPHIC_ONLY" mnemonicParsing="false" onAction="#minimize" focusTraversable="false" visible="${!controller.trayIconPresent}" managed="${!controller.trayIconPresent}">
+		<Button contentDisplay="GRAPHIC_ONLY" mnemonicParsing="false" onAction="#minimize" focusTraversable="false" visible="${controller.showMinimizeButton}" managed="${controller.showMinimizeButton}">
 			<graphic>
 				<FontAwesome5IconView glyph="WINDOW_MINIMIZE" glyphSize="12"/>
 			</graphic>

+ 2 - 0
main/ui/src/main/resources/fxml/preferences_general.fxml

@@ -32,6 +32,8 @@
 			<RadioButton fx:id="nodeOrientationRtl" text="%preferences.general.interfaceOrientation.rtl" alignment="CENTER_RIGHT" toggleGroup="${nodeOrientation}"/>
 		</HBox>
 
+		<CheckBox fx:id="showMinimizeButtonCheckbox" text="%preferences.general.showMinimizeButton" visible="${controller.trayMenuInitialized}" managed="${controller.trayMenuInitialized}"/>
+
 		<CheckBox fx:id="showTrayIconCheckbox" text="%preferences.general.showTrayIcon" visible="${controller.trayMenuSupported}" managed="${controller.trayMenuSupported}"/>
 
 		<CheckBox fx:id="startHiddenCheckbox" text="%preferences.general.startHidden" />

+ 1 - 0
main/ui/src/main/resources/i18n/strings.properties

@@ -150,6 +150,7 @@ preferences.general.theme.automatic=Automatic
 preferences.general.theme.light=Light
 preferences.general.theme.dark=Dark
 preferences.general.unlockThemes=Unlock dark mode
+preferences.general.showMinimizeButton=Show minimize button
 preferences.general.showTrayIcon=Show tray icon (requires restart)
 preferences.general.startHidden=Hide window when starting Cryptomator
 preferences.general.debugLogging=Enable debug logging