diff --git a/MacPass.xcodeproj/project.pbxproj b/MacPass.xcodeproj/project.pbxproj index dbab76bb..0c7b71f9 100644 --- a/MacPass.xcodeproj/project.pbxproj +++ b/MacPass.xcodeproj/project.pbxproj @@ -7,7 +7,8 @@ objects = { /* Begin PBXBuildFile section */ - 4C01C23C1764D1AA0016D5D0 /* KdbKeyPaths.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C01C23B1764D1460016D5D0 /* KdbKeyPaths.m */; }; + 4C01C23F1764D2980016D5D0 /* KdbEntry+Undo.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C01C23E1764D2980016D5D0 /* KdbEntry+Undo.m */; }; + 4C01C2421764D8980016D5D0 /* MPContextMenuHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C01C2411764D8980016D5D0 /* MPContextMenuHelper.m */; }; 4C1DDCDD1711ECEB00C98DA3 /* PasswordCreatorWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C1DDCDC1711ECEB00C98DA3 /* PasswordCreatorWindow.xib */; }; 4C22040D1746ED160054C916 /* KdbGroup+Undo.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C22040C1746ED160054C916 /* KdbGroup+Undo.m */; }; 4C25D58716CF0FAA00F6806C /* EntryView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C25D58616CF0FAA00F6806C /* EntryView.xib */; }; @@ -129,8 +130,10 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 4C01C23A1764CDA20016D5D0 /* KdbKeyPaths.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KdbKeyPaths.h; sourceTree = ""; }; - 4C01C23B1764D1460016D5D0 /* KdbKeyPaths.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KdbKeyPaths.m; sourceTree = ""; }; + 4C01C23D1764D2980016D5D0 /* KdbEntry+Undo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "KdbEntry+Undo.h"; sourceTree = ""; }; + 4C01C23E1764D2980016D5D0 /* KdbEntry+Undo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "KdbEntry+Undo.m"; sourceTree = ""; }; + 4C01C2401764D8980016D5D0 /* MPContextMenuHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPContextMenuHelper.h; sourceTree = ""; }; + 4C01C2411764D8980016D5D0 /* MPContextMenuHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPContextMenuHelper.m; sourceTree = ""; }; 4C1DDCDC1711ECEB00C98DA3 /* PasswordCreatorWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PasswordCreatorWindow.xib; sourceTree = ""; }; 4C22040B1746ED160054C916 /* KdbGroup+Undo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "KdbGroup+Undo.h"; sourceTree = ""; }; 4C22040C1746ED160054C916 /* KdbGroup+Undo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "KdbGroup+Undo.m"; sourceTree = ""; }; @@ -405,6 +408,8 @@ 4C2C4C2516D3BCEA00D49295 /* KeePassLibAdditions */ = { isa = PBXGroup; children = ( + 4C01C23D1764D2980016D5D0 /* KdbEntry+Undo.h */, + 4C01C23E1764D2980016D5D0 /* KdbEntry+Undo.m */, 4C2C4C2A16D3BE3700D49295 /* KdbGroup+MPAdditions.h */, 4C2C4C2B16D3BE3700D49295 /* KdbGroup+MPAdditions.m */, 4CC1AEBC16D4467C006D2AAB /* KdbTree+MPAdditions.h */, @@ -413,8 +418,6 @@ 4C22040C1746ED160054C916 /* KdbGroup+Undo.m */, 4C4A101017629DA900BBF2CA /* KdbGroup+KVOAdditions.h */, 4C4A101117629DA900BBF2CA /* KdbGroup+KVOAdditions.m */, - 4C01C23A1764CDA20016D5D0 /* KdbKeyPaths.h */, - 4C01C23B1764D1460016D5D0 /* KdbKeyPaths.m */, ); name = KeePassLibAdditions; sourceTree = ""; @@ -430,6 +433,8 @@ 4CBA2AB917074C07006D8139 /* MPSettingsHelper.m */, 4C5BF679175C01F300D53DF7 /* MPUppercaseStringValueTransformer.h */, 4C5BF67A175C01F300D53DF7 /* MPUppercaseStringValueTransformer.m */, + 4C01C2401764D8980016D5D0 /* MPContextMenuHelper.h */, + 4C01C2411764D8980016D5D0 /* MPContextMenuHelper.m */, ); name = Helper; sourceTree = ""; @@ -937,7 +942,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 4C01C23C1764D1AA0016D5D0 /* KdbKeyPaths.m in Sources */, 4C77E37315B84A240093A587 /* main.m in Sources */, 4CBA2ABA17074C07006D8139 /* MPSettingsHelper.m in Sources */, 4C77E37A15B84A240093A587 /* MPAppDelegate.m in Sources */, @@ -1024,6 +1028,8 @@ 4C4A101217629DA900BBF2CA /* KdbGroup+KVOAdditions.m in Sources */, 4CAF62FC1763604000CD7084 /* HNHBadgedTextFieldCell.m in Sources */, 4C58BD4F176370B100B8178C /* HNHBadgedTextField.m in Sources */, + 4C01C23F1764D2980016D5D0 /* KdbEntry+Undo.m in Sources */, + 4C01C2421764D8980016D5D0 /* MPContextMenuHelper.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/MacPass/KdbKeyPaths.h b/MacPass/KdbKeyPaths.h deleted file mode 100644 index cbcee230..00000000 --- a/MacPass/KdbKeyPaths.h +++ /dev/null @@ -1,20 +0,0 @@ -// -// KdbKeyPaths.h -// MacPass -// -// Created by Michael Starke on 09.06.13. -// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. -// - -#ifndef MacPass_KdbKeyPaths_h -#define MacPass_KdbKeyPaths_h - -#import - -FOUNDATION_EXPORT NSString *const MPEntryKeyForTitle;// = @"title"; -FOUNDATION_EXPORT NSString *const MPEntryKeyForUsername;// = @"username"; -FOUNDATION_EXPORT NSString *const MPEntryKeyForUrl;// = @"url"; -FOUNDATION_EXPORT NSString *const MPEntryKeyForPassword;// = @"password"; -FOUNDATION_EXPORT NSString *const MPEntryKeyForNotes;// = @"notes"; - -#endif diff --git a/MacPass/KdbKeyPaths.m b/MacPass/KdbKeyPaths.m deleted file mode 100644 index e0bb46de..00000000 --- a/MacPass/KdbKeyPaths.m +++ /dev/null @@ -1,15 +0,0 @@ -// -// KdbKeyPaths.m -// MacPass -// -// Created by Michael Starke on 09.06.13. -// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. -// - -#import "KdbKeyPaths.h" - -NSString *const MPEntryKeyForTitle = @"title"; -NSString *const MPEntryKeyForUsername = @"username"; -NSString *const MPEntryKeyForUrl = @"url"; -NSString *const MPEntryKeyForPassword = @"password"; -NSString *const MPEntryKeyForNotes = @"notes"; diff --git a/MacPass/MPAppDelegate.h b/MacPass/MPAppDelegate.h index e92dcd29..12534d39 100644 --- a/MacPass/MPAppDelegate.h +++ b/MacPass/MPAppDelegate.h @@ -8,16 +8,6 @@ #import -typedef enum { - MPContextMenuCreate = 1<<0, - MPContextMenuDelete = 1<<1, - MPContextMenuCopy = 1<<2, - MPContextMenuMinimal = MPContextMenuCreate | MPContextMenuDelete, - MPContextMenuFull = MPContextMenuMinimal | MPContextMenuCopy, -}MPContextMenuItemsFlags; - -@class MPDatabaseDocument; - @interface MPAppDelegate : NSObject @property (retain) IBOutlet NSWindow *passwordCreatorWindow; @@ -26,10 +16,4 @@ typedef enum { - (NSString *)applicationName; -/* - Creates an array of menuitems to be used as a menu - Automatically sets up actions, so you need to take care of the responder chain - */ -- (NSArray *)contextMenuItemsWithItems:(MPContextMenuItemsFlags)flags; - @end \ No newline at end of file diff --git a/MacPass/MPAppDelegate.m b/MacPass/MPAppDelegate.m index a4839fcd..53f86d00 100644 --- a/MacPass/MPAppDelegate.m +++ b/MacPass/MPAppDelegate.m @@ -8,12 +8,9 @@ #import "MPAppDelegate.h" -#import "MPDocumentWindowController.h" #import "MPSettingsWindowController.h" #import "MPPasswordCreatorViewController.h" -#import "MPActionHelper.h" #import "MPSettingsHelper.h" -#import "NSString+MPPasswordCreation.h" #import "MPUppercaseStringValueTransformer.h" @interface MPAppDelegate () @@ -65,71 +62,4 @@ [self.passwordCreatorWindow makeKeyAndOrderFront:self.passwordCreatorWindow]; } -- (NSArray *)contextMenuItemsWithItems:(MPContextMenuItemsFlags)flags { - BOOL insertCreate = (0 != (flags & MPContextMenuCreate)); - BOOL insertDelete = (0 != (flags & MPContextMenuDelete)); - BOOL insertCopy = (0 != (flags & MPContextMenuCopy)); - - NSMutableArray *items = [NSMutableArray arrayWithCapacity:7]; - if(insertCreate) { - - NSMenuItem *newGroup = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"ADD_GROUP", @"") - action:[MPActionHelper actionOfType:MPActionAddGroup] - keyEquivalent:@"G"]; - NSMenuItem *newEntry = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"ADD_ENTRY", @"") - action:[MPActionHelper actionOfType:MPActionAddEntry] - keyEquivalent:@"E"]; - - [items addObjectsFromArray:@[ newGroup, newEntry ]]; - [newEntry release]; - [newGroup release]; - } - if(insertDelete) { - if([items count] > 0) { - [items addObject:[NSMenuItem separatorItem]]; - } - NSMenuItem *delete = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"DELETE", @"") - action:[MPActionHelper actionOfType:MPActionDelete] - keyEquivalent:@""]; - [items addObject:delete]; - [delete release]; - } - if(insertCopy) { - if([items count] > 0) { - [items addObject:[NSMenuItem separatorItem]]; - } - NSMenuItem *copyUsername = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"COPY_USERNAME", @"") - action:[MPActionHelper actionOfType:MPActionCopyUsername] - keyEquivalent:@"C"]; - NSMenuItem *copyPassword = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"COPY_PASSWORD", @"") - action:[MPActionHelper actionOfType:MPActionCopyPassword] - keyEquivalent:@"c"]; - NSMenu *urlMenu = [[NSMenu alloc] init]; - NSMenuItem *urlItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"URL", @"") - action:0 - keyEquivalent:@""]; - [urlItem setSubmenu:urlMenu]; - [urlMenu release]; - - NSMenuItem *copyURL = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"COPY_URL", @"") - action:[MPActionHelper actionOfType:MPActionCopyURL] - keyEquivalent:@"u"]; - NSMenuItem *openURL = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"OPEN_URL", @"") - action:[MPActionHelper actionOfType:MPActionOpenURL] - keyEquivalent:@"U"]; - [urlMenu addItem:copyURL]; - [urlMenu addItem:openURL]; - [openURL release]; - [copyURL release]; - - [items addObjectsFromArray:@[ copyUsername, copyPassword, urlItem]]; - [urlItem release]; - [copyPassword release]; - [copyUsername release]; - } - return items; -} - - - @end diff --git a/MacPass/MPContextMenuHelper.h b/MacPass/MPContextMenuHelper.h new file mode 100644 index 00000000..7a5b1ea2 --- /dev/null +++ b/MacPass/MPContextMenuHelper.h @@ -0,0 +1,27 @@ +// +// MPContextMenuHelper.h +// MacPass +// +// Created by Michael Starke on 09.06.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import + +typedef enum { + MPContextMenuCreate = 1<<0, + MPContextMenuDelete = 1<<1, + MPContextMenuCopy = 1<<2, + MPContextMenuMinimal = MPContextMenuCreate | MPContextMenuDelete, + MPContextMenuFull = MPContextMenuMinimal | MPContextMenuCopy, +} MPContextMenuItemsFlags; + +@interface MPContextMenuHelper : NSTableCellView + +/* + Creates an array of menuitems to be used as a menu + Automatically sets up actions, so you need to take care of the responder chain + */ ++ (NSArray *)contextMenuItemsWithItems:(MPContextMenuItemsFlags)flags; + +@end diff --git a/MacPass/MPContextMenuHelper.m b/MacPass/MPContextMenuHelper.m new file mode 100644 index 00000000..741a0754 --- /dev/null +++ b/MacPass/MPContextMenuHelper.m @@ -0,0 +1,81 @@ +// +// MPContextMenuHelper.m +// MacPass +// +// Created by Michael Starke on 09.06.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import "MPContextMenuHelper.h" +#import "MPActionHelper.h" + +@implementation MPContextMenuHelper + ++ (NSArray *)contextMenuItemsWithItems:(MPContextMenuItemsFlags)flags { + BOOL insertCreate = (0 != (flags & MPContextMenuCreate)); + BOOL insertDelete = (0 != (flags & MPContextMenuDelete)); + BOOL insertCopy = (0 != (flags & MPContextMenuCopy)); + + NSMutableArray *items = [NSMutableArray arrayWithCapacity:7]; + if(insertCreate) { + + NSMenuItem *newGroup = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"ADD_GROUP", @"") + action:[MPActionHelper actionOfType:MPActionAddGroup] + keyEquivalent:@"G"]; + NSMenuItem *newEntry = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"ADD_ENTRY", @"") + action:[MPActionHelper actionOfType:MPActionAddEntry] + keyEquivalent:@"E"]; + + [items addObjectsFromArray:@[ newGroup, newEntry ]]; + [newEntry release]; + [newGroup release]; + } + if(insertDelete) { + if([items count] > 0) { + [items addObject:[NSMenuItem separatorItem]]; + } + NSMenuItem *delete = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"DELETE", @"") + action:[MPActionHelper actionOfType:MPActionDelete] + keyEquivalent:@""]; + [items addObject:delete]; + [delete release]; + } + if(insertCopy) { + if([items count] > 0) { + [items addObject:[NSMenuItem separatorItem]]; + } + NSMenuItem *copyUsername = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"COPY_USERNAME", @"") + action:[MPActionHelper actionOfType:MPActionCopyUsername] + keyEquivalent:@"C"]; + NSMenuItem *copyPassword = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"COPY_PASSWORD", @"") + action:[MPActionHelper actionOfType:MPActionCopyPassword] + keyEquivalent:@"c"]; + [copyPassword setKeyEquivalentModifierMask:[copyPassword keyEquivalentModifierMask] | NSAlternateKeyMask]; + NSMenu *urlMenu = [[NSMenu alloc] init]; + NSMenuItem *urlItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"URL", @"") + action:0 + keyEquivalent:@""]; + [urlItem setSubmenu:urlMenu]; + [urlMenu release]; + + NSMenuItem *copyURL = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"COPY_URL", @"") + action:[MPActionHelper actionOfType:MPActionCopyURL] + keyEquivalent:@"u"]; + NSMenuItem *openURL = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"OPEN_URL", @"") + action:[MPActionHelper actionOfType:MPActionOpenURL] + keyEquivalent:@"U"]; + [urlMenu addItem:copyURL]; + [urlMenu addItem:openURL]; + [openURL release]; + [copyURL release]; + + [items addObjectsFromArray:@[ copyUsername, copyPassword, urlItem]]; + [urlItem release]; + [copyPassword release]; + [copyUsername release]; + } + return items; +} + + +@end diff --git a/MacPass/MPDocument.h b/MacPass/MPDocument.h index 1fdb85f0..daa6e05c 100644 --- a/MacPass/MPDocument.h +++ b/MacPass/MPDocument.h @@ -33,12 +33,13 @@ APPKIT_EXTERN NSString *const MPDocumentGroupKey; - (id)initWithVersion:(MPDatabaseVersion)version; - (BOOL)decryptWithPassword:(NSString *)password keyFileURL:(NSURL *)keyFileURL; +/* Undoable Intiialization of elements */ - (KdbGroup *)createGroup:(KdbGroup *)parent; - (KdbEntry *)createEntry:(KdbGroup *)parent; -- (void)deleteEntry:(KdbEntry *)entry; -- (void)deleteGroup:(KdbGroup *)group; - +/* + Undoable movement of object +*/ - (void)moveGroup:(KdbGroup *)group toGroup:(KdbGroup *)target index:(NSInteger)index; - (BOOL)group:(KdbGroup *)group isMoveableToGroup:(KdbGroup *)target; diff --git a/MacPass/MPDocument.m b/MacPass/MPDocument.m index 06e82111..67ffc746 100644 --- a/MacPass/MPDocument.m +++ b/MacPass/MPDocument.m @@ -155,22 +155,6 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey"; return newGroup; } -- (void)deleteEntry:(KdbEntry *)entry { - if(entry.parent) { - NSDictionary *userInfo = @{ MPDocumentEntryKey : entry }; - [[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentWillDeleteEntryNotification object:self userInfo:userInfo]; - [entry.parent removeEntryUndoable:entry]; - } -} - -- (void)deleteGroup:(KdbGroup *)group { - if(group.parent) { - NSDictionary *userInfo = @{ MPDocumentEntryKey : group }; - [[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentWillDelteGroupNotification object:self userInfo:userInfo]; - [group.parent removeGroupUndoable:group]; - } -} - - (void)moveGroup:(KdbGroup *)group toGroup:(KdbGroup *)target index:(NSInteger)index { NSInteger oldIndex = [group.parent.groups indexOfObject:group]; if(group.parent == target && oldIndex == index) { @@ -178,13 +162,11 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey"; } [[[self undoManager] prepareWithInvocationTarget:self] moveGroup:group toGroup:group.parent index:oldIndex]; [[self undoManager] setActionName:@"MOVE_GROUP"]; - [group retain]; // Might get freed in the process [group.parent removeObjectFromGroupsAtIndex:oldIndex]; if(index < 0 || index > [target.groups count] ) { index = [target.groups count]; } [target insertObject:group inGroupsAtIndex:index]; - [group release]; } - (BOOL)group:(KdbGroup *)group isMoveableToGroup:(KdbGroup *)target { diff --git a/MacPass/MPEntryViewController.m b/MacPass/MPEntryViewController.m index 6cfa7c0e..78b307e3 100644 --- a/MacPass/MPEntryViewController.m +++ b/MacPass/MPEntryViewController.m @@ -18,6 +18,7 @@ #import "KdbGroup+MPAdditions.h" #import "KdbGroup+Undo.h" #import "KdbEntry+Undo.h" +#import "MPContextMenuHelper.h" NSString *const MPDidChangeSelectedEntryNotification = @"com.macpass.MPDidChangeSelectedEntryNotification"; @@ -71,27 +72,6 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername"; @property (assign, nonatomic) MPFilterModeType filterMode; @property (retain, nonatomic) NSDictionary *filterButtonToMode; -- (IBAction)_toggleFilterSpace:(id)sender; - -- (BOOL)_shouldFilterURLs; -- (BOOL)_shouldFilterTitles; -- (BOOL)_shouldFilterUsernames; - -- (BOOL)hasFilter; -- (BOOL)_showsFilterBar; -- (void)updateFilter; -- (void)updateFilterText:(id)sender; -- (void)setupFilterBar; -- (void)_setupEntryMenu; -/* Notification handling */ -- (void)_didChangeGroupSelectionInOutlineView:(NSNotification *)notification; -- (void)_showFilterBarAnimated:(BOOL)animate; -- (void)_hideFilterBarAnimated:(BOOL)animate; - -- (void)_columnDoubleClick:(id)sender; -- (void)_copyToPasteboard:(NSString *)data overlayInfo:(MPOVerlayInfoType)overlayInfoType; -- (KdbEntry *)_clickedOrSelectedEntry; - @end @implementation MPEntryViewController @@ -422,7 +402,7 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername"; - (void)_setupEntryMenu { NSMenu *menu = [[NSMenu alloc] init]; - NSArray *items = [(MPAppDelegate *)[NSApp delegate] contextMenuItemsWithItems:MPContextMenuFull]; + NSArray *items = [MPContextMenuHelper contextMenuItemsWithItems:MPContextMenuFull]; for(NSMenuItem *item in items) { [menu addItem:item]; } diff --git a/MacPass/MPInspectorViewController.m b/MacPass/MPInspectorViewController.m index c45a660f..6e51de9c 100644 --- a/MacPass/MPInspectorViewController.m +++ b/MacPass/MPInspectorViewController.m @@ -15,7 +15,7 @@ #import "MPIconSelectViewController.h" #import "KdbLib.h" #import "KdbGroup+Undo.h" -#import "KdbKeyPaths.h" +#import "KdbEntry+Undo.h" @interface MPInspectorViewController () { BOOL _visible; @@ -28,15 +28,6 @@ @property (retain) NSLayoutConstraint *showConstraint; @property (retain) NSLayoutConstraint *hideConstraint; -- (void)_didChangeSelectedEntry:(NSNotification *)notification; -- (void)_didChangeSelectedGroup:(NSNotification *)notification; -- (void)_updateContent; -- (void)_showGroup; -- (void)_showEntry; -- (void)_clearContent; -- (void)_setInputEnabled:(BOOL)enabled; -- (void)_showImagePopup:(id)sender; - @end @implementation MPInspectorViewController @@ -96,13 +87,13 @@ } - (void)_showEntry { - [self.itemNameTextfield bind:NSValueBinding toObject:self.selectedEntry withKeyPath:MPEntryKeyForTitle options:nil]; + [self.itemNameTextfield bind:NSValueBinding toObject:self.selectedEntry withKeyPath:MPEntryTitleUndoableKey options:nil]; [self.itemImageView setImage:[MPIconHelper icon:(MPIconType)self.selectedEntry.image ]]; - [self.passwordTextField bind:NSValueBinding toObject:self.selectedEntry withKeyPath:MPEntryKeyForPassword options:nil]; - [self.usernameTextField bind:NSValueBinding toObject:self.selectedEntry withKeyPath:MPEntryKeyForUsername options:nil]; + [self.passwordTextField bind:NSValueBinding toObject:self.selectedEntry withKeyPath:MPEntryPasswordUndoableKey options:nil]; + [self.usernameTextField bind:NSValueBinding toObject:self.selectedEntry withKeyPath:MPEntryUsernameUndoableKey options:nil]; [self.titleOrNameLabel setStringValue:NSLocalizedString(@"TITLE",@"")]; - [self.titleTextField bind:NSValueBinding toObject:self.selectedEntry withKeyPath:MPEntryKeyForTitle options:nil]; - [self.URLTextField bind:NSValueBinding toObject:self.selectedEntry withKeyPath:MPEntryKeyForUrl options:nil]; + [self.titleTextField bind:NSValueBinding toObject:self.selectedEntry withKeyPath:MPEntryTitleUndoableKey options:nil]; + [self.URLTextField bind:NSValueBinding toObject:self.selectedEntry withKeyPath:MPEntryUrlUndoableKey options:nil]; [self _setInputEnabled:YES]; } diff --git a/MacPass/MPOutlineDataSource.m b/MacPass/MPOutlineDataSource.m index 9889de8e..4ddf0a4e 100644 --- a/MacPass/MPOutlineDataSource.m +++ b/MacPass/MPOutlineDataSource.m @@ -54,12 +54,12 @@ NSString *const MPPasteBoardType = @"com.hicknhack.macpass.pasteboard"; accepted &= index != NSOutlineViewDropOnItemIndex; accepted &= index != [_draggedItem.parent.groups indexOfObject:_draggedItem]; } - info.animatesToDestination = YES; MPDocument *document = [[[outlineView window] windowController] document]; accepted = [document group:_draggedItem isMoveableToGroup:target]; if( accepted ) { [document moveGroup:_draggedItem toGroup:target index:index]; } + info.animatesToDestination = !accepted; return accepted; } @end diff --git a/MacPass/MPOutlineViewController.m b/MacPass/MPOutlineViewController.m index 58fbe75e..b46dbf9c 100644 --- a/MacPass/MPOutlineViewController.m +++ b/MacPass/MPOutlineViewController.m @@ -12,6 +12,8 @@ #import "MPDocument.h" #import "MPAppDelegate.h" #import "KdbLib.h" +#import "KdbGroup+Undo.h" +#import "MPContextMenuHelper.h" @interface MPOutlineViewController () { @@ -25,11 +27,6 @@ @property (retain) MPOutlineViewDelegate *outlineDelegate; @property (retain) NSMenu *menu; - -- (void)_didUpdateData:(NSNotification *)notification; -- (NSMenu *)_contextMenu; -- (KdbGroup *)_clickedOrSelectedGroup; - @end @implementation MPOutlineViewController @@ -45,17 +42,6 @@ _bindingEstablished = NO; _outlineDelegate = [[MPOutlineViewDelegate alloc] init]; _datasource = [[MPOutlineDataSource alloc] init]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(_didUpdateData:) - name:MPDocumentDidAddGroupNotification - object:[[self windowController] document]]; - - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(_didUpdateData:) - name:MPDocumentWillDelteGroupNotification - object:[[self windowController] document]]; } @@ -99,7 +85,7 @@ - (NSMenu *)_contextMenu { NSMenu *menu = [[NSMenu alloc] init]; - NSArray *items = [(MPAppDelegate *)[NSApp delegate] contextMenuItemsWithItems:MPContextMenuMinimal]; + NSArray *items = [MPContextMenuHelper contextMenuItemsWithItems:MPContextMenuMinimal]; for(NSMenuItem *item in items) { [menu addItem:item]; } @@ -132,15 +118,13 @@ if(group) { MPDocument *document = [[self windowController] document]; [document createEntry:group]; - // Notify the the entry view about changes } } - (void)deleteEntry:(id)sender { KdbGroup *group = [self _clickedOrSelectedGroup]; - if(group) { - MPDocument *document = [[self windowController] document]; - [document deleteGroup:group]; + if(group && group.parent) { + [group.parent removeGroupUndoable:group]; } } @@ -152,9 +136,4 @@ return [[self.outlineView itemAtRow:row] representedObject]; } -- (void)_didUpdateData:(NSNotification *)notification { - [self.outlineView reloadData]; -} - - @end diff --git a/MacPass/MPPopupImageView.m b/MacPass/MPPopupImageView.m index d4ee020a..217744e2 100644 --- a/MacPass/MPPopupImageView.m +++ b/MacPass/MPPopupImageView.m @@ -40,7 +40,7 @@ - (void)drawRect:(NSRect)dirtyRect { - [super drawRect:dirtyRect]; + if(self.showOverlay && [self isEnabled]) { [[NSGraphicsContext currentContext] saveGraphicsState]; @@ -70,6 +70,7 @@ [shadow release]; [[NSGraphicsContext currentContext] restoreGraphicsState]; } + [super drawRect:dirtyRect]; /* Draw Overlay */ } diff --git a/MacPass/MPSettingsHelper.m b/MacPass/MPSettingsHelper.m index 22c13c0a..14ce2e60 100644 --- a/MacPass/MPSettingsHelper.m +++ b/MacPass/MPSettingsHelper.m @@ -28,7 +28,7 @@ NSString *const kMPSettingsKeyOpenEmptyDatabaseOnLaunch = @"OpenEmptyDatabaseOnL return @{ kMPSettingsKeyPasteboardClearTimeout: @10, kMPSettingsKeyClearPasteboardOnQuit: @YES, - kMPSettingsKeyOpenEmptyDatabaseOnLaunch: @NO, + kMPSettingsKeyOpenEmptyDatabaseOnLaunch: @YES, }; } diff --git a/MacPass/MPToolbarDelegate.m b/MacPass/MPToolbarDelegate.m index cf147907..40553c7f 100644 --- a/MacPass/MPToolbarDelegate.m +++ b/MacPass/MPToolbarDelegate.m @@ -12,6 +12,7 @@ #import "MPToolbarButton.h" #import "MPToolbarItem.h" #import "MPActionHelper.h" +#import "MPContextMenuHelper.h" NSString *const MPToolbarItemLock = @"TOOLBAR_LOCK"; NSString *const MPToolbarItemAddGroup = @"TOOLBAR_ADD_GROUP"; @@ -75,7 +76,7 @@ NSString *const MPToolbarItemInspector = @"TOOLBAR_INSPECTOR"; [actionImageItem setImage:self.toolbarImages[MPToolbarItemAction]]; [menu addItem:actionImageItem]; [actionImageItem release]; - NSArray *menuItems = [(MPAppDelegate *)[NSApp delegate] contextMenuItemsWithItems:MPContextMenuFull]; + NSArray *menuItems = [MPContextMenuHelper contextMenuItemsWithItems:MPContextMenuFull]; for(NSMenuItem *item in menuItems) { [menu addItem:item]; } diff --git a/MacPass/MPViewController.m b/MacPass/MPViewController.m index 2812dc14..c279265a 100644 --- a/MacPass/MPViewController.m +++ b/MacPass/MPViewController.m @@ -24,8 +24,11 @@ return [[[self view] window] windowController]; } -- (NSResponder *)reconmendedFirstResponder { - return nil; +#pragma mark Responder Chain + +- (BOOL)becomeFirstResponder { + NSLog(@"%@: about to become firt responder.", [self class]); + return YES; } - (void)updateResponderChain { diff --git a/MacPass/MacPass-Info.plist b/MacPass/MacPass-Info.plist index 46c5fed1..829c36bc 100644 --- a/MacPass/MacPass-Info.plist +++ b/MacPass/MacPass-Info.plist @@ -48,7 +48,7 @@ CFBundleSignature ???? CFBundleVersion - AEE + B0A LSMinimumSystemVersion ${MACOSX_DEPLOYMENT_TARGET} NSHumanReadableCopyright