change theme on all app windows

This commit is contained in:
Craig Raw 2020-12-08 17:24:22 +02:00
parent 6a1c3fa3da
commit 76820377ae
2 changed files with 24 additions and 3 deletions

View file

@ -1014,10 +1014,16 @@ public class AppController implements Initializable {
Config.get().setTheme(selectedTheme);
}
if(selectedTheme == Theme.DARK) {
tabs.getScene().getStylesheets().add(getClass().getResource("darktheme.css").toExternalForm());
EventManager.get().post(new ThemeChangedEvent(selectedTheme));
}
@Subscribe
public void themeChanged(ThemeChangedEvent event) {
String darkCss = getClass().getResource("darktheme.css").toExternalForm();
if(event.getTheme() == Theme.DARK && !tabs.getScene().getStylesheets().contains(darkCss)) {
tabs.getScene().getStylesheets().add(darkCss);
} else {
tabs.getScene().getStylesheets().remove(getClass().getResource("darktheme.css").toExternalForm());
tabs.getScene().getStylesheets().remove(darkCss);
}
}

View file

@ -0,0 +1,15 @@
package com.sparrowwallet.sparrow.event;
import com.sparrowwallet.sparrow.Theme;
public class ThemeChangedEvent {
private final Theme theme;
public ThemeChangedEvent(Theme theme) {
this.theme = theme;
}
public Theme getTheme() {
return theme;
}
}