summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dedietrich@qt.io>2018-04-16 18:55:57 -0700
committerGabriel de Dietrich <gabriel.dedietrich@qt.io>2018-04-19 22:19:59 +0000
commit99290faa66eba7abe613d2d0df00e88434470f2e (patch)
tree03e0090e8d7a77db2125c2a07570e0f0e72d809e
parentb7be91b5f28cd42e6f9898f480fa12a0cd359a84 (diff)
QCocoaMenuLoader: Add app specific items after Preferences
This is in accordance with the macOS HIG which state that, "in general, a Preferences menu item should be the first app-specific menu item." See https://developer.apple.com/macos/human-interface-guidelines/menus/menu-bar-menus/ Change-Id: Ie2b6ce274995a7d0b0e934c6a68241500a39f7aa Task-number: QTBUG-63756 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenuloader.mm15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoamenuloader.mm b/src/plugins/platforms/cocoa/qcocoamenuloader.mm
index 00776f4b18..d4009cf63b 100644
--- a/src/plugins/platforms/cocoa/qcocoamenuloader.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenuloader.mm
@@ -126,6 +126,11 @@
preferencesItem.hidden = YES;
[appMenu addItem:preferencesItem];
+ // We'll be adding app specific items after this. The macOS HIG state that,
+ // "In general, a Preferences menu item should be the first app-specific menu item."
+ // https://developer.apple.com/macos/human-interface-guidelines/menus/menu-bar-menus/
+ lastAppSpecificItem = preferencesItem;
+
[appMenu addItem:[NSMenuItem separatorItem]];
// Services item and menu
@@ -278,14 +283,12 @@
// it as an autorelease item.
QCocoaNSMenuItem *item = [[QCocoaNSMenuItem alloc] initWithPlatformMenuItem:platformItem];
- NSInteger location;
- if (lastAppSpecificItem == nil) {
- location = [appMenu indexOfItem:aboutQtItem];
- } else {
- location = [appMenu indexOfItem:lastAppSpecificItem];
+ NSInteger location = [appMenu indexOfItem:lastAppSpecificItem];
+
+ if (!lastAppSpecificItem.separatorItem)
[lastAppSpecificItem release];
- }
lastAppSpecificItem = item; // Keep track of this for later (i.e., don't release it)
+
[appMenu insertItem:item atIndex:location + 1];
return [[item retain] autorelease];