This commit is contained in:
crschnick
2024-12-24 17:15:11 +00:00
parent 3a47f0c06a
commit 1d52d3bdc3
8 changed files with 91 additions and 20 deletions

View File

@@ -0,0 +1,33 @@
package io.xpipe.app.comp.base;
import atlantafx.base.layout.InputGroup;
import io.xpipe.app.comp.Comp;
import io.xpipe.app.comp.CompStructure;
import io.xpipe.app.comp.SimpleCompStructure;
import javafx.geometry.Pos;
import java.util.List;
public class InputGroupComp extends Comp<CompStructure<InputGroup>> {
private final List<Comp<?>> entries;
public InputGroupComp(List<Comp<?>> comps) {
entries = List.copyOf(comps);
}
public Comp<CompStructure<InputGroup>> spacing(double spacing) {
return apply(struc -> struc.get().setSpacing(spacing));
}
@Override
public CompStructure<InputGroup> createBase() {
InputGroup b = new InputGroup();
b.getStyleClass().add("input-group-comp");
for (var entry : entries) {
b.getChildren().add(entry.createRegion());
}
b.setAlignment(Pos.CENTER);
return new SimpleCompStructure<>(b);
}
}

View File

@@ -1,5 +1,6 @@
package io.xpipe.app.comp.base;
import atlantafx.base.controls.Spacer;
import io.xpipe.app.comp.Comp;
import io.xpipe.app.comp.CompStructure;
import io.xpipe.app.core.AppFont;
@@ -13,6 +14,7 @@ import javafx.event.ActionEvent;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;
import lombok.*;
@@ -31,6 +33,9 @@ public class TileButtonComp extends Comp<TileButtonComp.Structure> {
@Setter
private double iconSize = 0.55;
@Setter
private Comp<?> right;
public TileButtonComp(String nameKey, String descriptionKey, String icon, Consumer<ActionEvent> action) {
this.name = AppI18n.observable(nameKey);
this.description = AppI18n.observable(descriptionKey);
@@ -54,7 +59,9 @@ public class TileButtonComp extends Comp<TileButtonComp.Structure> {
var bt = new Button();
bt.getStyleClass().add("tile-button-comp");
bt.setOnAction(e -> {
action.accept(e);
if (action != null) {
action.accept(e);
}
});
var header = new Label();
@@ -69,6 +76,11 @@ public class TileButtonComp extends Comp<TileButtonComp.Structure> {
var fi = new FontIconComp(icon).createStructure();
var pane = fi.getPane();
var hbox = new HBox(pane, text);
Region rightRegion = right != null ? right.createRegion() : null;
if (rightRegion != null) {
hbox.getChildren().add(new Spacer());
hbox.getChildren().add(rightRegion);
}
hbox.setSpacing(8);
pane.prefWidthProperty()
.bind(Bindings.createDoubleBinding(
@@ -91,6 +103,7 @@ public class TileButtonComp extends Comp<TileButtonComp.Structure> {
.content(hbox)
.name(header)
.description(desc)
.right(rightRegion)
.build();
}
@@ -102,6 +115,7 @@ public class TileButtonComp extends Comp<TileButtonComp.Structure> {
FontIcon graphic;
Label name;
Label description;
Region right;
@Override
public Button get() {

View File

@@ -17,12 +17,11 @@ public class AppPtbCheck {
return;
}
var content = AppWindowHelper.dialogText("You are running a PTB build of XPipe."
var content = AppDialog.dialogText("You are running a PTB build of XPipe."
+ " This version is unstable and might contain bugs."
+ " You should not use it as a daily driver."
+ " It will also not receive regular updates after its testing period."
+ " You will have to install and launch the normal XPipe release for that.");
;
var modal = ModalOverlay.of("ptbNotice", content);
modal.persist();
modal.addButton(ModalButton.ok());

View File

@@ -226,13 +226,17 @@ public abstract class OperationMode {
return ALL;
}
public static void startNewInstance() throws Exception {
var loc = AppProperties.get().isDevelopmentEnvironment()
? XPipeInstallation.getLocalDefaultInstallationBasePath()
: XPipeInstallation.getCurrentInstallationBasePath().toString();
var exec = XPipeInstallation.createExternalAsyncLaunchCommand(loc, XPipeDaemonMode.GUI, "", true);
LocalShell.getShell().executeSimpleCommand(exec);
}
public static void restart() {
OperationMode.executeAfterShutdown(() -> {
var loc = AppProperties.get().isDevelopmentEnvironment()
? XPipeInstallation.getLocalDefaultInstallationBasePath()
: XPipeInstallation.getCurrentInstallationBasePath().toString();
var exec = XPipeInstallation.createExternalAsyncLaunchCommand(loc, XPipeDaemonMode.GUI, "", true);
LocalShell.getShell().executeSimpleCommand(exec);
startNewInstance();
});
}

View File

@@ -1,6 +1,11 @@
package io.xpipe.app.core.window;
import atlantafx.base.layout.ModalBox;
import io.xpipe.app.comp.Comp;
import io.xpipe.app.comp.base.ModalButton;
import io.xpipe.app.comp.base.ModalOverlay;
import io.xpipe.app.core.AppFont;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.util.PlatformInit;
import io.xpipe.app.util.PlatformThread;
import io.xpipe.app.util.ThreadHelper;
@@ -9,10 +14,14 @@ import javafx.animation.PauseTransition;
import javafx.application.Platform;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Text;
import javafx.util.Duration;
import lombok.Getter;
import java.util.concurrent.atomic.AtomicBoolean;
public class AppDialog {
@Getter
@@ -63,4 +72,25 @@ public class AppDialog {
waitForClose();
}
}
public static Comp<?> dialogText(String s) {
return Comp.of(() -> {
var text = new Text(s);
text.setWrappingWidth(450);
AppFont.medium(text);
var sp = new StackPane(text);
return sp;
})
.prefWidth(450);
}
public static boolean confirm(String translationKey) {
var confirmed = new AtomicBoolean(false);
var content = dialogText(AppI18n.get(translationKey + "Content"));
var modal = ModalOverlay.of(translationKey + "Title", content);
modal.addButton(ModalButton.cancel());
modal.addButton(ModalButton.ok(() -> confirmed.set(true)));
showAndWait(modal);
return confirmed.get();
}
}

View File

@@ -47,17 +47,6 @@ public class AppWindowHelper {
return alertContentText(s, 450);
}
public static Comp<?> dialogText(String s) {
return Comp.of(() -> {
var text = new Text(s);
text.setWrappingWidth(450);
AppFont.medium(text);
var sp = new StackPane(text);
return sp;
})
.prefWidth(450);
}
public static Region alertContentText(String s, int width) {
var text = new Text(s);
text.setWrappingWidth(width);

View File

@@ -49,7 +49,7 @@ public abstract class ExternalApplicationType implements PrefsChoiceValue {
"mdfind -literal 'kMDItemFSName = \"%s.app\"' -onlyin /Applications -onlyin ~/Applications -onlyin /System/Applications",
applicationName))
.readStdoutIfPossible();
return out.isPresent() && !out.get().isBlank();
return out.isPresent() && !out.get().isBlank() && out.get().contains(applicationName + ".app");
} catch (Exception e) {
ErrorEvent.fromThrowable(e).handle();
return false;

View File

@@ -599,3 +599,5 @@ loadingSettings=Loading settings ...
loadingConnections=Loading connections ...
renderingContent=Rendering content ...
ptbNotice=Notice for the public test build
userDeletionTitle=User deletion
userDeletionContent=Do you want to delete this user? This will also remove all personal identities and connections of this user. XPipe will restart to apply the user changes.