From 2e8d35a4324d8a64dc44f1462e4ab134b88b5760 Mon Sep 17 00:00:00 2001 From: michael starke Date: Tue, 26 Feb 2013 12:20:47 +0100 Subject: [PATCH] Enhancement on selection behavior --- MacPass/EntryView.xib | 22 ++++++++++++++++++++-- MacPass/MPEntryViewController.m | 9 ++++++++- MacPass/MPIconHelper.m | 3 +++ MacPass/MPMainWindowController.h | 2 ++ MacPass/MPMainWindowController.m | 4 ++++ MacPass/MPOutlineViewController.h | 3 ++- MacPass/MPOutlineViewController.m | 4 ++-- MacPass/MPOutlineViewDelegate.m | 4 +--- MacPass/MPToolbarDelegate.m | 8 +++++--- MacPass/MacPass-Info.plist | 2 +- 10 files changed, 48 insertions(+), 13 deletions(-) diff --git a/MacPass/EntryView.xib b/MacPass/EntryView.xib index 8d3fa22b..a245ec9e 100644 --- a/MacPass/EntryView.xib +++ b/MacPass/EntryView.xib @@ -102,7 +102,7 @@ 6 System headerColor - + 3 MQA @@ -258,7 +258,20 @@ 3 2 - + + 6 + System + _sourceListBackgroundColor + + 6 + System + alternateSelectedControlColor + + 1 + MCAwIDEAA + + + 6 System @@ -1547,6 +1560,7 @@ NSButton NSButton NSButton + NSView NSLayoutConstraint NSLayoutConstraint @@ -1579,6 +1593,10 @@ filterUsernameButton NSButton + + pathBar + NSView + tableToBottom NSLayoutConstraint diff --git a/MacPass/MPEntryViewController.m b/MacPass/MPEntryViewController.m index 45362cf9..463201dc 100644 --- a/MacPass/MPEntryViewController.m +++ b/MacPass/MPEntryViewController.m @@ -11,6 +11,7 @@ #import "MPDatabaseController.h" #import "MPDatabaseDocument.h" #import "MPIconHelper.h" +#import "MPMainWindowController.h" #import "KdbGroup+MPAdditions.h" #import @@ -151,12 +152,13 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername"; NSTableCellView *view = nil; if(isTitleColumn || isGroupColumn) { view = [tableView makeViewWithIdentifier:_MPTableImageCellView owner:self]; - [[view imageView] setImage:[MPIconHelper randomIcon]]; if( isTitleColumn ) { [[view textField] setStringValue:entry.title]; + [[view imageView] setImage:[MPIconHelper icon:(MPIconType)entry.image]]; } else { [[view textField] setStringValue:entry.parent.name]; + [[view imageView] setImage:[MPIconHelper icon:(MPIconType)entry.parent.image]]; } } else if( isPasswordColum ) { @@ -207,6 +209,10 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername"; } } +- (void)deselectAll:(id)sender { + [self.entryTable deselectAll:self]; +} + - (void)clearFilter { self.filter = nil; [[self.entryTable tableColumnWithIdentifier:MPEntryTableParentColumnIdentifier] setHidden:YES]; @@ -287,6 +293,7 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername"; return; // nothign to to } + [((MPMainWindowController *)[[self.view window] windowController]) clearOutlineSelection:nil]; self.isStatusBarVisible = YES; self.tableToTop.constant = [self.filterBar frame].size.height; diff --git a/MacPass/MPIconHelper.m b/MacPass/MPIconHelper.m index 2399833b..253247ab 100644 --- a/MacPass/MPIconHelper.m +++ b/MacPass/MPIconHelper.m @@ -12,6 +12,9 @@ + (NSImage *)icon:(MPIconType)type { NSDictionary *icons = [MPIconHelper availableIcons]; + if(type >= [icons count]) { + return [NSImage imageNamed:NSImageNameActionTemplate]; + } NSString *imageName = icons[@(type)]; return [[NSBundle mainBundle] imageForResource:imageName]; } diff --git a/MacPass/MPMainWindowController.h b/MacPass/MPMainWindowController.h index 871c6f05..46e7f7d6 100644 --- a/MacPass/MPMainWindowController.h +++ b/MacPass/MPMainWindowController.h @@ -15,6 +15,8 @@ - (void)showEntries; - (void)showMainWindow:(id)sender; - (void)performFindPanelAction:(id)sender; +- (void)clearOutlineSelection:(id)sender; + /* Sets the content View controller @param viewController - use nil to reset to welcome screen diff --git a/MacPass/MPMainWindowController.m b/MacPass/MPMainWindowController.m index 6bc2cd49..a175c622 100644 --- a/MacPass/MPMainWindowController.m +++ b/MacPass/MPMainWindowController.m @@ -192,6 +192,10 @@ [self.entryViewController clearFilter]; } +- (void)clearOutlineSelection:(id)sender { + [self.outlineViewController clearSelection]; +} + - (NSSearchField *)locateToolbarSearchField { for(NSToolbarItem *toolbarItem in [[self.window toolbar] items]) { NSView *view = [toolbarItem view]; diff --git a/MacPass/MPOutlineViewController.h b/MacPass/MPOutlineViewController.h index 09391e1f..259d2e6b 100644 --- a/MacPass/MPOutlineViewController.h +++ b/MacPass/MPOutlineViewController.h @@ -11,6 +11,7 @@ @interface MPOutlineViewController : MPViewController @property (retain, readonly) NSMenu *menu; -- (void)deselectAll; + +- (void)clearSelection; @end diff --git a/MacPass/MPOutlineViewController.m b/MacPass/MPOutlineViewController.m index 453d5e6e..979548e7 100644 --- a/MacPass/MPOutlineViewController.m +++ b/MacPass/MPOutlineViewController.m @@ -73,8 +73,8 @@ } } -- (void)deselectAll { - [self.outlineView deselectAll:self]; +- (void)clearSelection { + [self.outlineView deselectAll:nil]; } - (void)setupMenu { diff --git a/MacPass/MPOutlineViewDelegate.m b/MacPass/MPOutlineViewDelegate.m index 40167c5a..4ff19d26 100644 --- a/MacPass/MPOutlineViewDelegate.m +++ b/MacPass/MPOutlineViewDelegate.m @@ -32,9 +32,7 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell"; } else { view = [outlineView makeViewWithIdentifier:_MPOutlineViewDataViewIdentifier owner:self]; - NSDictionary *availableIcons = [MPIconHelper availableIcons]; - NSInteger randomIndex = rand() % [availableIcons count]; - NSImage *icon = [MPIconHelper icon:(MPIconType)randomIndex]; + NSImage *icon = [MPIconHelper icon:(MPIconType)[group image]]; [view.imageView setImage:icon]; [view.textField setStringValue:[group name]]; diff --git a/MacPass/MPToolbarDelegate.m b/MacPass/MPToolbarDelegate.m index 1f283cc6..72116fad 100644 --- a/MacPass/MPToolbarDelegate.m +++ b/MacPass/MPToolbarDelegate.m @@ -85,9 +85,7 @@ NSString *const MPToolbarItemSearch = @"Search"; Cleanup */ [menuItem release]; - [menu release]; - - + [menu release]; [item setView:popupButton]; [popupButton release]; } @@ -101,6 +99,10 @@ NSString *const MPToolbarItemSearch = @"Search"; [button setImage:image]; [button setImagePosition:NSImageOnly]; [button sizeToFit]; + if([itemIdentifier isEqualToString:MPToolbarItemDelete]) { + [button setTarget:nil]; + [button setAction:@selector(clearOutlineSelection:)]; + } NSRect fittingRect = [button frame]; fittingRect.size.width = MAX( (CGFloat)32.0,fittingRect.size.width); diff --git a/MacPass/MacPass-Info.plist b/MacPass/MacPass-Info.plist index ef836337..58697cb0 100644 --- a/MacPass/MacPass-Info.plist +++ b/MacPass/MacPass-Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 304 + 310 LSMinimumSystemVersion ${MACOSX_DEPLOYMENT_TARGET} NSHumanReadableCopyright