Browse Source

Settings: Issue warning if theme is reinstalled unnecessarily

spotless
weisj 3 years ago
parent
commit
88e8bf8b87
No known key found for this signature in database
GPG Key ID: 31124CB75461DA2A
  1. 14
      core/src/main/java/com/github/weisj/darklaf/LafManager.java
  2. 2
      core/src/main/java/com/github/weisj/darklaf/settings/ThemeSettings.java

14
core/src/main/java/com/github/weisj/darklaf/LafManager.java

@ -350,7 +350,12 @@ public final class LafManager {
* @return the currently installed theme.
*/
public static Theme getInstalledTheme() {
return installedTheme != null ? installedTheme : getTheme();
Theme installed = getInstalledThemeInternal();
return installed != null ? installed : getTheme();
}
private static Theme getInstalledThemeInternal() {
return installedTheme;
}
static void setInstalledTheme(final Theme theme) {
@ -439,6 +444,13 @@ public final class LafManager {
*/
public static void install() {
Theme theme = getTheme();
Theme installed = getInstalledThemeInternal();
if (isInstalled() && installed != null && installed.appearsEqualTo(theme)) {
LOGGER.warning("Theme " + theme
+ " is already installed. Additional installs are unnecessary and should be avoided."
+ " The theme will be installed regardless to ensure all properties have the correct value."
+ " If this operation was intentional consider creating a custom theme.");
}
installer.install(theme);
setInstalledTheme(theme);
}

2
core/src/main/java/com/github/weisj/darklaf/settings/ThemeSettings.java

@ -483,7 +483,7 @@ public class ThemeSettings implements ThemePreferenceListener {
protected void applyTheme(final Theme theme) {
if (theme == null) return;
if (LafManager.isInstalled() && LafManager.getTheme().appearsEqualTo(theme)) return;
if (LafManager.isInstalled() && LafManager.getInstalledTheme().appearsEqualTo(theme)) return;
UIThread.runOnUIThread(() -> {
LafManager.installTheme(theme);
refresh();

Loading…
Cancel
Save