Browse Source

Fix integration with system menu in macOS

pull/36/head
Vladimir Sitnikov 5 years ago
parent
commit
265c1c1725
  1. 18
      core/src/main/java/com/github/weisj/darklaf/DarkLaf.java

18
core/src/main/java/com/github/weisj/darklaf/DarkLaf.java

@ -105,7 +105,6 @@ public class DarkLaf extends BasicLookAndFeel implements PropertyChangeListener
loadThemeDefaults(defaults); loadThemeDefaults(defaults);
initIdeaDefaults(defaults); initIdeaDefaults(defaults);
patchComboBox(metalDefaults, defaults); patchComboBox(metalDefaults, defaults);
adjustPlatformSpecifics(defaults);
JFrame.setDefaultLookAndFeelDecorated(true); JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true);
@ -117,15 +116,13 @@ public class DarkLaf extends BasicLookAndFeel implements PropertyChangeListener
return super.getDefaults(); return super.getDefaults();
} }
protected void adjustPlatformSpecifics(final UIDefaults defaults) { protected void adjustPlatformSpecifics(final Properties uiProps) {
boolean useScreenMenuBar = "true".equalsIgnoreCase(System.getProperty("apple.laf.useScreenMenuBar", boolean useScreenMenuBar = Boolean.getBoolean("apple.laf.useScreenMenuBar");
"false")); // If user wants to use Apple menu bar, then we need to keep the default
if (SystemInfo.isMac && !useScreenMenuBar) { // component for MenuBarUI and MenuUI
defaults.put("MenuBarUI", "com.github.weisj.darklaf.ui.menu.DarkMenuBarUI"); if (SystemInfo.isMac && useScreenMenuBar) {
defaults.put("MenuUI", "com.github.weisj.darklaf.ui.menu.DarkMenuUI"); uiProps.remove("MenuBarUI");
} else { uiProps.remove("MenuUI");
defaults.remove("MenuBarUI");
defaults.remove("MenuUI");
} }
} }
@ -182,6 +179,7 @@ public class DarkLaf extends BasicLookAndFeel implements PropertyChangeListener
currentTheme.loadUIProperties(uiProps, defaults); currentTheme.loadUIProperties(uiProps, defaults);
currentTheme.loadIconProperties(uiProps, defaults); currentTheme.loadIconProperties(uiProps, defaults);
currentTheme.loadPlatformProperties(uiProps, defaults); currentTheme.loadPlatformProperties(uiProps, defaults);
adjustPlatformSpecifics(uiProps);
defaults.putAll(uiProps); defaults.putAll(uiProps);
StyleSheet styleSheet = currentTheme.loadStyleSheet(); StyleSheet styleSheet = currentTheme.loadStyleSheet();

Loading…
Cancel
Save