Rework transparency style

This commit is contained in:
crschnick 2024-07-05 13:00:16 +00:00
parent 2fb2ce35a0
commit bbe3f09837
22 changed files with 105 additions and 30 deletions

View file

@ -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);

View file

@ -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());
});
@ -257,6 +259,15 @@ public class AppTheme {
Application.setUserAgentStylesheet(theme.getUserAgentStylesheetBSS());
}
public List<String> getAdditionalStylesheets() {
var r = AppResources.getResourceURL(AppResources.XPIPE_MODULE, "theme/" + getId() + ".css");
if (r.isEmpty()) {
return List.of();
} else {
return List.of(r.get().toString());
}
}
@Override
public ObservableValue<String> toTranslatedString() {
return new SimpleStringProperty(theme.getName());

View file

@ -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();

View file

@ -6,15 +6,12 @@ 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 org.apache.commons.lang3.SystemUtils;
import java.awt.*;
import java.util.Optional;
import java.util.concurrent.CountDownLatch;
public enum PlatformState {
@ -26,8 +23,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
@ -48,26 +52,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 {
@ -87,11 +90,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
@ -128,23 +134,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;
}
}
}

View file

@ -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 {

View file

@ -9,22 +9,40 @@
-fx-background-color: transparent;
}
.root:dark .background {
.root:dark:separate-frame .background {
-fx-background-color: derive(-color-bg-default, 1%);
}
.root:light .background {
.root:light:separate-frame .background {
-fx-background-color: derive(-color-bg-default, -9%);
}
.root:dark.background {
.root:dark:separate-frame.background {
-fx-background-color: derive(-color-bg-default, 1%);
}
.root:light.background {
.root:light:separate-frame.background {
-fx-background-color: derive(-color-bg-default, -9%);
}
.root:dark:seamless-frame .background {
-fx-background-color: derive(-color-bg-default-transparent, 1%);
}
.root:light:seamless-frame .background {
-fx-background-color: derive(-color-bg-default-transparent, -9%);
}
.root:dark:seamless-frame.background {
-fx-background-color: derive(-color-bg-default-transparent, 1%);
}
.root:light:seamless-frame.background {
-fx-background-color: derive(-color-bg-default-transparent, -9%);
}
.root:seamless-frame.layout > .background {
-fx-background-insets: 5 0 0 0;
-fx-border-insets: 5 0 0 0;

View file

@ -0,0 +1 @@
.root { -color-bg-default-transparent: #0d1117d2; }

View file

@ -0,0 +1 @@
.root { -color-bg-default-transparent: #0d1117d2; }

View file

@ -0,0 +1 @@
.root { -color-bg-default-transparent: #FFFFFF99; }

View file

@ -0,0 +1 @@
.root { -color-bg-default-transparent: #0d1117d2; }

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -331,3 +331,5 @@ vmActions=VMアクション
dockerContextActions=コンテキストアクション
k8sPodActions=ポッドアクション
openVnc=VNCを設定する
commandGroup.displayName=コマンドグループ
commandGroup.displayDescription=システムで使用可能なコマンドをグループ化する

View file

@ -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

View file

@ -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

View file

@ -331,3 +331,5 @@ vmActions=Действия виртуальной машины
dockerContextActions=Контекстные действия
k8sPodActions=Действия в капсуле
openVnc=Настройте VNC
commandGroup.displayName=Группа команд
commandGroup.displayDescription=Группа доступных команд для системы

View file

@ -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

View file

@ -331,3 +331,5 @@ vmActions=虚拟机操作
dockerContextActions=上下文操作
k8sPodActions=Pod 操作
openVnc=设置 VNC
commandGroup.displayName=命令组
commandGroup.displayDescription=系统可用命令组