Fix operation mode handling when tray is not available

This commit is contained in:
crschnick
2023-08-04 05:03:24 +00:00
parent 03b5b67a42
commit 5c6b98fd14
7 changed files with 69 additions and 22 deletions

View File

@@ -53,7 +53,11 @@ public class SideMenuBarComp extends Comp<CompStructure<VBox>> {
{
var fi = new FontIcon("mdi2u-update");
var b = new IconButtonComp("mdi2u-update", () -> UpdateAvailableAlert.showIfNeeded());
var b = new IconButtonComp("mdi2u-update", () -> UpdateAvailableAlert.showIfNeeded())
.apply(new FancyTooltipAugment<>("updateAvailableTooltip"));
b.apply(struc -> {
AppFont.setSize(struc.get(), 2);
});
b.hide(PlatformThread.sync(Bindings.createBooleanBinding(
() -> {
return XPipeDistributionType.get()
@@ -76,5 +80,4 @@ public class SideMenuBarComp extends Comp<CompStructure<VBox>> {
vbox.getStyleClass().add("sidebar-comp");
return new SimpleCompStructure<>(vbox);
}
}

View File

@@ -148,7 +148,7 @@ public class AppMainWindow {
Stage.getWindows().stream().filter(w -> !w.equals(stage)).toList().forEach(w -> w.fireEvent(e));
stage.close();
AppPrefs.get().closeBehaviour().getValue().getExit().run();
AppPrefs.get().closeBehaviour().getValue().run();
e.consume();
});

View File

@@ -14,6 +14,8 @@ import io.xpipe.core.util.JacksonMapper;
public class BaseMode extends OperationMode {
private boolean initialized;
@Override
public boolean isSupported() {
return true;
@@ -26,6 +28,10 @@ public class BaseMode extends OperationMode {
@Override
public void onSwitchTo() throws Throwable {
if (initialized) {
return;
}
TrackEvent.info("mode", "Initializing base mode components ...");
AppExtensionManager.init(true);
JacksonMapper.initModularized(AppExtensionManager.getInstance().getExtendedLayer());
@@ -45,6 +51,7 @@ public class BaseMode extends OperationMode {
FileBridge.init();
AppSocketServer.init();
TrackEvent.info("mode", "Finished base components initialization");
initialized = true;
}
@Override

View File

@@ -6,23 +6,47 @@ import lombok.Getter;
@Getter
public enum CloseBehaviour implements PrefsChoiceValue {
QUIT("app.quit", () -> {
OperationMode.shutdown(false, false);
}),
QUIT("app.quit") {
@Override
public void run() {
OperationMode.shutdown(false, false);
}
MINIMIZE_TO_TRAY("app.minimizeToTray", () -> {
OperationMode.switchToAsync(OperationMode.TRAY);
});
@Override
public boolean isSelectable() {
return true;
}
},
MINIMIZE_TO_TRAY("app.minimizeToTray") {
@Override
public void run() {
OperationMode.switchToAsync(OperationMode.TRAY);
}
@Override
public boolean isSelectable() {
return OperationMode.TRAY.isSupported();
}
},
CONTINUE_IN_BACKGROUND("app.continueInBackground") {
@Override
public void run() {
OperationMode.switchToAsync(OperationMode.BACKGROUND);
}
@Override
public boolean isSelectable() {
return !OperationMode.TRAY.isSupported();
}
};
private final String id;
private final Runnable exit;
CloseBehaviour(String id, Runnable exit) {
CloseBehaviour(String id) {
this.id = id;
this.exit = exit;
}
public boolean isSelectable() {
return true;
}
public abstract void run();
}

View File

@@ -194,7 +194,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
// Note for later: When debugging konsole launches, it will always open as a child process of
// IntelliJ/XPipe even though we try to detach it.
// This is not the case for production where it works as expected
return CommandBuilder.of().add("--new-tab", "-e").add("--").addFile(file);
return CommandBuilder.of().add("--new-tab", "-e").addFile(file);
}
@Override

View File

@@ -1,5 +1,6 @@
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;
@@ -8,13 +9,24 @@ import lombok.Getter;
@Getter
@AllArgsConstructor
public enum StartupBehaviour implements PrefsChoiceValue {
GUI("app.startGui", XPipeDaemonMode.GUI),
TRAY("app.startInTray", XPipeDaemonMode.TRAY);
GUI("app.startGui", XPipeDaemonMode.GUI) {
public boolean isSelectable() {
return true;
}
},
TRAY("app.startInTray", XPipeDaemonMode.TRAY) {
public boolean isSelectable() {
return OperationMode.TRAY.isSupported();
}
},
BACKGROUND("app.startInBackground", XPipeDaemonMode.BACKGROUND) {
public boolean isSelectable() {
return !OperationMode.TRAY.isSupported();
}
};
private final String id;
private final XPipeDaemonMode mode;
public boolean isSelectable() {
return true;
}
}

View File

@@ -199,6 +199,7 @@ updateReadyDescription=An update was downloaded and is ready to be installed
updateReadyDescriptionPortable=An update is available to download
updateRestart=Restart to update
never=Never
updateAvailableTooltip=Update available
updateAvailable=Update available: $VERSION$
downloadUpdate=Download update
legalAccept=I accept the EULA and the privacy policy