From ba5ffc258f6d58bf9d01226baea016db10cfd811 Mon Sep 17 00:00:00 2001 From: Modmuss50 Date: Wed, 7 Jun 2017 08:29:37 +0100 Subject: Added theme switcher + dark theme (#60) * Initial work on the color config * Save and read config from file.+ * Allow changing the editor colors * Remove the right margin * Move config to the user's home dir * Use Guava instead of Apache commons * Add runtime theme switching, includes example "dark" theme. * Rename dark theme as requested * Small clean up * Include suggestions from @Thog --- .../java/cuchaz/enigma/gui/elements/MenuBar.java | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/main/java/cuchaz/enigma/gui/elements') diff --git a/src/main/java/cuchaz/enigma/gui/elements/MenuBar.java b/src/main/java/cuchaz/enigma/gui/elements/MenuBar.java index e446c5a..c0568bf 100644 --- a/src/main/java/cuchaz/enigma/gui/elements/MenuBar.java +++ b/src/main/java/cuchaz/enigma/gui/elements/MenuBar.java @@ -1,5 +1,7 @@ package cuchaz.enigma.gui.elements; +import cuchaz.enigma.config.Config; +import cuchaz.enigma.config.Themes; import cuchaz.enigma.gui.Gui; import cuchaz.enigma.gui.dialog.AboutDialog; import cuchaz.enigma.throwables.MappingParseException; @@ -210,6 +212,35 @@ public class MenuBar extends JMenuBar { item.addActionListener(event -> this.gui.close()); } } + { + JMenu menu = new JMenu("View"); + this.add(menu); + { + JMenu themes = new JMenu("Themes"); + menu.add(themes); + { + JMenuItem defaultTheme = new JMenuItem("Default"); + themes.add(defaultTheme); + defaultTheme.addActionListener(event -> Themes.setDefault(gui)); + JMenuItem dark = new JMenuItem("Dank"); + themes.add(dark); + dark.addActionListener(event -> Themes.setDark(gui)); + themes.addSeparator(); + JMenuItem refresh = new JMenuItem("Reload From config"); + themes.add(refresh); + refresh.addActionListener(event -> { + try { + Config.getInstance().reset(); + Config.getInstance().saveConfig(); + Themes.updateTheme(gui); + } catch (IOException e) { + e.printStackTrace(); + } + }); + } + + } + } { JMenu menu = new JMenu("Help"); this.add(menu); -- cgit v1.2.3