changed mainWindow StageStyle to UNDECORATED

removed main_window_title area
moved main_window_resize functions to MainWindowController
put add vault button under the vault list and wrapped both in a ScrollPane
bound vault list height properties to amount of entries and width to scroll pane width
add listener to scroll down after adding a vault
moved preferences button under vault list
new style classes for new elements
changed wording
This commit is contained in:
Jan-Peter Klein
2024-05-28 21:56:03 +02:00
parent 8c7dd8c74f
commit e038348dca
8 changed files with 132 additions and 25 deletions

View File

@@ -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<Vault> selectedVault;
private final Settings settings;
public StackPane root;
@Inject
public MainWindowController(@MainWindow Stage window, ObjectProperty<Vault> selectedVault) {
public MainWindowController(@MainWindow Stage window, ObjectProperty<Vault> 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) {

View File

@@ -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;

View File

@@ -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<Vault> 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<Vault>) c -> {
vaultList.prefHeightProperty().bind(vaultList.fixedCellSizeProperty().multiply(vaultList.getItems().size()));
});
selectedVault.bind(vaultList.getSelectionModel().selectedItemProperty());
vaults.addListener((ListChangeListener.Change<? extends Vault> 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() {