show supported mount features in preferences/volume

This commit is contained in:
Armin Schrenk
2023-01-13 18:11:36 +01:00
parent 08d741ecf5
commit 5e32cbcdd0
3 changed files with 73 additions and 3 deletions

View File

@@ -25,6 +25,10 @@ public class VolumePreferencesController implements FxController {
private final Settings settings;
private final ObservableValue<ActualMountService> selectedMountService;
private final BooleanExpression loopbackPortSupported;
private final ObservableValue<Boolean> mountToDirSupported;
private final ObservableValue<Boolean> mountToDriveLetterSupported;
private final ObservableValue<Boolean> mountFlagsSupported;
private final ObservableValue<Boolean> readonlySupported;
private final List<MountService> mountProviders;
public ChoiceBox<MountService> volumeTypeChoiceBox;
public TextField loopbackPortField;
@@ -36,6 +40,10 @@ public class VolumePreferencesController implements FxController {
this.mountProviders = mountProviders;
this.selectedMountService = actualMountService;
this.loopbackPortSupported = BooleanExpression.booleanExpression(selectedMountService.map(as -> as.service().hasCapability(MountCapability.LOOPBACK_PORT)));
this.mountToDirSupported = selectedMountService.map(as -> as.service().hasCapability(MountCapability.MOUNT_WITHIN_EXISTING_PARENT) || as.service().hasCapability(MountCapability.MOUNT_TO_EXISTING_DIR));
this.mountToDriveLetterSupported = selectedMountService.map(as -> as.service().hasCapability(MountCapability.MOUNT_AS_DRIVE_LETTER));
this.mountFlagsSupported = selectedMountService.map(as -> as.service().hasCapability(MountCapability.MOUNT_FLAGS));
this.readonlySupported = selectedMountService.map(as -> as.service().hasCapability(MountCapability.READ_ONLY));
}
public void initialize() {
@@ -47,7 +55,6 @@ public class VolumePreferencesController implements FxController {
loopbackPortField.setText(String.valueOf(settings.port().get()));
loopbackPortApplyButton.visibleProperty().bind(settings.port().asString().isNotEqualTo(loopbackPortField.textProperty()));
loopbackPortApplyButton.disableProperty().bind(Bindings.createBooleanBinding(this::validateLoopbackPort, loopbackPortField.textProperty()).not());
}
private boolean validateLoopbackPort() {
@@ -76,6 +83,38 @@ public class VolumePreferencesController implements FxController {
return loopbackPortSupported.get();
}
public ObservableValue<Boolean> readonlySupportedProperty() {
return readonlySupported;
}
public boolean isReadonlySupported() {
return readonlySupported.getValue();
}
public ObservableValue<Boolean> mountToDirSupportedProperty() {
return mountToDirSupported;
}
public boolean isMountToDirSupported() {
return mountToDirSupported.getValue();
}
public ObservableValue<Boolean> mountToDriveLetterSupportedProperty() {
return mountToDriveLetterSupported;
}
public boolean isMountToDriveLetterSupported() {
return mountToDriveLetterSupported.getValue();
}
public ObservableValue<Boolean> mountFlagsSupportedProperty() {
return mountFlagsSupported;
}
public boolean isMountFlagsSupported() {
return mountFlagsSupported.getValue();
}
/* Helpers */
private static class MountServiceConverter extends StringConverter<MountService> {
@@ -90,6 +129,4 @@ public class VolumePreferencesController implements FxController {
throw new UnsupportedOperationException();
}
}
}

View File

@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import org.cryptomator.ui.controls.FontAwesome5IconView?>
<?import org.cryptomator.ui.controls.NumericTextField?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
@@ -25,5 +26,32 @@
<NumericTextField fx:id="loopbackPortField"/>
<Button text="%generic.button.apply" fx:id="loopbackPortApplyButton" onAction="#doChangeLoopbackPort"/>
</HBox>
<Label text="%preferences.volume.supportedFeatures"/>
<VBox spacing="12">
<padding>
<Insets left="24"/>
</padding>
<Label text="%preferences.volume.feature.mountToDir" visible="${controller.mountToDirSupported}" managed="${controller.mountToDirSupported}" contentDisplay="LEFT">
<graphic>
<FontAwesome5IconView glyph="CHECK"/>
</graphic>
</Label>
<Label text="%preferences.volume.feature.mountToDriveLetter" visible="${controller.mountToDriveLetterSupported}" managed="${controller.mountToDriveLetterSupported}">
<graphic>
<FontAwesome5IconView glyph="CHECK"/>
</graphic>
</Label>
<Label text="%preferences.volume.feature.mountFlags" visible="${controller.mountFlagsSupported}" managed="${controller.mountFlagsSupported}">
<graphic>
<FontAwesome5IconView glyph="CHECK"/>
</graphic>
</Label>
<Label text="%preferences.volume.feature.readOnly" visible="${controller.readonlySupported}" managed="${controller.readonlySupported}">
<graphic>
<FontAwesome5IconView glyph="CHECK"/>
</graphic>
</Label>
</VBox>
</children>
</VBox>

View File

@@ -278,6 +278,11 @@ preferences.interface.showTrayIcon=Show tray icon (requires restart)
preferences.volume=Virtual Drive
preferences.volume.type=Volume Type
preferences.volume.tcp.port=TCP Port
preferences.volume.supportedFeatures=This volume type supports the following features:
preferences.volume.feature.mountToDir=Custom directory as mount point
preferences.volume.feature.mountToDriveLetter=Drive letter as mount point
preferences.volume.feature.mountFlags=Custom mount options
preferences.volume.feature.readOnly=Mount read-only
## Updates
preferences.updates=Updates
preferences.updates.currentVersion=Current Version: %s