mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-09-01 21:57:19 +00:00
Co-authored-by: Sebastian Stenzel <sebastian.stenzel@gmail.com>
This commit is contained in:
co-authored by
Sebastian Stenzel
parent
f5822fc568
commit
1ef3e948be
@@ -27,6 +27,7 @@ import javafx.stage.DirectoryChooser;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.StringConverter;
|
||||
import java.io.File;
|
||||
import java.nio.file.InvalidPathException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.Set;
|
||||
@@ -94,7 +95,9 @@ public class MountOptionsController implements FxController {
|
||||
driveLetterSelection.setConverter(new WinDriveLetterLabelConverter(windowsDriveLetters, resourceBundle));
|
||||
driveLetterSelection.setValue(vault.getVaultSettings().winDriveLetter().get());
|
||||
|
||||
if (vault.getVaultSettings().useCustomMountPath().get() && !getRestrictToStableFuseOnWindows() /* to prevent invalid states */) {
|
||||
if (vault.getVaultSettings().useCustomMountPath().get()
|
||||
&& vault.getVaultSettings().getCustomMountPath().isPresent()
|
||||
&& !getRestrictToStableFuseOnWindows() /* to prevent invalid states */) {
|
||||
mountPoint.selectToggle(mountPointCustomDir);
|
||||
} else if (!Strings.isNullOrEmpty(vault.getVaultSettings().winDriveLetter().get())) {
|
||||
mountPoint.selectToggle(mountPointWinDriveLetter);
|
||||
@@ -125,25 +128,30 @@ public class MountOptionsController implements FxController {
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void chooseCustomMountPoint() {
|
||||
public void chooseCustomMountPoint() {
|
||||
chooseCustomMountPointOrReset(mountPointCustomDir);
|
||||
}
|
||||
|
||||
private void chooseCustomMountPointOrReset(Toggle previousMountToggle) {
|
||||
DirectoryChooser directoryChooser = new DirectoryChooser();
|
||||
directoryChooser.setTitle(resourceBundle.getString("vaultOptions.mount.mountPoint.directoryPickerTitle"));
|
||||
try {
|
||||
directoryChooser.setInitialDirectory(Path.of(System.getProperty("user.home")).toFile());
|
||||
} catch (Exception e) {
|
||||
//NO-OP
|
||||
var initialDir = vault.getVaultSettings().getCustomMountPath().orElse(System.getProperty("user.home"));
|
||||
directoryChooser.setInitialDirectory(Path.of(initialDir).toFile());
|
||||
} catch (InvalidPathException e) {
|
||||
// no-op
|
||||
}
|
||||
File file = directoryChooser.showDialog(window);
|
||||
if (file != null) {
|
||||
vault.getVaultSettings().customMountPath().set(file.getAbsolutePath());
|
||||
} else {
|
||||
vault.getVaultSettings().customMountPath().set(null);
|
||||
mountPoint.selectToggle(previousMountToggle);
|
||||
}
|
||||
}
|
||||
|
||||
private void toggleMountPoint(@SuppressWarnings("unused") ObservableValue<? extends Toggle> observable, @SuppressWarnings("unused") Toggle oldValue, Toggle newValue) {
|
||||
private void toggleMountPoint(@SuppressWarnings("unused") ObservableValue<? extends Toggle> observable, Toggle oldValue, Toggle newValue) {
|
||||
if (mountPointCustomDir.equals(newValue) && Strings.isNullOrEmpty(vault.getVaultSettings().customMountPath().get())) {
|
||||
chooseCustomMountPoint();
|
||||
chooseCustomMountPointOrReset(oldValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user