mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-08-01 21:06:02 +00:00
store autolock time in seconds instead of minutes
This commit is contained in:
+23
-3
@@ -8,12 +8,13 @@ import javax.inject.Inject;
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.CheckBox;
|
||||
import javafx.util.converter.NumberStringConverter;
|
||||
import javafx.util.StringConverter;
|
||||
|
||||
@VaultOptionsScoped
|
||||
public class AutoLockVaultOptionsController implements FxController {
|
||||
|
||||
private final Vault vault;
|
||||
|
||||
public CheckBox lockAfterTimeCheckbox;
|
||||
public NumericTextField lockTimeInMinutesTextField;
|
||||
|
||||
@@ -24,8 +25,27 @@ public class AutoLockVaultOptionsController implements FxController {
|
||||
|
||||
@FXML
|
||||
public void initialize() {
|
||||
lockAfterTimeCheckbox.selectedProperty().bindBidirectional(vault.getVaultSettings().lockAfterTime());
|
||||
Bindings.bindBidirectional(lockTimeInMinutesTextField.textProperty(), vault.getVaultSettings().lockTimeInMinutes(), new NumberStringConverter());
|
||||
lockAfterTimeCheckbox.selectedProperty().bindBidirectional(vault.getVaultSettings().autoLockWhenIdle());
|
||||
Bindings.bindBidirectional(lockTimeInMinutesTextField.textProperty(), vault.getVaultSettings().autoLockIdleSeconds(), new IdleTimeSecondsConverter());
|
||||
}
|
||||
|
||||
private static class IdleTimeSecondsConverter extends StringConverter<Number> {
|
||||
|
||||
@Override
|
||||
public String toString(Number seconds) {
|
||||
int minutes = seconds.intValue() / 60; // int-truncate
|
||||
return Integer.toString(minutes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Number fromString(String string) {
|
||||
try {
|
||||
int minutes = Integer.valueOf(string);
|
||||
return minutes * 60;
|
||||
} catch (NumberFormatException e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user