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>
This commit is contained in:
Gabriel de Dietrich 2018-04-16 18:55:57 -07:00
parent b7be91b5f2
commit 99290faa66

View File

@ -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];