mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-04 21:36:45 +00:00
change theme on all app windows
This commit is contained in:
parent
6a1c3fa3da
commit
76820377ae
2 changed files with 24 additions and 3 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue