diff --git a/app/src/main/java/io/xpipe/app/launcher/LauncherCommand.java b/app/src/main/java/io/xpipe/app/launcher/LauncherCommand.java index 47bf8c3e..00381c91 100644 --- a/app/src/main/java/io/xpipe/app/launcher/LauncherCommand.java +++ b/app/src/main/java/io/xpipe/app/launcher/LauncherCommand.java @@ -6,6 +6,7 @@ import io.xpipe.app.core.mode.OperationMode; import io.xpipe.app.issue.ErrorEvent; import io.xpipe.app.issue.LogErrorHandler; import io.xpipe.app.issue.TrackEvent; +import io.xpipe.app.prefs.AppPrefs; import io.xpipe.app.util.ThreadHelper; import io.xpipe.beacon.BeaconServer; import io.xpipe.beacon.exchange.FocusExchange; @@ -112,7 +113,7 @@ public class LauncherCommand implements Callable { return XPipeDaemonMode.get(opModeName); } - return XPipeDaemonMode.GUI; + return AppPrefs.get().startupBehaviour().getValue().getMode(); } @Override diff --git a/app/src/main/java/io/xpipe/app/prefs/AppPrefs.java b/app/src/main/java/io/xpipe/app/prefs/AppPrefs.java index 334458b5..567b5e96 100644 --- a/app/src/main/java/io/xpipe/app/prefs/AppPrefs.java +++ b/app/src/main/java/io/xpipe/app/prefs/AppPrefs.java @@ -80,8 +80,6 @@ public class AppPrefs { FXCollections.observableArrayList(PrefsChoiceValue.getSupported(CloseBehaviour.class))); private final SimpleListProperty externalEditorList = new SimpleListProperty<>( FXCollections.observableArrayList(PrefsChoiceValue.getSupported(ExternalEditorType.class))); - private final SimpleListProperty externalStartupBehaviourList = new SimpleListProperty<>( - FXCollections.observableArrayList(PrefsChoiceValue.getSupported(ExternalStartupBehaviour.class))); private final SimpleListProperty logLevelList = new SimpleListProperty<>(FXCollections.observableArrayList("trace", "debug", "info", "warn", "error")); private final Map> classMap = new HashMap<>(); @@ -160,11 +158,13 @@ public class AppPrefs { // Start behaviour // =============== - private final ObjectProperty externalStartupBehaviour = - typed(new SimpleObjectProperty<>(ExternalStartupBehaviour.TRAY), ExternalStartupBehaviour.class); + private final SimpleListProperty startupBehaviourList = new SimpleListProperty<>( + FXCollections.observableArrayList(PrefsChoiceValue.getSupported(StartupBehaviour.class))); + private final ObjectProperty startupBehaviour = + typed(new SimpleObjectProperty<>(StartupBehaviour.GUI), StartupBehaviour.class); - private final SingleSelectionField externalStartupBehaviourControl = - Field.ofSingleSelectionType(externalStartupBehaviourList, externalStartupBehaviour) + private final SingleSelectionField startupBehaviourControl = + Field.ofSingleSelectionType(startupBehaviourList, startupBehaviour) .render(() -> new TranslatableComboBoxControl<>()); // Close behaviour @@ -311,8 +311,8 @@ public class AppPrefs { return editorReloadTimeout; } - public ReadOnlyProperty externalStartupBehaviour() { - return externalStartupBehaviour; + public ReadOnlyProperty startupBehaviour() { + return startupBehaviour; } public ReadOnlyBooleanProperty automaticallyUpdate() { @@ -524,9 +524,10 @@ public class AppPrefs { Group.of( "appBehaviour", Setting.of( - "externalStartupBehaviour", - externalStartupBehaviourControl, - externalStartupBehaviour), + "startupBehaviour", + startupBehaviourControl, + startupBehaviour + ), Setting.of("closeBehaviour", closeBehaviourControl, closeBehaviour)), Group.of("security", Setting.of("workspaceLock", lockCryptControl, lockCrypt)), Group.of( diff --git a/app/src/main/java/io/xpipe/app/prefs/ExternalStartupBehaviour.java b/app/src/main/java/io/xpipe/app/prefs/StartupBehaviour.java similarity index 50% rename from app/src/main/java/io/xpipe/app/prefs/ExternalStartupBehaviour.java rename to app/src/main/java/io/xpipe/app/prefs/StartupBehaviour.java index 0911c52d..d86e8bb0 100644 --- a/app/src/main/java/io/xpipe/app/prefs/ExternalStartupBehaviour.java +++ b/app/src/main/java/io/xpipe/app/prefs/StartupBehaviour.java @@ -1,18 +1,18 @@ package io.xpipe.app.prefs; -import io.xpipe.app.core.mode.OperationMode; import io.xpipe.app.ext.PrefsChoiceValue; +import io.xpipe.core.util.XPipeDaemonMode; import lombok.AllArgsConstructor; import lombok.Getter; @Getter @AllArgsConstructor -public enum ExternalStartupBehaviour implements PrefsChoiceValue { - GUI("app.startGui", OperationMode.GUI), - TRAY("app.startInTray", OperationMode.TRAY); +public enum StartupBehaviour implements PrefsChoiceValue { + GUI("app.startGui", XPipeDaemonMode.GUI), + TRAY("app.startInTray", XPipeDaemonMode.TRAY); private final String id; - private final OperationMode mode; + private final XPipeDaemonMode mode; public boolean isSelectable() { return true; diff --git a/app/src/main/resources/io/xpipe/app/resources/lang/preferences_en.properties b/app/src/main/resources/io/xpipe/app/resources/lang/preferences_en.properties index b5478bda..67bb9531 100644 --- a/app/src/main/resources/io/xpipe/app/resources/lang/preferences_en.properties +++ b/app/src/main/resources/io/xpipe/app/resources/lang/preferences_en.properties @@ -35,8 +35,8 @@ continueInBackground=Continue in background minimizeToTray=Minimize to tray closeBehaviourAlertTitle=Set closing behaviour closeBehaviourAlertTitleHeader=Select what should happen when closing the window. -externalStartupBehaviour=External startup behaviour -externalStartupBehaviourDescription=Controls the behavior of the desktop application when XPipe is started from for example the CLI or an API. +startupBehaviour=Startup behaviour +startupBehaviourDescription=Controls the default behavior of the desktop application when XPipe is started. clearCachesAlertTitle=Clean Cache clearCachesAlertTitleHeader=Do you want to clean all XPipe caches? clearCachesAlertTitleContent=Note that this will delete all the data that is stored to improve the user experience.