diff --git a/MacPass/MPActionHelper.h b/MacPass/MPActionHelper.h index 7c2c984e..2d35e7df 100644 --- a/MacPass/MPActionHelper.h +++ b/MacPass/MPActionHelper.h @@ -47,6 +47,7 @@ typedef NS_ENUM(NSUInteger, MPActionType) { MPActionToggleQuicklook, MPActionShowEntryHistory, // show history MPActionHideEntryHistory, // exit history + MPActionShowGroupInOutline, // show the group (of the entry) in the outline view MPActionPerformAutotypeForSelectedEntry, // Perform Autotype for selected Entry MPActionRemoveAttachment // Remove an attachment }; diff --git a/MacPass/MPActionHelper.m b/MacPass/MPActionHelper.m index f539b243..dca564ec 100644 --- a/MacPass/MPActionHelper.m +++ b/MacPass/MPActionHelper.m @@ -57,6 +57,7 @@ @(MPActionToggleQuicklook): NSStringFromSelector(@selector(toggleQuicklookPreview:)), @(MPActionShowEntryHistory): NSStringFromSelector(@selector(showEntryHistory:)), @(MPActionHideEntryHistory): NSStringFromSelector(@selector(hideEntryHistory:)), + @(MPActionShowGroupInOutline): NSStringFromSelector(@selector(showGroupInOutline:)), @(MPActionPerformAutotypeForSelectedEntry): NSStringFromSelector(@selector(performAutotypeForEntry:)), @(MPActionRemoveAttachment): NSStringFromSelector(@selector(removeAttachment:)) }; diff --git a/MacPass/MPAppDelegate.m b/MacPass/MPAppDelegate.m index 8d6c0c56..ae683871 100644 --- a/MacPass/MPAppDelegate.m +++ b/MacPass/MPAppDelegate.m @@ -158,7 +158,7 @@ typedef NS_OPTIONS(NSInteger, MPAppStartupState) { [fileMenu insertItem:item atIndex:insertIndex]; } [self.itemMenu removeAllItems]; - for(NSMenuItem *item in [MPContextMenuHelper contextMenuItemsWithItems:MPContextMenuFull]) { + for(NSMenuItem *item in [MPContextMenuHelper contextMenuItemsWithItems:MPContextMenuFull|MPContextMenuShowGroupInOutline]) { [self.itemMenu addItem:item]; } self.itemMenu.delegate = self.itemActionMenuDelegate; diff --git a/MacPass/MPContextMenuHelper.h b/MacPass/MPContextMenuHelper.h index ae083579..a6072221 100644 --- a/MacPass/MPContextMenuHelper.h +++ b/MacPass/MPContextMenuHelper.h @@ -23,16 +23,17 @@ #import typedef NS_OPTIONS(NSUInteger, MPContextMenuItemsFlags) { - MPContextMenuCreate = 1 << 0, - MPContextMenuDelete = 1 << 1, - MPContextMenuCopy = 1 << 2, - MPContextMenuTrash = 1 << 3, - MPContextMenuDuplicate = 1 << 4, - MPContextMenuAutotype = 1 << 5, - MPContextMenuHistory = 1 << 6, - MPContextMenuMinimal = MPContextMenuCreate | MPContextMenuDelete, - MPContextMenuFull = MPContextMenuMinimal | MPContextMenuCopy | MPContextMenuDuplicate | MPContextMenuAutotype | MPContextMenuHistory, - MPContextMenuExtended = MPContextMenuFull | MPContextMenuTrash + MPContextMenuCreate = 1 << 0, + MPContextMenuDelete = 1 << 1, + MPContextMenuCopy = 1 << 2, + MPContextMenuTrash = 1 << 3, + MPContextMenuDuplicate = 1 << 4, + MPContextMenuAutotype = 1 << 5, + MPContextMenuHistory = 1 << 6, + MPContextMenuShowGroupInOutline = 1 << 7, + MPContextMenuMinimal = MPContextMenuCreate | MPContextMenuDelete, + MPContextMenuFull = MPContextMenuMinimal | MPContextMenuCopy | MPContextMenuDuplicate | MPContextMenuAutotype | MPContextMenuHistory, + MPContextMenuExtended = MPContextMenuFull | MPContextMenuTrash }; @interface MPContextMenuHelper : NSTableCellView diff --git a/MacPass/MPContextMenuHelper.m b/MacPass/MPContextMenuHelper.m index 3691ffa4..058cbb60 100644 --- a/MacPass/MPContextMenuHelper.m +++ b/MacPass/MPContextMenuHelper.m @@ -42,6 +42,7 @@ static void MPContextmenuHelperBeginSection(NSMutableArray *items) { BOOL const insertDuplicate = MPIsFlagSetInOptions(MPContextMenuDuplicate, flags); BOOL const insertAutotype = MPIsFlagSetInOptions(MPContextMenuAutotype, flags); BOOL const insertHistory = MPIsFlagSetInOptions(MPContextMenuHistory, flags); + BOOL const insertShowGroupInOutline = MPIsFlagSetInOptions(MPContextMenuShowGroupInOutline, flags); NSMutableArray *items = [NSMutableArray arrayWithCapacity:10]; if(insertCreate) { @@ -113,7 +114,7 @@ static void MPContextmenuHelperBeginSection(NSMutableArray *items) { [items addObjectsFromArray:@[ copyUsername, copyPassword, urlItem]]; } - if(insertAutotype || insertHistory) { + if(insertAutotype || insertHistory || insertShowGroupInOutline) { MPContextmenuHelperBeginSection(items); if(insertAutotype) { NSMenuItem *performAutotype = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"PERFORM_AUTOTYPE_FOR_ENTRY", @"Menu item to perform autotype with the selected entry") @@ -128,6 +129,12 @@ static void MPContextmenuHelperBeginSection(NSMutableArray *items) { showHistory.keyEquivalentModifierMask = (showHistory.keyEquivalentModifierMask | NSCommandKeyMask | NSControlKeyMask); [items addObject:showHistory]; } + if(insertShowGroupInOutline) { + NSMenuItem *showGroupInOutline = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"SHOW_GROUP_IN_OUTLINE", @"Menu item to show the entries group in the outline view") + action:[MPActionHelper actionOfType:MPActionShowGroupInOutline] + keyEquivalent:@""]; + [items addObject:showGroupInOutline]; + } } return items; diff --git a/MacPass/MPDocument.m b/MacPass/MPDocument.m index 1feab801..42f490db 100644 --- a/MacPass/MPDocument.m +++ b/MacPass/MPDocument.m @@ -914,6 +914,9 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou case MPActionCopyCustomAttribute: case MPActionCopyAsReference: valid &= (nil != targetEntry); + case MPActionShowGroupInOutline: + valid &= (nil != targetEntry); + valid &= self.hasSearch; break; default: break; diff --git a/MacPass/MPDocumentWindowController.h b/MacPass/MPDocumentWindowController.h index e02521b4..2b51042c 100644 --- a/MacPass/MPDocumentWindowController.h +++ b/MacPass/MPDocumentWindowController.h @@ -66,11 +66,11 @@ - (IBAction)delete:(id)sender; - (IBAction)duplicateEntryWithOptions:(id)sender; - - (IBAction)pickExpiryDate:(id)sender; - - (IBAction)performAutotypeForEntry:(id)sender; +- (IBAction)showGroupInOutline:(id)sender; + /* actions relayed to MPEntryViewController */ - (IBAction)copyUsername:(id)sender; - (IBAction)copyPassword:(id)sender; diff --git a/MacPass/MPDocumentWindowController.m b/MacPass/MPDocumentWindowController.m index ece7e22f..87f9fd67 100644 --- a/MacPass/MPDocumentWindowController.m +++ b/MacPass/MPDocumentWindowController.m @@ -545,6 +545,14 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword); [contentView layoutSubtreeIfNeeded]; } +- (void)showGroupInOutline:(id)sender { + NSArray *targetEntries = self.entryViewController.currentTargetEntries; + if(targetEntries.count != 1) { + return; + } + [self.outlineViewController selectGroup:targetEntries.lastObject.parent]; +} + #pragma mark - #pragma mark Actions forwarded to MPEntryViewController - (void)copyUsername:(id)sender { diff --git a/MacPass/MPEntryContextMenuDelegate.h b/MacPass/MPEntryContextMenuDelegate.h index bd7add5f..72600915 100644 --- a/MacPass/MPEntryContextMenuDelegate.h +++ b/MacPass/MPEntryContextMenuDelegate.h @@ -23,7 +23,7 @@ #import /** - Delegate is used for context menus that are show in the entries table + Delegate is used for context menus that are show in the entries table as well as the items menu in the main menu */ @interface MPEntryContextMenuDelegate : NSObject diff --git a/MacPass/MPEntryViewController.m b/MacPass/MPEntryViewController.m index f074d6d6..d072d8c5 100644 --- a/MacPass/MPEntryViewController.m +++ b/MacPass/MPEntryViewController.m @@ -602,7 +602,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell"; - (void)_setupEntryMenu { NSMenu *menu = [[NSMenu alloc] init]; - NSArray *items = [MPContextMenuHelper contextMenuItemsWithItems:MPContextMenuFull]; + NSArray *items = [MPContextMenuHelper contextMenuItemsWithItems:MPContextMenuFull|MPContextMenuShowGroupInOutline]; for(NSMenuItem *item in items) { [menu addItem:item]; } @@ -777,12 +777,8 @@ NSString *const _MPTableSecurCellView = @"PasswordCell"; } - (void)_executeGroupColumnDoubleClick { - NSUInteger clickedRow = self.entryTable.clickedRow; - if(clickedRow < 0 || clickedRow > [self.entryArrayController.arrangedObjects count]) { - return; - } - KPKEntry *entry = self.entryArrayController.arrangedObjects[clickedRow]; - [((MPDocumentWindowController *)self.windowController).outlineViewController selectGroup:entry.parent]; + id target = [NSApp targetForAction:@selector(showGroupInOutline:)]; + [target showGroupInOutline:self]; } - (void)_executeTitleColumnDoubleClick { diff --git a/MacPass/MPOutlineViewController.m b/MacPass/MPOutlineViewController.m index 3d492ca1..6ca32135 100644 --- a/MacPass/MPOutlineViewController.m +++ b/MacPass/MPOutlineViewController.m @@ -157,6 +157,7 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell"; } NSUInteger rowToSelect = [self _rowForUUID:groupUUID node:node]; [self.outlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:rowToSelect] byExtendingSelection:NO]; + [self.outlineView scrollRowToVisible:rowToSelect]; } - (void)_expandItems:(NSTreeNode *)node { diff --git a/MacPass/MPToolbarDelegate.m b/MacPass/MPToolbarDelegate.m index 22852525..098ef5b0 100644 --- a/MacPass/MPToolbarDelegate.m +++ b/MacPass/MPToolbarDelegate.m @@ -128,7 +128,7 @@ NSString *const MPToolbarItemAutotype = @"TOOLBAR_AUTOTYPE"; NSMenuItem *actionImageItem = [[NSMenuItem alloc] initWithTitle:@"" action:NULL keyEquivalent:@""]; actionImageItem.image = self.toolbarImages[MPToolbarItemAction]; [menu addItem:actionImageItem]; - NSArray *menuItems = [MPContextMenuHelper contextMenuItemsWithItems:MPContextMenuExtended]; + NSArray *menuItems = [MPContextMenuHelper contextMenuItemsWithItems:MPContextMenuExtended|MPContextMenuShowGroupInOutline]; for(NSMenuItem *item in menuItems) { [menu addItem:item]; }