Fix action shortcut issues

This commit is contained in:
crschnick
2025-09-03 23:23:18 +00:00
parent dc8cf7de85
commit a88e222b50
3 changed files with 34 additions and 6 deletions

View File

@@ -7,6 +7,7 @@ import io.xpipe.app.comp.base.ButtonComp;
import io.xpipe.app.comp.base.InputGroupComp;
import io.xpipe.app.comp.base.TextFieldComp;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.core.AppInstallation;
import io.xpipe.app.update.AppDistributionType;
import io.xpipe.app.util.*;
@@ -60,6 +61,7 @@ public class ActionShortcutComp extends SimpleComp {
field.grow(true, false);
field.apply(struc -> struc.get().setEditable(false));
var group = new InputGroupComp(List.of(field, copyButton));
group.setHeightReference(copyButton);
return group;
}
@@ -74,7 +76,8 @@ public class ActionShortcutComp extends SimpleComp {
});
var copyButton = new ButtonComp(null, new FontIcon("mdi2f-file-move-outline"), () -> {
ThreadHelper.runFailableAsync(() -> {
var file = DesktopShortcuts.createCliOpen(url.getValue(), name.getValue());
var exec = AppInstallation.ofCurrent().getCliExecutablePath().toString();
var file = DesktopShortcuts.create(exec, "open \"" + url.getValue() + "\"", name.getValue());
DesktopHelper.browseFileInDirectory(file);
});
})
@@ -83,6 +86,7 @@ public class ActionShortcutComp extends SimpleComp {
var field = new TextFieldComp(name);
field.grow(true, false);
var group = new InputGroupComp(List.of(field, copyButton));
group.setHeightReference(copyButton);
return group;
}
@@ -103,6 +107,7 @@ public class ActionShortcutComp extends SimpleComp {
field.grow(true, false);
field.apply(struc -> struc.get().setEditable(false));
var group = new InputGroupComp(List.of(field, copyButton));
group.setHeightReference(copyButton);
return group;
}

View File

@@ -4,9 +4,12 @@ import io.xpipe.app.comp.Comp;
import io.xpipe.app.comp.CompStructure;
import io.xpipe.app.comp.SimpleCompStructure;
import io.xpipe.app.core.AppFontSizes;
import javafx.geometry.Pos;
import atlantafx.base.layout.InputGroup;
import javafx.scene.layout.Region;
import lombok.Setter;
import java.util.List;
@@ -14,6 +17,9 @@ public class InputGroupComp extends Comp<CompStructure<InputGroup>> {
private final List<Comp<?>> entries;
@Setter
private Comp<?> heightReference;
public InputGroupComp(List<Comp<?>> comps) {
entries = List.copyOf(comps);
}
@@ -30,6 +36,28 @@ public class InputGroupComp extends Comp<CompStructure<InputGroup>> {
b.getChildren().add(entry.createRegion());
}
b.setAlignment(Pos.CENTER);
if (heightReference != null && entries.contains(heightReference)) {
var refIndex = entries.indexOf(heightReference);
var ref = b.getChildren().get(refIndex);
if (ref instanceof Region refR) {
for (int i = 0; i < entries.size(); i++) {
if (i == refIndex) {
continue;
}
var entry = b.getChildren().get(i);
if (!(entry instanceof Region entryR)) {
continue;
}
entryR.minHeightProperty().bind(refR.heightProperty());
entryR.maxHeightProperty().bind(refR.heightProperty());
entryR.prefHeightProperty().bind(refR.heightProperty());
}
}
}
return new SimpleCompStructure<>(b);
}
}

View File

@@ -123,11 +123,6 @@ public class DesktopShortcuts {
return base;
}
public static Path createCliOpen(String action, String name) throws Exception {
var exec = AppInstallation.ofCurrent().getCliExecutablePath().toString();
return create(exec, "open " + action, name);
}
public static Path create(String executable, String args, String name) throws Exception {
var compat = OsFileSystem.ofLocal().makeFileSystemCompatible(name);
if (OsType.getLocal() == OsType.WINDOWS) {