From e98aac1e67653cd2852044799cd7342d825633a8 Mon Sep 17 00:00:00 2001 From: ghidragon <106987263+ghidragon@users.noreply.github.com> Date: Wed, 10 Jan 2024 11:55:34 -0500 Subject: [PATCH] GP-4172 simplified theme switcher dialog. Also added in double click to pick and exit --- .../help/topics/Theming/ThemingUserDocs.html | 8 +++---- .../app/plugin/gui/ThemeChooserDialog.java | 23 +++++-------------- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/Ghidra/Framework/Docking/src/main/help/help/topics/Theming/ThemingUserDocs.html b/Ghidra/Framework/Docking/src/main/help/help/topics/Theming/ThemingUserDocs.html index 67fc52ce8d..0b3ce4947e 100644 --- a/Ghidra/Framework/Docking/src/main/help/help/topics/Theming/ThemingUserDocs.html +++ b/Ghidra/Framework/Docking/src/main/help/help/topics/Theming/ThemingUserDocs.html @@ -32,10 +32,10 @@
The Theme Chooser dialog displays a list of all the know themes, both built-in and custom. - As you pick different themes, the application will switch to that theme. Press the "OK" button - when the desired theme is selected. Pressing the "Cancel" button will restore the theme to - the what it was when the dialog was invoked.
+The Theme Chooser dialog displays a list of all the known themes, both built-in and custom. + Select the desired theme and press the "OK" button to have the application switch to that + theme. Pressing the "Cancel" button will exit the dialog without changing the theme. You + can also double click on a theme to switch to that theme and exit the dialog.
diff --git a/Ghidra/Framework/Project/src/main/java/ghidra/app/plugin/gui/ThemeChooserDialog.java b/Ghidra/Framework/Project/src/main/java/ghidra/app/plugin/gui/ThemeChooserDialog.java index 925fb7eddf..32dfa7c461 100644 --- a/Ghidra/Framework/Project/src/main/java/ghidra/app/plugin/gui/ThemeChooserDialog.java +++ b/Ghidra/Framework/Project/src/main/java/ghidra/app/plugin/gui/ThemeChooserDialog.java @@ -35,22 +35,21 @@ public class ThemeChooserDialog extends DialogComponentProvider { public ThemeChooserDialog(ThemeManager themeManager) { super("Change Theme"); this.themeManager = themeManager; + addWorkPanel(buildMainPanel()); addOKButton(); - addApplyButton(); addCancelButton(); setRememberSize(false); setHelpLocation(new HelpLocation("Theming", "Switch_Theme")); - updateOkApplyButtons(); + updateButtonEnablement(); } - private void updateOkApplyButtons() { + private void updateButtonEnablement() { GTheme selectedValue = listPanel.getSelectedValue(); GTheme currentTheme = themeManager.getActiveTheme(); boolean canApplyTheme = selectedValue != null && !currentTheme.equals(selectedValue); setOkEnabled(canApplyTheme); - setApplyEnabled(canApplyTheme); } @Override @@ -59,22 +58,12 @@ public class ThemeChooserDialog extends DialogComponentProvider { close(); } - @Override - protected void applyCallback() { - applyTheme(); - } - private void applyTheme() { GTheme selectedValue = listPanel.getSelectedValue(); - if (selectedValue == null) { - return; - } GTheme activeTheme = themeManager.getActiveTheme(); - if (selectedValue != activeTheme) { + if (selectedValue != null && selectedValue != activeTheme) { Swing.runLater(() -> themeManager.setTheme(selectedValue)); } - setOkEnabled(false); - setApplyEnabled(false); } protected void cancelCallback() { @@ -93,12 +82,12 @@ public class ThemeChooserDialog extends DialogComponentProvider { listPanel.setSelectedValue(activeTheme); listPanel.addListSelectionListener(e -> selectionChanged()); panel.add(listPanel); - + listPanel.setDoubleClickActionListener(e -> okCallback()); return panel; } private void selectionChanged() { - updateOkApplyButtons(); + updateButtonEnablement(); } private class ThemeListModel extends AbstractListModel