diff --git a/Cartfile b/Cartfile index df2a98a8..eaaaee28 100644 --- a/Cartfile +++ b/Cartfile @@ -1,3 +1,3 @@ github "sparkle-project/Sparkle" ~> 1.18.1 -github "MacPass/KeePassKit" ~> 1.13.9 -github "mstarke/HNHUi" ~> 2.0 +github "MacPass/KeePassKit" ~> 1.13.10 +github "mstarke/HNHUi" ~> 3.0 diff --git a/Cartfile.resolved b/Cartfile.resolved index 3752b292..46a0eef5 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,4 +1,4 @@ -github "MacPass/KeePassKit" "1.13.9" -github "mstarke/HNHUi" "2.0.1" +github "MacPass/KeePassKit" "1.13.10" +github "mstarke/HNHUi" "3.0" github "robbiehanson/KissXML" "5.2.3" github "sparkle-project/Sparkle" "1.20.0" diff --git a/MacPass.xcodeproj/project.pbxproj b/MacPass.xcodeproj/project.pbxproj index b806e3f8..b4c77e95 100644 --- a/MacPass.xcodeproj/project.pbxproj +++ b/MacPass.xcodeproj/project.pbxproj @@ -49,6 +49,7 @@ 4C2F17A21FD69BCA0097418D /* MPUserNotificationCenterDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C2F17A11FD69BCA0097418D /* MPUserNotificationCenterDelegate.m */; }; 4C32B0E71A1D4436007E12F1 /* KPKFormat+MPUTIDetection.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C32B0E61A1D4436007E12F1 /* KPKFormat+MPUTIDetection.m */; }; 4C3666411787327E00B249F1 /* MPDocument+Attachments.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C3666401787327E00B249F1 /* MPDocument+Attachments.m */; }; + 4C370EFE215B76CB00703AAE /* MPOutlineTableCellView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C370EFD215B76CB00703AAE /* MPOutlineTableCellView.m */; }; 4C37A84015B8B474005EF8EE /* MPOutlineDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C37A83F15B8B474005EF8EE /* MPOutlineDataSource.m */; }; 4C3826721AD04B51007D7D67 /* addFolderTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4C3826711AD04B51007D7D67 /* addFolderTemplate.pdf */; }; 4C3826741AD04BA5007D7D67 /* infoTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4C3826731AD04BA5007D7D67 /* infoTemplate.pdf */; }; @@ -392,6 +393,8 @@ 4C32B0E51A1D4436007E12F1 /* KPKFormat+MPUTIDetection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "KPKFormat+MPUTIDetection.h"; sourceTree = ""; }; 4C32B0E61A1D4436007E12F1 /* KPKFormat+MPUTIDetection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "KPKFormat+MPUTIDetection.m"; sourceTree = ""; }; 4C3666401787327E00B249F1 /* MPDocument+Attachments.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "MPDocument+Attachments.m"; sourceTree = ""; }; + 4C370EFC215B76CB00703AAE /* MPOutlineTableCellView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MPOutlineTableCellView.h; sourceTree = ""; }; + 4C370EFD215B76CB00703AAE /* MPOutlineTableCellView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MPOutlineTableCellView.m; sourceTree = ""; }; 4C37A83E15B8B474005EF8EE /* MPOutlineDataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPOutlineDataSource.h; sourceTree = ""; }; 4C37A83F15B8B474005EF8EE /* MPOutlineDataSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPOutlineDataSource.m; sourceTree = ""; }; 4C3826711AD04B51007D7D67 /* addFolderTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; name = addFolderTemplate.pdf; path = Icons/addFolderTemplate.pdf; sourceTree = ""; }; @@ -1027,6 +1030,8 @@ 4CF6C3011FBF39BF0055AD03 /* MPPluginTabelCellView.m */, 4C0F043E2147A6FA000B8568 /* MPCustomFieldTableView.h */, 4C0F043F2147A6FA000B8568 /* MPCustomFieldTableView.m */, + 4C370EFC215B76CB00703AAE /* MPOutlineTableCellView.h */, + 4C370EFD215B76CB00703AAE /* MPOutlineTableCellView.m */, ); name = Views; sourceTree = ""; @@ -1942,6 +1947,7 @@ 4C65C79C16DD283900E32CFF /* MPToolbarButton.m in Sources */, 4C431BCD16E2A82800700A81 /* MPPasteBoardController.m in Sources */, 4C6AEEF91A043E2B00CA2420 /* MPDocumentController.m in Sources */, + 4C370EFE215B76CB00703AAE /* MPOutlineTableCellView.m in Sources */, 4CE8246F16E2E93400573141 /* MPOverlayWindowController.m in Sources */, 4CE8247516E2F2B900573141 /* MPOverlayView.m in Sources */, 4C7B63761C0CB51F00D7038C /* TTTJSONTransformer.m in Sources */, diff --git a/MacPass/MPOutlineTableCellView.h b/MacPass/MPOutlineTableCellView.h new file mode 100644 index 00000000..84994dc8 --- /dev/null +++ b/MacPass/MPOutlineTableCellView.h @@ -0,0 +1,21 @@ +// +// MPOutlineTableCellView.h +// MacPass +// +// Created by Michael Starke on 26.09.18. +// Copyright © 2018 HicknHack Software GmbH. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface MPOutlineTableCellView : NSTableCellView + +@property (nonatomic) NSInteger count; +@property (nonatomic) BOOL hideZeroCount; +@property (nonatomic, strong) IBOutlet NSButton *countButton; + +@end + +NS_ASSUME_NONNULL_END diff --git a/MacPass/MPOutlineTableCellView.m b/MacPass/MPOutlineTableCellView.m new file mode 100644 index 00000000..ca749cb6 --- /dev/null +++ b/MacPass/MPOutlineTableCellView.m @@ -0,0 +1,73 @@ +// +// MPOutlineTableCellView.m +// MacPass +// +// Created by Michael Starke on 26.09.18. +// Copyright © 2018 HicknHack Software GmbH. All rights reserved. +// + +#import "MPOutlineTableCellView.h" + +@implementation MPOutlineTableCellView + +@synthesize count = _count; + +- (instancetype)initWithFrame:(NSRect)frameRect { + self = [super initWithFrame:frameRect]; + if(self) { + [self _setupDefaults]; + [self _updateCountDisplay]; + } + return self; +} + +- (instancetype)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if(self) { + [self _setupDefaults]; + if([decoder containsValueForKey:NSStringFromSelector(@selector(count))]) { + _count = [decoder decodeIntegerForKey:NSStringFromSelector(@selector(count))]; + } + if([decoder containsValueForKey:NSStringFromSelector(@selector(hideZeroCount))]) { + _hideZeroCount = [decoder decodeBoolForKey:NSStringFromSelector(@selector(hideZeroCount))]; + } + [self _updateCountDisplay]; + } + return self; +} + +- (void)encodeWithCoder:(NSCoder *)aCoder { + [super encodeWithCoder:aCoder]; + [aCoder encodeBool:_hideZeroCount forKey:NSStringFromSelector(@selector(hideZeroCount))]; + [aCoder encodeInteger:_count forKey:NSStringFromSelector(@selector(count))]; +} + +- (void)awakeFromNib { + [self _updateCountDisplay]; +} + +- (void)_setupDefaults { + _count = 0; + _hideZeroCount = YES; +} + +- (void)setCount:(NSInteger)count { + if(_count != count) { + _count = count; + [self _updateCountDisplay]; + } +} + +- (void)setHideZeroCount:(BOOL)hideZeroCount { + if(_hideZeroCount != hideZeroCount) { + _hideZeroCount = hideZeroCount; + [self _updateCountDisplay]; + } +} + +- (void)_updateCountDisplay { + self.countButton.title = [NSString stringWithFormat:@"%ld", _count]; + self.countButton.hidden = (self.hideZeroCount && self.count == 0); +} + +@end diff --git a/MacPass/MPOutlineViewController.m b/MacPass/MPOutlineViewController.m index a787ff28..1b27e5bf 100644 --- a/MacPass/MPOutlineViewController.m +++ b/MacPass/MPOutlineViewController.m @@ -30,6 +30,7 @@ #import "MPNotifications.h" #import "MPOutlineContextMenuDelegate.h" #import "MPOutlineDataSource.h" +#import "MPOutlineTableCellView.h" #import "KeePassKit/KeePassKit.h" #import "KPKNode+IconImage.h" @@ -258,7 +259,7 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell"; #pragma mark NSOutlineViewDelegate - (NSView *)outlineView:(NSOutlineView *)outlineView viewForTableColumn:(NSTableColumn *)tableColumn item:(id)item { - NSTableCellView *view; + MPOutlineTableCellView *view; if( [self _itemIsRootNode:item] ) { view = [outlineView makeViewWithIdentifier:_MPOutlinveViewHeaderViewIdentifier owner:self]; [view.textField bind:NSValueBinding toObject:self withKeyPath:NSStringFromSelector(@selector(databaseNameWrapper)) options:nil]; @@ -273,7 +274,7 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell"; NSString *entriesCountKeyPath = [[NSString alloc] initWithFormat:@"%@.%@.%@", NSStringFromSelector(@selector(representedObject)), KPKEntriesArrayBinding, @"@count"]; - [view.textField bind:NSStringFromSelector(@selector(count)) toObject:item withKeyPath:entriesCountKeyPath options:nil]; + [view bind:NSStringFromSelector(@selector(count)) toObject:item withKeyPath:entriesCountKeyPath options:nil]; } return view; diff --git a/MacPass/OutlineView.xib b/MacPass/OutlineView.xib index a518ee7c..fa11291f 100644 --- a/MacPass/OutlineView.xib +++ b/MacPass/OutlineView.xib @@ -1,8 +1,8 @@ - + - + @@ -65,7 +65,7 @@ - + @@ -77,14 +77,21 @@ - - + + + @@ -92,9 +99,12 @@ - + + + + @@ -122,7 +132,7 @@ - +