From eef1f1d5e173a461909815ab53262ba0d20ab5e0 Mon Sep 17 00:00:00 2001 From: Ingo Kegel Date: Sun, 21 Nov 2021 18:21:26 +0100 Subject: [PATCH] Fix for menu items with and without icons were not aligned on macOS --- .../src/main/kotlin/browser/BrowserFrame.kt | 16 ++++++++-------- .../src/main/kotlin/util/DefaultAction.kt | 10 ++++++---- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/modules/browser/src/main/kotlin/browser/BrowserFrame.kt b/modules/browser/src/main/kotlin/browser/BrowserFrame.kt index 5127eaa6..c2a49c07 100644 --- a/modules/browser/src/main/kotlin/browser/BrowserFrame.kt +++ b/modules/browser/src/main/kotlin/browser/BrowserFrame.kt @@ -99,11 +99,11 @@ class BrowserFrame : JFrame() { } } - val setupClasspathAction = DefaultAction(getString("action.setup.class.path"), getString("action.setup.class.path.description")) { + val setupClasspathAction = DefaultAction(getString("action.setup.class.path"), getString("action.setup.class.path.description"), "") { classpathSetupDialog.isVisible = true } - val newWindowAction = DefaultAction(getString("action.new.window"), getString("action.new.window.description")) { + val newWindowAction = DefaultAction(getString("action.new.window"), getString("action.new.window.description"), "") { saveWindowSettings() BrowserFrame().isVisible = true }.apply { @@ -116,7 +116,7 @@ class BrowserFrame : JFrame() { isEnabled = false } - val newWorkspaceAction = DefaultAction(getString("action.new.workspace"), getString("action.new.workspace.description")) { + val newWorkspaceAction = DefaultAction(getString("action.new.workspace"), getString("action.new.workspace.description"), "") { if (frameContent.closeAllTabs()) { workspaceFile = null config.clear() @@ -142,25 +142,25 @@ class BrowserFrame : JFrame() { } } - val saveClassesAction = DefaultAction(getString("action.save.open.classes"), getString("action.save.open.classes.description")) { + val saveClassesAction = DefaultAction(getString("action.save.open.classes"), getString("action.save.open.classes.description"), "") { if (saveClassesFileChooser.select()) { frameContent.saveClassesToDirectory(saveClassesFileChooser.selectedFile) } } - val saveWorkspaceAsAction = DefaultAction(getString("action.save.workspace.as"), getString("action.save.workspace.as.description")) { + val saveWorkspaceAsAction = DefaultAction(getString("action.save.workspace.as"), getString("action.save.workspace.as.description"), "") { saveWorkspace() }.apply { disabled() } - val quitAction = DefaultAction(getString("action.quit")) { + val quitAction = DefaultAction(getString("action.quit"), "", "") { if (prepareClose()) { exit() } } - val closeAction = DefaultAction(getString("action.close.window")) { + val closeAction = DefaultAction(getString("action.close.window"), "", "") { if (prepareClose()) { isVisible = false dispose() @@ -212,7 +212,7 @@ class BrowserFrame : JFrame() { GUIHelper.showURL("https://www.ej-technologies.com") } - val aboutAction = DefaultAction(getString("action.about"), getString("action.about.description")) { + val aboutAction = DefaultAction(getString("action.about"), getString("action.about.description"), "") { BrowserAboutDialog(this).isVisible = true } diff --git a/modules/browser/src/main/kotlin/util/DefaultAction.kt b/modules/browser/src/main/kotlin/util/DefaultAction.kt index 7be7a13d..5e77ec0c 100644 --- a/modules/browser/src/main/kotlin/util/DefaultAction.kt +++ b/modules/browser/src/main/kotlin/util/DefaultAction.kt @@ -26,10 +26,12 @@ class DefaultAction( init { if (iconFileName != null) { - putValue(SMALL_ICON, BrowserFrame.getSvgIcon(iconFileName, SMALL_ICON_SIZE)) - putValue(LARGE_ICON_KEY, BrowserFrame.getSvgIcon(iconFileName, LARGE_ICON_SIZE)) - } else { - putValue(SMALL_ICON, GUIHelper.ICON_EMPTY) + if (iconFileName.isEmpty()) { + putValue(SMALL_ICON, GUIHelper.ICON_EMPTY) + } else { + putValue(SMALL_ICON, BrowserFrame.getSvgIcon(iconFileName, SMALL_ICON_SIZE)) + putValue(LARGE_ICON_KEY, BrowserFrame.getSvgIcon(iconFileName, LARGE_ICON_SIZE)) + } } if (shortDescription != null) { putValue(SHORT_DESCRIPTION, shortDescription)