Various small fixes

This commit is contained in:
crschnick 2025-03-01 11:40:51 +00:00
parent 6958a4979c
commit ee82a912fa
11 changed files with 71 additions and 110 deletions

View file

@ -32,23 +32,6 @@ import java.util.function.Function;
public class StoreEntryListOverviewComp extends SimpleComp {
private final Property<StoreSortMode> sortMode;
public StoreEntryListOverviewComp() {
this.sortMode = new SimpleObjectProperty<>();
StoreViewState.get().getActiveCategory().subscribe(val -> {
sortMode.setValue(val.getSortMode().getValue());
});
sortMode.addListener((observable, oldValue, newValue) -> {
var cat = StoreViewState.get().getActiveCategory().getValue();
if (cat == null) {
return;
}
cat.getSortMode().setValue(newValue);
});
}
private Region createGroupListHeader() {
var label = new Label();
var name = BindingsHelper.flatMap(
@ -142,6 +125,7 @@ public class StoreEntryListOverviewComp extends SimpleComp {
}
private Comp<?> createAlphabeticalSortButton() {
var sortMode = StoreViewState.get().getSortMode();
var icon = Bindings.createObjectBinding(
() -> {
if (sortMode.getValue() == StoreSortMode.ALPHABETICAL_ASC) {
@ -182,6 +166,7 @@ public class StoreEntryListOverviewComp extends SimpleComp {
}
private Comp<?> createDateSortButton() {
var sortMode = StoreViewState.get().getSortMode();
var icon = Bindings.createObjectBinding(
() -> {
if (sortMode.getValue() == StoreSortMode.DATE_ASC) {

View file

@ -39,6 +39,9 @@ public class StoreViewState {
@Getter
private final Property<StoreCategoryWrapper> activeCategory = new SimpleObjectProperty<>();
@Getter
private final Property<StoreSortMode> sortMode = new SimpleObjectProperty<>();
@Getter
private StoreSection currentTopLevelSection;
@ -125,8 +128,17 @@ public class StoreViewState {
.map(StoreCategoryWrapper::new)
.toList()));
sortMode.addListener((observable, oldValue, newValue) -> {
var cat = getActiveCategory().getValue();
if (cat == null) {
return;
}
cat.getSortMode().setValue(newValue);
});
activeCategory.addListener((observable, oldValue, newValue) -> {
DataStorage.get().setSelectedCategory(newValue.getCategory());
sortMode.setValue(newValue.getSortMode().getValue());
});
var selected = AppCache.getNonNull("selectedCategory", UUID.class, () -> DataStorage.DEFAULT_CATEGORY_UUID);
activeCategory.setValue(categories.getList().stream()

View file

@ -1,36 +0,0 @@
package io.xpipe.app.core.check;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.core.process.OsType;
import java.util.concurrent.TimeUnit;
public class AppBundledToolsCheck {
private static boolean getResult() {
var fc = new ProcessBuilder("where", "ssh")
.redirectErrorStream(true)
.redirectOutput(ProcessBuilder.Redirect.DISCARD);
try {
var proc = fc.start();
proc.waitFor(2, TimeUnit.SECONDS);
return proc.exitValue() == 0;
} catch (Exception e) {
return false;
}
}
public static void check() {
if (AppPrefs.get().useBundledTools().get()) {
return;
}
if (!OsType.getLocal().equals(OsType.WINDOWS)) {
return;
}
if (!getResult()) {
AppPrefs.get().useBundledTools.set(true);
}
}
}

View file

@ -56,9 +56,6 @@ public class BaseMode extends OperationMode {
TrackEvent.info("Initializing base mode components ...");
AppMainWindow.loadingText("initializingApp");
LicenseProvider.get().init();
// We no longer need this
// AppCertutilCheck.check();
AppBundledToolsCheck.check();
AppHomebrewCoreutilsCheck.check();
AppAvCheck.check();
AppJavaOptionsCheck.check();

View file

@ -32,8 +32,8 @@ public class AboutCategory extends AppPrefsCategory {
.grow(true, false),
null)
.addComp(
new TileButtonComp("slack", "slackDescription", "mdi2s-slack", e -> {
Hyperlinks.open(Hyperlinks.SLACK);
new TileButtonComp("documentation", "documentationDescription", "mdi2b-book-open-variant", e -> {
Hyperlinks.open(Hyperlinks.DOCS);
e.consume();
})
.grow(true, false),
@ -45,13 +45,6 @@ public class AboutCategory extends AppPrefsCategory {
})
.grow(true, false),
null)
.addComp(
new TileButtonComp("securityPolicy", "securityPolicyDescription", "mdrmz-security", e -> {
Hyperlinks.open(Hyperlinks.DOCS_SECURITY);
e.consume();
})
.grow(true, false),
null)
.addComp(
new TileButtonComp("privacy", "privacyDescription", "mdomz-privacy_tip", e -> {
Hyperlinks.open(Hyperlinks.DOCS_PRIVACY);
@ -66,7 +59,8 @@ public class AboutCategory extends AppPrefsCategory {
.styleClass("open-source-notices");
var modal = ModalOverlay.of("openSourceNotices", comp);
modal.show();
}))
})
.grow(true, false))
.addComp(
new TileButtonComp("eula", "eulaDescription", "mdi2c-card-text-outline", e -> {
Hyperlinks.open(Hyperlinks.DOCS_EULA);

View file

@ -9,6 +9,7 @@ import io.xpipe.app.icon.SystemIconSource;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.terminal.ExternalTerminalType;
import io.xpipe.app.util.PlatformState;
import io.xpipe.app.util.PlatformThread;
import io.xpipe.core.util.ModuleHelper;
@ -57,8 +58,6 @@ public class AppPrefs {
mapVaultShared(new SimpleBooleanProperty(false), "dontAcceptNewHostKeys", Boolean.class, false);
public final BooleanProperty performanceMode =
mapLocal(new SimpleBooleanProperty(), "performanceMode", Boolean.class, false);
public final BooleanProperty useBundledTools =
mapLocal(new SimpleBooleanProperty(false), "useBundledTools", Boolean.class, true);
public final ObjectProperty<AppTheme.Theme> theme =
mapLocal(new SimpleObjectProperty<>(), "theme", AppTheme.Theme.class, false);
final BooleanProperty useSystemFont =
@ -326,10 +325,6 @@ public class AppPrefs {
return performanceMode;
}
public ObservableBooleanValue useBundledTools() {
return useBundledTools;
}
public ObservableValue<Boolean> useSystemFont() {
return useSystemFont;
}
@ -510,6 +505,9 @@ public class AppPrefs {
} else if (System.getProperty("os.name").toLowerCase().contains("server")) {
performanceMode.setValue(true);
}
var f = PlatformState.determineDefaultScalingFactor();
uiScale.setValue(f.isPresent() ? f.getAsInt() : null);
}
}

View file

@ -30,8 +30,6 @@ public class ConnectionsCategory extends AppPrefsCategory {
if (OsType.getLocal() == OsType.WINDOWS) {
options.addTitle("sshConfiguration")
.sub(new OptionsBuilder()
.pref(prefs.useBundledTools)
.addToggle(prefs.useBundledTools)
.addComp(prefs.getCustomComp("x11WslInstance")));
}
return options.buildComp();

View file

@ -4,6 +4,7 @@ import io.xpipe.app.core.check.AppSystemFontCheck;
import io.xpipe.app.core.window.ModifiedStage;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.core.process.CommandBuilder;
import io.xpipe.core.process.OsType;
import javafx.application.Platform;
@ -14,6 +15,7 @@ import lombok.Setter;
import org.apache.commons.lang3.SystemUtils;
import java.awt.*;
import java.util.OptionalInt;
import java.util.concurrent.CountDownLatch;
public enum PlatformState {
@ -166,4 +168,45 @@ public enum PlatformState {
return;
}
}
public static OptionalInt determineDefaultScalingFactor() {
if (OsType.getLocal() != OsType.LINUX) {
return OptionalInt.empty();
}
try (var sc = LocalShell.getShell().start()) {
var factor = sc.command(CommandBuilder.of().add("gsettings", "get", "org.gnome.desktop.interface", "scaling-factor")).readStdoutIfPossible();
if (factor.isEmpty()) {
return OptionalInt.empty();
}
var readCustom = factor.get().equals("uint32 1") || factor.get().equals("uint32 2");
if (!readCustom) {
return OptionalInt.empty();
}
var textFactor = sc.command(CommandBuilder.of().add("gsettings", "get", "org.gnome.desktop.interface", "text-scaling-factor")).readStdoutIfPossible();
if (textFactor.isEmpty()) {
return OptionalInt.empty();
}
var s = textFactor.get();
if (s.equals("1.0")) {
return OptionalInt.empty();
} else if (s.equals("2.0")) {
return OptionalInt.of(200);
} else if (s.equals("1.25")) {
return OptionalInt.of(125);
} else if (s.equals("1.5")) {
return OptionalInt.of(150);
} else if (s.equals("1.75")) {
return OptionalInt.of(175);
} else {
return OptionalInt.empty();
}
} catch (Exception e) {
ErrorEvent.fromThrowable(e).handle();
return OptionalInt.empty();
}
}
}

View file

@ -201,19 +201,12 @@ public class SshLocalBridge {
}
private static String getSshd(ShellControl sc) throws Exception {
if (OsType.getLocal() == OsType.WINDOWS) {
return XPipeInstallation.getLocalBundledToolsDirectory()
.resolve("openssh")
.resolve("sshd")
.toString();
} else {
var exec = CommandSupport.findProgram(sc, "sshd");
if (exec.isEmpty()) {
throw ErrorEvent.expected(new IllegalStateException(
"No sshd executable found in PATH. The SSH terminal bridge requires a local ssh server"));
}
return exec.get();
var exec = CommandSupport.findProgram(sc, "sshd");
if (exec.isEmpty()) {
throw ErrorEvent.expected(new IllegalStateException(
"No sshd executable found in PATH. The SSH terminal bridge requires a local ssh server"));
}
return exec.get();
}
public static void reset() {

View file

@ -14,7 +14,6 @@ import java.util.Optional;
public class XPipeInstallation {
public static final String DATA_DIR_PROP = "io.xpipe.app.dataDir";
private static final String STAGING_PROP = "io.xpipe.app.staging";
@Getter
@ -157,29 +156,6 @@ public class XPipeInstallation {
return v;
}
public static Path getLocalBundledToolsDirectory() {
Path path = getCurrentInstallationBasePath();
// Check for development environment
if (!ModuleHelper.isImage()) {
if (OsType.getLocal().equals(OsType.WINDOWS)) {
return path.resolve("dist").resolve("bundled_bin").resolve("windows");
} else if (OsType.getLocal().equals(OsType.LINUX)) {
return path.resolve("dist").resolve("bundled_bin").resolve("linux");
} else {
return path.resolve("dist").resolve("bundled_bin").resolve("osx");
}
}
if (OsType.getLocal().equals(OsType.WINDOWS)) {
return path.resolve("bundled");
} else if (OsType.getLocal().equals(OsType.LINUX)) {
return path.resolve("bundled");
} else {
return path.resolve("Contents").resolve("Resources").resolve("bundled");
}
}
public static String getLocalDefaultCliExecutable() {
Path path = ModuleHelper.isImage()
? getCurrentInstallationBasePath()

View file

@ -1345,3 +1345,4 @@ upgradeInstructions=Upgrade instructions
externalLaunchTitle=External launch request
externalLaunchContent=An external terminal has requested to launch a shell connection. Do you want to allow launching shell connections from outside XPipe?
noScriptStateAvailable=Refresh to determine script compatibility ...
documentationDescription=Check out the documentation