diff --git a/MacPass.xcodeproj/project.pbxproj b/MacPass.xcodeproj/project.pbxproj index c09248bd..f4b3eac0 100644 --- a/MacPass.xcodeproj/project.pbxproj +++ b/MacPass.xcodeproj/project.pbxproj @@ -168,6 +168,7 @@ 4C67D33017981A2B00A7BDFC /* HNHTokenField.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C67D32F17981A2B00A7BDFC /* HNHTokenField.m */; }; 4C67D33317981ABA00A7BDFC /* HNHTokenFieldCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C67D33217981ABA00A7BDFC /* HNHTokenFieldCell.m */; }; 4C69A73A16D589DF00EC1B1A /* HNHGradientView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C69A73916D589DF00EC1B1A /* HNHGradientView.m */; }; + 4C6BEA3117A88E6C00CF69A8 /* MPStripLineBreaksTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C6BEA3017A88E6C00CF69A8 /* MPStripLineBreaksTransformer.m */; }; 4C6D1D25178579570014C5A5 /* 48_FolderTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4C6D1D24178579570014C5A5 /* 48_FolderTemplate.pdf */; }; 4C6D1D27178586CA0014C5A5 /* 99_AddFolderTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4C6D1D26178586CA0014C5A5 /* 99_AddFolderTemplate.pdf */; }; 4C6D1D2B17858A250014C5A5 /* MacPass.icns in Resources */ = {isa = PBXBuildFile; fileRef = 4C6D1D2A17858A250014C5A5 /* MacPass.icns */; }; @@ -577,6 +578,8 @@ 4C67D33217981ABA00A7BDFC /* HNHTokenFieldCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HNHTokenFieldCell.m; sourceTree = ""; }; 4C69A73816D589DF00EC1B1A /* HNHGradientView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HNHGradientView.h; sourceTree = ""; }; 4C69A73916D589DF00EC1B1A /* HNHGradientView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HNHGradientView.m; sourceTree = ""; }; + 4C6BEA2F17A88E6C00CF69A8 /* MPStripLineBreaksTransformer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPStripLineBreaksTransformer.h; sourceTree = ""; }; + 4C6BEA3017A88E6C00CF69A8 /* MPStripLineBreaksTransformer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPStripLineBreaksTransformer.m; sourceTree = ""; }; 4C6D1D24178579570014C5A5 /* 48_FolderTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = 48_FolderTemplate.pdf; sourceTree = ""; }; 4C6D1D26178586CA0014C5A5 /* 99_AddFolderTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = 99_AddFolderTemplate.pdf; sourceTree = ""; }; 4C6D1D2A17858A250014C5A5 /* MacPass.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = MacPass.icns; path = "../Assets/App icon/MacPass.icns"; sourceTree = ""; }; @@ -1082,6 +1085,8 @@ 4C5BF67A175C01F300D53DF7 /* MPUppercaseStringValueTransformer.m */, 4CF6C70F176F4533007A811D /* MPStringLengthValueTransformer.h */, 4CF6C710176F4533007A811D /* MPStringLengthValueTransformer.m */, + 4C6BEA2F17A88E6C00CF69A8 /* MPStripLineBreaksTransformer.h */, + 4C6BEA3017A88E6C00CF69A8 /* MPStripLineBreaksTransformer.m */, 4C888C9516EB754B003D34A1 /* MPActionHelper.h */, 4C888C9616EB754B003D34A1 /* MPActionHelper.m */, 4C2E382116D1421B00037A9D /* MPIconHelper.h */, @@ -2060,6 +2065,7 @@ 4CD7223B17A7CB0700F5A1E1 /* MPWorkflowSettingsController.m in Sources */, 4C2671AD17A7D8FC00F3A645 /* HNHColorWell.m in Sources */, 4CA08DA017A831B200A6544B /* MPAddEntryContextMenuDelegate.m in Sources */, + 4C6BEA3117A88E6C00CF69A8 /* MPStripLineBreaksTransformer.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/MacPass/EntryView.xib b/MacPass/EntryView.xib index cd7e680c..165c0c8f 100644 --- a/MacPass/EntryView.xib +++ b/MacPass/EntryView.xib @@ -45,7 +45,7 @@ NSApplication - + 268 @@ -55,8 +55,10 @@ 268 + {{7, 5}, {32, 19}} + _NS:9 YES @@ -86,6 +88,7 @@ {694, 30} + _NS:9 HNHGradientView @@ -104,6 +107,7 @@ {694, 548} + _NS:13 YES @@ -114,6 +118,7 @@ 256 {694, 17} + @@ -143,7 +148,7 @@ 6 System headerColor - + 3 MQA @@ -299,10 +304,7 @@ 3 2 - - 1 - MSAxIDEAA - + 6 System @@ -326,17 +328,19 @@ {{0, 17}, {694, 548}} + _NS:11 - 6 + 4 -2147483392 {{224, 17}, {15, 102}} + _NS:58 NO @@ -349,6 +353,7 @@ -2147483392 {{0, 310}, {480, 16}} + _NS:60 NO @@ -365,6 +370,7 @@ {694, 17} + @@ -373,6 +379,7 @@ {{0, 30}, {694, 565}} + _NS:9 133680 @@ -387,6 +394,8 @@ {694, 594} + + _NS:9 NSView @@ -1729,7 +1738,7 @@ - 844 + 867 @@ -1756,7 +1765,7 @@ NSButton NSButton NSButton - NSLayoutConstraint + NSLayoutConstraint HNHGradientView @@ -1804,8 +1813,8 @@ filterUsernameButton NSButton - - tableToTop + + tableToTopConstraint NSLayoutConstraint diff --git a/MacPass/IconSelection.xib b/MacPass/IconSelection.xib index b2d06fcf..bf86973c 100644 --- a/MacPass/IconSelection.xib +++ b/MacPass/IconSelection.xib @@ -45,9 +45,10 @@ 268 - {{182, 18}, {118, 25}} + {{262, 18}, {118, 25}} + _NS:22 YES @@ -81,7 +82,7 @@ 4370 - {300, 250} + {380, 280} @@ -105,7 +106,7 @@ 0 - {300, 250} + {380, 280} @@ -151,7 +152,7 @@ 0.63157892227172852 - {{10, 50}, {300, 250}} + {{10, 50}, {380, 280}} @@ -165,7 +166,7 @@ 1 - {320, 310} + {400, 340} @@ -179,9 +180,10 @@ 268 - {{9, 9}, {32, 32}} + {{4, 4}, {32, 32}} + _NS:9 YES @@ -205,7 +207,7 @@ NO - {50, 50} + {40, 40} @@ -562,22 +564,22 @@ - 148 + 161 - 149 + 162 - 150 + 168 - 151 + 169 @@ -617,10 +619,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 HNHScrollView com.apple.InterfaceBuilder.CocoaPlugin @@ -635,7 +637,7 @@ - 151 + 169 @@ -688,6 +690,27 @@ ./Classes/MPViewController.h + + NSCollectionViewItem + + NSImageView + NSTextField + + + + imageView + NSImageView + + + textField + NSTextField + + + + IBProjectSource + ./Classes/NSCollectionViewItem.h + + NSLayoutConstraint NSObject diff --git a/MacPass/KdbEntry+Undo.h b/MacPass/KdbEntry+Undo.h index 5c80cb13..fa93440f 100644 --- a/MacPass/KdbEntry+Undo.h +++ b/MacPass/KdbEntry+Undo.h @@ -8,13 +8,6 @@ #import "Kdb.h" -APPKIT_EXTERN NSString *const MPEntryTitleUndoableKey; -APPKIT_EXTERN NSString *const MPEntryUsernameUndoableKey; -APPKIT_EXTERN NSString *const MPEntryPasswordUndoableKey; -APPKIT_EXTERN NSString *const MPEntryUrlUndoableKey; -APPKIT_EXTERN NSString *const MPEntryNotesUndoableKey; - - @interface KdbEntry (Undo) - (NSString *)titleUndoable; diff --git a/MacPass/KdbEntry+Undo.m b/MacPass/KdbEntry+Undo.m index aa79da7e..213168c4 100644 --- a/MacPass/KdbEntry+Undo.m +++ b/MacPass/KdbEntry+Undo.m @@ -11,12 +11,6 @@ #import "KdbGroup+KVOAdditions.h" #import "KdbGroup+MPTreeTools.h" -NSString *const MPEntryTitleUndoableKey = @"titleUndoable"; -NSString *const MPEntryUsernameUndoableKey = @"usernameUndoable"; -NSString *const MPEntryPasswordUndoableKey = @"passwordUndoable"; -NSString *const MPEntryUrlUndoableKey = @"urlUndoable"; -NSString *const MPEntryNotesUndoableKey = @"notesUndoable"; - #ifndef MPSetActionName #define MPSetActionName(key, comment) \ if(![[self undoManager] isUndoing]) {\ diff --git a/MacPass/MPAppDelegate.m b/MacPass/MPAppDelegate.m index 6e26abc4..d7ed4113 100644 --- a/MacPass/MPAppDelegate.m +++ b/MacPass/MPAppDelegate.m @@ -13,6 +13,7 @@ #import "MPSettingsHelper.h" #import "MPUppercaseStringValueTransformer.h" #import "MPStringLengthValueTransformer.h" +#import "MPStripLineBreaksTransformer.h" #import "MPServerDaemon.h" #import "MPLockDaemon.h" #import "MPDocumentWindowController.h" @@ -37,6 +38,7 @@ [MPSettingsHelper setupDefaults]; [MPUppercaseStringValueTransformer registerTransformer]; [MPStringLengthValueTransformer registerTransformer]; + [MPStripLineBreaksTransformer registerTransformer]; } - (void)dealloc { diff --git a/MacPass/MPDocument.m b/MacPass/MPDocument.m index befec16f..d84b7627 100644 --- a/MacPass/MPDocument.m +++ b/MacPass/MPDocument.m @@ -99,6 +99,7 @@ typedef NS_ENUM(NSUInteger, MPAlertType) { _readOnly = NO; _rootAdapter = [[MPRootAdapter alloc] init]; _version = version; + [[self undoManager] setLevelsOfUndo:10]; switch(_version) { case MPDatabaseVersion3: self.tree = [Kdb3Tree templateTree]; @@ -195,10 +196,10 @@ typedef NS_ENUM(NSUInteger, MPAlertType) { #pragma mark Lock/Unlock/Decrypt - (BOOL)unlockWithPassword:(NSString *)password keyFileURL:(NSURL *)keyFileURL { -// KPKPassword *pwd = [[KPKPassword alloc] initWithPassword:password key:nil]; -// -// KPKTreeCryptor *cryptor = [KPKTreeCryptor treeCryptorWithData:_fileData password:pwd]; -// KPKTree *tree = [cryptor decryptTree:NULL]; + // KPKPassword *pwd = [[KPKPassword alloc] initWithPassword:password key:nil]; + // + // KPKTreeCryptor *cryptor = [KPKTreeCryptor treeCryptorWithData:_fileData password:pwd]; + // KPKTree *tree = [cryptor decryptTree:NULL]; self.key = keyFileURL; self.password = [password length] > 0 ? password : nil; diff --git a/MacPass/MPDocumentWindowDelegate.m b/MacPass/MPDocumentWindowDelegate.m index c8fb53a7..fcf7deda 100644 --- a/MacPass/MPDocumentWindowDelegate.m +++ b/MacPass/MPDocumentWindowDelegate.m @@ -24,7 +24,7 @@ NSArray *classArray = [NSArray arrayWithObject:[NSURL class]]; NSArray *arrayOfURLs = [draggingPasteBoard readObjectsForClasses:classArray options:nil]; - BOOL ok; + BOOL ok = NO; for(NSURL *url in arrayOfURLs) { if([url isFileURL] || [url isFileReferenceURL]) { continue; diff --git a/MacPass/MPEntryContextMenuDelegate.h b/MacPass/MPEntryContextMenuDelegate.h index 5a16c1e9..a05434a3 100644 --- a/MacPass/MPEntryContextMenuDelegate.h +++ b/MacPass/MPEntryContextMenuDelegate.h @@ -7,10 +7,7 @@ // #import -@class MPEntryViewController; @interface MPEntryContextMenuDelegate : NSObject -@property (weak) MPEntryViewController *viewController; - @end diff --git a/MacPass/MPEntryContextMenuDelegate.m b/MacPass/MPEntryContextMenuDelegate.m index f6aa05ed..ba0bd801 100644 --- a/MacPass/MPEntryContextMenuDelegate.m +++ b/MacPass/MPEntryContextMenuDelegate.m @@ -7,7 +7,7 @@ // #import "MPEntryContextMenuDelegate.h" -#import "MPEntryViewController.h" +#import "MPDocument.h" #import "Kdb4Node.h" @@ -30,9 +30,9 @@ static NSUInteger const kMPAttachmentsMenuItem = 2000; if([lastItem isSeparatorItem]) { [menu removeItem:lastItem]; } - - if([self.viewController.selectedEntry isKindOfClass:[Kdb4Entry class]]) { - Kdb4Entry *entry = (Kdb4Entry *)self.viewController.selectedEntry; + MPDocument *document = [[NSDocumentController sharedDocumentController] currentDocument]; + if([document.selectedEntry isKindOfClass:[Kdb4Entry class]]) { + Kdb4Entry *entry = (Kdb4Entry *)document.selectedEntry; if([entry.stringFields count] > 0) { [menu addItem:[NSMenuItem separatorItem]]; NSMenuItem *customFieldsItem = [[NSMenuItem alloc] init]; diff --git a/MacPass/MPEntryViewController.m b/MacPass/MPEntryViewController.m index 316be541..ec266956 100644 --- a/MacPass/MPEntryViewController.m +++ b/MacPass/MPEntryViewController.m @@ -21,6 +21,7 @@ #import "MPConstants.h" #import "MPEntryTableDataSource.h" #import "MPStringLengthValueTransformer.h" +#import "MPStripLineBreaksTransformer.h" #import "MPEntryContextMenuDelegate.h" #import "HNHTableHeaderCell.h" @@ -54,6 +55,8 @@ NSString *const MPEntryTableTitleColumnIdentifier = @"MPTitleColumnIdentifier"; NSString *const MPEntryTablePasswordColumnIdentifier = @"MPPasswordColumnIdentifier"; NSString *const MPEntryTableParentColumnIdentifier = @"MPParentColumnIdentifier"; NSString *const MPEntryTableURLColumnIdentifier = @"MPEntryTableURLColumnIdentifier"; +NSString *const MPEntryTableNotesColumnIdentifier = @"MPEntryTableNotesColumnIdentifier"; +NSString *const MPEntryTableAttachmentColumnIdentifier = @"MPEntryTableAttachmentColumnIdentifier"; NSString *const _MPTableImageCellView = @"ImageCell"; NSString *const _MPTableStringCellView = @"StringCell"; @@ -113,9 +116,7 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername"; _entryArrayController = [[NSArrayController alloc] init]; _dataSource = [[MPEntryTableDataSource alloc] init]; _dataSource.viewController = self; - _menuDelegate = [[MPEntryContextMenuDelegate alloc] init]; - _menuDelegate.viewController = self; - + _menuDelegate = [[MPEntryContextMenuDelegate alloc] init]; _selectedEntry = nil; } return self; @@ -127,7 +128,7 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername"; } - (void)didLoadView { - [self.view setWantsLayer:YES]; + [[self view] setWantsLayer:YES]; [self _hideFilterBarAnimated]; [_bottomBar setBorderType:HNHBorderTop]; @@ -150,7 +151,10 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername"; NSTableColumn *userNameColumn = [self.entryTable tableColumns][2]; NSTableColumn *passwordColumn = [self.entryTable tableColumns][3]; NSTableColumn *urlColumn = [self.entryTable tableColumns][4]; - + NSTableColumn *attachmentsColumn = [[NSTableColumn alloc] initWithIdentifier:MPEntryTableAttachmentColumnIdentifier]; + NSTableColumn *notesColumn = [[NSTableColumn alloc] initWithIdentifier:MPEntryTableNotesColumnIdentifier]; + [self.entryTable addTableColumn:notesColumn]; + [self.entryTable addTableColumn:attachmentsColumn]; [parentColumn setIdentifier:MPEntryTableParentColumnIdentifier]; [titleColumn setIdentifier:MPEntryTableTitleColumnIdentifier]; @@ -169,16 +173,19 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername"; [userNameColumn setSortDescriptorPrototype:userNameSortDescriptor]; [urlColumn setSortDescriptorPrototype:urlSortDescriptor]; - [[parentColumn headerCell] setStringValue:@"Group"]; - [[titleColumn headerCell] setStringValue:@"Title"]; - [[userNameColumn headerCell] setStringValue:@"Username"]; - [[passwordColumn headerCell] setStringValue:@"Password"]; - [[urlColumn headerCell] setStringValue:@"URL"]; + [[parentColumn headerCell] setStringValue:NSLocalizedString(@"GROUP", "")]; + [[titleColumn headerCell] setStringValue:NSLocalizedString(@"TITLE", "")]; + [[userNameColumn headerCell] setStringValue:NSLocalizedString(@"USERNAME", "")]; + [[passwordColumn headerCell] setStringValue:NSLocalizedString(@"PASSWORD", "")]; + [[urlColumn headerCell] setStringValue:NSLocalizedString(@"URL", "")]; + [[notesColumn headerCell] setStringValue:NSLocalizedString(@"NOTES", "")]; + [[attachmentsColumn headerCell] setStringValue:NSLocalizedString(@"ATTACHMENTS", "")]; [self.entryTable bind:NSContentBinding toObject:self.entryArrayController withKeyPath:@"arrangedObjects" options:nil]; [self.entryTable bind:NSSortDescriptorsBinding toObject:self.entryArrayController withKeyPath:@"sortDescriptors" options:nil]; [self.entryTable setDataSource:_dataSource]; + [self _setupHeaderMenu]; [parentColumn setHidden:YES]; } @@ -195,18 +202,19 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername"; - (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { KdbEntry *entry = [self.entryArrayController arrangedObjects][row]; - - const BOOL isTitleColumn = [[tableColumn identifier] isEqualToString:MPEntryTableTitleColumnIdentifier]; - const BOOL isGroupColumn = [[tableColumn identifier] isEqualToString:MPEntryTableParentColumnIdentifier]; - const BOOL isPasswordColum = [[tableColumn identifier] isEqualToString:MPEntryTablePasswordColumnIdentifier]; - const BOOL isUsernameColumn = [[tableColumn identifier] isEqualToString:MPEntryTableUserNameColumnIdentifier]; - const BOOL isURLColumn = [[tableColumn identifier] isEqualToString:MPEntryTableURLColumnIdentifier]; + BOOL isTitleColumn = [[tableColumn identifier] isEqualToString:MPEntryTableTitleColumnIdentifier]; + BOOL isGroupColumn = [[tableColumn identifier] isEqualToString:MPEntryTableParentColumnIdentifier]; + BOOL isPasswordColum = [[tableColumn identifier] isEqualToString:MPEntryTablePasswordColumnIdentifier]; + BOOL isUsernameColumn = [[tableColumn identifier] isEqualToString:MPEntryTableUserNameColumnIdentifier]; + BOOL isURLColumn = [[tableColumn identifier] isEqualToString:MPEntryTableURLColumnIdentifier]; + BOOL isAttachmentColumn = [[tableColumn identifier] isEqualToString:MPEntryTableAttachmentColumnIdentifier]; + BOOL isNotesColumn = [[tableColumn identifier] isEqualToString:MPEntryTableNotesColumnIdentifier]; NSTableCellView *view = nil; if(isTitleColumn || isGroupColumn) { view = [tableView makeViewWithIdentifier:_MPTableImageCellView owner:self]; if( isTitleColumn ) { - [[view textField] bind:NSValueBinding toObject:entry withKeyPath:MPEntryTitleUndoableKey options:nil]; + [[view textField] bind:NSValueBinding toObject:entry withKeyPath:@"titleUndoable" options:nil]; [[view imageView] setImage:[MPIconHelper icon:(MPIconType)entry.image]]; } else { @@ -218,17 +226,23 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername"; else if( isPasswordColum ) { view = [tableView makeViewWithIdentifier:_MPTAbleSecurCellView owner:self]; NSDictionary *options = @{ NSValueTransformerBindingOption : [NSValueTransformer valueTransformerForName:MPStringLengthValueTransformerName] }; - [[view textField] bind:NSValueBinding toObject:entry withKeyPath:MPEntryPasswordUndoableKey options:options]; + [[view textField] bind:NSValueBinding toObject:entry withKeyPath:@"passwordUndoable" options:options]; } - else if( isUsernameColumn || isURLColumn ) { + else { view = [tableView makeViewWithIdentifier:_MPTableStringCellView owner:self]; if(isURLColumn) { - [[view textField] bind:NSValueBinding toObject:entry withKeyPath:MPEntryUrlUndoableKey options:nil]; - //[[view textField] setStringValue:entry.url]; + [[view textField] bind:NSValueBinding toObject:entry withKeyPath:@"urlUndoable" options:nil]; } - else { - [[view textField] bind:NSValueBinding toObject:entry withKeyPath:MPEntryUsernameUndoableKey options:nil]; - //[[view textField] setStringValue:entry.username]; + else if( isUsernameColumn) { + [[view textField] bind:NSValueBinding toObject:entry withKeyPath:@"usernameUndoable" options:nil]; + } + else if( isNotesColumn ) { + NSDictionary *options = @{ NSValueTransformerNameBindingOption : MPStripLineBreaksTransformerName }; + [[view textField] bind:NSValueBinding toObject:entry withKeyPath:@"notesUndoable" options:options]; + } + else if( isAttachmentColumn ) { + [[view textField] setStringValue:@""]; + //[[view textField] bind:NSValueBinding toObject:entry withKeyPath:@"countOfBinaries" options:nil]; } } @@ -412,7 +426,6 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername"; multiplier:1 constant:0]; [[self view] addConstraint:self.filterbarTopConstraint]; - [NSAnimationContext runAnimationGroup:^(NSAnimationContext* context) { context.duration = STATUS_BAR_ANIMATION_TIME; context.allowsImplicitAnimation = YES; @@ -424,7 +437,6 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername"; } - (void)_hideFilterBarAnimated { - if(![self _showsFilterBar]) { return; // nothing to do; } @@ -522,7 +534,7 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername"; self.trashBar.inactiveGradient = [[NSGradient alloc] initWithColors:inactiveColors]; } -#pragma mark EntryMenu +#pragma mark ContextMenu - (void)_setupEntryMenu { @@ -533,9 +545,36 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername"; } [menu setDelegate:_menuDelegate]; [self.entryTable setMenu:menu]; - } +- (void)_setupHeaderMenu { + NSMenu *headerMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] init]; + + [headerMenu addItemWithTitle:NSLocalizedString(@"TITLE", "") action:NULL keyEquivalent:@""]; + [headerMenu addItemWithTitle:NSLocalizedString(@"USERNAME", "") action:NULL keyEquivalent:@""]; + [headerMenu addItemWithTitle:NSLocalizedString(@"PASSWORD", "") action:NULL keyEquivalent:@""]; + [headerMenu addItemWithTitle:NSLocalizedString(@"URL", "") action:NULL keyEquivalent:@""]; + [headerMenu addItemWithTitle:NSLocalizedString(@"NOTES", "") action:NULL keyEquivalent:@""]; + [headerMenu addItemWithTitle:NSLocalizedString(@"ATTACHMENTS", "") action:NULL keyEquivalent:@""]; + + NSArray *identifier = @[ MPEntryTableTitleColumnIdentifier, + MPEntryTableUserNameColumnIdentifier, + MPEntryTablePasswordColumnIdentifier, + MPEntryTableURLColumnIdentifier, + MPEntryTableNotesColumnIdentifier, + MPEntryTableAttachmentColumnIdentifier ]; + + NSDictionary *options = @{ NSValueTransformerNameBindingOption : NSNegateBooleanTransformerName }; + for(NSMenuItem *item in [headerMenu itemArray]) { + NSUInteger index = [headerMenu indexOfItem:item]; + NSTableColumn *column= [self.entryTable tableColumnWithIdentifier:identifier[index]]; + [item bind:NSValueBinding toObject:column withKeyPath:@"hidden" options:options]; + } + + [[self.entryTable headerView] setMenu:headerMenu]; +} + + #pragma makr Action Helper - (KdbEntry *)_clickedOrSelectedEntry { @@ -598,6 +637,10 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername"; [document deleteEntry:entry]; } +//- (void)toggleHeader:(id)sender { +// // +//} + #pragma mark Validation - (BOOL)validateMenuItem:(NSMenuItem *)menuItem { return YES; @@ -643,6 +686,7 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername"; else [self copyURL:nil]; } + // TODO: Add more actions for new columns } - (void)setFilterMode:(MPFilterModeType)newFilterMode { diff --git a/MacPass/MPStripLineBreaksTransformer.h b/MacPass/MPStripLineBreaksTransformer.h new file mode 100644 index 00000000..75c983cd --- /dev/null +++ b/MacPass/MPStripLineBreaksTransformer.h @@ -0,0 +1,17 @@ +// +// MPStripLineBreaksTransformer.h +// MacPass +// +// Created by Michael Starke on 31.07.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import + +FOUNDATION_EXPORT NSString *const MPStripLineBreaksTransformerName; + +@interface MPStripLineBreaksTransformer : NSValueTransformer + ++ (void)registerTransformer; + +@end diff --git a/MacPass/MPStripLineBreaksTransformer.m b/MacPass/MPStripLineBreaksTransformer.m new file mode 100644 index 00000000..26c96305 --- /dev/null +++ b/MacPass/MPStripLineBreaksTransformer.m @@ -0,0 +1,37 @@ +// +// MPStripLineBreaksTransformer.m +// MacPass +// +// Created by Michael Starke on 31.07.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import "MPStripLineBreaksTransformer.h" + +NSString *const MPStripLineBreaksTransformerName = @"com.hicknhack.macpass.MPStripLineBreaksTransformerName"; + +@implementation MPStripLineBreaksTransformer + ++ (Class)transformedValueClass { + return [NSString class]; +} + ++ (BOOL)allowsReverseTransformation { + return NO; +} + ++ (void)registerTransformer { + MPStripLineBreaksTransformer *transformer = [[MPStripLineBreaksTransformer alloc] init]; + [NSValueTransformer setValueTransformer:transformer + forName:MPStripLineBreaksTransformerName]; +} + +- (id)transformedValue:(id)value { + if(![value isKindOfClass:[NSString class]]) { + return nil; + } + NSArray *elements = [value componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]]; + return [elements componentsJoinedByString:@" "]; +} + +@end diff --git a/MacPass/MacPass-Info.plist b/MacPass/MacPass-Info.plist index 71d05b9a..4dfa2d40 100644 --- a/MacPass/MacPass-Info.plist +++ b/MacPass/MacPass-Info.plist @@ -48,7 +48,7 @@ CFBundleSignature ???? CFBundleVersion - 2525 + 2527 LSMinimumSystemVersion ${MACOSX_DEPLOYMENT_TARGET} NSHumanReadableCopyright diff --git a/MacPass/de.lproj/Localizable.strings b/MacPass/de.lproj/Localizable.strings index f3690182..2fb634ba 100644 Binary files a/MacPass/de.lproj/Localizable.strings and b/MacPass/de.lproj/Localizable.strings differ diff --git a/MacPass/en.lproj/Localizable.strings b/MacPass/en.lproj/Localizable.strings index 08d3ba1f..2e72c31c 100644 Binary files a/MacPass/en.lproj/Localizable.strings and b/MacPass/en.lproj/Localizable.strings differ