From 4689bcc2aac370d1b998d38fbe6faad658b1f77d Mon Sep 17 00:00:00 2001 From: crschnick Date: Mon, 19 Jun 2023 09:03:34 +0000 Subject: [PATCH] Various small UI improvements --- .../io/xpipe/app/browser/BrowserComp.java | 12 ++--- .../io/xpipe/app/browser/BrowserModel.java | 14 +++-- .../xpipe/app/browser/BrowserWelcomeComp.java | 54 ++++++++++--------- .../xpipe/app/prefs/CustomFormRenderer.java | 2 +- .../io/xpipe/app/prefs/PropertiesComp.java | 19 +++---- .../resources/lang/preferences_en.properties | 4 +- .../resources/lang/translations_en.properties | 4 +- .../io/xpipe/app/resources/style/about.css | 4 ++ .../io/xpipe/app/resources/style/browser.css | 4 ++ 9 files changed, 65 insertions(+), 52 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserComp.java b/app/src/main/java/io/xpipe/app/browser/BrowserComp.java index 7074ed28..53111591 100644 --- a/app/src/main/java/io/xpipe/app/browser/BrowserComp.java +++ b/app/src/main/java/io/xpipe/app/browser/BrowserComp.java @@ -22,6 +22,7 @@ import javafx.application.Platform; import javafx.beans.binding.Bindings; import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.property.SimpleStringProperty; +import javafx.beans.value.ObservableBooleanValue; import javafx.collections.ListChangeListener; import javafx.geometry.Insets; import javafx.geometry.Orientation; @@ -29,10 +30,7 @@ import javafx.geometry.Pos; import javafx.scene.Node; import javafx.scene.control.*; import javafx.scene.input.DragEvent; -import javafx.scene.layout.HBox; -import javafx.scene.layout.Priority; -import javafx.scene.layout.Region; -import javafx.scene.layout.VBox; +import javafx.scene.layout.*; import java.util.HashMap; import java.util.Map; @@ -89,7 +87,7 @@ public class BrowserComp extends SimpleComp { .widthProperty() .addListener( // set sidebar width in pixels depending on split pane width - (obs, old, val) -> splitPane.setDividerPosition(0, 280 / splitPane.getWidth())); + (obs, old, val) -> splitPane.setDividerPosition(0, 320 / splitPane.getWidth())); var r = addBottomBar(splitPane); r.getStyleClass().add("browser"); @@ -137,10 +135,10 @@ public class BrowserComp extends SimpleComp { } private Node createTabs() { - var multi = new MultiContentComp(Map.of( + var multi = new MultiContentComp(Map., ObservableBooleanValue>of( Comp.of(() -> createTabPane()), BindingsHelper.persist(Bindings.isNotEmpty(model.getOpenFileSystems())), - new BrowserWelcomeComp(model), + new BrowserWelcomeComp(model).apply(struc -> StackPane.setAlignment(struc.get(), Pos.CENTER_LEFT)), BindingsHelper.persist(Bindings.isEmpty(model.getOpenFileSystems())))); return multi.createRegion(); } diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserModel.java b/app/src/main/java/io/xpipe/app/browser/BrowserModel.java index a254e371..6626aa83 100644 --- a/app/src/main/java/io/xpipe/app/browser/BrowserModel.java +++ b/app/src/main/java/io/xpipe/app/browser/BrowserModel.java @@ -71,11 +71,15 @@ public class BrowserModel { public void restoreState(BrowserSavedState state) { state.getLastSystems().forEach(e -> { - var storageEntry = DataStorage.get().getStoreEntry(e.getUuid()); - storageEntry.ifPresent(entry -> { - openFileSystemAsync( - entry.getName(), entry.getStore().asNeeded(), e.getPath(), new SimpleBooleanProperty()); - }); + restoreState(e, null); + }); + } + + public void restoreState(BrowserSavedState.Entry e, BooleanProperty busy) { + var storageEntry = DataStorage.get().getStoreEntry(e.getUuid()); + storageEntry.ifPresent(entry -> { + openFileSystemAsync( + entry.getName(), entry.getStore().asNeeded(), e.getPath(), busy); }); } diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserWelcomeComp.java b/app/src/main/java/io/xpipe/app/browser/BrowserWelcomeComp.java index 7e050424..bf0954b7 100644 --- a/app/src/main/java/io/xpipe/app/browser/BrowserWelcomeComp.java +++ b/app/src/main/java/io/xpipe/app/browser/BrowserWelcomeComp.java @@ -1,18 +1,23 @@ package io.xpipe.app.browser; -import atlantafx.base.controls.Spacer; +import atlantafx.base.controls.Tile; +import atlantafx.base.theme.Styles; +import io.xpipe.app.comp.base.TileButtonComp; import io.xpipe.app.core.AppFont; import io.xpipe.app.fxcomps.SimpleComp; +import io.xpipe.app.fxcomps.impl.FancyTooltipAugment; import io.xpipe.app.fxcomps.impl.PrettyImageComp; import io.xpipe.app.storage.DataStorage; import javafx.beans.property.SimpleStringProperty; import javafx.geometry.Insets; +import javafx.geometry.Orientation; import javafx.scene.control.Button; import javafx.scene.control.Label; +import javafx.scene.control.ScrollPane; +import javafx.scene.control.Separator; import javafx.scene.layout.Region; import javafx.scene.layout.VBox; - -import java.util.concurrent.atomic.AtomicBoolean; +import org.kordamp.ikonli.javafx.FontIcon; public class BrowserWelcomeComp extends SimpleComp { @@ -29,6 +34,7 @@ public class BrowserWelcomeComp extends SimpleComp { var welcome = new BrowserGreetingComp().createSimple(); var vbox = new VBox(welcome); + vbox.setMaxWidth(600); vbox.setPadding(new Insets(40, 40, 40, 50)); vbox.setSpacing(18); if (state == null) { @@ -39,11 +45,11 @@ public class BrowserWelcomeComp extends SimpleComp { } var header = new Label("Last time you were connected to the following systems:"); + header.getStyleClass().add(Styles.TEXT_MUTED); AppFont.header(header); vbox.getChildren().add(header); var storeList = new VBox(); - storeList.setPadding(new Insets(0, 0, 0, 10)); storeList.setSpacing(8); state.getLastSystems().forEach(e-> { var entry = DataStorage.get().getStoreEntry(e.getUuid()); @@ -53,31 +59,29 @@ public class BrowserWelcomeComp extends SimpleComp { var graphic = entry.get().getProvider().getDisplayIconFileName(entry.get().getStore()); - var view = new PrettyImageComp(new SimpleStringProperty(graphic), 24, 24); - var l = new Label(entry.get().getName() + (e.getPath() != null ? ": " + e.getPath() : ""), view.createRegion()); - l.setGraphicTextGap(10); - storeList.getChildren().add(l); + var view = new PrettyImageComp(new SimpleStringProperty(graphic), 45, 45); + var openButton = new Button(null, new FontIcon("mdmz-restore")); + new FancyTooltipAugment<>("restore").augment(openButton); + openButton.getStyleClass().addAll(Styles.FLAT, Styles.BUTTON_CIRCLE); + openButton.setOnAction(event -> { + model.restoreState(e, openButton.disableProperty()); + event.consume(); + }); + var tile = new Tile(entry.get().getName(), e.getPath(), view.createRegion()); + tile.setAction(openButton); + storeList.getChildren().add(tile); }); - vbox.getChildren().add(storeList); - vbox.getChildren().add(new Spacer(20)); + var sp = new ScrollPane(storeList); + sp.setFitToWidth(true); + vbox.getChildren().add(sp); + vbox.getChildren().add(new Separator(Orientation.HORIZONTAL)); - var restoreLabel = new Label("Do you want to restore these sessions?"); - AppFont.header(restoreLabel); - vbox.getChildren().add(restoreLabel); - - var restoreButton = new Button("Restore sessions"); - var done = new AtomicBoolean(); - restoreButton.setOnAction(event -> { - if (done.get()) { - return; - } - - done.set(true); + var tile = new TileButtonComp("restore", "restoreAllSessions", "mdmz-restore", actionEvent -> { model.restoreState(state); - event.consume(); - }); - vbox.getChildren().add(restoreButton); + actionEvent.consume(); + }).grow(true, false); + vbox.getChildren().add(tile.createRegion()); return vbox; } diff --git a/app/src/main/java/io/xpipe/app/prefs/CustomFormRenderer.java b/app/src/main/java/io/xpipe/app/prefs/CustomFormRenderer.java index ef9b1c9a..9a4391ab 100644 --- a/app/src/main/java/io/xpipe/app/prefs/CustomFormRenderer.java +++ b/app/src/main/java/io/xpipe/app/prefs/CustomFormRenderer.java @@ -84,7 +84,7 @@ public class CustomFormRenderer extends PreferencesFxFormRenderer { var descriptionLabel = new Label(); AppFont.medium(descriptionLabel); descriptionLabel.setWrapText(true); - descriptionLabel.setMaxWidth(700); + descriptionLabel.setMaxWidth(800); descriptionLabel .disableProperty() .bind(c.getFieldLabel().disabledProperty()); diff --git a/app/src/main/java/io/xpipe/app/prefs/PropertiesComp.java b/app/src/main/java/io/xpipe/app/prefs/PropertiesComp.java index 3c67a907..8244a211 100644 --- a/app/src/main/java/io/xpipe/app/prefs/PropertiesComp.java +++ b/app/src/main/java/io/xpipe/app/prefs/PropertiesComp.java @@ -1,5 +1,6 @@ package io.xpipe.app.prefs; +import atlantafx.base.controls.Tile; import io.xpipe.app.core.App; import io.xpipe.app.core.AppFont; import io.xpipe.app.core.AppI18n; @@ -7,7 +8,7 @@ import io.xpipe.app.core.AppProperties; import io.xpipe.app.fxcomps.Comp; import io.xpipe.app.fxcomps.SimpleComp; import io.xpipe.app.fxcomps.impl.LabelComp; -import io.xpipe.app.util.DynamicOptionsBuilder; +import io.xpipe.app.util.OptionsBuilder; import javafx.scene.control.Label; import javafx.scene.image.ImageView; import javafx.scene.layout.Region; @@ -24,26 +25,22 @@ public class PropertiesComp extends SimpleComp { var label = new Label(AppI18n.get("xPipeClient"), image); label.getStyleClass().add("header"); AppFont.setSize(label, 5); - return label; + return new Tile(AppI18n.get("xPipeClient"), "Version " + AppProperties.get().getVersion() + " (" + + AppProperties.get().getArch() + ")", image); }); - var section = new DynamicOptionsBuilder(false) + var section = new OptionsBuilder() .addComp(title, null) + .name("build") .addComp( - AppI18n.observable("version"), - new LabelComp(AppProperties.get().getVersion() + " (" - + AppProperties.get().getArch() + ")"), - null) - .addComp( - AppI18n.observable("build"), new LabelComp(AppProperties.get().getBuild()), null) + .name("runtimeVersion") .addComp( - AppI18n.observable("runtimeVersion"), new LabelComp(System.getProperty("java.vm.version")), null) + .name("virtualMachine") .addComp( - AppI18n.observable("virtualMachine"), new LabelComp(System.getProperty("java.vm.vendor") + " " + System.getProperty("java.vm.name")), null) .buildComp(); diff --git a/app/src/main/resources/io/xpipe/app/resources/lang/preferences_en.properties b/app/src/main/resources/io/xpipe/app/resources/lang/preferences_en.properties index 8b626876..8bf579b0 100644 --- a/app/src/main/resources/io/xpipe/app/resources/lang/preferences_en.properties +++ b/app/src/main/resources/io/xpipe/app/resources/lang/preferences_en.properties @@ -64,7 +64,7 @@ developerModeDescription=When enabled, you will have access to a variety of addi editor=Editor custom=Custom customEditorCommand=Custom editor command -customEditorCommandDescription=The command to use to open the custom editor. The placeholder string $file will be replaced by the quoted absolute file name when called. +customEditorCommandDescription=The command to execute to open the custom editor. The placeholder string $file will be replaced by the quoted absolute file name when called. editorReloadTimeout=Editor reload timeout editorReloadTimeoutDescription=The amount of milliseconds to wait before reading a file after it has been updated. This avoids issues in cases where your editor is slow at writing or releasing file locks. notepad++=Notepad++ @@ -95,7 +95,7 @@ terminalProgram=Default program terminalProgramDescription=The default terminal to use when opening any kind of shell connection. This application is only used for display purposes, the started shell program depends on the shell connection itself. program=Program customTerminalCommand=Custom terminal command -customTerminalCommandDescription=The command to use to open the custom terminal. The placeholder string $cmd will be replaced by the quoted shell script file name when called. +customTerminalCommandDescription=The command to execute to open the custom terminal. The placeholder string $cmd will be replaced by the quoted shell script file name when called. cmd=cmd.exe powershell=Powershell pwsh=Powershell Core diff --git a/app/src/main/resources/io/xpipe/app/resources/lang/translations_en.properties b/app/src/main/resources/io/xpipe/app/resources/lang/translations_en.properties index ec17c324..60135a53 100644 --- a/app/src/main/resources/io/xpipe/app/resources/lang/translations_en.properties +++ b/app/src/main/resources/io/xpipe/app/resources/lang/translations_en.properties @@ -143,7 +143,7 @@ gedit=GEdit leafpad=Leafpad mousepad=Mousepad pluma=Pluma -noTerminalSet=No terminal application has been set. Please do so in the settings menu. +noTerminalSet=No terminal application has been set automatically. You can do so manually in the settings menu. textEdit=Text Edit sublime=Sublime Text newTable=new_table @@ -220,5 +220,7 @@ extensionInstallDescription=This action requires additional third party librarie extensionInstallLicenseNote=By performing the download and automatic installation you agree to the terms of the third party licenses: license=License installRequired=Installation Required +restore=Restore +restoreAllSessions=Restore all sessions diff --git a/app/src/main/resources/io/xpipe/app/resources/style/about.css b/app/src/main/resources/io/xpipe/app/resources/style/about.css index e1269795..a94cdabf 100644 --- a/app/src/main/resources/io/xpipe/app/resources/style/about.css +++ b/app/src/main/resources/io/xpipe/app/resources/style/about.css @@ -16,6 +16,10 @@ -fx-graphic-text-gap: 0.8em; } +.properties-comp .tile > * { + -fx-padding: 0.6em 0 0.6em 0; +} + .about-tab .information { -fx-spacing: 2em; } diff --git a/app/src/main/resources/io/xpipe/app/resources/style/browser.css b/app/src/main/resources/io/xpipe/app/resources/style/browser.css index bbceff46..b8bf5e97 100644 --- a/app/src/main/resources/io/xpipe/app/resources/style/browser.css +++ b/app/src/main/resources/io/xpipe/app/resources/style/browser.css @@ -4,6 +4,10 @@ -fx-padding: 1em; } +.browser .tile > * { + -fx-padding: 0.6em 0 0.6em 0; +} + .browser .overview { -fx-spacing: 1.5em; -fx-padding: 1.5em;