Skip to content

Commit

Permalink
fix(gui): use editor font in files tree and fix bundled font loading
Browse files Browse the repository at this point in the history
  • Loading branch information
skylot committed Jan 23, 2019
1 parent 82d0d62 commit 2931617
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
11 changes: 0 additions & 11 deletions jadx-gui/src/main/java/jadx/gui/settings/JadxSettingsWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
import jadx.gui.utils.LangLocale;
import jadx.gui.utils.NLS;

import static jadx.gui.utils.Utils.FONT_HACK;

public class JadxSettingsWindow extends JDialog {
private static final long serialVersionUID = -1804570470377354148L;

Expand All @@ -38,7 +36,6 @@ public JadxSettingsWindow(MainWindow mainWindow, JadxSettings settings) {
this.prevLang = settings.getLangLocale();

initUI();
registerBundledFonts();

setTitle(NLS.str("preferences.title"));
setSize(400, 550);
Expand All @@ -48,13 +45,6 @@ public JadxSettingsWindow(MainWindow mainWindow, JadxSettings settings) {
setLocationRelativeTo(null);
}

public static void registerBundledFonts() {
GraphicsEnvironment grEnv = GraphicsEnvironment.getLocalGraphicsEnvironment();
if (FONT_HACK != null) {
grEnv.registerFont(FONT_HACK);
}
}

private void initUI() {
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
Expand Down Expand Up @@ -202,7 +192,6 @@ public void mouseClicked(MouseEvent e) {
int i = themesCbx.getSelectedIndex();
EditorTheme editorTheme = editorThemes[i];
settings.setEditorThemePath(editorTheme.getPath());
mainWindow.setEditorTheme(editorTheme.getPath());
mainWindow.loadSettings();
});

Expand Down
26 changes: 18 additions & 8 deletions jadx-gui/src/main/java/jadx/gui/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,11 @@ public MainWindow(JadxSettings settings) {
this.cacheObject = new CacheObject();

resetCache();
registerBundledFonts();
initUI();
initMenuAndToolbar();
applySettings();
checkForUpdate();
}

private void applySettings() {
setFont(settings.getFont());
setEditorTheme(settings.getEditorThemePath());
loadSettings();
checkForUpdate();
}

public void open() {
Expand Down Expand Up @@ -649,7 +644,14 @@ public void updateFont(Font font) {
setFont(font);
}

public void setEditorTheme(String editorThemePath) {
public static void registerBundledFonts() {
GraphicsEnvironment grEnv = GraphicsEnvironment.getLocalGraphicsEnvironment();
if (Utils.FONT_HACK != null) {
grEnv.registerFont(Utils.FONT_HACK);
}
}

private void setEditorTheme(String editorThemePath) {
try {
editorTheme = Theme.load(getClass().getResourceAsStream(editorThemePath));
} catch (Exception e) {
Expand All @@ -667,6 +669,14 @@ public Theme getEditorTheme() {
}

public void loadSettings() {
Font font = settings.getFont();
Font largerFont = font.deriveFont(font.getSize() + 2.f);

setFont(largerFont);
setEditorTheme(settings.getEditorThemePath());
tree.setFont(largerFont);
tree.setRowHeight(-1);

tabbedPane.loadSettings();
}

Expand Down

0 comments on commit 2931617

Please sign in to comment.