mirror of
https://github.com/MacPass/MacPass.git
synced 2026-01-31 14:18:16 +00:00
Added show group in outline to context menus
This commit is contained in:
@@ -47,6 +47,7 @@ typedef NS_ENUM(NSUInteger, MPActionType) {
|
|||||||
MPActionToggleQuicklook,
|
MPActionToggleQuicklook,
|
||||||
MPActionShowEntryHistory, // show history
|
MPActionShowEntryHistory, // show history
|
||||||
MPActionHideEntryHistory, // exit history
|
MPActionHideEntryHistory, // exit history
|
||||||
|
MPActionShowGroupInOutline, // show the group (of the entry) in the outline view
|
||||||
MPActionPerformAutotypeForSelectedEntry, // Perform Autotype for selected Entry
|
MPActionPerformAutotypeForSelectedEntry, // Perform Autotype for selected Entry
|
||||||
MPActionRemoveAttachment // Remove an attachment
|
MPActionRemoveAttachment // Remove an attachment
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -57,6 +57,7 @@
|
|||||||
@(MPActionToggleQuicklook): NSStringFromSelector(@selector(toggleQuicklookPreview:)),
|
@(MPActionToggleQuicklook): NSStringFromSelector(@selector(toggleQuicklookPreview:)),
|
||||||
@(MPActionShowEntryHistory): NSStringFromSelector(@selector(showEntryHistory:)),
|
@(MPActionShowEntryHistory): NSStringFromSelector(@selector(showEntryHistory:)),
|
||||||
@(MPActionHideEntryHistory): NSStringFromSelector(@selector(hideEntryHistory:)),
|
@(MPActionHideEntryHistory): NSStringFromSelector(@selector(hideEntryHistory:)),
|
||||||
|
@(MPActionShowGroupInOutline): NSStringFromSelector(@selector(showGroupInOutline:)),
|
||||||
@(MPActionPerformAutotypeForSelectedEntry): NSStringFromSelector(@selector(performAutotypeForEntry:)),
|
@(MPActionPerformAutotypeForSelectedEntry): NSStringFromSelector(@selector(performAutotypeForEntry:)),
|
||||||
@(MPActionRemoveAttachment): NSStringFromSelector(@selector(removeAttachment:))
|
@(MPActionRemoveAttachment): NSStringFromSelector(@selector(removeAttachment:))
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ typedef NS_OPTIONS(NSInteger, MPAppStartupState) {
|
|||||||
[fileMenu insertItem:item atIndex:insertIndex];
|
[fileMenu insertItem:item atIndex:insertIndex];
|
||||||
}
|
}
|
||||||
[self.itemMenu removeAllItems];
|
[self.itemMenu removeAllItems];
|
||||||
for(NSMenuItem *item in [MPContextMenuHelper contextMenuItemsWithItems:MPContextMenuFull]) {
|
for(NSMenuItem *item in [MPContextMenuHelper contextMenuItemsWithItems:MPContextMenuFull|MPContextMenuShowGroupInOutline]) {
|
||||||
[self.itemMenu addItem:item];
|
[self.itemMenu addItem:item];
|
||||||
}
|
}
|
||||||
self.itemMenu.delegate = self.itemActionMenuDelegate;
|
self.itemMenu.delegate = self.itemActionMenuDelegate;
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ typedef NS_OPTIONS(NSUInteger, MPContextMenuItemsFlags) {
|
|||||||
MPContextMenuDuplicate = 1 << 4,
|
MPContextMenuDuplicate = 1 << 4,
|
||||||
MPContextMenuAutotype = 1 << 5,
|
MPContextMenuAutotype = 1 << 5,
|
||||||
MPContextMenuHistory = 1 << 6,
|
MPContextMenuHistory = 1 << 6,
|
||||||
|
MPContextMenuShowGroupInOutline = 1 << 7,
|
||||||
MPContextMenuMinimal = MPContextMenuCreate | MPContextMenuDelete,
|
MPContextMenuMinimal = MPContextMenuCreate | MPContextMenuDelete,
|
||||||
MPContextMenuFull = MPContextMenuMinimal | MPContextMenuCopy | MPContextMenuDuplicate | MPContextMenuAutotype | MPContextMenuHistory,
|
MPContextMenuFull = MPContextMenuMinimal | MPContextMenuCopy | MPContextMenuDuplicate | MPContextMenuAutotype | MPContextMenuHistory,
|
||||||
MPContextMenuExtended = MPContextMenuFull | MPContextMenuTrash
|
MPContextMenuExtended = MPContextMenuFull | MPContextMenuTrash
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ static void MPContextmenuHelperBeginSection(NSMutableArray *items) {
|
|||||||
BOOL const insertDuplicate = MPIsFlagSetInOptions(MPContextMenuDuplicate, flags);
|
BOOL const insertDuplicate = MPIsFlagSetInOptions(MPContextMenuDuplicate, flags);
|
||||||
BOOL const insertAutotype = MPIsFlagSetInOptions(MPContextMenuAutotype, flags);
|
BOOL const insertAutotype = MPIsFlagSetInOptions(MPContextMenuAutotype, flags);
|
||||||
BOOL const insertHistory = MPIsFlagSetInOptions(MPContextMenuHistory, flags);
|
BOOL const insertHistory = MPIsFlagSetInOptions(MPContextMenuHistory, flags);
|
||||||
|
BOOL const insertShowGroupInOutline = MPIsFlagSetInOptions(MPContextMenuShowGroupInOutline, flags);
|
||||||
|
|
||||||
NSMutableArray *items = [NSMutableArray arrayWithCapacity:10];
|
NSMutableArray *items = [NSMutableArray arrayWithCapacity:10];
|
||||||
if(insertCreate) {
|
if(insertCreate) {
|
||||||
@@ -113,7 +114,7 @@ static void MPContextmenuHelperBeginSection(NSMutableArray *items) {
|
|||||||
|
|
||||||
[items addObjectsFromArray:@[ copyUsername, copyPassword, urlItem]];
|
[items addObjectsFromArray:@[ copyUsername, copyPassword, urlItem]];
|
||||||
}
|
}
|
||||||
if(insertAutotype || insertHistory) {
|
if(insertAutotype || insertHistory || insertShowGroupInOutline) {
|
||||||
MPContextmenuHelperBeginSection(items);
|
MPContextmenuHelperBeginSection(items);
|
||||||
if(insertAutotype) {
|
if(insertAutotype) {
|
||||||
NSMenuItem *performAutotype = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"PERFORM_AUTOTYPE_FOR_ENTRY", @"Menu item to perform autotype with the selected entry")
|
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);
|
showHistory.keyEquivalentModifierMask = (showHistory.keyEquivalentModifierMask | NSCommandKeyMask | NSControlKeyMask);
|
||||||
[items addObject:showHistory];
|
[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;
|
return items;
|
||||||
|
|||||||
@@ -914,6 +914,9 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou
|
|||||||
case MPActionCopyCustomAttribute:
|
case MPActionCopyCustomAttribute:
|
||||||
case MPActionCopyAsReference:
|
case MPActionCopyAsReference:
|
||||||
valid &= (nil != targetEntry);
|
valid &= (nil != targetEntry);
|
||||||
|
case MPActionShowGroupInOutline:
|
||||||
|
valid &= (nil != targetEntry);
|
||||||
|
valid &= self.hasSearch;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -66,11 +66,11 @@
|
|||||||
- (IBAction)delete:(id)sender;
|
- (IBAction)delete:(id)sender;
|
||||||
|
|
||||||
- (IBAction)duplicateEntryWithOptions:(id)sender;
|
- (IBAction)duplicateEntryWithOptions:(id)sender;
|
||||||
|
|
||||||
- (IBAction)pickExpiryDate:(id)sender;
|
- (IBAction)pickExpiryDate:(id)sender;
|
||||||
|
|
||||||
- (IBAction)performAutotypeForEntry:(id)sender;
|
- (IBAction)performAutotypeForEntry:(id)sender;
|
||||||
|
|
||||||
|
- (IBAction)showGroupInOutline:(id)sender;
|
||||||
|
|
||||||
/* actions relayed to MPEntryViewController */
|
/* actions relayed to MPEntryViewController */
|
||||||
- (IBAction)copyUsername:(id)sender;
|
- (IBAction)copyUsername:(id)sender;
|
||||||
- (IBAction)copyPassword:(id)sender;
|
- (IBAction)copyPassword:(id)sender;
|
||||||
|
|||||||
@@ -545,6 +545,14 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
|
|||||||
[contentView layoutSubtreeIfNeeded];
|
[contentView layoutSubtreeIfNeeded];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)showGroupInOutline:(id)sender {
|
||||||
|
NSArray<KPKEntry *> *targetEntries = self.entryViewController.currentTargetEntries;
|
||||||
|
if(targetEntries.count != 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
[self.outlineViewController selectGroup:targetEntries.lastObject.parent];
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark Actions forwarded to MPEntryViewController
|
#pragma mark Actions forwarded to MPEntryViewController
|
||||||
- (void)copyUsername:(id)sender {
|
- (void)copyUsername:(id)sender {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
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 <NSMenuDelegate>
|
@interface MPEntryContextMenuDelegate : NSObject <NSMenuDelegate>
|
||||||
|
|
||||||
|
|||||||
@@ -602,7 +602,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
|
|||||||
- (void)_setupEntryMenu {
|
- (void)_setupEntryMenu {
|
||||||
|
|
||||||
NSMenu *menu = [[NSMenu alloc] init];
|
NSMenu *menu = [[NSMenu alloc] init];
|
||||||
NSArray *items = [MPContextMenuHelper contextMenuItemsWithItems:MPContextMenuFull];
|
NSArray *items = [MPContextMenuHelper contextMenuItemsWithItems:MPContextMenuFull|MPContextMenuShowGroupInOutline];
|
||||||
for(NSMenuItem *item in items) {
|
for(NSMenuItem *item in items) {
|
||||||
[menu addItem:item];
|
[menu addItem:item];
|
||||||
}
|
}
|
||||||
@@ -777,12 +777,8 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)_executeGroupColumnDoubleClick {
|
- (void)_executeGroupColumnDoubleClick {
|
||||||
NSUInteger clickedRow = self.entryTable.clickedRow;
|
id target = [NSApp targetForAction:@selector(showGroupInOutline:)];
|
||||||
if(clickedRow < 0 || clickedRow > [self.entryArrayController.arrangedObjects count]) {
|
[target showGroupInOutline:self];
|
||||||
return;
|
|
||||||
}
|
|
||||||
KPKEntry *entry = self.entryArrayController.arrangedObjects[clickedRow];
|
|
||||||
[((MPDocumentWindowController *)self.windowController).outlineViewController selectGroup:entry.parent];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)_executeTitleColumnDoubleClick {
|
- (void)_executeTitleColumnDoubleClick {
|
||||||
|
|||||||
@@ -157,6 +157,7 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
|
|||||||
}
|
}
|
||||||
NSUInteger rowToSelect = [self _rowForUUID:groupUUID node:node];
|
NSUInteger rowToSelect = [self _rowForUUID:groupUUID node:node];
|
||||||
[self.outlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:rowToSelect] byExtendingSelection:NO];
|
[self.outlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:rowToSelect] byExtendingSelection:NO];
|
||||||
|
[self.outlineView scrollRowToVisible:rowToSelect];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)_expandItems:(NSTreeNode *)node {
|
- (void)_expandItems:(NSTreeNode *)node {
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ NSString *const MPToolbarItemAutotype = @"TOOLBAR_AUTOTYPE";
|
|||||||
NSMenuItem *actionImageItem = [[NSMenuItem alloc] initWithTitle:@"" action:NULL keyEquivalent:@""];
|
NSMenuItem *actionImageItem = [[NSMenuItem alloc] initWithTitle:@"" action:NULL keyEquivalent:@""];
|
||||||
actionImageItem.image = self.toolbarImages[MPToolbarItemAction];
|
actionImageItem.image = self.toolbarImages[MPToolbarItemAction];
|
||||||
[menu addItem:actionImageItem];
|
[menu addItem:actionImageItem];
|
||||||
NSArray *menuItems = [MPContextMenuHelper contextMenuItemsWithItems:MPContextMenuExtended];
|
NSArray *menuItems = [MPContextMenuHelper contextMenuItemsWithItems:MPContextMenuExtended|MPContextMenuShowGroupInOutline];
|
||||||
for(NSMenuItem *item in menuItems) {
|
for(NSMenuItem *item in menuItems) {
|
||||||
[menu addItem:item];
|
[menu addItem:item];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user