diff --git a/src/main/java/org/cryptomator/ui/mainwindow/MainWindowController.java b/src/main/java/org/cryptomator/ui/mainwindow/MainWindowController.java index b2c912834..a09c3afba 100644 --- a/src/main/java/org/cryptomator/ui/mainwindow/MainWindowController.java +++ b/src/main/java/org/cryptomator/ui/mainwindow/MainWindowController.java @@ -1,6 +1,7 @@ package org.cryptomator.ui.mainwindow; import org.apache.commons.lang3.SystemUtils; +import org.cryptomator.common.settings.Settings; import org.cryptomator.common.vaults.Vault; import org.cryptomator.common.vaults.VaultListManager; import org.cryptomator.ui.common.FxController; @@ -22,13 +23,15 @@ public class MainWindowController implements FxController { private final Stage window; private final ReadOnlyObjectProperty selectedVault; + private final Settings settings; public StackPane root; @Inject - public MainWindowController(@MainWindow Stage window, ObjectProperty selectedVault) { + public MainWindowController(@MainWindow Stage window, ObjectProperty selectedVault, Settings settings) { this.window = window; this.selectedVault = selectedVault; + this.settings = settings; } @FXML @@ -38,6 +41,29 @@ public class MainWindowController implements FxController { root.getStyleClass().add("os-windows"); } window.focusedProperty().addListener(this::mainWindowFocusChanged); + + if (!neverTouched()) { + window.setHeight(settings.windowHeight.get() > window.getMinHeight() ? settings.windowHeight.get() : window.getMinHeight()); + window.setWidth(settings.windowWidth.get() > window.getMinWidth() ? settings.windowWidth.get() : window.getMinWidth()); + window.setX(settings.windowXPosition.get()); + window.setY(settings.windowYPosition.get()); + } + window.widthProperty().addListener((_,_,_) -> savePositionalSettings()); + window.heightProperty().addListener((_,_,_) -> savePositionalSettings()); + window.xProperty().addListener((_,_,_) -> savePositionalSettings()); + window.yProperty().addListener((_,_,_) -> savePositionalSettings()); + } + + private boolean neverTouched() { + return (settings.windowHeight.get() == 0) && (settings.windowWidth.get() == 0) && (settings.windowXPosition.get() == 0) && (settings.windowYPosition.get() == 0); + } + + @FXML + public void savePositionalSettings() { + settings.windowWidth.setValue(window.getWidth()); + settings.windowHeight.setValue(window.getHeight()); + settings.windowXPosition.setValue(window.getX()); + settings.windowYPosition.setValue(window.getY()); } private void mainWindowFocusChanged(Observable observable) { diff --git a/src/main/java/org/cryptomator/ui/mainwindow/MainWindowModule.java b/src/main/java/org/cryptomator/ui/mainwindow/MainWindowModule.java index 0b403bb47..bfddabf46 100644 --- a/src/main/java/org/cryptomator/ui/mainwindow/MainWindowModule.java +++ b/src/main/java/org/cryptomator/ui/mainwindow/MainWindowModule.java @@ -41,7 +41,6 @@ abstract class MainWindowModule { static Stage provideMainWindow(@PrimaryStage Stage stage, StageInitializer initializer) { initializer.accept(stage); stage.setTitle("Cryptomator"); - stage.initStyle(StageStyle.UNDECORATED); stage.setMinWidth(650); stage.setMinHeight(440); return stage; diff --git a/src/main/java/org/cryptomator/ui/mainwindow/VaultListController.java b/src/main/java/org/cryptomator/ui/mainwindow/VaultListController.java index e8ea21fe4..76a69ad14 100644 --- a/src/main/java/org/cryptomator/ui/mainwindow/VaultListController.java +++ b/src/main/java/org/cryptomator/ui/mainwindow/VaultListController.java @@ -9,6 +9,7 @@ import org.cryptomator.ui.addvaultwizard.AddVaultWizardComponent; import org.cryptomator.ui.common.FxController; import org.cryptomator.ui.common.VaultService; import org.cryptomator.ui.fxapp.FxApplicationWindows; +import org.cryptomator.ui.preferences.SelectedPreferencesTab; import org.cryptomator.ui.removevault.RemoveVaultComponent; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -27,13 +28,16 @@ import javafx.geometry.Side; import javafx.scene.control.Button; import javafx.scene.control.ContextMenu; import javafx.scene.control.ListView; +import javafx.scene.control.ScrollPane; import javafx.scene.input.ContextMenuEvent; import javafx.scene.input.DragEvent; import javafx.scene.input.KeyCode; import javafx.scene.input.KeyEvent; import javafx.scene.input.MouseEvent; import javafx.scene.input.TransferMode; +import javafx.scene.layout.HBox; import javafx.scene.layout.StackPane; +import javafx.scene.layout.VBox; import javafx.stage.Stage; import java.io.File; import java.io.IOException; @@ -71,8 +75,11 @@ public class VaultListController implements FxController { private final FxApplicationWindows appWindows; public ListView vaultList; + public ScrollPane scrollPane; + public VBox vbox; public StackPane root; public Button addVaultBtn; + public HBox addVaultArea; @FXML private ContextMenu addVaultContextMenu; @@ -106,6 +113,21 @@ public class VaultListController implements FxController { public void initialize() { vaultList.setItems(vaults); vaultList.setCellFactory(cellFactory); + + vaultList.prefHeightProperty().bind(vaultList.fixedCellSizeProperty().multiply(vaultList.getItems().size())); + vaultList.maxHeightProperty().bind(vaultList.prefHeightProperty()); + vaultList.prefWidthProperty().bind(scrollPane.widthProperty()); + + vbox.heightProperty().addListener((_, oldValue, newValue) -> { + if(newValue.doubleValue()>oldValue.doubleValue()){ + scrollPane.setVvalue(1.0); + } + }); + + vaults.addListener((ListChangeListener) c -> { + vaultList.prefHeightProperty().bind(vaultList.fixedCellSizeProperty().multiply(vaultList.getItems().size())); + }); + selectedVault.bind(vaultList.getSelectionModel().selectedItemProperty()); vaults.addListener((ListChangeListener.Change c) -> { while (c.next()) { @@ -171,7 +193,7 @@ public class VaultListController implements FxController { if (addVaultContextMenu.isShowing()) { addVaultContextMenu.hide(); } else { - addVaultContextMenu.show(addVaultBtn, Side.BOTTOM, 0.0, 0.0); + addVaultContextMenu.show(addVaultArea, Side.BOTTOM, 0.0, 0.0); } } @@ -247,6 +269,11 @@ public class VaultListController implements FxController { } } + @FXML + public void showPreferences() { + appWindows.showPreferencesWindow(SelectedPreferencesTab.ANY); + } + // Getter and Setter public BooleanBinding emptyVaultListProperty() { diff --git a/src/main/resources/css/dark_theme.css b/src/main/resources/css/dark_theme.css index 86d9aaa71..bba91cb11 100644 --- a/src/main/resources/css/dark_theme.css +++ b/src/main/resources/css/dark_theme.css @@ -341,6 +341,27 @@ -fx-background-color: CONTROL_BG_ARMED; } +.vault-list-box { + -fx-background-color: CONTROL_BG_NORMAL; +} + +.add-vault-btn { + -fx-background-color: CONTROL_BG_NORMAL; +} +.add-vault-btn .icon { + -fx-fill: TEXT_FILL_MUTED; +} +.add-vault-btn-label { + -fx-font-family: 'Open Sans SemiBold'; + -fx-font-size: 1.0em; +} + +.preferences-btn { + -fx-background-color: MAIN_BG; + -fx-border-color: CONTROL_BORDER_NORMAL transparent transparent transparent; + -fx-border-width: 1px 0 0 0; +} + /******************************************************************************* * * * ScrollBar * diff --git a/src/main/resources/css/light_theme.css b/src/main/resources/css/light_theme.css index 88cf6d970..d000c0464 100644 --- a/src/main/resources/css/light_theme.css +++ b/src/main/resources/css/light_theme.css @@ -340,6 +340,26 @@ -fx-background-color: CONTROL_BG_ARMED; } +.vault-list-box { + -fx-background-color: CONTROL_BG_NORMAL; +} + +.add-vault-btn { + -fx-background-color: CONTROL_BG_NORMAL; +} +.add-vault-btn .icon { + -fx-fill: GRAY_4; +} +.add-vault-btn-label { + -fx-font-family: 'Open Sans SemiBold'; + -fx-font-size: 1.0em; +} + +.preferences-btn { + -fx-border-color: CONTROL_BORDER_NORMAL transparent transparent transparent; + -fx-border-width: 1px 0 0 0; +} + /******************************************************************************* * * * ScrollBar * diff --git a/src/main/resources/fxml/main_window.fxml b/src/main/resources/fxml/main_window.fxml index 2796455d3..cefa18e58 100644 --- a/src/main/resources/fxml/main_window.fxml +++ b/src/main/resources/fxml/main_window.fxml @@ -9,11 +9,9 @@ fx:controller="org.cryptomator.ui.mainwindow.MainWindowController" styleClass="main-window"> - - diff --git a/src/main/resources/fxml/vault_list.fxml b/src/main/resources/fxml/vault_list.fxml index f9cb29258..a1fe141db 100644 --- a/src/main/resources/fxml/vault_list.fxml +++ b/src/main/resources/fxml/vault_list.fxml @@ -1,38 +1,54 @@ - - + + + - - - - - - - - - - - + + + + + + + + + + + + diff --git a/src/main/resources/i18n/strings.properties b/src/main/resources/i18n/strings.properties index acdac613b..4309351b5 100644 --- a/src/main/resources/i18n/strings.properties +++ b/src/main/resources/i18n/strings.properties @@ -389,7 +389,7 @@ main.vaultlist.contextMenu.unlock=Unlockā€¦ main.vaultlist.contextMenu.unlockNow=Unlock Now main.vaultlist.contextMenu.vaultoptions=Show Vault Options main.vaultlist.contextMenu.reveal=Reveal Drive -main.vaultlist.addVaultBtn=Add +main.vaultlist.addVaultBtn=Add Vault main.vaultlist.addVaultBtn.menuItemNew=New Vault... main.vaultlist.addVaultBtn.menuItemExisting=Existing Vault... ## Vault Detail