Improve window title

This commit is contained in:
crschnick 2024-04-03 04:08:49 +00:00
parent 6f612b82f9
commit 93786dc76c
2 changed files with 11 additions and 13 deletions

View file

@ -6,6 +6,7 @@ import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.TrackEvent; import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.prefs.AppPrefs; import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.update.XPipeDistributionType; import io.xpipe.app.update.XPipeDistributionType;
import io.xpipe.app.util.LicenseProvider;
import io.xpipe.core.process.OsType; import io.xpipe.core.process.OsType;
import javafx.application.Application; import javafx.application.Application;
import javafx.beans.binding.Bindings; import javafx.beans.binding.Bindings;
@ -56,27 +57,21 @@ public class App extends Application {
public void setupWindow() { public void setupWindow() {
var content = new AppLayoutComp(); var content = new AppLayoutComp();
var t = LicenseProvider.get().licenseTitle();
var u = XPipeDistributionType.get().getUpdateHandler().getPreparedUpdate();
var titleBinding = Bindings.createStringBinding( var titleBinding = Bindings.createStringBinding(
() -> { () -> {
var base = String.format( var base = String.format(
"XPipe Desktop (%s)", AppProperties.get().getVersion()); "XPipe %s (%s)", t.getValue(), AppProperties.get().getVersion());
var prefix = AppProperties.get().isStaging() ? "[Public Test Build, Not a proper release] " : ""; var prefix = AppProperties.get().isStaging() ? "[Public Test Build, Not a proper release] " : "";
var suffix = XPipeDistributionType.get() var suffix = u.getValue() != null
.getUpdateHandler()
.getPreparedUpdate()
.getValue()
!= null
? String.format( ? String.format(
" (Update to %s ready)", " (Update to %s ready)", u.getValue().getVersion())
XPipeDistributionType.get()
.getUpdateHandler()
.getPreparedUpdate()
.getValue()
.getVersion())
: ""; : "";
return prefix + base + suffix; return prefix + base + suffix;
}, },
XPipeDistributionType.get().getUpdateHandler().getPreparedUpdate()); u,
t);
var appWindow = AppMainWindow.init(stage); var appWindow = AppMainWindow.init(stage);
appWindow.getStage().titleProperty().bind(PlatformThread.sync(titleBinding)); appWindow.getStage().titleProperty().bind(PlatformThread.sync(titleBinding));

View file

@ -4,6 +4,7 @@ import io.xpipe.app.ext.ExtensionException;
import io.xpipe.app.fxcomps.Comp; import io.xpipe.app.fxcomps.Comp;
import io.xpipe.core.process.ShellControl; import io.xpipe.core.process.ShellControl;
import io.xpipe.core.util.ModuleLayerLoader; import io.xpipe.core.util.ModuleLayerLoader;
import javafx.beans.value.ObservableValue;
import java.util.ServiceLoader; import java.util.ServiceLoader;
@ -17,6 +18,8 @@ public abstract class LicenseProvider {
public abstract boolean hasLicense(); public abstract boolean hasLicense();
public abstract ObservableValue<String> licenseTitle();
public abstract LicensedFeature getFeature(String id); public abstract LicensedFeature getFeature(String id);
public abstract void handleShellControl(ShellControl sc); public abstract void handleShellControl(ShellControl sc);