Skip to content

Commit

Permalink
Always use default l&f
Browse files Browse the repository at this point in the history
  • Loading branch information
RetGal committed Feb 20, 2024
1 parent e1f6ffd commit 66900bf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/main/java/mpo/dayon/assistant/gui/Assistant.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public Assistant(String tokenServerUrl, String language) {
captureEngineConfiguration = new CaptureEngineConfiguration();
compressorEngineConfiguration = new CompressorEngineConfiguration();

final String lnf = configuration.getLookAndFeelClassName();
final String lnf = getDefaultLookAndFeel();
try {
UIManager.setLookAndFeel(lnf);
} catch (Exception ex) {
Expand Down Expand Up @@ -667,7 +667,7 @@ private JComboBox<Language> createLanguageSelection() {
languageSelection.addActionListener(ev -> {
Locale.setDefault(new Locale(languageSelection.getSelectedItem().toString()));
Log.info(format("New language %s", Locale.getDefault().getLanguage()));
configuration = new AssistantConfiguration(getDefaultLookAndFeel(), Locale.getDefault().getLanguage());
configuration = new AssistantConfiguration(Locale.getDefault().getLanguage());
configuration.persist();
initGui();
}
Expand Down
17 changes: 4 additions & 13 deletions src/main/java/mpo/dayon/assistant/gui/AssistantConfiguration.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package mpo.dayon.assistant.gui;

import mpo.dayon.common.configuration.Configuration;
import mpo.dayon.common.utils.SystemUtilities;

import java.util.Locale;

Expand All @@ -14,8 +13,6 @@ public class AssistantConfiguration extends Configuration {

private static final String PREF_LANGUAGE = "assistant.language";

private final String lookAndFeelClassName;

private final String language;

/**
Expand All @@ -24,19 +21,13 @@ public class AssistantConfiguration extends Configuration {
* @see mpo.dayon.common.preference.Preferences
*/
public AssistantConfiguration() {
lookAndFeelClassName = getPreferences().getStringPreference(PREF_LOOK_AND_FEEL, SystemUtilities.getDefaultLookAndFeel());
language = getPreferences().getStringPreference(PREF_LANGUAGE, Locale.getDefault().getLanguage());
}

AssistantConfiguration(String lookAndFeelClassName, String language) {
this.lookAndFeelClassName = lookAndFeelClassName;
AssistantConfiguration(String language) {
this.language = language;
}

String getLookAndFeelClassName() {
return lookAndFeelClassName;
}

String getLanguage() {
return language;
}
Expand All @@ -50,12 +41,12 @@ public boolean equals(Object o) {
return false;
}
final AssistantConfiguration that = (AssistantConfiguration) o;
return lookAndFeelClassName.equals(that.getLookAndFeelClassName());
return language.equals(that.getLanguage());
}

@Override
public int hashCode() {
return lookAndFeelClassName.hashCode();
return language.hashCode();
}

/**
Expand All @@ -66,8 +57,8 @@ public int hashCode() {
protected void persist(boolean clear) {
final Props props = new Props();
props.set(PREF_VERSION, String.valueOf(1));
props.set(PREF_LOOK_AND_FEEL, lookAndFeelClassName);
props.set(PREF_LANGUAGE, language);
props.clear(PREF_LOOK_AND_FEEL);
getPreferences().update(props); // atomic (!)
}

Expand Down

0 comments on commit 66900bf

Please sign in to comment.