mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-09-05 07:37:40 +00:00
Implemented some mount options (references #931)
This commit is contained in:
@@ -211,7 +211,7 @@ public class UnlockController implements ViewController {
|
||||
downloadsPageLink.setManaged(false);
|
||||
mountName.setText(vault.getMountName());
|
||||
useCustomMountFlags.setSelected(vault.isHavingCustomMountFlags());
|
||||
mountFlags.setText(vault.getMountFlags());
|
||||
mountFlags.setText(vault.getEffectiveMountFlags());
|
||||
savePassword.setSelected(false);
|
||||
// auto-fill pw from keychain:
|
||||
if (keychainAccess.isPresent()) {
|
||||
@@ -321,28 +321,28 @@ public class UnlockController implements ViewController {
|
||||
vault.setMountName(newValue);
|
||||
}
|
||||
if (!useCustomMountFlags.isSelected()) {
|
||||
mountFlags.setText(vault.getMountFlags()); // update default flags
|
||||
mountFlags.setText(vault.getEffectiveMountFlags()); // update default flags
|
||||
}
|
||||
}
|
||||
|
||||
private void useReadOnlyDidChange(@SuppressWarnings("unused") ObservableValue<? extends Boolean> property, @SuppressWarnings("unused") Boolean oldValue, Boolean newValue) {
|
||||
vault.getVaultSettings().usesReadOnlyMode().setValue(newValue);
|
||||
if (!useCustomMountFlags.isSelected()) {
|
||||
mountFlags.setText(vault.getMountFlags()); // update default flags
|
||||
mountFlags.setText(vault.getEffectiveMountFlags()); // update default flags
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void useCustomMountFlagsDidChange(@SuppressWarnings("unused") ObservableValue<? extends Boolean> property, @SuppressWarnings("unused") Boolean oldValue, Boolean newValue) {
|
||||
if (!newValue) {
|
||||
vault.setMountFlags(VaultSettings.DEFAULT_MOUNT_FLAGS);
|
||||
mountFlags.setText(vault.getMountFlags());
|
||||
vault.setCustomMountFlags(VaultSettings.DEFAULT_MOUNT_FLAGS);
|
||||
mountFlags.setText(vault.getEffectiveMountFlags());
|
||||
}
|
||||
}
|
||||
|
||||
private void mountFlagsDidChange(@SuppressWarnings("unused") ObservableValue<? extends String> property, @SuppressWarnings("unused") String oldValue, String newValue) {
|
||||
if (useCustomMountFlags.isSelected()) {
|
||||
vault.setMountFlags(newValue);
|
||||
vault.setCustomMountFlags(newValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.cryptomator.ui.controls;
|
||||
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.control.TextFormatter;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class AlphanumericTextField extends TextField {
|
||||
|
||||
private final static Pattern DIGIT_PATTERN = Pattern.compile("\\w*");
|
||||
|
||||
public AlphanumericTextField() {
|
||||
this.setTextFormatter(new TextFormatter<>(this::filterNumericTextChange));
|
||||
}
|
||||
|
||||
private TextFormatter.Change filterNumericTextChange(TextFormatter.Change change) {
|
||||
return DIGIT_PATTERN.matcher(change.getText()).matches() ? change : null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,13 +1,51 @@
|
||||
package org.cryptomator.ui.vaultoptions;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.CheckBox;
|
||||
import javafx.scene.control.TextField;
|
||||
import org.cryptomator.common.vaults.Vault;
|
||||
import org.cryptomator.ui.common.FxController;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@VaultOptionsScoped
|
||||
public class MountOptionsController implements FxController {
|
||||
|
||||
@Inject
|
||||
MountOptionsController(){}
|
||||
|
||||
private final Vault vault;
|
||||
public TextField driveName;
|
||||
public CheckBox readOnlyCheckbox;
|
||||
public CheckBox customMountFlagsCheckbox;
|
||||
public TextField mountFlags;
|
||||
|
||||
@Inject
|
||||
MountOptionsController(@VaultOptionsWindow Vault vault) {
|
||||
this.vault = vault;
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void initialize() {
|
||||
driveName.textProperty().bindBidirectional(vault.getVaultSettings().mountName());
|
||||
readOnlyCheckbox.selectedProperty().bindBidirectional(vault.getVaultSettings().usesReadOnlyMode());
|
||||
mountFlags.disableProperty().bind(customMountFlagsCheckbox.selectedProperty().not());
|
||||
|
||||
customMountFlagsCheckbox.setSelected(vault.isHavingCustomMountFlags());
|
||||
if (vault.isHavingCustomMountFlags()) {
|
||||
mountFlags.textProperty().bindBidirectional(vault.getVaultSettings().mountFlags());
|
||||
} else {
|
||||
mountFlags.textProperty().bind(vault.defaultMountFlagsProperty());
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void toggleUseCustomMountFlags() {
|
||||
if (customMountFlagsCheckbox.isSelected()) {
|
||||
mountFlags.textProperty().unbind();
|
||||
vault.setCustomMountFlags(vault.defaultMountFlagsProperty().get());
|
||||
mountFlags.textProperty().bindBidirectional(vault.getVaultSettings().mountFlags());
|
||||
} else {
|
||||
mountFlags.textProperty().unbindBidirectional(vault.getVaultSettings().mountFlags());
|
||||
vault.setCustomMountFlags(null);
|
||||
mountFlags.textProperty().bind(vault.defaultMountFlagsProperty());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,11 @@
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.TextField?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import javafx.scene.control.CheckBox?>
|
||||
<?import org.cryptomator.ui.controls.AlphanumericTextField?>
|
||||
<VBox xmlns="http://javafx.com/javafx"
|
||||
xmlns:fx="http://javafx.com/fxml"
|
||||
fx:controller="org.cryptomator.ui.vaultoptions.MountOptionsController"
|
||||
@@ -11,6 +15,16 @@
|
||||
<Insets bottom="12" left="12" right="12" top="12"/>
|
||||
</padding>
|
||||
<children>
|
||||
<Label text="todo mount options"/>
|
||||
<HBox spacing="12" alignment="BASELINE_LEFT">
|
||||
<Label text="%vaultOptions.mount.driveName"/>
|
||||
<AlphanumericTextField fx:id="driveName"/>
|
||||
</HBox>
|
||||
|
||||
<CheckBox fx:id="readOnlyCheckbox" text="%vaultOptions.mount.readonly"/>
|
||||
|
||||
<HBox spacing="12" alignment="BASELINE_LEFT">
|
||||
<CheckBox fx:id="customMountFlagsCheckbox" text="%vaultOptions.mount.customMountFlags" onAction="#toggleUseCustomMountFlags"/>
|
||||
<TextField fx:id="mountFlags" HBox.hgrow="ALWAYS" maxWidth="Infinity"/>
|
||||
</HBox>
|
||||
</children>
|
||||
</VBox>
|
||||
|
||||
@@ -16,4 +16,7 @@ preferences.volumeType=Volume type
|
||||
unlock.deleteSavedPasswordDialog.title=Delete Saved Password
|
||||
unlock.deleteSavedPasswordDialog.header=Do you really want to delete the saved password of this vault?
|
||||
unlock.deleteSavedPasswordDialog.content=The saved password of this vault will be immediately deleted from your system keychain. If you'd like to save your password again, you'd have to unlock your vault with the "Save Password" option enabled.
|
||||
vaultlist.emptyList.onboardingInstruction=Click here to add a vault
|
||||
vaultlist.emptyList.onboardingInstruction=Click here to add a vault
|
||||
vaultOptions.mount.readonly=Read-Only
|
||||
vaultOptions.mount.driveName=Drive Name
|
||||
vaultOptions.mount.customMountFlags=Custom Mount Flags
|
||||
@@ -12,4 +12,7 @@ preferences.debugLogging=Enable debug logging
|
||||
preferences.startHidden=Hide window when starting Cryptomator
|
||||
preferences.theme=Look & Feel
|
||||
preferences.volumeType=Volume type
|
||||
vaultlist.emptyList.onboardingInstruction=Click here to add a vault
|
||||
vaultlist.emptyList.onboardingInstruction=Click here to add a vault
|
||||
vaultOptions.mount.readonly=Read-Only
|
||||
vaultOptions.mount.driveName=Drive Name
|
||||
vaultOptions.mount.customMountFlags=Custom Mount Flags
|
||||
Reference in New Issue
Block a user