UI improvement: adding checkbox before textbox for entering own mountpath is given

This commit is contained in:
infeo
2018-03-30 12:43:50 +02:00
parent 2341440ed9
commit 13c5e2470b
6 changed files with 42 additions and 15 deletions

View File

@@ -28,6 +28,7 @@ public class VaultSettings {
public static final boolean DEFAULT_UNLOCK_AFTER_STARTUP = false;
public static final boolean DEFAULT_MOUNT_AFTER_UNLOCK = true;
public static final boolean DEFAULT_REAVEAL_AFTER_MOUNT = true;
public static final boolean DEFAULT_USES_INDIVIDUAL_MOUNTPATH = false;
private final String id;
private final ObjectProperty<Path> path = new SimpleObjectProperty<>();
@@ -36,6 +37,7 @@ public class VaultSettings {
private final BooleanProperty unlockAfterStartup = new SimpleBooleanProperty(DEFAULT_UNLOCK_AFTER_STARTUP);
private final BooleanProperty mountAfterUnlock = new SimpleBooleanProperty(DEFAULT_MOUNT_AFTER_UNLOCK);
private final BooleanProperty revealAfterMount = new SimpleBooleanProperty(DEFAULT_REAVEAL_AFTER_MOUNT);
private final BooleanProperty usesIndividualMountPath = new SimpleBooleanProperty(DEFAULT_USES_INDIVIDUAL_MOUNTPATH);
private final StringProperty individualMountPath = new SimpleStringProperty();
public VaultSettings(String id) {
@@ -45,7 +47,7 @@ public class VaultSettings {
}
Observable[] observables() {
return new Observable[]{path, mountName, winDriveLetter, unlockAfterStartup, mountAfterUnlock, revealAfterMount, individualMountPath};
return new Observable[]{path, mountName, winDriveLetter, unlockAfterStartup, mountAfterUnlock, revealAfterMount, usesIndividualMountPath, individualMountPath};
}
private void deriveMountNameFromPath(Path path) {
@@ -124,6 +126,10 @@ public class VaultSettings {
return revealAfterMount;
}
public BooleanProperty usesIndividualMountPath() {
return usesIndividualMountPath;
}
public StringProperty individualMountPath() {
return individualMountPath;
}

View File

@@ -27,9 +27,9 @@ class VaultSettingsJsonAdapter {
out.name("unlockAfterStartup").value(value.unlockAfterStartup().get());
out.name("mountAfterUnlock").value(value.mountAfterUnlock().get());
out.name("revealAfterMount").value(value.revealAfterMount().get());
if(value.individualMountPath().isNotEmpty().get()){
out.name("individualMountPath").value(value.individualMountPath().get());
}
out.name("usesIndividualMountPath").value(value.usesIndividualMountPath().get());
//TODO: should this always be written? ( because it could contain metadata, which the user does not want to save!)
out.name("individualMountPath").value(value.individualMountPath().get());
out.endObject();
}
@@ -42,6 +42,7 @@ class VaultSettingsJsonAdapter {
boolean unlockAfterStartup = VaultSettings.DEFAULT_UNLOCK_AFTER_STARTUP;
boolean mountAfterUnlock = VaultSettings.DEFAULT_MOUNT_AFTER_UNLOCK;
boolean revealAfterMount = VaultSettings.DEFAULT_REAVEAL_AFTER_MOUNT;
boolean usesIndividualMountPath = VaultSettings.DEFAULT_USES_INDIVIDUAL_MOUNTPATH;
in.beginObject();
while (in.hasNext()) {
@@ -68,6 +69,9 @@ class VaultSettingsJsonAdapter {
case "revealAfterMount":
revealAfterMount = in.nextBoolean();
break;
case "usesIndividualMountPath":
usesIndividualMountPath = in.nextBoolean();
break;
case "individualMountPath":
individualMountPath = in.nextString();
break;
@@ -85,6 +89,7 @@ class VaultSettingsJsonAdapter {
vaultSettings.unlockAfterStartup().set(unlockAfterStartup);
vaultSettings.mountAfterUnlock().set(mountAfterUnlock);
vaultSettings.revealAfterMount().set(revealAfterMount);
vaultSettings.usesIndividualMountPath().set(usesIndividualMountPath);
vaultSettings.individualMountPath().set(individualMountPath);
return vaultSettings;
}

View File

@@ -122,6 +122,9 @@ public class UnlockController implements ViewController {
@FXML
private ChoiceBox<Character> winDriveLetter;
@FXML
private CheckBox useOwnMountPath;
@FXML
private HBox mountPathBox;
@@ -163,13 +166,18 @@ public class UnlockController implements ViewController {
savePassword.setDisable(!keychainAccess.isPresent());
unlockAfterStartup.disableProperty().bind(savePassword.disabledProperty().or(savePassword.selectedProperty().not()));
mountPathBox.managedProperty().bind(mountPathLabel.visibleProperty());
mountPath.managedProperty().bind(mountPathLabel.visibleProperty());
changeMountPathButton.managedProperty().bind(mountPathLabel.visibleProperty());
mountPathLabel.setVisible(false);
mountPathBox.visibleProperty().bind(mountPathLabel.visibleProperty());
mountPathBox.managedProperty().bind(mountPathLabel.managedProperty());
mountPath.visibleProperty().bind(mountPathLabel.visibleProperty());
mountPath.managedProperty().bind(mountPathLabel.managedProperty());
changeMountPathButton.visibleProperty().bind(mountPathLabel.visibleProperty());
changeMountPathButton.managedProperty().bind(mountPathLabel.managedProperty());
if (SystemUtils.IS_OS_WINDOWS) {
winDriveLetter.setConverter(new WinDriveLetterLabelConverter());
mountPathLabel.setVisible(false);
useOwnMountPath.setVisible(false);
useOwnMountPath.setManaged(false);
mountPathLabel.setManaged(false);
//dirty cheat
mountPathBox.setMouseTransparent(true);
@@ -178,8 +186,9 @@ public class UnlockController implements ViewController {
winDriveLetterLabel.setManaged(false);
winDriveLetter.setVisible(false);
winDriveLetter.setManaged(false);
if(VolumeImpl.WEBDAV.equals(settings.volumeImpl().get())){
mountPathLabel.setVisible(false);
if (VolumeImpl.WEBDAV.equals(settings.volumeImpl().get())) {
useOwnMountPath.setVisible(false);
useOwnMountPath.setManaged(false);
mountPathLabel.setManaged(false);
}
}
@@ -243,15 +252,18 @@ public class UnlockController implements ViewController {
unlockAfterStartup.setSelected(savePassword.isSelected() && vaultSettings.unlockAfterStartup().get());
mountAfterUnlock.setSelected(vaultSettings.mountAfterUnlock().get());
revealAfterMount.setSelected(vaultSettings.revealAfterMount().get());
useOwnMountPath.setSelected(vaultSettings.usesIndividualMountPath().get());
vaultSubs = vaultSubs.and(EasyBind.subscribe(unlockAfterStartup.selectedProperty(), vaultSettings.unlockAfterStartup()::set));
vaultSubs = vaultSubs.and(EasyBind.subscribe(mountAfterUnlock.selectedProperty(), vaultSettings.mountAfterUnlock()::set));
vaultSubs = vaultSubs.and(EasyBind.subscribe(revealAfterMount.selectedProperty(), vaultSettings.revealAfterMount()::set));
vaultSubs = vaultSubs.and(EasyBind.subscribe(useOwnMountPath.selectedProperty(), vaultSettings.usesIndividualMountPath()::set));
changeMountPathButton.visibleProperty().bind(
vaultSettings.individualMountPath().isNotEqualTo(mountPath.textProperty())
vaultSettings.individualMountPath().isNotEqualTo(mountPath.textProperty())
);
mountPath.textProperty().setValue(vaultSettings.individualMountPath().getValueSafe());
mountPathLabel.visibleProperty().bind(useOwnMountPath.selectedProperty());
}

View File

@@ -57,7 +57,7 @@ public class FuseVolume implements Volume {
// auto assign drive letter
mountPath = windowsDriveLetters.getAvailableDriveLetters().iterator().next() + ":\\";
}
} else if (vaultSettings.individualMountPath().get() != null) {
} else if (vaultSettings.usesIndividualMountPath().get()) {
//specific path given
mountPath = vaultSettings.individualMountPath().get();
} else {

View File

@@ -91,12 +91,15 @@
<ChoiceBox GridPane.rowIndex="6" GridPane.columnIndex="1" fx:id="winDriveLetter" GridPane.hgrow="ALWAYS" maxWidth="Infinity" cacheShape="true" cache="true" />
<!-- Row 3.6 Alt2 -->
<Label GridPane.rowIndex="6" GridPane.columnIndex="0" fx:id="mountPathLabel" text="%unlock.label.mountPath" cacheShape="true" cache="true" />
<CheckBox GridPane.rowIndex="6" GridPane.columnIndex="0" fx:id="useOwnMountPath" text="%unlock.label.useOwnMountPath" cacheShape="true" cache="true" />
<HBox GridPane.rowIndex="6" GridPane.columnIndex="1" fx:id="mountPathBox" spacing="6.0">
<TextField GridPane.rowIndex="6" GridPane.columnIndex="1" fx:id="mountPath" cacheShape="true" cache="true" />
<Label GridPane.rowIndex="7" GridPane.columnIndex="0" fx:id="mountPathLabel" text="%unlock.label.mountPath" cacheShape="true" cache="true" />
<HBox GridPane.rowIndex="7" GridPane.columnIndex="1" fx:id="mountPathBox" spacing="6.0">
<TextField GridPane.rowIndex="7" GridPane.columnIndex="1" fx:id="mountPath" cacheShape="true" cache="true" />
<Button text="%unlock.label.mountPathButton" fx:id="changeMountPathButton" onAction="#didClickchangeMountPathButton"/>
</HBox>
</GridPane>
<!-- Row 4 -->

View File

@@ -67,6 +67,7 @@ unlock.label.mountName=Drive Name
unlock.label.unlockAfterStartup=Auto-Unlock on Start (Experimental)
unlock.label.revealAfterMount=Reveal Drive
unlock.label.winDriveLetter=Drive Letter
unlock.label.useOwnMountPath=Use own Mount point
unlock.label.mountPath=Mount Path
unlock.label.mountPathButton=Apply
unlock.label.downloadsPageLink=All Cryptomator versions