Merge pull request #3554 from cryptomator/feature/condensed-vault-list

Feature: Add Option to Enable Compact Vault List View
This commit is contained in:
mindmonk 2024-10-02 10:55:51 +02:00 committed by GitHub
commit ad555ece8e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 37 additions and 5 deletions

View File

@ -60,6 +60,7 @@ public class Settings {
public final ObjectProperty<NodeOrientation> userInterfaceOrientation; public final ObjectProperty<NodeOrientation> userInterfaceOrientation;
public final StringProperty licenseKey; public final StringProperty licenseKey;
public final BooleanProperty showTrayIcon; public final BooleanProperty showTrayIcon;
public final BooleanProperty compactMode;
public final IntegerProperty windowXPosition; public final IntegerProperty windowXPosition;
public final IntegerProperty windowYPosition; public final IntegerProperty windowYPosition;
public final IntegerProperty windowWidth; public final IntegerProperty windowWidth;
@ -96,6 +97,7 @@ public class Settings {
this.userInterfaceOrientation = new SimpleObjectProperty<>(this, "userInterfaceOrientation", parseEnum(json.uiOrientation, NodeOrientation.class, NodeOrientation.LEFT_TO_RIGHT)); this.userInterfaceOrientation = new SimpleObjectProperty<>(this, "userInterfaceOrientation", parseEnum(json.uiOrientation, NodeOrientation.class, NodeOrientation.LEFT_TO_RIGHT));
this.licenseKey = new SimpleStringProperty(this, "licenseKey", json.licenseKey); this.licenseKey = new SimpleStringProperty(this, "licenseKey", json.licenseKey);
this.showTrayIcon = new SimpleBooleanProperty(this, "showTrayIcon", json.showTrayIcon); this.showTrayIcon = new SimpleBooleanProperty(this, "showTrayIcon", json.showTrayIcon);
this.compactMode = new SimpleBooleanProperty(this, "compactMode", json.compactMode);
this.windowXPosition = new SimpleIntegerProperty(this, "windowXPosition", json.windowXPosition); this.windowXPosition = new SimpleIntegerProperty(this, "windowXPosition", json.windowXPosition);
this.windowYPosition = new SimpleIntegerProperty(this, "windowYPosition", json.windowYPosition); this.windowYPosition = new SimpleIntegerProperty(this, "windowYPosition", json.windowYPosition);
this.windowWidth = new SimpleIntegerProperty(this, "windowWidth", json.windowWidth); this.windowWidth = new SimpleIntegerProperty(this, "windowWidth", json.windowWidth);
@ -122,6 +124,7 @@ public class Settings {
userInterfaceOrientation.addListener(this::somethingChanged); userInterfaceOrientation.addListener(this::somethingChanged);
licenseKey.addListener(this::somethingChanged); licenseKey.addListener(this::somethingChanged);
showTrayIcon.addListener(this::somethingChanged); showTrayIcon.addListener(this::somethingChanged);
compactMode.addListener(this::somethingChanged);
windowXPosition.addListener(this::somethingChanged); windowXPosition.addListener(this::somethingChanged);
windowYPosition.addListener(this::somethingChanged); windowYPosition.addListener(this::somethingChanged);
windowWidth.addListener(this::somethingChanged); windowWidth.addListener(this::somethingChanged);
@ -175,6 +178,7 @@ public class Settings {
json.uiOrientation = userInterfaceOrientation.get().name(); json.uiOrientation = userInterfaceOrientation.get().name();
json.licenseKey = licenseKey.get(); json.licenseKey = licenseKey.get();
json.showTrayIcon = showTrayIcon.get(); json.showTrayIcon = showTrayIcon.get();
json.compactMode = compactMode.get();
json.windowXPosition = windowXPosition.get(); json.windowXPosition = windowXPosition.get();
json.windowYPosition = windowYPosition.get(); json.windowYPosition = windowYPosition.get();
json.windowWidth = windowWidth.get(); json.windowWidth = windowWidth.get();

View File

@ -54,6 +54,9 @@ class SettingsJson {
@JsonProperty("showTrayIcon") @JsonProperty("showTrayIcon")
boolean showTrayIcon; boolean showTrayIcon;
@JsonProperty("compactMode")
boolean compactMode;
@JsonProperty("startHidden") @JsonProperty("startHidden")
boolean startHidden = Settings.DEFAULT_START_HIDDEN; boolean startHidden = Settings.DEFAULT_START_HIDDEN;

View File

@ -1,5 +1,6 @@
package org.cryptomator.ui.mainwindow; package org.cryptomator.ui.mainwindow;
import org.cryptomator.common.settings.Settings;
import org.cryptomator.common.vaults.Vault; import org.cryptomator.common.vaults.Vault;
import org.cryptomator.common.vaults.VaultState; import org.cryptomator.common.vaults.VaultState;
import org.cryptomator.ui.common.Animations; import org.cryptomator.ui.common.Animations;
@ -18,6 +19,7 @@ public class VaultListCellController implements FxController {
private final ObjectProperty<Vault> vault = new SimpleObjectProperty<>(); private final ObjectProperty<Vault> vault = new SimpleObjectProperty<>();
private final ObservableValue<FontAwesome5Icon> glyph; private final ObservableValue<FontAwesome5Icon> glyph;
private final ObservableValue<Boolean> compactMode;
private AutoAnimator spinAnimation; private AutoAnimator spinAnimation;
@ -25,8 +27,9 @@ public class VaultListCellController implements FxController {
public FontAwesome5IconView vaultStateView; public FontAwesome5IconView vaultStateView;
@Inject @Inject
VaultListCellController() { VaultListCellController(Settings settings) {
this.glyph = vault.flatMap(Vault::stateProperty).map(this::getGlyphForVaultState); this.glyph = vault.flatMap(Vault::stateProperty).map(this::getGlyphForVaultState);
this.compactMode = settings.compactMode;
} }
public void initialize() { public void initialize() {
@ -68,6 +71,14 @@ public class VaultListCellController implements FxController {
return vault.get(); return vault.get();
} }
public ObservableValue<Boolean> compactModeProperty() {
return compactMode;
}
public boolean getCompactMode() {
return compactMode.getValue();
}
public void setVault(Vault value) { public void setVault(Vault value) {
vault.set(value); vault.set(value);
} }

View File

@ -1,6 +1,7 @@
package org.cryptomator.ui.mainwindow; package org.cryptomator.ui.mainwindow;
import org.apache.commons.lang3.SystemUtils; import org.apache.commons.lang3.SystemUtils;
import org.cryptomator.common.settings.Settings;
import org.cryptomator.common.vaults.Vault; import org.cryptomator.common.vaults.Vault;
import org.cryptomator.common.vaults.VaultListManager; import org.cryptomator.common.vaults.VaultListManager;
import org.cryptomator.cryptofs.CryptoFileSystemProvider; import org.cryptomator.cryptofs.CryptoFileSystemProvider;
@ -70,7 +71,7 @@ public class VaultListController implements FxController {
private final BooleanProperty draggingVaultOver = new SimpleBooleanProperty(); private final BooleanProperty draggingVaultOver = new SimpleBooleanProperty();
private final ResourceBundle resourceBundle; private final ResourceBundle resourceBundle;
private final FxApplicationWindows appWindows; private final FxApplicationWindows appWindows;
private final ObservableValue<Double> cellSize;
public ListView<Vault> vaultList; public ListView<Vault> vaultList;
public StackPane root; public StackPane root;
@FXML @FXML
@ -88,7 +89,8 @@ public class VaultListController implements FxController {
RemoveVaultComponent.Builder removeVaultDialogue, // RemoveVaultComponent.Builder removeVaultDialogue, //
VaultListManager vaultListManager, // VaultListManager vaultListManager, //
ResourceBundle resourceBundle, // ResourceBundle resourceBundle, //
FxApplicationWindows appWindows) { FxApplicationWindows appWindows, //
Settings settings) {
this.mainWindow = mainWindow; this.mainWindow = mainWindow;
this.vaults = vaults; this.vaults = vaults;
this.selectedVault = selectedVault; this.selectedVault = selectedVault;
@ -103,6 +105,7 @@ public class VaultListController implements FxController {
this.emptyVaultList = Bindings.isEmpty(vaults); this.emptyVaultList = Bindings.isEmpty(vaults);
selectedVault.addListener(this::selectedVaultDidChange); selectedVault.addListener(this::selectedVaultDidChange);
cellSize = settings.compactMode.map(compact -> compact ? 30.0 : 60.0);
} }
public void initialize() { public void initialize() {
@ -273,5 +276,12 @@ public class VaultListController implements FxController {
return draggingVaultOver.get(); return draggingVaultOver.get();
} }
public ObservableValue<Double> cellSizeProperty() {
return cellSize;
}
public Double getCellSize() {
return cellSize.getValue();
}
} }

View File

@ -37,6 +37,7 @@ public class InterfacePreferencesController implements FxController {
private final SupportedLanguages supportedLanguages; private final SupportedLanguages supportedLanguages;
public ChoiceBox<UiTheme> themeChoiceBox; public ChoiceBox<UiTheme> themeChoiceBox;
public CheckBox showTrayIconCheckbox; public CheckBox showTrayIconCheckbox;
public CheckBox compactModeCheckbox;
public ChoiceBox<String> preferredLanguageChoiceBox; public ChoiceBox<String> preferredLanguageChoiceBox;
public ToggleGroup nodeOrientation; public ToggleGroup nodeOrientation;
public RadioButton nodeOrientationLtr; public RadioButton nodeOrientationLtr;
@ -63,6 +64,7 @@ public class InterfacePreferencesController implements FxController {
themeChoiceBox.setConverter(new UiThemeConverter(resourceBundle)); themeChoiceBox.setConverter(new UiThemeConverter(resourceBundle));
showTrayIconCheckbox.selectedProperty().bindBidirectional(settings.showTrayIcon); showTrayIconCheckbox.selectedProperty().bindBidirectional(settings.showTrayIcon);
compactModeCheckbox.selectedProperty().bindBidirectional(settings.compactMode);
preferredLanguageChoiceBox.getItems().addAll(supportedLanguages.getLanguageTags()); preferredLanguageChoiceBox.getItems().addAll(supportedLanguages.getLanguageTags());
preferredLanguageChoiceBox.valueProperty().bindBidirectional(settings.language); preferredLanguageChoiceBox.valueProperty().bindBidirectional(settings.language);

View File

@ -38,5 +38,6 @@
</HBox> </HBox>
<CheckBox fx:id="showTrayIconCheckbox" text="%preferences.interface.showTrayIcon" visible="${controller.trayMenuSupported}" managed="${controller.trayMenuSupported}"/> <CheckBox fx:id="showTrayIconCheckbox" text="%preferences.interface.showTrayIcon" visible="${controller.trayMenuSupported}" managed="${controller.trayMenuSupported}"/>
<CheckBox fx:id="compactModeCheckbox" text="%preferences.interface.compactMode"/>
</children> </children>
</VBox> </VBox>

View File

@ -18,7 +18,7 @@
minWidth="206"> minWidth="206">
<VBox> <VBox>
<StackPane VBox.vgrow="ALWAYS"> <StackPane VBox.vgrow="ALWAYS">
<ListView fx:id="vaultList" editable="true" fixedCellSize="60"> <ListView fx:id="vaultList" editable="true" fixedCellSize="${controller.cellSize}">
<contextMenu> <contextMenu>
<fx:include source="vault_list_contextmenu.fxml"/> <fx:include source="vault_list_contextmenu.fxml"/>
</contextMenu> </contextMenu>

View File

@ -23,7 +23,7 @@
</VBox> </VBox>
<VBox spacing="4" HBox.hgrow="ALWAYS"> <VBox spacing="4" HBox.hgrow="ALWAYS">
<Label styleClass="header-label" text="${controller.vault.displayName}"/> <Label styleClass="header-label" text="${controller.vault.displayName}"/>
<Label styleClass="detail-label" text="${controller.vault.displayablePath}" textOverrun="CENTER_ELLIPSIS"> <Label styleClass="detail-label" text="${controller.vault.displayablePath}" textOverrun="CENTER_ELLIPSIS" visible="${!controller.compactMode}" managed="${!controller.compactMode}">
<tooltip> <tooltip>
<Tooltip text="${controller.vault.displayablePath}"/> <Tooltip text="${controller.vault.displayablePath}"/>
</tooltip> </tooltip>

View File

@ -301,6 +301,7 @@ preferences.interface.interfaceOrientation=Interface Orientation
preferences.interface.interfaceOrientation.ltr=Left to Right preferences.interface.interfaceOrientation.ltr=Left to Right
preferences.interface.interfaceOrientation.rtl=Right to Left preferences.interface.interfaceOrientation.rtl=Right to Left
preferences.interface.showTrayIcon=Show tray icon (requires restart) preferences.interface.showTrayIcon=Show tray icon (requires restart)
preferences.interface.compactMode=Enable compact vault list
## Volume ## Volume
preferences.volume=Virtual Drive preferences.volume=Virtual Drive
preferences.volume.type=Default Volume Type preferences.volume.type=Default Volume Type