Fixes [stage]

This commit is contained in:
crschnick
2024-12-26 14:39:44 +00:00
parent fd6517cf22
commit b120cf45d8
7 changed files with 48 additions and 71 deletions
@@ -1,5 +1,7 @@
package io.xpipe.app.beacon.impl;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.prefs.ExternalApplicationType;
import io.xpipe.app.terminal.TerminalView;
import io.xpipe.app.util.AskpassAlert;
import io.xpipe.app.util.SecretManager;
@@ -8,6 +10,7 @@ import io.xpipe.beacon.BeaconClientException;
import io.xpipe.beacon.api.AskpassExchange;
import com.sun.net.httpserver.HttpExchange;
import io.xpipe.core.process.OsType;
public class AskpassExchangeImpl extends AskpassExchange {
@@ -58,9 +61,17 @@ public class AskpassExchangeImpl extends AskpassExchange {
}
var control = term.get().controllable();
control.ifPresent(controllableTerminalSession -> {
controllableTerminalSession.focus();
});
if (control.isPresent()) {
control.get().focus();
} else {
if (OsType.getLocal() == OsType.MACOS) {
// Just focus the app, this is correct most of the time
var terminalType = AppPrefs.get().terminalType().getValue();
if (terminalType instanceof ExternalApplicationType.MacApplication m) {
m.focus();
}
}
}
}
@Override
@@ -1,60 +0,0 @@
package io.xpipe.app.comp.base;
import io.xpipe.app.comp.Comp;
import io.xpipe.app.comp.SimpleComp;
import io.xpipe.app.util.LabelGraphic;
import io.xpipe.app.util.PlatformThread;
import javafx.beans.property.Property;
import javafx.beans.property.SimpleObjectProperty;
import javafx.scene.control.TextArea;
import javafx.scene.layout.Region;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import lombok.AccessLevel;
import lombok.experimental.FieldDefaults;
import org.kordamp.ikonli.javafx.FontIcon;
@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
public class ErrorOverlayComp extends SimpleComp {
Comp<?> background;
Property<String> text;
public ErrorOverlayComp(Comp<?> background, Property<String> text) {
this.background = background;
this.text = text;
}
@Override
protected Region createSimple() {
var content = new SimpleObjectProperty<ModalOverlay>();
this.text.addListener((observable, oldValue, newValue) -> {
PlatformThread.runLaterIfNeeded(() -> {
var comp = Comp.of(() -> {
var l = new TextArea();
l.textProperty().bind(PlatformThread.sync(text));
l.setWrapText(true);
l.getStyleClass().add("error-overlay-comp");
l.setEditable(false);
return l;
});
var overlay = ModalOverlay.of("error", comp, new LabelGraphic.NodeGraphic(() -> {
var graphic = new FontIcon("mdomz-warning");
graphic.setIconColor(Color.RED);
return new StackPane(graphic);
}))
.withDefaultButtons();
content.set(overlay);
});
});
content.addListener((observable, oldValue, newValue) -> {
// Handle close
if (newValue == null) {
this.text.setValue(null);
}
});
return new ModalOverlayComp(background, content).createRegion();
}
}
@@ -219,8 +219,8 @@ public class ModalOverlayComp extends SimpleComp {
modalBox.setMinHeight(100);
modalBox.prefWidthProperty().bind(modalBoxWidth(pane, r));
modalBox.maxWidthProperty().bind(modalBox.prefWidthProperty());
modalBox.prefHeightProperty().bind(modalBoxHeight(pane, content));
modalBox.maxHeightProperty().bind(modalBox.prefHeightProperty());
modalBox.prefHeightProperty().bind(modalBoxHeight(pane, modalBox, content));
modalBox.setMaxHeight(Region.USE_PREF_SIZE);
modalBox.focusedProperty().addListener((o, old, n) -> {
if (n) {
content.requestFocus();
@@ -251,7 +251,7 @@ public class ModalOverlayComp extends SimpleComp {
r.prefWidthProperty());
}
private ObservableDoubleValue modalBoxHeight(ModalPane pane, Region content) {
private ObservableDoubleValue modalBoxHeight(ModalPane pane, ModalBox box, Region content) {
return Bindings.createDoubleBinding(
() -> {
var max = pane.getHeight() - 50;
@@ -263,8 +263,12 @@ public class ModalOverlayComp extends SimpleComp {
},
pane.heightProperty(),
pane.prefHeightProperty(),
box.heightProperty(),
box.prefHeightProperty(),
box.maxHeightProperty(),
content.prefHeightProperty(),
content.heightProperty());
content.heightProperty(),
content.maxHeightProperty());
}
private Button toButton(ModalButton mb) {
@@ -7,6 +7,8 @@ import io.xpipe.app.comp.SimpleCompStructure;
import javafx.beans.value.ObservableValue;
import javafx.scene.control.TitledPane;
import java.util.concurrent.atomic.AtomicInteger;
public class TitledPaneComp extends Comp<CompStructure<TitledPane>> {
private final ObservableValue<String> name;
@@ -26,6 +28,17 @@ public class TitledPaneComp extends Comp<CompStructure<TitledPane>> {
tp.getStyleClass().add("titled-pane-comp");
tp.setExpanded(false);
tp.setAnimated(false);
AtomicInteger minimizedSize = new AtomicInteger();
tp.expandedProperty().addListener((c, o, n) -> {
if (n) {
if (minimizedSize.get() == 0) {
minimizedSize.set((int) tp.getHeight());
}
tp.setPrefHeight(height);
} else {
tp.setPrefHeight(minimizedSize.get());
}
});
return new SimpleCompStructure<>(tp);
}
}
@@ -158,8 +158,8 @@ public class ErrorHandlerComp extends SimpleComp {
content.setFillWidth(true);
content.setMinHeight(Region.USE_PREF_SIZE);
var layout = new BorderPane();
layout.setCenter(content);
var layout = new VBox();
layout.getChildren().add(content);
layout.getStyleClass().add("error-handler-comp");
layout.getStyleClass().add("background");
@@ -167,7 +167,8 @@ public class ErrorHandlerComp extends SimpleComp {
content.getChildren().add(new Separator(Orientation.HORIZONTAL));
var details = createDetails();
AppFont.medium(details);
layout.setBottom(details);
layout.getChildren().add(details);
layout.prefHeightProperty().bind(content.heightProperty().add(65).add(details.prefHeightProperty()));
}
return layout;
@@ -56,6 +56,14 @@ public abstract class ExternalApplicationType implements PrefsChoiceValue {
}
}
public void focus() {
try (ShellControl pc = LocalShell.getShell().start()) {
pc.command(String.format("open -a \"%s.app\"", applicationName)).execute();
} catch (Exception e) {
ErrorEvent.fromThrowable(e).handle();
}
}
@Override
public boolean isSelectable() {
return OsType.getLocal().equals(OsType.MACOS);
+1 -1
View File
@@ -1 +1 @@
14.0-21
14.0-22