From 472e74f35955c263b33e6bc89a4279d627d9b7bb Mon Sep 17 00:00:00 2001 From: Junsoo Kim Date: Thu, 23 May 2024 09:22:45 -0400 Subject: [PATCH] [#538] Add dark mode option in menu and add CSS file for dark theme. --- src/org/jetuml/JetUML.properties | 3 +++ src/org/jetuml/application/UserPreferences.java | 2 +- src/org/jetuml/gui/EditorFrame.java | 8 ++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/org/jetuml/JetUML.properties b/src/org/jetuml/JetUML.properties index 4cd1de71..b650c042 100644 --- a/src/org/jetuml/JetUML.properties +++ b/src/org/jetuml/JetUML.properties @@ -284,6 +284,9 @@ view.verbose_tooltips.mnemonic=T view.autoedit_node.text=Auto Edit Node view.autoedit_node.mnemonic=A view.autoedit_node.icon=16x16/document-edit.png +view.dark_mode.text=Dark Mode +view.dark_mode.mnemonic=M +view.dark_mode.icon=16x16/dark-mode.png view.diagram_size.text=Set Diagram Size view.diagram_size.mnemonic=D view.diagram_size.icon=16x16/zoom-fit-width.png diff --git a/src/org/jetuml/application/UserPreferences.java b/src/org/jetuml/application/UserPreferences.java index 4c6908a0..523a5213 100644 --- a/src/org/jetuml/application/UserPreferences.java +++ b/src/org/jetuml/application/UserPreferences.java @@ -42,7 +42,7 @@ public final class UserPreferences public enum BooleanPreference { showGrid(true), showToolHints(false), autoEditNode(false), verboseToolTips(false), - showTips(true); + showTips(true), darkMode(false); private boolean aDefault; diff --git a/src/org/jetuml/gui/EditorFrame.java b/src/org/jetuml/gui/EditorFrame.java index 7b790ddd..064255e4 100644 --- a/src/org/jetuml/gui/EditorFrame.java +++ b/src/org/jetuml/gui/EditorFrame.java @@ -132,6 +132,9 @@ public EditorFrame(Stage pMainStage) getSelectedDiagramTab().keyTyped(e.getCharacter()); } }); + + getStylesheets().add(getClass().getResource("DarkMode.css").toExternalForm()); + getStylesheets().remove(getClass().getResource("DarkMode.css").toExternalForm()); } /* Returns the subset of pDesiredFormats for which a registered image writer @@ -236,6 +239,11 @@ private void createViewMenu(MenuBar pMenuBar) UserPreferences.instance().getBoolean(BooleanPreference.autoEditNode), event -> UserPreferences.instance().setBoolean(BooleanPreference.autoEditNode, ((CheckMenuItem) event.getSource()).isSelected())), + + factory.createCheckMenuItem("view.dark_mode", false, + UserPreferences.instance().getBoolean(BooleanPreference.darkMode), + event -> UserPreferences.instance().setBoolean(BooleanPreference.darkMode, + ((CheckMenuItem) event.getSource()).isSelected())), factory.createMenuItem("view.diagram_size", false, event -> new DiagramSizeDialog(aMainStage).show()), factory.createMenuItem("view.font", false, event -> new FontDialog(aMainStage).show()),