mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-21 23:20:23 +00:00
Fixes
This commit is contained in:
parent
5ac45dce41
commit
d39fbb5052
18 changed files with 91 additions and 41 deletions
|
@ -103,6 +103,12 @@ public class AppStyle {
|
|||
STYLESHEET_CONTENTS.values().forEach(s -> {
|
||||
scene.getStylesheets().add(s);
|
||||
});
|
||||
if (AppPrefs.get() != null) {
|
||||
var t = AppPrefs.get().theme.get();
|
||||
if (t != null) {
|
||||
scene.getStylesheets().addAll(t.getAdditionalStylesheets());
|
||||
}
|
||||
}
|
||||
TrackEvent.debug("Added stylesheets for scene");
|
||||
|
||||
scenes.add(scene);
|
||||
|
|
|
@ -59,6 +59,8 @@ public class AppTheme {
|
|||
}
|
||||
|
||||
stage.getScene().getRoot().getStyleClass().add(t.getCssId());
|
||||
stage.getScene().getStylesheets().removeAll(t.getAdditionalStylesheets());
|
||||
stage.getScene().getStylesheets().addAll(t.getAdditionalStylesheets());
|
||||
stage.getScene().getRoot().pseudoClassStateChanged(LIGHT, !t.isDark());
|
||||
stage.getScene().getRoot().pseudoClassStateChanged(DARK, t.isDark());
|
||||
});
|
||||
|
@ -175,8 +177,8 @@ public class AppTheme {
|
|||
|
||||
private final String name;
|
||||
|
||||
public DerivedTheme(String id, String cssId, String name, atlantafx.base.theme.Theme theme) {
|
||||
super(id, cssId, theme);
|
||||
public DerivedTheme(String id, String cssId, String name, atlantafx.base.theme.Theme theme, String transparentColor) {
|
||||
super(id, cssId, theme, transparentColor);
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
@ -211,17 +213,17 @@ public class AppTheme {
|
|||
@AllArgsConstructor
|
||||
public static class Theme implements PrefsChoiceValue {
|
||||
|
||||
public static final Theme PRIMER_LIGHT = new Theme("light", "primer", new PrimerLight());
|
||||
public static final Theme PRIMER_DARK = new Theme("dark", "primer", new PrimerDark());
|
||||
public static final Theme NORD_LIGHT = new Theme("nordLight", "nord", new NordLight());
|
||||
public static final Theme NORD_DARK = new Theme("nordDark", "nord", new NordDark());
|
||||
public static final Theme CUPERTINO_LIGHT = new Theme("cupertinoLight", "cupertino", new CupertinoLight());
|
||||
public static final Theme CUPERTINO_DARK = new Theme("cupertinoDark", "cupertino", new CupertinoDark());
|
||||
public static final Theme DRACULA = new Theme("dracula", "dracula", new Dracula());
|
||||
public static final Theme MOCHA = new DerivedTheme("mocha", "primer", "Mocha", new PrimerDark());
|
||||
public static final Theme PRIMER_LIGHT = new Theme("light", "primer", new PrimerLight(), "#ffffff88");
|
||||
public static final Theme PRIMER_DARK = new Theme("dark", "primer", new PrimerDark(), "#0d111788");
|
||||
public static final Theme NORD_LIGHT = new Theme("nordLight", "nord", new NordLight(), "#ffffff88");
|
||||
public static final Theme NORD_DARK = new Theme("nordDark", "nord", new NordDark(), "#0d111788");
|
||||
public static final Theme CUPERTINO_LIGHT = new Theme("cupertinoLight", "cupertino", new CupertinoLight(), "#ffffff88");
|
||||
public static final Theme CUPERTINO_DARK = new Theme("cupertinoDark", "cupertino", new CupertinoDark(), "#0d111788");
|
||||
public static final Theme DRACULA = new Theme("dracula", "dracula", new Dracula(), "#0d111788");
|
||||
public static final Theme MOCHA = new DerivedTheme("mocha", "primer", "Mocha", new PrimerDark(), "#0d111788");
|
||||
|
||||
// Adjust this to create your own theme
|
||||
public static final Theme CUSTOM = new DerivedTheme("custom", "primer", "Custom", new PrimerDark());
|
||||
public static final Theme CUSTOM = new DerivedTheme("custom", "primer", "Custom", new PrimerDark(), "#0d111788");
|
||||
|
||||
// Also include your custom theme here
|
||||
public static final List<Theme> ALL = List.of(
|
||||
|
@ -233,6 +235,8 @@ public class AppTheme {
|
|||
|
||||
protected final atlantafx.base.theme.Theme theme;
|
||||
|
||||
protected final String transparentBackground;
|
||||
|
||||
static Theme getDefaultLightTheme() {
|
||||
return switch (OsType.getLocal()) {
|
||||
case OsType.Windows windows -> PRIMER_LIGHT;
|
||||
|
@ -257,6 +261,10 @@ public class AppTheme {
|
|||
Application.setUserAgentStylesheet(theme.getUserAgentStylesheetBSS());
|
||||
}
|
||||
|
||||
public List<String> getAdditionalStylesheets() {
|
||||
return List.of(Styles.toDataURI(".root { -color-bg-default-transparent: " + transparentBackground + "; }"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObservableValue<String> toTranslatedString() {
|
||||
return new SimpleStringProperty(theme.getName());
|
||||
|
|
|
@ -94,13 +94,15 @@ public abstract class OperationMode {
|
|||
|
||||
// Handle uncaught exceptions
|
||||
Thread.setDefaultUncaughtExceptionHandler((thread, ex) -> {
|
||||
// It seems like a few exceptions are thrown in the quantum renderer
|
||||
// when in shutdown. We can ignore these
|
||||
if (OperationMode.isInShutdown() && Platform.isFxApplicationThread() && ex instanceof NullPointerException) {
|
||||
return;
|
||||
}
|
||||
|
||||
ErrorEvent.fromThrowable(ex).unhandled(true).build().handle();
|
||||
});
|
||||
|
||||
// if (true) {
|
||||
// throw new OutOfMemoryError();
|
||||
// }
|
||||
|
||||
TrackEvent.info("Initial setup");
|
||||
AppProperties.init();
|
||||
AppState.init();
|
||||
|
|
|
@ -5,14 +5,11 @@ import io.xpipe.app.issue.ErrorEvent;
|
|||
import io.xpipe.app.issue.TrackEvent;
|
||||
import io.xpipe.app.prefs.AppPrefs;
|
||||
import io.xpipe.core.process.OsType;
|
||||
|
||||
import javafx.application.Platform;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
public enum PlatformState {
|
||||
|
@ -24,8 +21,15 @@ public enum PlatformState {
|
|||
@Setter
|
||||
private static PlatformState current = PlatformState.NOT_INITIALIZED;
|
||||
|
||||
@Getter
|
||||
private static Exception lastError;
|
||||
private static Throwable lastError;
|
||||
private static boolean expectedError;
|
||||
|
||||
public static Throwable getLastError() {
|
||||
if (expectedError) {
|
||||
ErrorEvent.expected(lastError);
|
||||
}
|
||||
return lastError;
|
||||
}
|
||||
|
||||
public static void teardown() {
|
||||
// This is bad and can get sometimes stuck
|
||||
|
@ -46,26 +50,25 @@ public enum PlatformState {
|
|||
public static void initPlatformOrThrow() throws Exception {
|
||||
initPlatformIfNeeded();
|
||||
if (lastError != null) {
|
||||
throw lastError;
|
||||
throw lastError instanceof Exception e ? e : new Exception(lastError);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean initPlatformIfNeeded() {
|
||||
if (current == NOT_INITIALIZED) {
|
||||
var t = PlatformState.initPlatform().orElse(null);
|
||||
lastError = t instanceof Exception e ? e : t != null ? new Exception(t) : null;
|
||||
PlatformState.initPlatform();
|
||||
}
|
||||
|
||||
return current == RUNNING;
|
||||
}
|
||||
|
||||
private static Optional<Throwable> initPlatform() {
|
||||
private static void initPlatform() {
|
||||
if (current == EXITED) {
|
||||
return Optional.of(new IllegalStateException("Platform has already exited"));
|
||||
lastError = new IllegalStateException("Platform has already exited");
|
||||
return;
|
||||
}
|
||||
|
||||
if (current == RUNNING) {
|
||||
return Optional.empty();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -85,11 +88,14 @@ public enum PlatformState {
|
|||
+ " You don't have to install XPipe on any system like a server, a WSL distribution, a hypervisor, etc.,"
|
||||
+ " to have full access to that system, a shell connection to it is enough for XPipe to work from your local machine.";
|
||||
PlatformState.setCurrent(PlatformState.EXITED);
|
||||
return Optional.of(ErrorEvent.expected(new UnsupportedOperationException(msg)));
|
||||
expectedError = true;
|
||||
lastError = new UnsupportedOperationException(msg);
|
||||
return;
|
||||
} catch (Throwable t) {
|
||||
TrackEvent.warn(t.getMessage());
|
||||
PlatformState.setCurrent(PlatformState.EXITED);
|
||||
return Optional.of(t);
|
||||
lastError = t;
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if we have no fonts and set properties to load bundled ones
|
||||
|
@ -121,23 +127,26 @@ public enum PlatformState {
|
|||
try {
|
||||
latch.await();
|
||||
PlatformState.setCurrent(PlatformState.RUNNING);
|
||||
return Optional.empty();
|
||||
return;
|
||||
} catch (InterruptedException e) {
|
||||
return Optional.of(e);
|
||||
lastError = e;
|
||||
return;
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
// Check if we already exited
|
||||
if ("Platform.exit has been called".equals(t.getMessage())) {
|
||||
PlatformState.setCurrent(PlatformState.EXITED);
|
||||
return Optional.of(t);
|
||||
lastError = t;
|
||||
return;
|
||||
} else if ("Toolkit already initialized".equals(t.getMessage())) {
|
||||
PlatformState.setCurrent(PlatformState.RUNNING);
|
||||
return Optional.empty();
|
||||
return;
|
||||
} else {
|
||||
// Platform initialization has failed in this case
|
||||
PlatformState.setCurrent(PlatformState.EXITED);
|
||||
TrackEvent.error(t.getMessage());
|
||||
return Optional.of(t);
|
||||
lastError =t;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,8 +51,9 @@
|
|||
}
|
||||
|
||||
.browser .welcome {
|
||||
-fx-background-color: -color-bg-inset, -color-border-default, -color-bg-default;
|
||||
-fx-background-insets: 0, 2.65em 0 0 0, 2.70em 0 0 0;
|
||||
-fx-border-color: -color-bg-inset, -color-border-default;
|
||||
-fx-border-width: 2.65em 0 0 0, 0.05em 0 0 0;
|
||||
-fx-border-insets: 0, 2.65em 0 0 0;
|
||||
}
|
||||
|
||||
.root:seamless-frame .browser .welcome {
|
||||
|
|
|
@ -10,19 +10,19 @@
|
|||
}
|
||||
|
||||
.root:dark .background {
|
||||
-fx-background-color: derive(-color-bg-default, 1%);
|
||||
-fx-background-color: derive(-color-bg-default-transparent, 1%);
|
||||
}
|
||||
|
||||
.root:light .background {
|
||||
-fx-background-color: derive(-color-bg-default, -9%);
|
||||
-fx-background-color: derive(-color-bg-default-transparent, -9%);
|
||||
}
|
||||
|
||||
.root:dark.background {
|
||||
-fx-background-color: derive(-color-bg-default, 1%);
|
||||
-fx-background-color: derive(-color-bg-default-transparent, 1%);
|
||||
}
|
||||
|
||||
.root:light.background {
|
||||
-fx-background-color: derive(-color-bg-default, -9%);
|
||||
-fx-background-color: derive(-color-bg-default-transparent, -9%);
|
||||
}
|
||||
|
||||
.root:seamless-frame.layout > .background {
|
||||
|
|
|
@ -357,3 +357,5 @@ vmActions=VM-handlinger
|
|||
dockerContextActions=Kontekst-handlinger
|
||||
k8sPodActions=Pod-handlinger
|
||||
openVnc=Sæt VNC op
|
||||
commandGroup.displayName=Kommandogruppe
|
||||
commandGroup.displayDescription=Grupper tilgængelige kommandoer for et system
|
||||
|
|
|
@ -335,3 +335,5 @@ vmActions=VM-Aktionen
|
|||
dockerContextActions=Kontextbezogene Aktionen
|
||||
k8sPodActions=Pod-Aktionen
|
||||
openVnc=VNC einrichten
|
||||
commandGroup.displayName=Befehlsgruppe
|
||||
commandGroup.displayDescription=Verfügbare Befehle für ein System gruppieren
|
||||
|
|
|
@ -332,4 +332,6 @@ containerActions=Container actions
|
|||
vmActions=VM actions
|
||||
dockerContextActions=Context actions
|
||||
k8sPodActions=Pod actions
|
||||
openVnc=Set up VNC
|
||||
openVnc=Set up VNC
|
||||
commandGroup.displayName=Command group
|
||||
commandGroup.displayDescription=Group available commands for a system
|
|
@ -331,3 +331,5 @@ vmActions=Acciones VM
|
|||
dockerContextActions=Acciones contextuales
|
||||
k8sPodActions=Acciones del pod
|
||||
openVnc=Configurar VNC
|
||||
commandGroup.displayName=Grupo de comandos
|
||||
commandGroup.displayDescription=Agrupa los comandos disponibles para un sistema
|
||||
|
|
|
@ -331,3 +331,5 @@ vmActions=Actions VM
|
|||
dockerContextActions=Actions contextuelles
|
||||
k8sPodActions=Actions de pods
|
||||
openVnc=Configurer VNC
|
||||
commandGroup.displayName=Groupe de commande
|
||||
commandGroup.displayDescription=Groupe de commandes disponibles pour un système
|
||||
|
|
|
@ -331,3 +331,5 @@ vmActions=Azioni della VM
|
|||
dockerContextActions=Azioni contestuali
|
||||
k8sPodActions=Azioni del pod
|
||||
openVnc=Configurare VNC
|
||||
commandGroup.displayName=Gruppo di comando
|
||||
commandGroup.displayDescription=Gruppo di comandi disponibili per un sistema
|
||||
|
|
|
@ -331,3 +331,5 @@ vmActions=VMアクション
|
|||
dockerContextActions=コンテキストアクション
|
||||
k8sPodActions=ポッドアクション
|
||||
openVnc=VNCを設定する
|
||||
commandGroup.displayName=コマンドグループ
|
||||
commandGroup.displayDescription=システムで使用可能なコマンドをグループ化する
|
||||
|
|
|
@ -331,3 +331,5 @@ vmActions=VM-acties
|
|||
dockerContextActions=Context acties
|
||||
k8sPodActions=Pod acties
|
||||
openVnc=VNC instellen
|
||||
commandGroup.displayName=Opdrachtgroep
|
||||
commandGroup.displayDescription=Groep beschikbare commando's voor een systeem
|
||||
|
|
|
@ -331,3 +331,5 @@ vmActions=Acções VM
|
|||
dockerContextActions=Acções de contexto
|
||||
k8sPodActions=Acções de pod
|
||||
openVnc=Configura o VNC
|
||||
commandGroup.displayName=Grupo de comandos
|
||||
commandGroup.displayDescription=Agrupa os comandos disponíveis para um sistema
|
||||
|
|
|
@ -331,3 +331,5 @@ vmActions=Действия виртуальной машины
|
|||
dockerContextActions=Контекстные действия
|
||||
k8sPodActions=Действия в капсуле
|
||||
openVnc=Настройте VNC
|
||||
commandGroup.displayName=Группа команд
|
||||
commandGroup.displayDescription=Группа доступных команд для системы
|
||||
|
|
|
@ -331,3 +331,5 @@ vmActions=VM eylemleri
|
|||
dockerContextActions=Bağlam eylemleri
|
||||
k8sPodActions=Pod eylemleri
|
||||
openVnc=VNC'yi ayarlama
|
||||
commandGroup.displayName=Komuta grubu
|
||||
commandGroup.displayDescription=Bir sistem için mevcut komutları gruplama
|
||||
|
|
|
@ -331,3 +331,5 @@ vmActions=虚拟机操作
|
|||
dockerContextActions=上下文操作
|
||||
k8sPodActions=Pod 操作
|
||||
openVnc=设置 VNC
|
||||
commandGroup.displayName=命令组
|
||||
commandGroup.displayDescription=系统可用命令组
|
||||
|
|
Loading…
Reference in a new issue