mirror of
https://github.com/cryptomator/cryptomator.git
synced 2024-11-23 03:59:51 +00:00
optimised cellSize binding and removed unused imports
This commit is contained in:
parent
ce82593fc6
commit
2d96d2e5c6
@ -10,8 +10,6 @@ import org.cryptomator.ui.controls.FontAwesome5Icon;
|
||||
import org.cryptomator.ui.controls.FontAwesome5IconView;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.beans.binding.BooleanBinding;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
|
@ -71,8 +71,7 @@ public class VaultListController implements FxController {
|
||||
private final BooleanProperty draggingVaultOver = new SimpleBooleanProperty();
|
||||
private final ResourceBundle resourceBundle;
|
||||
private final FxApplicationWindows appWindows;
|
||||
private final Settings settings;
|
||||
|
||||
private final ObservableValue<Double> cellSize;
|
||||
public ListView<Vault> vaultList;
|
||||
public StackPane root;
|
||||
@FXML
|
||||
@ -102,20 +101,17 @@ public class VaultListController implements FxController {
|
||||
this.vaultListManager = vaultListManager;
|
||||
this.resourceBundle = resourceBundle;
|
||||
this.appWindows = appWindows;
|
||||
this.settings = settings;
|
||||
|
||||
this.emptyVaultList = Bindings.isEmpty(vaults);
|
||||
|
||||
selectedVault.addListener(this::selectedVaultDidChange);
|
||||
cellSize = settings.compactMode.map(compact -> compact ? 30.0 : 60.0);
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
vaultList.setItems(vaults);
|
||||
vaultList.setCellFactory(cellFactory);
|
||||
|
||||
vaultList.fixedCellSizeProperty().bind(Bindings.createDoubleBinding(() ->
|
||||
settings.compactMode.get() ? 30.0 : 60.0, settings.compactMode));
|
||||
|
||||
selectedVault.bind(vaultList.getSelectionModel().selectedItemProperty());
|
||||
vaults.addListener((ListChangeListener.Change<? extends Vault> c) -> {
|
||||
while (c.next()) {
|
||||
@ -280,5 +276,12 @@ public class VaultListController implements FxController {
|
||||
return draggingVaultOver.get();
|
||||
}
|
||||
|
||||
public ObservableValue<Double> cellSizeProperty() {
|
||||
return cellSize;
|
||||
}
|
||||
|
||||
public Double getCellSize() {
|
||||
return cellSize.getValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
minWidth="206">
|
||||
<VBox>
|
||||
<StackPane VBox.vgrow="ALWAYS">
|
||||
<ListView fx:id="vaultList" editable="true" fixedCellSize="60">
|
||||
<ListView fx:id="vaultList" editable="true" fixedCellSize="${controller.cellSize}">
|
||||
<contextMenu>
|
||||
<fx:include source="vault_list_contextmenu.fxml"/>
|
||||
</contextMenu>
|
||||
|
Loading…
Reference in New Issue
Block a user