diff --git a/MacPass.xcodeproj/project.pbxproj b/MacPass.xcodeproj/project.pbxproj index 44fa5079..2942ad1c 100644 --- a/MacPass.xcodeproj/project.pbxproj +++ b/MacPass.xcodeproj/project.pbxproj @@ -9,7 +9,6 @@ /* Begin PBXBuildFile section */ 4C1DDCDD1711ECEB00C98DA3 /* PasswordCreatorWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C1DDCDC1711ECEB00C98DA3 /* PasswordCreatorWindow.xib */; }; 4C22040D1746ED160054C916 /* KdbGroup+Undo.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C22040C1746ED160054C916 /* KdbGroup+Undo.m */; }; - 4C25D58516CF0F8800F6806C /* WelcomeView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C25D58416CF0F8800F6806C /* WelcomeView.xib */; }; 4C25D58716CF0FAA00F6806C /* EntryView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C25D58616CF0FAA00F6806C /* EntryView.xib */; }; 4C2C4C2C16D3BE3700D49295 /* KdbGroup+MPAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C2C4C2B16D3BE3700D49295 /* KdbGroup+MPAdditions.m */; }; 4C2E381D16D11FF900037A9D /* 03_ServerTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4C2E381A16D11FF900037A9D /* 03_ServerTemplate.pdf */; }; @@ -133,7 +132,6 @@ 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 = ""; }; - 4C25D58416CF0F8800F6806C /* WelcomeView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = WelcomeView.xib; sourceTree = ""; }; 4C25D58616CF0FAA00F6806C /* EntryView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = EntryView.xib; sourceTree = ""; }; 4C2C4C2A16D3BE3700D49295 /* KdbGroup+MPAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "KdbGroup+MPAdditions.h"; sourceTree = ""; }; 4C2C4C2B16D3BE3700D49295 /* KdbGroup+MPAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "KdbGroup+MPAdditions.m"; sourceTree = ""; }; @@ -377,7 +375,6 @@ 4CBFA23F172B385D006090DF /* PasswordEditView.xib */, 4C6B0E8B16C9B99B00A9ED23 /* PasswordInputView.xib */, 4C5A11FD1708DE8700223D8A /* PasswordCreatorView.xib */, - 4C25D58416CF0F8800F6806C /* WelcomeView.xib */, 4C3FFD9D16DAF60600DF9186 /* FilterBar.xib */, 4C77547616E55FFC00970E02 /* InspectorView.xib */, 4CE39AC016ECE359000FE29D /* IconSelection.xib */, @@ -878,7 +875,6 @@ 4CA0B2F015BCADC800654E32 /* GeneralSettings.xib in Resources */, 4CD884B715BD47080042BBF8 /* DocumentWindow.xib in Resources */, 4C6B0E8C16C9B99B00A9ED23 /* PasswordInputView.xib in Resources */, - 4C25D58516CF0F8800F6806C /* WelcomeView.xib in Resources */, 4C25D58716CF0FAA00F6806C /* EntryView.xib in Resources */, 4C586F9E16D07ABD00E7DB57 /* 00_PasswordTemplate.pdf in Resources */, 4C586FA016D07D7200E7DB57 /* 01_PackageNetworkTemplate.pdf in Resources */, diff --git a/MacPass/DocumentWindow.xib b/MacPass/DocumentWindow.xib index 1b1427cc..0fecc6de 100644 --- a/MacPass/DocumentWindow.xib +++ b/MacPass/DocumentWindow.xib @@ -11,9 +11,7 @@ 3084 - IBNSLayoutConstraint NSCustomObject - NSCustomView NSSplitView NSView NSWindowTemplate @@ -38,83 +36,35 @@ 15 2 - {{196, 240}, {727, 548}} + {{196, 240}, {560, 429}} 1618477056 Window NSWindow - {400, 400} 256 - - - - 319 - - - - 12 - - {200, 548} - - - - _NS:9 - NSView - - - - 256 - - {{201, 0}, {325, 548}} - - - - _NS:13 - NSView - - - - 268 - {{527, 0}, {200, 548}} - - - _NS:9 - NSView - - - {727, 548} - - - - _NS:9 - YES - 2 - - YES - - - - - - - - - - - - {727, 548} + + {560, 429} - {{0, 0}, {1920, 1058}} - {400, 422} {10000000000000, 10000000000000} YES + + + 268 + + {560, 194} + + + _NS:9 + YES + 2 + @@ -126,37 +76,13 @@ 501 - - - contentView - - - - 625 - splitView - + - 627 - - - - outlineView - - - - 634 - - - - inspectorView - - - - 676 + 700 @@ -196,120 +122,13 @@ 2 - - - - - 4 - 0 - - 4 - 1 - - 0.0 - - 1000 - - 8 - 29 - 3 - - - - 5 - 0 - - 5 - 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 - - + - 603 - - - - - - - - - - 605 - - - - - - 628 - - - - - 675 - - - - - 677 - - - - - 678 - - - - - 680 - - - - - 696 - - + 697 + + @@ -322,28 +141,16 @@ 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 + + + com.apple.InterfaceBuilder.CocoaPlugin - 696 + 709 @@ -361,53 +168,22 @@ id - - NSView - NSView - NSView - NSSplitView - NSTextField - NSView - - - - contentView - NSView - - - inspectorView - NSView - - - outlineView - NSView - - + + splitView + NSSplitView + + + splitView + splitView NSSplitView - - welcomeText - NSTextField - - - welcomeView - NSView - - + IBProjectSource ./Classes/MPDocumentWindowController.h - - NSLayoutConstraint - NSObject - - IBProjectSource - ./Classes/NSLayoutConstraint.h - - 0 diff --git a/MacPass/EntryView.xib b/MacPass/EntryView.xib index a25ed655..b39d14a0 100644 --- a/MacPass/EntryView.xib +++ b/MacPass/EntryView.xib @@ -320,7 +320,6 @@ {{0, 310}, {480, 16}} - _NS:60 NO 1 @@ -449,7 +448,7 @@ 266 - {104.5, 17} + {105, 17} {250, 750} @@ -471,7 +470,7 @@ NO - {{1, 1}, {104.5, 17}} + {{1, 1}, {105, 17}} @@ -540,7 +539,7 @@ NO - {{108.5, 1}, {144, 17}} + {{109, 1}, {144, 17}} _NS:9 @@ -583,7 +582,7 @@ NO - {{377, 1}, {113, 17}} + {{378, 1}, {113, 17}} @@ -600,7 +599,7 @@ 266 - {118.5, 17} + {119, 17} {250, 750} @@ -617,7 +616,7 @@ NO - {{255.5, 1}, {118.5, 17}} + {{256, 1}, {119, 17}} @@ -651,7 +650,7 @@ NO - {{493, 1}, {292, 17}} + {{494, 1}, {292, 17}} @@ -1439,7 +1438,8 @@ - + + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin diff --git a/MacPass/FilterBar.xib b/MacPass/FilterBar.xib index 70aa23cd..5a16ca59 100644 --- a/MacPass/FilterBar.xib +++ b/MacPass/FilterBar.xib @@ -39,7 +39,7 @@ NSApplication - + 268 @@ -47,6 +47,7 @@ 268 {{369, 5}, {136, 19}} + _NS:9 YES @@ -121,6 +122,7 @@ 268 {{513, 5}, {42, 17}} + _NS:9 YES @@ -144,6 +146,7 @@ 268 {{188, 5}, {38, 17}} + _NS:9 YES @@ -172,6 +175,7 @@ 268 {{104, 5}, {76, 17}} + _NS:9 YES @@ -196,6 +200,7 @@ 268 {{5, 6}, {44, 14}} + _NS:1535 YES @@ -236,6 +241,7 @@ 268 {{54, 4}, {42, 19}} + _NS:9 YES @@ -257,6 +263,8 @@ {563, 28} + + HNHGradientView @@ -820,6 +828,8 @@ + + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -867,6 +877,14 @@ + + HNHGradientView + NSView + + IBProjectSource + ./Classes/HNHGradientView.h + + MPEntryViewController MPViewController diff --git a/MacPass/InspectorView.xib b/MacPass/InspectorView.xib index 9ca7f004..c9114e3c 100644 --- a/MacPass/InspectorView.xib +++ b/MacPass/InspectorView.xib @@ -239,7 +239,6 @@ {{212, 286}, {32, 25}} - _NS:22 YES @@ -1391,6 +1390,8 @@ + + com.apple.InterfaceBuilder.CocoaPlugin diff --git a/MacPass/KdbGroup+KVOAdditions.m b/MacPass/KdbGroup+KVOAdditions.m index 77708d1a..2a5ad22e 100644 --- a/MacPass/KdbGroup+KVOAdditions.m +++ b/MacPass/KdbGroup+KVOAdditions.m @@ -17,8 +17,8 @@ - (void)removeObjectFromEntriesAtIndex:(NSUInteger)index { KdbEntry *entry = [entries objectAtIndex:index]; - entry.parent = nil; [entries removeObjectAtIndex:index]; + entry.parent = nil; } - (NSUInteger)countOfEntries { @@ -44,8 +44,8 @@ - (void)removeObjectFromGroupsAtIndex:(NSUInteger)index { KdbGroup *group = [groups objectAtIndex:index]; - group.parent = nil; [groups removeObjectAtIndex:index]; + group.parent = nil; } @end diff --git a/MacPass/MPActionHelper.h b/MacPass/MPActionHelper.h index 14ce02ff..8b65c59a 100644 --- a/MacPass/MPActionHelper.h +++ b/MacPass/MPActionHelper.h @@ -18,6 +18,7 @@ typedef enum { MPActionCopyURL, // copy url to pasteboard MPActionOpenURL, // open url in default browser MPActionToggleInspector, + MPActionLock, // show the lock screen } MPActionType; diff --git a/MacPass/MPActionHelper.m b/MacPass/MPActionHelper.m index 40d0ced5..c181ea20 100644 --- a/MacPass/MPActionHelper.m +++ b/MacPass/MPActionHelper.m @@ -15,16 +15,17 @@ static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ actionDict = [@{ - @(MPActionAddEntry) : @"createEntry:", - @(MPActionAddGroup) : @"createGroup:", - @(MPActionCopyPassword) : @"copyPassword:", - @(MPActionCopyURL) : @"copyURL:", - @(MPActionCopyUsername) : @"copyUsername:", - @(MPActionDelete) : @"deleteEntry:", - @(MPActionEdit) : @"editEntry:", - @(MPActionOpenURL) : @"openURL:", - @(MPActionToggleInspector) : @"toggleInspector:" - } retain]; + @(MPActionAddEntry) : @"createEntry:", + @(MPActionAddGroup) : @"createGroup:", + @(MPActionCopyPassword) : @"copyPassword:", + @(MPActionCopyURL) : @"copyURL:", + @(MPActionCopyUsername) : @"copyUsername:", + @(MPActionDelete) : @"deleteEntry:", + @(MPActionEdit) : @"editEntry:", + @(MPActionOpenURL) : @"openURL:", + @(MPActionToggleInspector) : @"toggleInspector:", + @(MPActionLock) : @"lock:" + } retain]; }); return NSSelectorFromString(actionDict[@(type)]); } diff --git a/MacPass/MPDocumentWindowController.h b/MacPass/MPDocumentWindowController.h index 98c727d4..40e67825 100644 --- a/MacPass/MPDocumentWindowController.h +++ b/MacPass/MPDocumentWindowController.h @@ -31,9 +31,6 @@ - (void)performFindPanelAction:(id)sender; - (void)clearOutlineSelection:(id)sender; - (IBAction)editPassword:(id)sender; -/* - Clears the Search filter - */ -- (void)toggleInspector:(id)sender; +- (void)lock:(id)sender; @end diff --git a/MacPass/MPDocumentWindowController.m b/MacPass/MPDocumentWindowController.m index d2c51261..53a23d0c 100644 --- a/MacPass/MPDocumentWindowController.m +++ b/MacPass/MPDocumentWindowController.m @@ -15,20 +15,15 @@ #import "MPOutlineViewController.h" #import "MPInspectorViewController.h" #import "MPAppDelegate.h" -#import "DMSplitView.h" +#import "MPActionHelper.h" @interface MPDocumentWindowController () { @private BOOL _needsDecryption; } -@property (assign) IBOutlet NSView *outlineView; -@property (assign) IBOutlet NSSplitView *splitView; -@property (assign) IBOutlet NSView *contentView; -@property (assign) IBOutlet NSView *inspectorView; +@property (retain) IBOutlet NSSplitView *splitView; -@property (retain) IBOutlet NSView *welcomeView; -@property (assign) IBOutlet NSTextField *welcomeText; @property (retain) NSToolbar *toolbar; @property (retain) MPPasswordInputController *passwordInputController; @@ -40,8 +35,6 @@ @property (retain) MPToolbarDelegate *toolbarDelegate; - (void)_setContentViewController:(MPViewController *)viewController; -- (void)_setOutlineVisible:(BOOL)isVisible; - @end @@ -55,6 +48,7 @@ _outlineViewController = [[MPOutlineViewController alloc] init]; _inspectorTabViewController = [[MPInspectorViewController alloc] init]; _passwordEditController = [[MPPasswordEditViewController alloc] init]; + _entryViewController = [[MPEntryViewController alloc] init]; } return self; } @@ -70,6 +64,7 @@ [_creationViewController release]; [_toolbarDelegate release]; + [_splitView release]; [super dealloc]; } @@ -78,7 +73,6 @@ - (void)windowDidLoad { [super windowDidLoad]; - _toolbar = [[NSToolbar alloc] initWithIdentifier:@"MainWindowToolbar"]; [self.toolbar setAllowsUserCustomization:YES]; [self.toolbar setDelegate:self.toolbarDelegate]; @@ -86,105 +80,72 @@ [self.splitView setTranslatesAutoresizingMaskIntoConstraints:NO]; - /* Add outlineview */ - 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]; + NSView *outlineView = [_outlineViewController view]; + NSView *inspectorView = [_inspectorTabViewController view]; + NSView *entryView = [_entryViewController view]; + [self.splitView addSubview:outlineView]; + [self.splitView addSubview:entryView]; + [self.splitView addSubview:inspectorView]; - /* Add inspector view */ - const NSRect inspectorFrame = [self.inspectorView frame]; - [self.inspectorTabViewController.view setFrame:inspectorFrame]; - [self.splitView replaceSubview:self.inspectorView with:[self.inspectorTabViewController view]]; - [self.inspectorTabViewController updateResponderChain]; - - [self _setOutlineVisible:NO]; + //TODO: Fix setup on start MPDocument *document = [self document]; if(!document.isDecrypted) { [self showPasswordInput]; } else { - [self editPassword:nil]; + [self showEntries]; } } - (void)_setContentViewController:(MPViewController *)viewController { - NSView *newContentView = self.welcomeView; + + NSView *newContentView = nil; if(viewController && viewController.view) { newContentView = viewController.view; } - /* - Set correct size and resizing for view - */ - [newContentView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; - NSSize frameSize = [self.contentView frame].size; - [newContentView setFrame:NSMakeRect(0,0, frameSize.width, frameSize.height)]; + NSView *contentView = [[self window] contentView]; + NSView *oldSubView = nil; + if([[contentView subviews] count] == 1) { + oldSubView = [contentView subviews][0]; + } + if(oldSubView == newContentView) { + return; // View is already present + } + [oldSubView removeFromSuperviewWithoutNeedingDisplay]; + [contentView addSubview:newContentView]; + [contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[newContentView]|" + options:0 + metrics:nil + views:NSDictionaryOfVariableBindings(newContentView)]]; + + [contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[newContentView]|" + options:0 + metrics:nil + views:NSDictionaryOfVariableBindings(newContentView)]]; - /* - Add or replace subview - */ - NSArray *subViews = [self.contentView subviews]; - BOOL hasSubViews = ([subViews count] > 0); - if(hasSubViews) { - NSView *subView = subViews[0]; - assert(subView); - [self.contentView replaceSubview:subView with:newContentView]; - } - else { - [self.contentView addSubview:newContentView]; - } + [contentView layout]; [viewController updateResponderChain]; - [self.contentView setNeedsDisplay:YES]; - [self.splitView adjustSubviews]; - /* - Set focus AFTER having added the view - */ [self.window makeFirstResponder:[viewController reconmendedFirstResponder]]; } -- (void)_setOutlineVisible:(BOOL)isVisible { - self.outlineViewController.isVisible = isVisible; -} - #pragma mark Actions - -- (void)toggleInspector:(id)sender { - //if(self.inspectorTabViewController) { - // [self.inspectorTabViewController toggleVisible]; - //} -} - - (void)performFindPanelAction:(id)sender { [self.entryViewController showFilter:sender]; } -- (void)toggleOutlineView:(id)sender { - -} - - (BOOL)validateMenuItem:(NSMenuItem *)menuItem { - SEL menuAction = [menuItem action]; - if(menuAction == @selector(main:)) { - NSString *title = self.outlineViewController.isVisible ? NSLocalizedString(@"SHOW_OUTLINE_VIEW", @"") : NSLocalizedString(@"HIDE_OUTLINE_VIEW", @"Hide the Outline View"); - - [menuItem setTitle:title]; - return YES; - } - if( menuAction == @selector(toggleInspector:) ) { - NSString *title = [self.inspectorTabViewController isVisible] ? NSLocalizedString(@"SHOW_INSPECTOR", @"Show the Inspector") : NSLocalizedString(@"HIDE_INSPECTOR", @"Hide the Inspector"); - - [menuItem setTitle:title]; - return YES; - } return YES; } - (BOOL)validateToolbarItem:(NSToolbarItem *)theItem { + SEL itemAction = [theItem action]; + if( itemAction == [MPActionHelper actionOfType:MPActionLock]) { + return (nil == [[_passwordInputController view] superview]); + } + return YES; return [self.toolbarDelegate validateToolbarItem:theItem]; } - - (void)showPasswordInput { if(!self.passwordInputController) { self.passwordInputController = [[[MPPasswordInputController alloc] init] autorelease]; @@ -204,8 +165,57 @@ [self _setContentViewController:self.passwordEditController]; } -#pragma mark Helper +- (void)lock:(id)sender { + [self showPasswordInput]; +} +- (void)showEntries { + NSView *contentView = [[self window] contentView]; + if(_splitView == contentView) { + return; // We are displaying the entries already + } + if([[contentView subviews] count] == 1) { + [[contentView subviews][0] removeFromSuperviewWithoutNeedingDisplay]; + } + [contentView addSubview:_splitView]; + [_splitView adjustSubviews]; + NSView *outlineView = [_outlineViewController view]; + NSView *inspectorView = [_inspectorTabViewController view]; + NSView *entryView = [_entryViewController view]; + + NSDictionary *views = NSDictionaryOfVariableBindings(outlineView, inspectorView, entryView, _splitView); + [self.splitView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[outlineView(>=150,<=250)]-1-[entryView(>=250)]-1-[inspectorView(>=200)]|" + options:0 + metrics:nil + views:views]]; + [self.splitView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[outlineView]|" + options:0 + metrics:nil + views:views]]; + [self.splitView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[entryView(>=300)]|" + options:0 + metrics:nil + views:views]]; + [self.splitView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[inspectorView]|" + options:0 + metrics:nil + views:views]]; + [contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[_splitView]|" + options:0 + metrics:nil + views:views]]; + [contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[_splitView]|" + options:0 + metrics:nil + views:views]]; + [contentView layout]; + [_entryViewController updateResponderChain]; + [_inspectorTabViewController updateResponderChain]; + [_outlineViewController updateResponderChain]; + [_outlineViewController showOutline]; +} + +#pragma mark Helper - (NSSearchField *)locateToolbarSearchField { for(NSToolbarItem *toolbarItem in [[self.window toolbar] items]) { NSView *view = [toolbarItem view]; @@ -216,14 +226,5 @@ return nil; } -#pragma mark Notifications -- (void)showEntries { - if(!self.entryViewController) { - _entryViewController = [[MPEntryViewController alloc] init]; - } - [self _setContentViewController:self.entryViewController]; - [self.outlineViewController showOutline]; - [self _setOutlineVisible:YES]; -} @end diff --git a/MacPass/MPEntryViewController.m b/MacPass/MPEntryViewController.m index 0e34a40e..8cd025dd 100644 --- a/MacPass/MPEntryViewController.m +++ b/MacPass/MPEntryViewController.m @@ -136,8 +136,6 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername"; name:MPOutlineViewDidChangeGroupSelection object:windowController.outlineViewController.outlineDelegate]; - //[[NSNotificationCenter defaultCenter] addObserver:self.entryTable selector:@selector(reloadData) name:MPDocumentDidAddEntryNotification object:nil]; - [self.entryTable setDelegate:self]; [self.entryTable setDoubleAction:@selector(_columnDoubleClick:)]; [self.entryTable setTarget:self]; @@ -305,7 +303,6 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername"; - (void)setupFilterBar { if(!self.filterBar) { [[NSBundle mainBundle] loadNibNamed:@"FilterBar" owner:self topLevelObjects:nil]; - [self.filterBar setAutoresizingMask:NSViewWidthSizable|NSViewMinYMargin]; [self.filterURLButton setIdentifier:_toggleFilterURLButton]; [self.filterUsernameButton setIdentifier:_toggleFilterUsernameButton]; [self.filterTitleButton setIdentifier:_toggleFilterTitleButton]; diff --git a/MacPass/MPInspectorViewController.h b/MacPass/MPInspectorViewController.h index 91b200a0..3644cf45 100644 --- a/MacPass/MPInspectorViewController.h +++ b/MacPass/MPInspectorViewController.h @@ -25,7 +25,6 @@ @property (assign) IBOutlet NSButton *showPasswordCreator; - (BOOL)isVisible; -- (void)toggleVisible; - (IBAction)togglePasswordDisplay:(id)sender; - (void)hideImagePopup:(id)sender; diff --git a/MacPass/MPInspectorViewController.m b/MacPass/MPInspectorViewController.m index 6d52f427..9429fd68 100644 --- a/MacPass/MPInspectorViewController.m +++ b/MacPass/MPInspectorViewController.m @@ -76,22 +76,6 @@ selector:@selector(_didChangeSelectedGroup:) name:MPOutlineViewDidChangeGroupSelection object:nil]; - - self.showConstraint = [NSLayoutConstraint constraintWithItem:[self view] attribute:NSLayoutAttributeWidth - relatedBy:NSLayoutRelationGreaterThanOrEqual - toItem:nil - attribute:NSLayoutAttributeNotAnAttribute - multiplier:1 - constant:200]; - self.hideConstraint = [NSLayoutConstraint constraintWithItem:[self view] attribute:NSLayoutAttributeWidth - relatedBy:NSLayoutRelationEqual - toItem:nil - attribute:NSLayoutAttributeNotAnAttribute - multiplier:1 - constant:0]; - - [self.view addConstraint:self.showConstraint]; - [self _clearContent]; } @@ -99,14 +83,6 @@ return [[self view] frame].size.width > 0; } -- (void)toggleVisible { - NSLayoutConstraint *add = [self isVisible] ? self.hideConstraint : self.showConstraint; - NSLayoutConstraint *remove = [self isVisible] ? self.showConstraint : self.hideConstraint; - [[self view] removeConstraint:remove]; - [[self view] addConstraint:add]; - [[[self view] window] layoutIfNeeded]; -} - - (void)_updateContent { if(self.showsEntry && self.selectedEntry) { [self _showEntry]; diff --git a/MacPass/MPOutlineViewController.h b/MacPass/MPOutlineViewController.h index fee5115c..7ad1a817 100644 --- a/MacPass/MPOutlineViewController.h +++ b/MacPass/MPOutlineViewController.h @@ -14,7 +14,6 @@ @interface MPOutlineViewController : MPViewController @property (retain, readonly) MPOutlineViewDelegate *outlineDelegate; -@property (assign, nonatomic) BOOL isVisible; - (void)clearSelection; diff --git a/MacPass/MPOutlineViewController.m b/MacPass/MPOutlineViewController.m index 80e693b8..f61ad866 100644 --- a/MacPass/MPOutlineViewController.m +++ b/MacPass/MPOutlineViewController.m @@ -13,7 +13,9 @@ #import "MPAppDelegate.h" #import "KdbLib.h" -@interface MPOutlineViewController () +@interface MPOutlineViewController () { + BOOL _bindingEstablished; +} @property (assign) IBOutlet NSOutlineView *outlineView; @@ -21,8 +23,6 @@ @property (retain) MPOutlineDataSource *datasource; @property (retain) MPOutlineViewDelegate *outlineDelegate; @property (retain) NSMenu *menu; -@property (retain) NSArray *showConstraints; -@property (retain) NSArray *hideConstraints; - (void)_didUpdateData:(NSNotification *)notification; @@ -40,8 +40,8 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { - _isVisible = YES; _treeController = [[NSTreeController alloc] init]; + _bindingEstablished = NO; self.outlineDelegate = [[[MPOutlineViewDelegate alloc] init] autorelease]; self.datasource = [[[MPOutlineDataSource alloc] init] autorelease]; @@ -77,27 +77,16 @@ [self.outlineView setAllowsEmptySelection:YES]; [self.outlineView setFloatsGroupRows:NO]; [self.outlineView setDraggingSourceOperationMask:NSDragOperationEvery forLocal:YES]; - - - NSView *myView = [self view]; - self.showConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"H:[myView(>=100,<=250)]" - options:0 - metrics:nil - views:NSDictionaryOfVariableBindings(myView)]; - - self.hideConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"H:[myView(==0)]" - options:0 - metrics:nil - views:NSDictionaryOfVariableBindings(myView)]; - [[self view] addConstraints:_showConstraints]; - } - (void)showOutline { - MPDocument *document = [[NSDocumentController sharedDocumentController] currentDocument]; - [_treeController setChildrenKeyPath:@"groups"]; - [_treeController bind:NSContentBinding toObject:document withKeyPath:@"root" options:nil]; - [_outlineView bind:NSContentBinding toObject:_treeController withKeyPath:@"arrangedObjects" options:nil]; + if(!_bindingEstablished) { + MPDocument *document = [[self windowController] document]; + [_treeController setChildrenKeyPath:@"groups"]; + [_treeController bind:NSContentBinding toObject:document withKeyPath:@"root" options:nil]; + [_outlineView bind:NSContentBinding toObject:_treeController withKeyPath:@"arrangedObjects" options:nil]; + _bindingEstablished = YES; + } NSTreeNode *node = [_outlineView itemAtRow:0]; [_outlineView expandItem:node expandChildren:NO]; } @@ -106,16 +95,6 @@ [self.outlineView deselectAll:nil]; } -- (void)setIsVisible:(BOOL)isVisible { - if(_isVisible == isVisible) { - return; // nichts zu tun - } - [[self view] removeConstraints:(isVisible ? self.hideConstraints : self.showConstraints)]; - [[self view] addConstraints:(isVisible ? self.showConstraints : self.hideConstraints)]; - _isVisible = isVisible; -} - - - (NSMenu *)_contextMenu { NSMenu *menu = [[NSMenu alloc] init]; NSArray *items = [(MPAppDelegate *)[NSApp delegate] contextMenuItemsWithItems:MPContextMenuMinimal]; diff --git a/MacPass/MPPasswordInputController.m b/MacPass/MPPasswordInputController.m index 183b6216..9ddebe24 100644 --- a/MacPass/MPPasswordInputController.m +++ b/MacPass/MPPasswordInputController.m @@ -51,10 +51,21 @@ } - (IBAction)_decrypt:(id)sender { - MPDocumentWindowController *windowController = (MPDocumentWindowController *)[[[self view] window] windowController]; + id windowController = [[[self view] window] windowController]; MPDocument *document = [windowController document]; if(document) { - BOOL isOk = [document decryptWithPassword:[self.passwordTextField stringValue] keyFileURL:[self.keyPathControl URL]]; + BOOL isOk = NO; + if(document.isDecrypted) { + // TODO: Fix unlocking to actually test + BOOL noPassword = !document.password && [[self.passwordTextField stringValue] length] == 0; + BOOL passwordOk = [document.password isEqualToString:[self.passwordTextField stringValue]]; + BOOL noKey = document.key == [self.keyPathControl URL]; + BOOL keyOk = [document.key isEqualTo:[self.keyPathControl URL]]; + isOk = (noPassword || passwordOk) && (noKey || keyOk); + } + else { + isOk = [document decryptWithPassword:[self.passwordTextField stringValue] keyFileURL:[self.keyPathControl URL]]; + } if(!isOk) { [self _showError]; } @@ -69,6 +80,7 @@ [self.keyPathControl setURL:nil]; [self.errorInfoTextField setHidden:YES]; [self.errorImageView setHidden:YES]; + } - (void)_showError { diff --git a/MacPass/MPToolbarDelegate.m b/MacPass/MPToolbarDelegate.m index db1f101d..cf147907 100644 --- a/MacPass/MPToolbarDelegate.m +++ b/MacPass/MPToolbarDelegate.m @@ -13,6 +13,7 @@ #import "MPToolbarItem.h" #import "MPActionHelper.h" +NSString *const MPToolbarItemLock = @"TOOLBAR_LOCK"; NSString *const MPToolbarItemAddGroup = @"TOOLBAR_ADD_GROUP"; NSString *const MPToolbarItemAddEntry = @"TOOLBAR_ADD_ENTRY"; NSString *const MPToolbarItemEdit = @"TOOLBAR_EDIT"; @@ -37,7 +38,7 @@ NSString *const MPToolbarItemInspector = @"TOOLBAR_INSPECTOR"; - (id)init { self = [super init]; if (self) { - _toolbarIdentifiers = [@[ MPToolbarItemAddEntry, MPToolbarItemDelete, MPToolbarItemAddGroup, MPToolbarItemAction, NSToolbarFlexibleSpaceItemIdentifier, NSToolbarSpaceItemIdentifier, MPToolbarItemInspector ] retain]; + _toolbarIdentifiers = [@[ MPToolbarItemAddEntry, MPToolbarItemDelete, MPToolbarItemAddGroup, MPToolbarItemAction, NSToolbarFlexibleSpaceItemIdentifier, MPToolbarItemLock ] retain]; _toolbarImages = [[self createToolbarImages] retain]; _toolbarItems = [[NSMutableDictionary alloc] initWithCapacity:[self.toolbarIdentifiers count]]; } @@ -68,7 +69,7 @@ NSString *const MPToolbarItemInspector = @"TOOLBAR_INSPECTOR"; NSRect newFrame = [popupButton frame]; newFrame.size.width += 20; - + NSMenu *menu = [[NSMenu allocWithZone:[NSMenu menuZone]] init]; NSMenuItem *actionImageItem = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:@"" action:NULL keyEquivalent:@""]; [actionImageItem setImage:self.toolbarImages[MPToolbarItemAction]]; @@ -129,7 +130,8 @@ NSString *const MPToolbarItemInspector = @"TOOLBAR_INSPECTOR"; } - (NSDictionary *)createToolbarImages{ - NSDictionary *imageDict = @{ MPToolbarItemAddEntry: [MPIconHelper icon:MPIconPassword], + NSDictionary *imageDict = @{ MPToolbarItemLock: [NSImage imageNamed:NSImageNameLockUnlockedTemplate], + MPToolbarItemAddEntry: [MPIconHelper icon:MPIconPassword], MPToolbarItemAddGroup: [MPIconHelper icon:MPIconPassword], MPToolbarItemDelete: [NSImage imageNamed:NSImageNameRemoveTemplate], MPToolbarItemAction: [NSImage imageNamed:NSImageNameActionTemplate], @@ -139,25 +141,25 @@ NSString *const MPToolbarItemInspector = @"TOOLBAR_INSPECTOR"; } - (NSString *)_localizedLabelForToolbarItemIdentifier:(NSString *)identifier { - NSDictionary *labelDict = @{ - MPToolbarItemAction: NSLocalizedString(@"ACTION", @""), - MPToolbarItemAddEntry: NSLocalizedString(@"ADD_ENTRY", @""), - MPToolbarItemAddGroup: NSLocalizedString(@"ADD_GROUP", @""), - MPToolbarItemDelete: NSLocalizedString(@"DELETE", @""), - MPToolbarItemEdit: NSLocalizedString(@"EDIT", @""), - MPToolbarItemInspector: NSLocalizedString(@"TOGGLE_INSPECTOR", @"") - }; + NSDictionary *labelDict = @{ MPToolbarItemLock: NSLocalizedString(@"LOCK", @""), + MPToolbarItemAction: NSLocalizedString(@"ACTION", @""), + MPToolbarItemAddEntry: NSLocalizedString(@"ADD_ENTRY", @""), + MPToolbarItemAddGroup: NSLocalizedString(@"ADD_GROUP", @""), + MPToolbarItemDelete: NSLocalizedString(@"DELETE", @""), + MPToolbarItemEdit: NSLocalizedString(@"EDIT", @""), + MPToolbarItemInspector: NSLocalizedString(@"TOGGLE_INSPECTOR", @"") + }; return labelDict[identifier]; } - (SEL)_actionForToolbarItemIdentifier:(NSString *)identifier { - NSDictionary *actionDict = @{ - MPToolbarItemAddEntry: @(MPActionAddEntry), - MPToolbarItemAddGroup: @(MPActionAddGroup), - MPToolbarItemDelete: @(MPActionDelete), - MPToolbarItemEdit: @(MPActionEdit), - MPToolbarItemInspector: @(MPActionToggleInspector) - }; + NSDictionary *actionDict = @{ MPToolbarItemLock: @(MPActionLock), + MPToolbarItemAddEntry: @(MPActionAddEntry), + MPToolbarItemAddGroup: @(MPActionAddGroup), + MPToolbarItemDelete: @(MPActionDelete), + MPToolbarItemEdit: @(MPActionEdit), + MPToolbarItemInspector: @(MPActionToggleInspector) + }; MPActionType actionType = (MPActionType)[actionDict[identifier] integerValue]; return [MPActionHelper actionOfType:actionType]; } diff --git a/MacPass/MPToolbarItem.m b/MacPass/MPToolbarItem.m index 91a6529b..c9406fc6 100644 --- a/MacPass/MPToolbarItem.m +++ b/MacPass/MPToolbarItem.m @@ -14,7 +14,9 @@ - (void)validate { if(![self.view menu]) { id target = [NSApp targetForAction:[self action] to:nil from:self]; - [self setEnabled:( nil != target )]; + BOOL isValid = [[[[NSApplication sharedApplication] keyWindow] windowController] validateToolbarItem:self]; + [self setEnabled:( isValid && (nil != target) )]; + } } @end diff --git a/MacPass/MPViewController.m b/MacPass/MPViewController.m index 2d629bb4..2812dc14 100644 --- a/MacPass/MPViewController.m +++ b/MacPass/MPViewController.m @@ -29,8 +29,7 @@ } - (void)updateResponderChain { - if(self.view) { - NSLog(@"Updated responder chain"); + if(self.view && [self.view nextResponder] != self) { NSResponder *nextResponder = [[self view] nextResponder]; [[self view] setNextResponder:self]; [self setNextResponder:nextResponder]; diff --git a/MacPass/MacPass-Info.plist b/MacPass/MacPass-Info.plist index a89e8acb..7c9a4689 100644 --- a/MacPass/MacPass-Info.plist +++ b/MacPass/MacPass-Info.plist @@ -48,7 +48,7 @@ CFBundleSignature ???? CFBundleVersion - 979 + A2F LSMinimumSystemVersion ${MACOSX_DEPLOYMENT_TARGET} NSHumanReadableCopyright diff --git a/MacPass/OutlineView.xib b/MacPass/OutlineView.xib index 338357dd..19bbf340 100644 --- a/MacPass/OutlineView.xib +++ b/MacPass/OutlineView.xib @@ -42,7 +42,7 @@ NSApplication - + 268 @@ -59,6 +59,7 @@ {177, 299} + _NS:13 YES @@ -173,6 +174,7 @@ {177, 299} + _NS:11 @@ -184,6 +186,7 @@ -2147483392 {{224, 17}, {15, 102}} + _NS:15 NO @@ -196,6 +199,7 @@ -2147483392 {{1, 119}, {238, 15}} + _NS:60 NO 1 @@ -206,6 +210,7 @@ {177, 299} + _NS:9 133680 @@ -219,6 +224,8 @@ {177, 299} + + _NS:9 NSView @@ -806,6 +813,8 @@ + + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -874,6 +883,14 @@ + + HNHBadgedTextField + NSTextField + + IBProjectSource + ./Classes/HNHBadgedTextField.h + + HNHBadgedTextFieldCell NSTextFieldCell diff --git a/MacPass/PasswordCreatorView.xib b/MacPass/PasswordCreatorView.xib index 561a8b27..aa5f6d2f 100644 --- a/MacPass/PasswordCreatorView.xib +++ b/MacPass/PasswordCreatorView.xib @@ -2,9 +2,9 @@ 1070 - 12D78 + 12E55 3084 - 1187.37 + 1187.39 626.00 com.apple.InterfaceBuilder.CocoaPlugin @@ -57,7 +57,6 @@ {{18, 19}, {230, 22}} - _NS:9 YES @@ -1494,6 +1493,8 @@ + + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin diff --git a/MacPass/PasswordEditView.xib b/MacPass/PasswordEditView.xib index ee5d1343..cd23cdcc 100644 --- a/MacPass/PasswordEditView.xib +++ b/MacPass/PasswordEditView.xib @@ -225,7 +225,6 @@ {{195, 13}, {88, 32}} - _NS:9 {250, 250} YES @@ -837,6 +836,8 @@ + + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin diff --git a/MacPass/PasswordInputView.xib b/MacPass/PasswordInputView.xib index 9012686e..2cb9bae2 100644 --- a/MacPass/PasswordInputView.xib +++ b/MacPass/PasswordInputView.xib @@ -49,16 +49,15 @@ 268 - {{96, 175}, {184, 17}} + {{125, 175}, {113, 17}} - _NS:1535 YES 68157504 272630784 - Could not decrypt Database! + Wrong password! LucidaGrande 13 @@ -100,7 +99,6 @@ {{157, 200}, {48, 48}} - _NS:9 YES @@ -120,31 +118,6 @@ NO YES - - - 268 - {{127, 50}, {82, 32}} - - - - _NS:9 - YES - - 67108864 - 134217728 - Cancel - - _NS:9 - - -2038284288 - 129 - - Gw - 200 - 25 - - NO - 268 @@ -154,8 +127,7 @@ {{83, 94}, {197, 22}} - - + _NS:9 YES @@ -179,7 +151,6 @@ 268 {{86, 123}, {191, 22}} - _NS:9 YES @@ -217,7 +188,6 @@ 268 {{17, 126}, {64, 17}} - _NS:1535 YES @@ -238,7 +208,6 @@ 268 {{35, 99}, {46, 17}} - _NS:1535 YES @@ -257,16 +226,16 @@ 268 - {{209, 50}, {74, 32}} + {{200, 50}, {83, 32}} - + _NS:9 {250, 250} YES 67108864 134217728 - Open + Unlock _NS:9 @@ -282,7 +251,6 @@ {362, 268} - {751, 750} NSView @@ -385,22 +353,6 @@ 1 - - - 5 - 0 - - 6 - 1 - - 12 - - 1000 - - 6 - 24 - 3 - 3 @@ -449,22 +401,6 @@ 40 3 - - - 11 - 0 - - 11 - 1 - - 0.0 - - 1000 - - 6 - 24 - 2 - 5 @@ -657,21 +593,21 @@ 24 2 - - - 5 - 1 - - 5 + + + 9 + 0 + + 9 1 - - 20 + + 0.0 1000 - 9 - 40 - 3 + 6 + 24 + 2 @@ -705,28 +641,27 @@ 40 3 - - - 6 - 0 - - 6 + + + 5 + 1 + + 5 1 - - 0.0 + + 20 1000 - 6 - 24 - 2 + 9 + 40 + 3 - @@ -883,29 +818,6 @@ - - 257 - - - - - - - - 258 - - - - - 259 - - - - - 260 - - - 262 @@ -984,11 +896,6 @@ - - 287 - - - 288 @@ -1004,17 +911,22 @@ + + 296 + + + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - - + + - + @@ -1027,12 +939,12 @@ - - + + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -1062,11 +974,6 @@ 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 @@ -1081,10 +988,10 @@ 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 com.apple.InterfaceBuilder.CocoaPlugin @@ -1094,7 +1001,7 @@ - 295 + 296 diff --git a/MacPass/WelcomeView.xib b/MacPass/WelcomeView.xib deleted file mode 100644 index bf480fb5..00000000 --- a/MacPass/WelcomeView.xib +++ /dev/null @@ -1,242 +0,0 @@ - - - - 1080 - 12D78 - 3084 - 1187.37 - 626.00 - - com.apple.InterfaceBuilder.CocoaPlugin - 3084 - - - IBNSLayoutConstraint - NSCustomObject - NSCustomView - NSTextField - NSTextFieldCell - - - com.apple.InterfaceBuilder.CocoaPlugin - - - PluginDependencyRecalculationVersion - - - - - MPDocumentWindowController - - - FirstResponder - - - NSApplication - - - - 268 - - - - 268 - {{223, 214}, {152, 29}} - - _NS:1535 - YES - - 68157504 - 272630784 - No Database - - LucidaGrande - 24 - 16 - - _NS:1535 - - - 6 - System - controlColor - - 3 - MC42NjY2NjY2NjY3AA - - - - 6 - System - disabledControlTextColor - - 3 - MC4zMzMzMzMzMzMzAA - - - - NO - - - {597, 456} - - NSView - - - - - - - welcomeView - - - - 12 - - - - welcomeText - - - - 17 - - - - - - 0 - - - - - - -2 - - - File's Owner - - - -1 - - - First Responder - - - -3 - - - Application - - - 1 - - - - - 9 - 0 - - 9 - 1 - - 0.0 - - 1000 - - 5 - 22 - 2 - - - - 10 - 0 - - 10 - 1 - - 0.0 - - 1000 - - 5 - 22 - 2 - - - - - - - 2 - - - - - - - - 3 - - - - - 21 - - - - - 22 - - - - - - - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - - - - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - - 1 - MSAxIDEAA - - - - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - - - - - - 22 - - - - - NSLayoutConstraint - NSObject - - IBProjectSource - ./Classes/NSLayoutConstraint.h - - - - - 0 - IBCocoaFramework - YES - 3 - YES - - diff --git a/MacPass/en.lproj/Localizable.strings b/MacPass/en.lproj/Localizable.strings index 0f3d23a8..3d0fd2fb 100644 Binary files a/MacPass/en.lproj/Localizable.strings and b/MacPass/en.lproj/Localizable.strings differ