diff --git a/MacPass/Base.lproj/InspectorView.xib b/MacPass/Base.lproj/InspectorView.xib index 961385e0..ac757642 100644 --- a/MacPass/Base.lproj/InspectorView.xib +++ b/MacPass/Base.lproj/InspectorView.xib @@ -7,13 +7,10 @@ - - - @@ -24,35 +21,6 @@ - - - - - - - - - - - - - - - - - @@ -81,7 +49,7 @@ - + @@ -135,11 +103,11 @@ - + - + @@ -147,19 +115,19 @@ - + - + - + - + - + @@ -178,14 +146,14 @@ - + - + @@ -201,20 +169,15 @@ - - - - - - + diff --git a/MacPass/MPActionHelper.h b/MacPass/MPActionHelper.h index a9d4ffbf..fd92f274 100644 --- a/MacPass/MPActionHelper.h +++ b/MacPass/MPActionHelper.h @@ -28,8 +28,8 @@ typedef NS_ENUM(NSUInteger, MPActionType) { MPActionExportXML, // Export as XML MPActionImportXML, // Import form XML MPActionToggleQuicklook, - MPActionShowHistory, // show history - MPActionExitHistory, // exit history + MPActionShowEntryHistory, // show history + MPActionHideEntryHistory, // exit history MPActionPerformAutotypeForSelectedEntry // Perform Autotype for selected Entry }; /** diff --git a/MacPass/MPActionHelper.m b/MacPass/MPActionHelper.m index 4692ddfb..cfb9c4db 100644 --- a/MacPass/MPActionHelper.m +++ b/MacPass/MPActionHelper.m @@ -37,8 +37,8 @@ @(MPActionExportXML): NSStringFromSelector(@selector(exportAsXML:)), @(MPActionImportXML): NSStringFromSelector(@selector(importFromXML:)), @(MPActionToggleQuicklook): NSStringFromSelector(@selector(toggleQuicklookPreview:)), - @(MPActionShowHistory): NSStringFromSelector(@selector(showHistory:)), - @(MPActionExitHistory): NSStringFromSelector(@selector(exitHistory:)), + @(MPActionShowEntryHistory): NSStringFromSelector(@selector(showHistoryForEntry:)), + @(MPActionHideEntryHistory): NSStringFromSelector(@selector(hideHistoryForEntry:)), @(MPActionPerformAutotypeForSelectedEntry): NSStringFromSelector(@selector(performAutotypeForEntry:)) }; }); diff --git a/MacPass/MPContextMenuHelper.h b/MacPass/MPContextMenuHelper.h index 92c4d458..6a352e58 100644 --- a/MacPass/MPContextMenuHelper.h +++ b/MacPass/MPContextMenuHelper.h @@ -15,8 +15,9 @@ typedef NS_OPTIONS(NSUInteger, MPContextMenuItemsFlags) { MPContextMenuTrash = 1 << 3, MPContextMenuDuplicate = 1 << 4, MPContextMenuAutotype = 1 << 5, + MPContextMenuHistory = 1 << 6, MPContextMenuMinimal = MPContextMenuCreate | MPContextMenuDelete, - MPContextMenuFull = MPContextMenuMinimal | MPContextMenuCopy | MPContextMenuDuplicate | MPContextMenuAutotype, + MPContextMenuFull = MPContextMenuMinimal | MPContextMenuCopy | MPContextMenuDuplicate | MPContextMenuAutotype | MPContextMenuHistory, MPContextMenuExtended = MPContextMenuFull | MPContextMenuTrash }; diff --git a/MacPass/MPContextMenuHelper.m b/MacPass/MPContextMenuHelper.m index 4274e388..5893a93a 100644 --- a/MacPass/MPContextMenuHelper.m +++ b/MacPass/MPContextMenuHelper.m @@ -12,7 +12,7 @@ #import "MPFlagsHelper.h" static void MPContextmenuHelperBeginSection(NSMutableArray *items) { - if([items count] > 0) { + if(items.count > 0) { [items addObject:[NSMenuItem separatorItem]]; } } @@ -27,6 +27,7 @@ static void MPContextmenuHelperBeginSection(NSMutableArray *items) { BOOL const insertTrash = MPIsFlagSetInOptions(MPContextMenuTrash, flags); BOOL const insertDuplicate = MPIsFlagSetInOptions(MPContextMenuDuplicate, flags); BOOL const insertAutotype = MPIsFlagSetInOptions(MPContextMenuAutotype, flags); + BOOL const insertHistory = MPIsFlagSetInOptions(MPContextMenuHistory, flags); NSMutableArray *items = [NSMutableArray arrayWithCapacity:10]; if(insertCreate) { @@ -43,14 +44,14 @@ static void MPContextmenuHelperBeginSection(NSMutableArray *items) { if(insertDuplicate) { MPContextmenuHelperBeginSection(items); NSMenuItem *duplicateEntry = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"DUPLICATE_ENTRY", @"") - action:[MPActionHelper actionOfType:MPActionDuplicateEntry] - keyEquivalent:@"D"]; + action:[MPActionHelper actionOfType:MPActionDuplicateEntry] + keyEquivalent:@"D"]; NSMenuItem *duplicateEntyWithOptions = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"DUPLICATE_ENTRY_WITH_OPTIONS", @"") - action:[MPActionHelper actionOfType:MPActionDuplicateEntryWithOptions] - keyEquivalent:@""]; + action:[MPActionHelper actionOfType:MPActionDuplicateEntryWithOptions] + keyEquivalent:@""]; [items addObjectsFromArray:@[ duplicateEntry, duplicateEntyWithOptions ]]; - + } if(insertDelete || insertTrash) { MPContextmenuHelperBeginSection(items); @@ -98,13 +99,22 @@ static void MPContextmenuHelperBeginSection(NSMutableArray *items) { [items addObjectsFromArray:@[ copyUsername, copyPassword, urlItem]]; } - if(insertAutotype) { + if(insertAutotype || insertHistory) { MPContextmenuHelperBeginSection(items); - NSMenuItem *performAutotype = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"PERFORM_AUTOTYPE_FOR_ENTRY", @"") - action:[MPActionHelper actionOfType:MPActionPerformAutotypeForSelectedEntry] - keyEquivalent:@"a"]; - [performAutotype setKeyEquivalentModifierMask:[performAutotype keyEquivalentModifierMask] | NSControlKeyMask]; - [items addObject:performAutotype]; + if(insertAutotype) { + NSMenuItem *performAutotype = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"PERFORM_AUTOTYPE_FOR_ENTRY", @"") + action:[MPActionHelper actionOfType:MPActionPerformAutotypeForSelectedEntry] + keyEquivalent:@"a"]; + performAutotype.keyEquivalentModifierMask = (performAutotype.keyEquivalentModifierMask | NSControlKeyMask); + [items addObject:performAutotype]; + } + if(insertHistory) { + NSMenuItem *showHistory = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"SHOW_ENTRY_HISTORY", @"") + action:[MPActionHelper actionOfType:MPActionShowEntryHistory] + keyEquivalent:@"h"]; + showHistory.keyEquivalentModifierMask = (showHistory.keyEquivalentModifierMask | NSCommandKeyMask | NSControlKeyMask); + [items addObject:showHistory]; + } } return items; diff --git a/MacPass/MPDocument.h b/MacPass/MPDocument.h index 114e4c36..72f8e59f 100644 --- a/MacPass/MPDocument.h +++ b/MacPass/MPDocument.h @@ -227,9 +227,6 @@ FOUNDATION_EXPORT NSString *const MPDocumentDidExitHistoryNotification; @interface MPDocument (HistoryBrowsing) -- (IBAction)showHistory:(id)sender; -- (IBAction)exitHistory:(id)sender; - @end #pragma mark - diff --git a/MacPass/MPDocument.m b/MacPass/MPDocument.m index f2c3dcf3..676c6380 100644 --- a/MacPass/MPDocument.m +++ b/MacPass/MPDocument.m @@ -685,7 +685,9 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou KPKEntry *targetEntry = targetEntries.count == 1 ? targetEntries.firstObject : nil; KPKGroup *targetGroup = targetGroups.count == 1 ? targetGroups.firstObject : nil; - if(self.encrypted || self.isReadOnly) { return NO; } + if(self.encrypted || self.isReadOnly) { + return NO; + } BOOL valid = /*targetNode ? targetNode.isEditable : */YES; switch([MPActionHelper typeForAction:[anItem action]]) { @@ -713,7 +715,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou valid &= targetEntries.count > 0; break; case MPActionEmptyTrash: - valid &= ([self.trash.groups count] + [self.trash.entries count]) > 0; + valid &= (self.trash.groups.count + self.trash.entries.count) > 0; break; case MPActionDatabaseSettings: case MPActionEditPassword: @@ -722,19 +724,20 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou case MPActionLock: valid &= self.compositeKey.hasPasswordOrKeyFile; break; - case MPActionShowHistory: + case MPActionShowEntryHistory: valid &= (nil != targetEntry); + valid &= targetEntry.history.count > 0; break; /* Entry View Actions */ case MPActionCopyUsername: - valid &= (nil != targetEntry) && ([targetEntry.username length] > 0); + valid &= (nil != targetEntry) && (targetEntry.username.length > 0); break; case MPActionCopyPassword: - valid &= (nil != targetEntry ) && ([targetEntry.password length] > 0); + valid &= (nil != targetEntry ) && (targetEntry.password.length > 0); break; case MPActionCopyURL: case MPActionOpenURL: - valid &= (nil != targetEntry ) && ([targetEntry.url length] > 0); + valid &= (nil != targetEntry ) && (targetEntry.url.length > 0); break; case MPActionPerformAutotypeForSelectedEntry: valid &= (nil != targetEntry); diff --git a/MacPass/MPDocumentWindowController.h b/MacPass/MPDocumentWindowController.h index 2596a5c6..eb1b2c7f 100644 --- a/MacPass/MPDocumentWindowController.h +++ b/MacPass/MPDocumentWindowController.h @@ -53,6 +53,8 @@ - (IBAction)pickExpiryDate:(id)sender; - (IBAction)performAutotypeForEntry:(id)sender; +- (IBAction)showHistoryForEntry:(id)sender; +- (IBAction)hideHistoryForEntry:(id)sender; #pragma mark Helper - (IBAction)fixAutotype:(id)sender; diff --git a/MacPass/MPDocumentWindowController.m b/MacPass/MPDocumentWindowController.m index a9702b13..4b58b6d2 100644 --- a/MacPass/MPDocumentWindowController.m +++ b/MacPass/MPDocumentWindowController.m @@ -486,9 +486,18 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword); [contentView layoutSubtreeIfNeeded]; } +- (IBAction)showHistoryForEntry:(id)sender { + [self.document showHistoryForEntry:nil]; +} + +- (IBAction)hideHistoryForEntry:(id)sender { + +} + + #pragma mark Validation - (BOOL)validateMenuItem:(NSMenuItem *)menuItem { - return ([[self document] validateMenuItem:menuItem]); + return ([self.document validateMenuItem:menuItem]); } #pragma mark NSAlert handling diff --git a/MacPass/MPOutlineContextMenuDelegate.m b/MacPass/MPOutlineContextMenuDelegate.m index 443e412a..034820e4 100644 --- a/MacPass/MPOutlineContextMenuDelegate.m +++ b/MacPass/MPOutlineContextMenuDelegate.m @@ -57,9 +57,9 @@ NSString *const _MPOutlineMenuTemplate = @"Template"; if( [item isKindOfClass:[KPKGroup class]]) { KPKGroup *group = (KPKGroup *)item; - MPDocument *document = [[NSDocumentController sharedDocumentController] currentDocument]; + MPDocument *document = [NSDocumentController sharedDocumentController].currentDocument; if(group && document.root == group ) { - + } if(group.isTrash) { [self _updateTrashMenu:menu]; @@ -77,7 +77,7 @@ NSString *const _MPOutlineMenuTemplate = @"Template"; } - (void)_updateRootMenu:(NSMenu *)menu { - if([[menu title] isEqualToString:_MPOutlineMenuRoot]) { + if([menu.title isEqualToString:_MPOutlineMenuRoot]) { return; // nothing to do, all fine } [menu removeAllItems]; @@ -85,11 +85,11 @@ NSString *const _MPOutlineMenuTemplate = @"Template"; action:[MPActionHelper actionOfType:MPActionDatabaseSettings] keyEquivalent:@""]; - [menu setTitle:_MPOutlineMenuRoot]; + menu.title = _MPOutlineMenuRoot; } - (void)_updateTrashMenu:(NSMenu *)menu { - if([[menu title] isEqualToString:_MPOutlineMenuTrash]) { + if([menu.title isEqualToString:_MPOutlineMenuTrash]) { return; // nothing to do, all fine } [menu removeAllItems]; @@ -101,11 +101,11 @@ NSString *const _MPOutlineMenuTemplate = @"Template"; action:[MPActionHelper actionOfType:MPActionEmptyTrash] keyEquivalent:@""]; - [menu setTitle:_MPOutlineMenuTrash]; + menu.title = _MPOutlineMenuTrash; } - (void)_updateTrashItemMenu:(NSMenu *)menu { - if([[menu title] isEqualToString:_MPOutlineMenuTrashItem]) { + if([menu.title isEqualToString:_MPOutlineMenuTrashItem]) { return; // nothing to do, all fine } [menu removeAllItems]; @@ -117,11 +117,11 @@ NSString *const _MPOutlineMenuTemplate = @"Template"; action:[MPActionHelper actionOfType:MPActionEmptyTrash] keyEquivalent:@""]; - [menu setTitle:_MPOutlineMenuTrashItem]; + menu.title = _MPOutlineMenuTrashItem; } - (void)_updateTemplateMenu:(NSMenu *)menu { - if([[menu title] isEqualToString:_MPOutlineMenuTemplate]) { + if([menu.title isEqualToString:_MPOutlineMenuTemplate]) { return; // nothing to do, all fine } [menu removeAllItems]; @@ -132,12 +132,12 @@ NSString *const _MPOutlineMenuTemplate = @"Template"; for(NSMenuItem *item in [MPContextMenuHelper contextMenuItemsWithItems:MPContextMenuMinimal]) { [menu addItem:item]; } - [menu setTitle:_MPOutlineMenuTemplate]; + menu.title = _MPOutlineMenuTemplate; } - (void)_updateDefaultMenu:(NSMenu *)menu { - if([[menu title] isEqualToString:_MPOutlineMenuDefault]) { + if([menu.title isEqualToString:_MPOutlineMenuDefault]) { return; // nothing to do, all fine } [menu removeAllItems];