Workaround for settings cancel bug and cleanup

This commit is contained in:
crschnick 2023-05-19 18:26:47 +00:00
parent 7b5ea652b6
commit 8e7f3f5aab
9 changed files with 18 additions and 104 deletions

View file

@ -4,13 +4,13 @@ import atlantafx.base.theme.Styles;
import io.xpipe.app.browser.action.BrowserAction;
import io.xpipe.app.browser.icon.FileIconManager;
import io.xpipe.app.comp.base.LazyTextFieldComp;
import io.xpipe.app.fxcomps.SimpleComp;
import io.xpipe.app.fxcomps.SimpleCompStructure;
import io.xpipe.app.fxcomps.augment.ContextMenuAugment;
import io.xpipe.app.fxcomps.impl.SvgCacheComp;
import io.xpipe.app.fxcomps.util.PlatformThread;
import io.xpipe.app.fxcomps.util.SimpleChangeListener;
import io.xpipe.app.util.BusyProperty;
import io.xpipe.app.util.Containers;
import io.xpipe.app.util.HumanReadableFormat;
import io.xpipe.app.util.ThreadHelper;
import io.xpipe.core.impl.FileNames;
@ -24,7 +24,6 @@ import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.css.PseudoClass;
import javafx.geometry.Bounds;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.control.*;
@ -42,7 +41,7 @@ import java.util.Objects;
import static io.xpipe.app.util.HumanReadableFormat.byteCount;
import static javafx.scene.control.TableColumn.SortType.ASCENDING;
final class BrowserFileListComp extends AnchorPane {
final class BrowserFileListComp extends SimpleComp {
private static final PseudoClass HIDDEN = PseudoClass.getPseudoClass("hidden");
private static final PseudoClass EMPTY = PseudoClass.getPseudoClass("empty");
@ -56,14 +55,15 @@ final class BrowserFileListComp extends AnchorPane {
public BrowserFileListComp(BrowserFileListModel fileList) {
this.fileList = fileList;
}
@Override
protected Region createSimple() {
TableView<BrowserEntry> table = createTable();
SimpleChangeListener.apply(table.comparatorProperty(), (newValue) -> {
fileList.setComparator(newValue);
});
getChildren().setAll(table);
getStyleClass().addAll("table-directory-view");
Containers.setAnchors(table, Insets.EMPTY);
return table;
}
@SuppressWarnings("unchecked")

View file

@ -66,9 +66,7 @@ public class OpenFileSystemComp extends SimpleComp {
topBar.getItems()
.setAll(backBtn, forthBtn, new Spacer(10), new BrowserNavBar(model).createRegion(), filter.get(), refreshBtn, terminalBtn, menuButton);
// ~
BrowserFileListComp directoryView = new BrowserFileListComp(model.getFileList());
var directoryView = new BrowserFileListComp(model.getFileList()).createRegion();
var root = new VBox(topBar, directoryView);
if (model.getBrowserModel().getMode() == BrowserModel.Mode.BROWSER) {

View file

@ -6,7 +6,6 @@ import io.xpipe.app.core.AppI18n;
import io.xpipe.app.fxcomps.SimpleComp;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.prefs.ClearCacheAlert;
import javafx.beans.binding.Bindings;
import javafx.geometry.Pos;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.HBox;
@ -33,27 +32,6 @@ public class PrefsComp extends SimpleComp {
MasterDetailPane p = (MasterDetailPane) pfx.getCenter();
p.dividerPositionProperty().setValue(0.27);
var cancel = new ButtonComp(AppI18n.observable("cancel"), null, () -> {
AppPrefs.get().cancel();
layout.selectedProperty().setValue(layout.getEntries().get(0));
})
.createRegion();
var apply = new ButtonComp(AppI18n.observable("apply"), null, () -> {
AppPrefs.get().save();
layout.selectedProperty().setValue(layout.getEntries().get(0));
})
.createRegion();
var maxWidth = Bindings.max(cancel.widthProperty(), apply.widthProperty());
cancel.minWidthProperty().bind(maxWidth);
apply.minWidthProperty().bind(maxWidth);
var rightButtons = new HBox(apply, cancel);
rightButtons.setSpacing(8);
var rightPane = new AnchorPane(rightButtons);
rightPane.setPickOnBounds(false);
AnchorPane.setBottomAnchor(rightButtons, 15.0);
AnchorPane.setRightAnchor(rightButtons, 55.0);
var clearCaches = new ButtonComp(AppI18n.observable("clearCaches"), null, ClearCacheAlert::show).createRegion();
// var reload = new ButtonComp(AppI18n.observable("reload"), null, () -> OperationMode.reload()).createRegion();
var leftButtons = new HBox(clearCaches);
@ -65,7 +43,7 @@ public class PrefsComp extends SimpleComp {
AnchorPane.setBottomAnchor(leftButtons, 15.0);
AnchorPane.setLeftAnchor(leftButtons, 15.0);
var stack = new StackPane(pfx, rightPane, leftPane);
var stack = new StackPane(pfx, leftPane);
stack.setPickOnBounds(false);
AppFont.medium(stack);

View file

@ -27,6 +27,11 @@ public abstract class ExternalApplicationType implements PrefsChoiceValue {
public abstract boolean isAvailable();
@Override
public String toString() {
return getId();
}
public static class MacApplication extends ExternalApplicationType {
protected final String applicationName;

View file

@ -1,62 +0,0 @@
package io.xpipe.app.util;
import javafx.geometry.Insets;
import javafx.scene.Node;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.ColumnConstraints;
import javafx.scene.layout.Priority;
import javafx.scene.layout.Region;
import static javafx.scene.layout.Region.USE_COMPUTED_SIZE;
import static javafx.scene.layout.Region.USE_PREF_SIZE;
public final class Containers {
public static final ColumnConstraints H_GROW_NEVER = columnConstraints(Priority.NEVER);
public static void setAnchors(Node node, Insets insets) {
if (insets.getTop() >= 0) {
AnchorPane.setTopAnchor(node, insets.getTop());
}
if (insets.getRight() >= 0) {
AnchorPane.setRightAnchor(node, insets.getRight());
}
if (insets.getBottom() >= 0) {
AnchorPane.setBottomAnchor(node, insets.getBottom());
}
if (insets.getLeft() >= 0) {
AnchorPane.setLeftAnchor(node, insets.getLeft());
}
}
public static void setScrollConstraints(ScrollPane scrollPane,
ScrollPane.ScrollBarPolicy vbarPolicy, boolean fitHeight,
ScrollPane.ScrollBarPolicy hbarPolicy, boolean fitWidth) {
scrollPane.setVbarPolicy(vbarPolicy);
scrollPane.setFitToHeight(fitHeight);
scrollPane.setHbarPolicy(hbarPolicy);
scrollPane.setFitToWidth(fitWidth);
}
public static ColumnConstraints columnConstraints(Priority hgrow) {
return columnConstraints(USE_COMPUTED_SIZE, hgrow);
}
public static ColumnConstraints columnConstraints(double minWidth, Priority hgrow) {
double maxWidth = hgrow == Priority.ALWAYS ? Double.MAX_VALUE : USE_PREF_SIZE;
ColumnConstraints constraints = new ColumnConstraints(minWidth, USE_COMPUTED_SIZE, maxWidth);
constraints.setHgrow(hgrow);
return constraints;
}
public static void usePrefWidth(Region region) {
region.setMinWidth(USE_PREF_SIZE);
region.setMaxWidth(USE_PREF_SIZE);
}
public static void usePrefHeight(Region region) {
region.setMinHeight(USE_PREF_SIZE);
region.setMaxHeight(USE_PREF_SIZE);
}
}

View file

@ -1,5 +0,0 @@
package io.xpipe.app.util;
public final class Controls {
}

View file

@ -12,6 +12,8 @@ lockCreationAlertHeader=Set your new lock password
finish=Finish
error=Error
ok=Ok
newFile=New file
newDirectory=New directory
password=Password
unlockAlertTitle=Unlock workspace
unlockAlertHeader=Enter your lock password to continue

View file

@ -148,7 +148,7 @@
visibility: hidden ;
}
.browser .table-directory-view .table-view {
.browser .table-view {
-color-header-bg: -color-bg-default;
-color-cell-bg-selected: -color-neutral-emphasis;
-color-cell-fg-selected: -color-fg-emphasis;
@ -161,7 +161,7 @@
-fx-opacity: 0.75;
}
.browser .table-directory-view .table-view:drag-into-current .table-row-cell {
.browser .table-view:drag-into-current .table-row-cell {
-fx-opacity: 0.8;
}

View file

@ -1,5 +1,4 @@
.modal-overlay-comp .titled-pane {
-fx-font-size: 1.6em;
-fx-padding: 0;
-fx-border-radius: 0;
}
@ -10,7 +9,6 @@
}
.modal-overlay-comp .titled-pane > * {
-fx-font-size: 1.0em;
-fx-border-radius: 0;
}