mirror of https://github.com/mpv-player/mpv
osx: add some more menu bar items as suggested by Apples's HIG
this adds the standard menu bar items Services, Hide Others, Show All and Close, as suggested by Apple's HIG. https://developer.apple.com/macos/human-interface-guidelines/menus/menu-bar-menus/#app-menu - Services are useful to add custom actions and shortcuts via the System Preferences to mpv - Close is important since the menu bar can open secondary windows, like About or the Open dialogue. those couldn't be closed with the standard system shortcut before. this is now possible.
This commit is contained in:
parent
828f38e10d
commit
0d964471b8
|
@ -86,12 +86,32 @@
|
|||
"text editor."
|
||||
}],
|
||||
@{ @"name": @"separator" },
|
||||
[NSMutableDictionary dictionaryWithDictionary:@{
|
||||
@"name" : @"Services",
|
||||
@"key" : @"",
|
||||
}],
|
||||
@{ @"name": @"separator" },
|
||||
[NSMutableDictionary dictionaryWithDictionary:@{
|
||||
@"name" : @"Hide mpv",
|
||||
@"action" : @"hide:",
|
||||
@"key" : @"h",
|
||||
@"target" : NSApp
|
||||
}],
|
||||
[NSMutableDictionary dictionaryWithDictionary:@{
|
||||
@"name" : @"Hide Others",
|
||||
@"action" : @"hideOtherApplications:",
|
||||
@"key" : @"h",
|
||||
@"modifiers" : [NSNumber numberWithUnsignedInteger:
|
||||
NSEventModifierFlagCommand |
|
||||
NSEventModifierFlagOption],
|
||||
@"target" : NSApp
|
||||
}],
|
||||
[NSMutableDictionary dictionaryWithDictionary:@{
|
||||
@"name" : @"Show All",
|
||||
@"action" : @"unhideAllApplications:",
|
||||
@"key" : @"",
|
||||
@"target" : NSApp
|
||||
}],
|
||||
@{ @"name": @"separator" },
|
||||
[NSMutableDictionary dictionaryWithDictionary:@{
|
||||
@"name" : @"Quit and Remember Position",
|
||||
|
@ -125,6 +145,11 @@
|
|||
@"target" : self
|
||||
}],
|
||||
@{ @"name": @"separator" },
|
||||
[NSMutableDictionary dictionaryWithDictionary:@{
|
||||
@"name" : @"Close",
|
||||
@"action" : @"performClose:",
|
||||
@"key" : @"w"
|
||||
}],
|
||||
[NSMutableDictionary dictionaryWithDictionary:@{
|
||||
@"name" : @"Save Screenshot",
|
||||
@"action" : @"cmd:",
|
||||
|
@ -577,6 +602,7 @@
|
|||
- (NSMenu *)mainMenu
|
||||
{
|
||||
NSMenu *mainMenu = [[NSMenu alloc] initWithTitle:@"MainMenu"];
|
||||
NSApp.servicesMenu = [NSMenu alloc];
|
||||
|
||||
for(id mMenu in menuTree) {
|
||||
NSMenu *menu = [[NSMenu alloc] initWithTitle:mMenu[@"name"]];
|
||||
|
@ -600,6 +626,15 @@
|
|||
keyEquivalent:subMenu[@"key"]];
|
||||
[iItem setTarget:subMenu[@"target"]];
|
||||
[subMenu setObject:iItem forKey:@"menuItem"];
|
||||
|
||||
NSNumber *m = subMenu[@"modifiers"];
|
||||
if (m) {
|
||||
[iItem setKeyEquivalentModifierMask:m.unsignedIntegerValue];
|
||||
}
|
||||
|
||||
if ([subMenu[@"name"] isEqual:@"Services"]) {
|
||||
iItem.submenu = NSApp.servicesMenu;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue