From 51c486fb828a04281278f3cd922901de5430f9e9 Mon Sep 17 00:00:00 2001 From: Michael Starke Date: Thu, 14 Feb 2019 17:49:43 +0100 Subject: [PATCH] Use itemDelgate for item menu and remove special treatment in app delegate --- MacPass/MPAppDelegate.m | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/MacPass/MPAppDelegate.m b/MacPass/MPAppDelegate.m index 257a3fb1..5c982f93 100644 --- a/MacPass/MPAppDelegate.m +++ b/MacPass/MPAppDelegate.m @@ -41,6 +41,7 @@ #import "MPUserNotificationCenterDelegate.h" #import "MPWelcomeViewController.h" #import "MPPlugin.h" +#import "MPEntryContextMenuDelegate.h" #import "NSApplication+MPAdditions.h" @@ -54,6 +55,8 @@ NSString *const MPDidChangeStoredKeyFilesSettings = @"com.hicknhack.macpass.MPDi @private MPDockTileHelper *_dockTileHelper; MPUserNotificationCenterDelegate *_userNotificationCenterDelegate; + MPEntryContextMenuDelegate *_entryContextMenuDelegate; + BOOL _shouldOpenFile; // YES if app was started to open a } @@ -78,6 +81,7 @@ NSString *const MPDidChangeStoredKeyFilesSettings = @"com.hicknhack.macpass.MPDi self = [super init]; if(self) { _userNotificationCenterDelegate = [[MPUserNotificationCenterDelegate alloc] init]; + _entryContextMenuDelegate = [[MPEntryContextMenuDelegate alloc] init]; /* We know that we do not use the variable after instantiation */ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunused-variable" @@ -122,6 +126,11 @@ NSString *const MPDidChangeStoredKeyFilesSettings = @"com.hicknhack.macpass.MPDi for(NSMenuItem *item in items.reverseObjectEnumerator) { [fileMenu insertItem:item atIndex:insertIndex]; } + [self.itemMenu removeAllItems]; + for(NSMenuItem *item in [MPContextMenuHelper contextMenuItemsWithItems:MPContextMenuFull]) { + [self.itemMenu addItem:item]; + } + self.itemMenu.delegate = _entryContextMenuDelegate; } #pragma mark - @@ -206,12 +215,6 @@ NSString *const MPDidChangeStoredKeyFilesSettings = @"com.hicknhack.macpass.MPDi if(menu == self.fixAutotypeMenuItem.menu) { self.fixAutotypeMenuItem.hidden = !(NSEvent.modifierFlags & NSAlternateKeyMask); } - if(menu == self.itemMenu) { - [menu removeAllItems]; - for(NSMenuItem *item in [MPContextMenuHelper contextMenuItemsWithItems:MPContextMenuFull]) { - [menu addItem:item]; - } - } if(menu == self.importMenu) { NSMenuItem *exportXML = menu.itemArray.firstObject; [menu removeAllItems];