From 99290faa66eba7abe613d2d0df00e88434470f2e Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 16 Apr 2018 18:55:57 -0700 Subject: QCocoaMenuLoader: Add app specific items after Preferences MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ø --- src/plugins/platforms/cocoa/qcocoamenuloader.mm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src') 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]; -- cgit v1.2.3