diff --git a/KeePassKit b/KeePassKit index 76975731..43af7b31 160000 --- a/KeePassKit +++ b/KeePassKit @@ -1 +1 @@ -Subproject commit 76975731c37c9108d9e707b9bc170505c65882c4 +Subproject commit 43af7b31f0127f21220ffff346ccb81479ed6f90 diff --git a/MacPass/Base.lproj/InspectorView.xib b/MacPass/Base.lproj/InspectorView.xib index fb0f2093..dfc3738f 100644 --- a/MacPass/Base.lproj/InspectorView.xib +++ b/MacPass/Base.lproj/InspectorView.xib @@ -107,7 +107,7 @@ 134217728 33554432 - + NSImage NSActionTemplate @@ -127,22 +127,24 @@ -2147483380 - {{20, 2}, {35, 25}} + {{197, 2}, {60, 25}} - _NS:22 YES -2080374784 134217728 - + Edit _NS:22 -2034483200 163 - + + NSImage + 07_NotepadTemplate + 400 @@ -164,7 +166,6 @@ {{0, 30}, {278, 369}} - _NS:9 @@ -175,7 +176,7 @@ {278, 369} - + _NS:28 Entry @@ -317,6 +318,14 @@ 3095 + + + editButton + + + + 3122 + @@ -610,6 +619,23 @@ 2930 + + + 6 + 0 + + 6 + 1 + + 21 + + 1000 + + 3 + 9 + 3 + NO + 10 @@ -627,23 +653,6 @@ 2 NO - - - 5 - 0 - - 5 - 1 - - 20 - - 1000 - - 0 - 29 - 3 - NO - 8 @@ -877,13 +886,13 @@ - 3111 - + 3112 + - 3112 - + 3123 + @@ -925,8 +934,8 @@ com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin @@ -968,14 +977,14 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin - 3117 + 3123 @@ -1004,6 +1013,7 @@ HNHGradientView NSTextField + NSButton MPPopupImageView NSTextField NSTextField @@ -1019,6 +1029,10 @@ createdTextField NSTextField + + editButton + NSButton + itemImageView MPPopupImageView @@ -1084,10 +1098,10 @@ YES 3 - - NSActionTemplate - {15, 15} - + + {16, 16} + {15, 15} + YES diff --git a/MacPass/MPDocument.h b/MacPass/MPDocument.h index c525b995..dc4b966d 100644 --- a/MacPass/MPDocument.h +++ b/MacPass/MPDocument.h @@ -18,12 +18,6 @@ APPKIT_EXTERN NSString *const MPDocumentDidUnlockDatabaseNotification; APPKIT_EXTERN NSString *const MPDocumentEntryKey; APPKIT_EXTERN NSString *const MPDocumentGroupKey; -/* - APPKIT_EXTERN NSString *const MPDocumentDidChangeCurrentItemNotification; -APPKIT_EXTERN NSString *const MPDocumentDidChangeCurrentGroupNotication; -APPKIT_EXTERN NSString *const MPDocumnetDidChangeCurrentEntryNotification; -*/ - @class KPKGroup; @class KPKEntry; @class KPKTree; @@ -32,7 +26,6 @@ APPKIT_EXTERN NSString *const MPDocumnetDidChangeCurrentEntryNotification; @interface MPDocument : NSDocument -/* true, if password and/or keyfile are set */ @property (assign, readonly) BOOL hasPasswordOrKey; @property (nonatomic, readonly, assign) BOOL encrypted; @@ -63,21 +56,32 @@ APPKIT_EXTERN NSString *const MPDocumnetDidChangeCurrentEntryNotification; - (BOOL)unlockWithPassword:(NSString *)password keyFileURL:(NSURL *)keyFileURL error:(NSError *__autoreleasing*)error; #pragma mark Data Lookup -/* - Returns the entry for the given UUID, nil if none was found +/** + * Finds an entry with the given UUID. If none is found, nil is returned + * @param uuid The UUID for the searched Entry + * @return enty, matching the UUID, nil if none was found */ - (KPKEntry *)findEntry:(NSUUID *)uuid; +/** + * Finds the group with the given UUID in this document. If none if found, nil is returned + * @param uuid The UUID of the searched group + * @return matching group, nil if none was found + */ - (KPKGroup *)findGroup:(NSUUID *)uuid; - (void)useGroupAsTrash:(KPKGroup *)group; - (void)useGroupAsTemplate:(KPKGroup *)group; - +/** + * Determines, whether the given item is inside the trash. + * The trash group itself is not considered as trashed. + * Hence when sending this message with the trash group as item, NO is returned + * @param item Item to test if trashed or not + * @return YES, if the item is inside the trash, NO otherwise (and if item is trash group) + */ - (BOOL)isItemTrashed:(id)item; -#pragma mark Export - (void)writeXMLToURL:(NSURL *)url; -#pragma mark Undo Data Manipulation /* Undoable Intiialization of elements */ - (KPKGroup *)createGroup:(KPKGroup *)parent; - (KPKEntry *)createEntry:(KPKGroup *)parent; diff --git a/MacPass/MPDocument.m b/MacPass/MPDocument.m index 8301a6df..4817658c 100644 --- a/MacPass/MPDocument.m +++ b/MacPass/MPDocument.m @@ -239,7 +239,6 @@ typedef NS_ENUM(NSUInteger, MPAlertType) { } #pragma mark Properties - - (KPKVersion)versionForFileType { return [[self class] versionForFileType:[self fileType]]; } diff --git a/MacPass/MPDocumentWindowController.m b/MacPass/MPDocumentWindowController.m index ff53fa06..dfed6ac5 100644 --- a/MacPass/MPDocumentWindowController.m +++ b/MacPass/MPDocumentWindowController.m @@ -406,6 +406,8 @@ typedef NS_ENUM(NSUInteger, MPAlertContext) { [_entryViewController updateResponderChain]; [_inspectorViewController updateResponderChain]; [_outlineViewController updateResponderChain]; + /* Custom setup after being added to window */ + [_inspectorViewController prepareView]; [_outlineViewController showOutline]; } diff --git a/MacPass/MPEntryViewController.m b/MacPass/MPEntryViewController.m index b6ac6323..461e72d1 100644 --- a/MacPass/MPEntryViewController.m +++ b/MacPass/MPEntryViewController.m @@ -245,7 +245,6 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell"; NSTextField *textField = [view textField]; if(!isModifedColumn && !isNotesColumn) { /* clean up old formatter that might be left */ - NSLog(@"Cleaing formatter. %@", [textField formatter]); [textField setFormatter:nil]; } if(isModifedColumn) { diff --git a/MacPass/MPInspectorViewController.h b/MacPass/MPInspectorViewController.h index a0c2f858..c447829b 100644 --- a/MacPass/MPInspectorViewController.h +++ b/MacPass/MPInspectorViewController.h @@ -19,10 +19,12 @@ @property (weak) IBOutlet NSTextField *noSelectionInfo; @property (weak) IBOutlet MPPopupImageView *itemImageView; @property (weak) IBOutlet NSTextField *itemNameTextField; +@property (weak) IBOutlet NSButton *editButton; - (IBAction)showImagePopup:(id)sender; /* Seperate call to ensure alle registered objects are in place */ - (void)setupNotifications:(NSWindowController *)windowController; +- (void)prepareView; @end diff --git a/MacPass/MPInspectorViewController.m b/MacPass/MPInspectorViewController.m index d5a9a129..6b0c9bb5 100644 --- a/MacPass/MPInspectorViewController.m +++ b/MacPass/MPInspectorViewController.m @@ -16,6 +16,8 @@ #import "NSDate+Humanized.h" +#import "KPKTree.h" +#import "KPKMetaData.h" #import "HNHGradientView.h" #import "MPPopupImageView.h" @@ -35,6 +37,8 @@ typedef NS_ENUM(NSUInteger, MPContentTab) { @property (nonatomic, strong) NSDate *modificationDate; @property (nonatomic, strong) NSDate *creationDate; +@property (nonatomic, assign) BOOL showEditButton; + @property (nonatomic, assign) NSUInteger activeTab; @property (weak) IBOutlet NSTabView *tabView; @@ -52,6 +56,7 @@ typedef NS_ENUM(NSUInteger, MPContentTab) { _activeTab = MPEmptyTab; _entryViewController = [[MPEntryInspectorViewController alloc] init]; _groupViewController = [[MPGroupInspectorViewController alloc] init]; + _showEditButton = NO; } return self; } @@ -60,6 +65,21 @@ typedef NS_ENUM(NSUInteger, MPContentTab) { [[NSNotificationCenter defaultCenter] removeObserver:self]; } +#pragma mark Properties +- (void)setActiveTab:(NSUInteger)activeTab { + if(_activeTab != activeTab) { + _activeTab = activeTab; + self.showEditButton = [[[self windowController] document] tree].metaData.isHistoryEnabled; + } +} + +- (void)setShowEditButton:(BOOL)showEditButton { + showEditButton &= (self.activeTab == MPEntryTab); + if(_showEditButton != showEditButton) { + _showEditButton = showEditButton; + } +} + - (void)didLoadView { [_bottomBar setBorderType:HNHBorderTop]; [[self.noSelectionInfo cell] setBackgroundStyle:NSBackgroundStyleRaised]; @@ -94,7 +114,6 @@ typedef NS_ENUM(NSUInteger, MPContentTab) { selector:@selector(_didChangeCurrentItem:) name:MPCurrentItemChangedNotification object:document]; - [_entryViewController setupBindings:document]; [_groupViewController setupBindings:document]; @@ -145,9 +164,14 @@ typedef NS_ENUM(NSUInteger, MPContentTab) { _popover = nil; } - #pragma mark - -#pragma mark Item Binding +#pragma mark Bindings +- (void)prepareView { + MPDocument *document = [[self windowController] document]; + [self bind:@"showEditButton" toObject:document.tree.metaData withKeyPath:@"isHistoryEnabled" options:nil]; + NSDictionary *bindingOptions = @{ NSValueTransformerNameBindingOption : NSNegateBooleanTransformerName }; + [self.editButton bind:NSHiddenBinding toObject:self withKeyPath:@"showEditButton" options:bindingOptions]; +} - (void)_updateItemBindings:(id)item { if(!item) { @@ -177,6 +201,7 @@ typedef NS_ENUM(NSUInteger, MPContentTab) { - (void)_didChangeCurrentItem:(NSNotification *)notification { MPDocument *document = [notification object]; if(!document.selectedItem) { + /* show emty tab and hide edit button */ self.activeTab = MPEmptyTab; } else { @@ -191,5 +216,4 @@ typedef NS_ENUM(NSUInteger, MPContentTab) { } [self _updateItemBindings:document.selectedItem]; } - @end \ No newline at end of file