From 2b1d2dca060989146a14cc962dd8c0bcb51cbbb0 Mon Sep 17 00:00:00 2001 From: michael starke Date: Thu, 23 May 2013 22:50:34 +0200 Subject: [PATCH] More work on undo/redo Updated README --- MacPass/DocumentWindow.xib | 110 ++++++++++++++++++++++++++- MacPass/KdbEntry+Undo.h | 2 + MacPass/KdbEntry+Undo.m | 39 +++++----- MacPass/KdbGroup+Undo.h | 5 ++ MacPass/KdbGroup+Undo.m | 16 ++++ MacPass/MPDocumentWindowController.m | 14 ++-- MacPass/MPEntryViewController.h | 1 + MacPass/MPEntryViewController.m | 11 +-- MacPass/MacPass-Info.plist | 2 +- README.md | 9 ++- 10 files changed, 172 insertions(+), 37 deletions(-) diff --git a/MacPass/DocumentWindow.xib b/MacPass/DocumentWindow.xib index 3798ee63..70a57954 100644 --- a/MacPass/DocumentWindow.xib +++ b/MacPass/DocumentWindow.xib @@ -11,6 +11,7 @@ 3084 + IBNSLayoutConstraint NSCustomObject NSCustomView NSSplitView @@ -80,7 +81,6 @@ {{527, 0}, {200, 449}} - _NS:9 NSView @@ -110,7 +110,7 @@ - {{0, 0}, {1680, 1028}} + {{0, 0}, {1920, 1058}} {400, 422} {10000000000000, 10000000000000} YES @@ -198,6 +198,70 @@ + + + 5 + 0 + + 5 + 1 + + 0.0 + + 1000 + + 8 + 29 + 3 + + + + 4 + 0 + + 4 + 1 + + 0.0 + + 1000 + + 8 + 29 + 3 + + + + 3 + 0 + + 3 + 1 + + 0.0 + + 1000 + + 8 + 29 + 3 + + + + 6 + 0 + + 6 + 1 + + 0.0 + + 1000 + + 8 + 29 + 3 + @@ -227,6 +291,26 @@ + + 677 + + + + + 678 + + + + + 679 + + + + + 680 + + + @@ -238,17 +322,28 @@ com.apple.InterfaceBuilder.CocoaPlugin {{357, 418}, {480, 270}} + + + + + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin - 676 + 680 @@ -305,11 +400,20 @@ ./Classes/MPDocumentWindowController.h + + NSLayoutConstraint + NSObject + + IBProjectSource + ./Classes/NSLayoutConstraint.h + + 0 IBCocoaFramework YES 3 + YES diff --git a/MacPass/KdbEntry+Undo.h b/MacPass/KdbEntry+Undo.h index fe28ef9a..e91f55ae 100644 --- a/MacPass/KdbEntry+Undo.h +++ b/MacPass/KdbEntry+Undo.h @@ -10,6 +10,8 @@ @interface KdbEntry (Undo) ++ (NSUndoManager *)undoManager; + - (NSString *)titleUndoable; - (NSString *)usernameUndoable; - (NSString *)passwordUndoable; diff --git a/MacPass/KdbEntry+Undo.m b/MacPass/KdbEntry+Undo.m index 57777943..de0280ba 100644 --- a/MacPass/KdbEntry+Undo.m +++ b/MacPass/KdbEntry+Undo.m @@ -11,6 +11,10 @@ @implementation KdbEntry (Undo) ++ (NSUndoManager *)undoManager { + return [[[NSDocumentController sharedDocumentController] currentDocument] undoManager]; +} + - (NSString *)titleUndoable { return [self title]; } @@ -33,37 +37,32 @@ - (void)setTitleUndoable:(NSString *)title { - NSDocument *document = [[NSDocumentController sharedDocumentController] currentDocument]; - [[document undoManager] registerUndoWithTarget:self selector:@selector(setTitleUndoable:) object:self.title]; - [[document undoManager] setActionName:NSLocalizedString(@"UNDO_SET_TITLE", "Undo set title")]; + [[KdbEntry undoManager] registerUndoWithTarget:self selector:@selector(setTitleUndoable:) object:self.title]; + [[KdbEntry undoManager] setActionName:NSLocalizedString(@"UNDO_SET_TITLE", "Undo set title")]; [self setTitle:title]; } - (void)setUsernameUndoable:(NSString *)username { - NSDocument *document = [[NSDocumentController sharedDocumentController] currentDocument]; - [[document undoManager] registerUndoWithTarget:self selector:@selector(setUsernameUndoable:) object:self.username]; - [[document undoManager] setActionName:NSLocalizedString(@"UNDO_SET_USERNAME", "Undo set username")]; + [[KdbEntry undoManager] registerUndoWithTarget:self selector:@selector(setUsernameUndoable:) object:self.username]; + [[KdbEntry undoManager] setActionName:NSLocalizedString(@"UNDO_SET_USERNAME", "Undo set username")]; [self setUsername:username]; } - (void)setPasswordUndoable:(NSString *)password { - NSDocument *document = [[NSDocumentController sharedDocumentController] currentDocument]; - [[document undoManager] registerUndoWithTarget:self selector:@selector(setTitleUndoable:) object:self.password]; - [[document undoManager] setActionName:NSLocalizedString(@"UNDO_SET_PASSWORT", "Undo set password")]; + [[KdbEntry undoManager] registerUndoWithTarget:self selector:@selector(setTitleUndoable:) object:self.password]; + [[KdbEntry undoManager] setActionName:NSLocalizedString(@"UNDO_SET_PASSWORT", "Undo set password")]; [self setPassword:password]; } - (void)setUrlUndoable:(NSString *)url { - NSDocument *document = [[NSDocumentController sharedDocumentController] currentDocument]; - [[document undoManager] registerUndoWithTarget:self selector:@selector(setTitleUndoable:) object:self.url]; - [[document undoManager] setActionName:NSLocalizedString(@"UNDO_SET_URL", "Undo set URL")]; + [[KdbEntry undoManager] registerUndoWithTarget:self selector:@selector(setTitleUndoable:) object:self.url]; + [[KdbEntry undoManager] setActionName:NSLocalizedString(@"UNDO_SET_URL", "Undo set URL")]; [self setUrl:url]; } - (void)setNotesUndoable:(NSString *)notes { - NSDocument *document = [[NSDocumentController sharedDocumentController] currentDocument]; - [[document undoManager] registerUndoWithTarget:self selector:@selector(setTitleUndoable:) object:self.notes]; - [[document undoManager] setActionName:NSLocalizedString(@"UNDO_SET_NOTES", "Undo set notes")]; + [[KdbEntry undoManager] registerUndoWithTarget:self selector:@selector(setTitleUndoable:) object:self.notes]; + [[KdbEntry undoManager] setActionName:NSLocalizedString(@"UNDO_SET_NOTES", "Undo set notes")]; [self setNotes:notes]; } @@ -73,9 +72,8 @@ } NSUInteger iIndex = [index unsignedIntegerValue]; NSNumber *oldIndex = @([self.parent.entries indexOfObject:self]); - NSDocument *document = [[NSDocumentController sharedDocumentController] currentDocument]; - [[document undoManager] registerUndoWithTarget:self selector:@selector(moveToIndexUndoable:) object:oldIndex]; - [[document undoManager] setActionName:NSLocalizedString(@"UNDO_SET_POSITION", "Undo set entry position")]; + [[KdbEntry undoManager] registerUndoWithTarget:self selector:@selector(moveToIndexUndoable:) object:oldIndex]; + [[KdbEntry undoManager] setActionName:NSLocalizedString(@"UNDO_SET_POSITION", "Undo set entry position")]; [self.parent moveEntry:self toIndex:iIndex]; } @@ -87,9 +85,8 @@ if(!self.parent || !newGroup) { return; } - NSDocument *document = [[NSDocumentController sharedDocumentController] currentDocument]; - [[document undoManager] registerUndoWithTarget:self selector:@selector(moveToGroupUndoable:) object:self.parent]; - [[document undoManager] setActionName:NSLocalizedString(@"UNDO_MOVE_ENTRY", "Undo move entry to group")]; + [[KdbEntry undoManager] registerUndoWithTarget:self selector:@selector(moveToGroupUndoable:) object:self.parent]; + [[KdbEntry undoManager] setActionName:NSLocalizedString(@"UNDO_MOVE_ENTRY", "Undo move entry to group")]; [self.parent moveEntry:self toGroup:newGroup]; } @end \ No newline at end of file diff --git a/MacPass/KdbGroup+Undo.h b/MacPass/KdbGroup+Undo.h index f5f5f476..a78f9d1b 100644 --- a/MacPass/KdbGroup+Undo.h +++ b/MacPass/KdbGroup+Undo.h @@ -10,4 +10,9 @@ @interface KdbGroup (Undo) ++ (NSUndoManager *)undoManager; + +- (void)removeEntryUndoable:(KdbEntry *)entry; +- (void)addEntryUndoable:(KdbEntry *)entry; + @end diff --git a/MacPass/KdbGroup+Undo.m b/MacPass/KdbGroup+Undo.m index c157e52c..076fe4eb 100644 --- a/MacPass/KdbGroup+Undo.m +++ b/MacPass/KdbGroup+Undo.m @@ -10,4 +10,20 @@ @implementation KdbGroup (Undo) ++ (NSUndoManager *)undoManager { + return [[[NSDocumentController sharedDocumentController] currentDocument] undoManager]; +} + +- (void)removeEntryUndoable:(KdbEntry *)entry { + [[KdbGroup undoManager] registerUndoWithTarget:self selector:@selector(addEntryUndoable:) object:entry]; + [[KdbGroup undoManager] setActionName:NSLocalizedString(@"UNDO_DELETE_ENTRY", "Undo deleting of entry")]; + [self removeEntry:entry]; +} + +- (void)addEntryUndoable:(KdbEntry *)entry { + [[KdbGroup undoManager] registerUndoWithTarget:self selector:@selector(removeEntryUndoable:) object:entry]; + [[KdbGroup undoManager] setActionName:NSLocalizedString(@"UNDO_ADD_ENTRY", "Undo adding of entry")]; + [self addEntry:entry]; +} + @end diff --git a/MacPass/MPDocumentWindowController.m b/MacPass/MPDocumentWindowController.m index f5cc9498..c6ef34f9 100644 --- a/MacPass/MPDocumentWindowController.m +++ b/MacPass/MPDocumentWindowController.m @@ -83,17 +83,19 @@ [self.toolbar setDelegate:self.toolbarDelegate]; [self.window setToolbar:self.toolbar]; + [self.splitView setTranslatesAutoresizingMaskIntoConstraints:NO]; + /* Add outlineview */ - const NSRect outlineFrame = [self.outlineView frame]; - [self.outlineViewController.view setFrame:outlineFrame]; - [self.outlineViewController.view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; + //const NSRect outlineFrame = [self.outlineView frame]; + //[self.outlineViewController.view setFrame:outlineFrame]; + //[self.outlineViewController.view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; [self.splitView replaceSubview:self.outlineView with:[self.outlineViewController view]]; [self.outlineViewController updateResponderChain]; /* Add inspector view */ - const NSRect inspectorFrame = [self.inspectorView frame]; - [self.inspectorTabViewController.view setFrame:inspectorFrame]; - [self.inspectorTabViewController.view setAutoresizesSubviews:NSViewWidthSizable | NSViewHeightSizable ]; + //const NSRect inspectorFrame = [self.inspectorView frame]; + //[self.inspectorTabViewController.view setFrame:inspectorFrame]; + //[self.inspectorTabViewController.view setAutoresizesSubviews:NSViewWidthSizable | NSViewHeightSizable ]; [self.splitView replaceSubview:self.inspectorView with:[self.inspectorTabViewController view]]; [self.inspectorTabViewController updateResponderChain]; diff --git a/MacPass/MPEntryViewController.h b/MacPass/MPEntryViewController.h index 62ee58f5..4f5ebf95 100644 --- a/MacPass/MPEntryViewController.h +++ b/MacPass/MPEntryViewController.h @@ -49,6 +49,7 @@ typedef enum { - (void)openURL:(id)sender; /* Entry Handling*/ +- (void)createEntry:(id)sender; - (void)deleteEntry:(id)sender; @end diff --git a/MacPass/MPEntryViewController.m b/MacPass/MPEntryViewController.m index 3d14c846..f9ca39b8 100644 --- a/MacPass/MPEntryViewController.m +++ b/MacPass/MPEntryViewController.m @@ -16,6 +16,7 @@ #import "MPPasteBoardController.h" #import "MPOverlayWindowController.h" #import "KdbGroup+MPAdditions.h" +#import "KdbEntry+Undo.h" NSString *const MPDidChangeSelectedEntryNotification = @"com.macpass.MPDidChangeSelectedEntryNotification"; @@ -472,12 +473,12 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername"; } } +- (void)createEntry:(id)sender { + // TODO: +} + - (void)deleteEntry:(id)sender { - KdbEntry *selectedEntry = [self _clickedOrSelectedEntry]; - if(selectedEntry) { - [self.entryArrayController removeObject:selectedEntry]; - [selectedEntry.parent removeEntry:selectedEntry]; - } + // TODO: } - (void)_toggleFilterSpace:(id)sender { diff --git a/MacPass/MacPass-Info.plist b/MacPass/MacPass-Info.plist index e01e6ce5..81363ac3 100644 --- a/MacPass/MacPass-Info.plist +++ b/MacPass/MacPass-Info.plist @@ -46,7 +46,7 @@ CFBundleSignature ???? CFBundleVersion - 6EE + 6F7 LSMinimumSystemVersion ${MACOSX_DEPLOYMENT_TARGET} NSHumanReadableCopyright diff --git a/README.md b/README.md index c12cdc0d..eedcf3e6 100644 --- a/README.md +++ b/README.md @@ -6,13 +6,20 @@ KeePass can be used via Mono on OS X but lacks vital functionality and feels slu This is an attempt to create an OS X port that should at least be able to read KeePass files. +Status +------ + +The Project is in heavy development and it's likely to take some time till it reaches a usable state. +Beware that I'm going to shift things around so stuff is going to break. A lot. + + Alternatives ------------ Currently there is an alpha Version available of [KeePassX](http://www.keepassx.org). It's Qt based KeePass manager, than can handle KeePass 1 and 2 containers rather nicely. Compared to running KeePass with Mono it very fast and remarkably stable for an alpha relaese. -Feel free to give it a try. +Feel free to give it a try. The biggest draw-back is it's inablity to create passwords via a wizzard. What does it look like? -----------------------