Skip to content

Commit 48120aa

Browse files
committed
Persist the "isDark" property in preference store
This is needed when the user had previously selected a theme which is not available anymore. In this case we want to fall back to respect whether that previous choice was dark or not.
1 parent fb81db2 commit 48120aa

File tree

1 file changed

+7
-1
lines changed
  • bundles/org.eclipse.e4.ui.css.swt.theme/src/org/eclipse/e4/ui/css/swt/internal/theme

1 file changed

+7
-1
lines changed

bundles/org.eclipse.e4.ui.css.swt.theme/src/org/eclipse/e4/ui/css/swt/internal/theme/ThemeEngine.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public class ThemeEngine implements IThemeEngine {
8181
private HashMap<String, List<IResourceLocator>> sourceLocators = new HashMap<>();
8282

8383
private static final String THEMEID_KEY = "themeid";
84+
private static final String THEME_IS_DARK_KEY = "themeIsDark";
8485

8586
public static final String THEME_PLUGIN_ID = "org.eclipse.e4.ui.css.swt.theme";
8687

@@ -501,6 +502,7 @@ public void setTheme(ITheme theme, boolean restore, boolean force) {
501502
EclipsePreferencesHelper.setCurrentThemeId(theme.getId());
502503

503504
pref.put(THEMEID_KEY, theme.getId());
505+
pref.putBoolean(THEME_IS_DARK_KEY, theme.isDark());
504506
try {
505507
pref.flush();
506508
} catch (BackingStoreException e) {
@@ -565,6 +567,10 @@ private String getPreferenceThemeId() {
565567
return getPreferences().get(THEMEID_KEY, null);
566568
}
567569

570+
private boolean getPreferenceThemeIsDark() {
571+
return getPreferences().getBoolean(THEME_IS_DARK_KEY, false);
572+
}
573+
568574
private IEclipsePreferences getPreferences() {
569575
return InstanceScope.INSTANCE.getNode(FrameworkUtil.getBundle(ThemeEngine.class).getSymbolicName());
570576
}
@@ -612,7 +618,7 @@ public void restore(String alternateTheme) {
612618
* this case want to fall back to respect whether that previous choice was dark
613619
* or not. https://github.com/eclipse-platform/eclipse.platform.ui/issues/2776
614620
*/
615-
overrideWithDarkTheme = prefThemeId.contains("dark");
621+
overrideWithDarkTheme = getPreferenceThemeIsDark();
616622
} else {
617623
/*
618624
* No previous theme selection in preferences. In this case check if the system

0 commit comments

Comments
 (0)