Skip to content

Commit

Permalink
wip remove SwingUtilities.invokeLater to preference change listener
Browse files Browse the repository at this point in the history
  • Loading branch information
bric3 committed Feb 8, 2022
1 parent 94849a7 commit 98ecef8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 26 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ repositories {
dependencies {
implementation(libs.bundles.flatlaf)
// implementation(libs.darklaf)
implementation("com.github.weisj:darklaf-platform-preferences-jnf:latest.integration")
implementation("com.github.weisj:darklaf-platform-preferences:latest.integration")
implementation(libs.flightrecorder)

// implementation(libs.graal.sdk)
Expand Down
38 changes: 13 additions & 25 deletions src/main/java/com/github/bric3/fireplace/FirePlaceMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,33 +209,21 @@ private static void setupLaF() {

SystemPreferencesManager manager = new SystemPreferencesManager();
manager.addListener(style -> {
SwingUtilities.invokeLater(() -> {
System.out.println(">>>> theme preference changed = " + style.getColorToneRule());
switch (style.getColorToneRule()) {
case DARK:
FlatDarculaLaf.setup();
Colors.setDarkMode(true);
break;
case LIGHT:
FlatIntelliJLaf.setup();
Colors.setDarkMode(false);
break;
}
FlatLaf.updateUI();
FlatAnimatedLafChange.hideSnapshotWithAnimation();
});
System.out.println(">>>> theme preference changed = " + manager.getPreferredThemeStyle());
switch (manager.getPreferredThemeStyle().getColorToneRule()) {
case DARK:
FlatDarculaLaf.setup();
Colors.setDarkMode(true);
break;
case LIGHT:
FlatIntelliJLaf.setup();
Colors.setDarkMode(false);
break;
}
FlatLaf.updateUI();
FlatAnimatedLafChange.hideSnapshotWithAnimation();
});
manager.enableReporting(true);
switch (manager.getPreferredThemeStyle().getColorToneRule()) {
case DARK:
FlatDarculaLaf.setup();
Colors.setDarkMode(true);
break;
case LIGHT:
FlatIntelliJLaf.setup();
Colors.setDarkMode(false);
break;
}
// Logger.getLogger("com.github.weisj.darklaf").setLevel(Level.INFO);
// Runtime.getRuntime().addShutdownHook(new Thread(() -> manager.enableReporting(false)));
}
Expand Down

0 comments on commit 98ecef8

Please sign in to comment.