Skip to content

Commit

Permalink
Changing Theme Resets FontSize
Browse files Browse the repository at this point in the history
  • Loading branch information
deathmarine committed Jun 5, 2018
1 parent 1a493c8 commit 6042502
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/us/deathmarine/luyten/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ private String getLegalStr() {

public void onThemesChanged() {
this.getModel().changeTheme(luytenPrefs.getThemeXml());
luytenPrefs.setFont_size(this.getModel().getTheme().baseFont.getSize());
}

public void onSettingsChanged() {
Expand Down
24 changes: 16 additions & 8 deletions src/us/deathmarine/luyten/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@ public Model(MainWindow mainWindow) {

try {
String themeXml = luytenPrefs.getThemeXml();
theme = Theme.load(getClass().getResourceAsStream(LuytenPreferences.THEME_XML_PATH + themeXml));
setTheme(Theme.load(getClass().getResourceAsStream(LuytenPreferences.THEME_XML_PATH + themeXml)));
} catch (Exception e1) {
try {
Luyten.showExceptionDialog("Exception!", e1);
String themeXml = LuytenPreferences.DEFAULT_THEME_XML;
luytenPrefs.setThemeXml(themeXml);
theme = Theme.load(getClass().getResourceAsStream(LuytenPreferences.THEME_XML_PATH + themeXml));
setTheme(Theme.load(getClass().getResourceAsStream(LuytenPreferences.THEME_XML_PATH + themeXml)));
} catch (Exception e2) {
Luyten.showExceptionDialog("Exception!", e2);
}
Expand Down Expand Up @@ -185,7 +185,7 @@ public void showLegal(String legalStr) {
}

public void show(String name, String contents) {
OpenFile open = new OpenFile(name, "*/" + name, theme, mainWindow);
OpenFile open = new OpenFile(name, "*/" + name, getTheme(), mainWindow);
open.setContent(contents);
hmap.add(open);
addOrSwitchToTab(open);
Expand Down Expand Up @@ -413,7 +413,7 @@ void extractClassToTextPane(TypeReference type, String tabTitle, String path, St
sameTitledOpen.decompile();
addOrSwitchToTab(sameTitledOpen);
} else {
OpenFile open = new OpenFile(tabTitle, path, theme, mainWindow);
OpenFile open = new OpenFile(tabTitle, path, getTheme(), mainWindow);
open.setDecompilerReferences(metadataSystem, settings, decompilationOptions);
open.setType(resolvedType);
open.setInitialNavigationLink(navigatonLink);
Expand Down Expand Up @@ -474,7 +474,7 @@ public void extractSimpleFileEntryToTextPane(InputStream inputStream, String tab
sameTitledOpen.setContent(sb.toString());
addOrSwitchToTab(sameTitledOpen);
} else {
OpenFile open = new OpenFile(tabTitle, path, theme, mainWindow);
OpenFile open = new OpenFile(tabTitle, path, getTheme(), mainWindow);
open.setDecompilerReferences(metadataSystem, settings, decompilationOptions);
open.setContent(sb.toString());
hmap.add(open);
Expand Down Expand Up @@ -904,9 +904,9 @@ public void changeTheme(String xml) {
InputStream in = getClass().getResourceAsStream(LuytenPreferences.THEME_XML_PATH + xml);
try {
if (in != null) {
theme = Theme.load(in);
setTheme(Theme.load(in));
for (OpenFile f : hmap) {
theme.apply(f.textArea);
getTheme().apply(f.textArea);
}
}
} catch (Exception e1) {
Expand Down Expand Up @@ -976,7 +976,7 @@ public void run() {
.setUnicodeOutputEnabled(decompilationOptions.getSettings().isUnicodeOutputEnabled());
settings.getLanguage().decompileType(resolvedType, plainTextOutput, decompilationOptions);
String decompiledSource = stringwriter.toString();
OpenFile open = new OpenFile(internalName, "*/" + internalName, theme, mainWindow);
OpenFile open = new OpenFile(internalName, "*/" + internalName, getTheme(), mainWindow);
open.setContent(decompiledSource);
JTabbedPane pane = new JTabbedPane();
pane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
Expand Down Expand Up @@ -1036,4 +1036,12 @@ public State getState() {
return state;
}

public Theme getTheme() {
return theme;
}

public void setTheme(Theme theme) {
this.theme = theme;
}

}

0 comments on commit 6042502

Please sign in to comment.