diff --git a/MacPass/MPContextToolbarButton.h b/MacPass/MPContextToolbarButton.h index 9d497e01..45873e49 100644 --- a/MacPass/MPContextToolbarButton.h +++ b/MacPass/MPContextToolbarButton.h @@ -27,4 +27,7 @@ - (void)setImage:(NSImage *)image; - (void)setContextMenu:(NSMenu *)menu; +- (NSControlSize)controlSize; +- (void)setControlSize:(NSControlSize)controlSize; + @end diff --git a/MacPass/MPContextToolbarButton.m b/MacPass/MPContextToolbarButton.m index 40ed7600..2e11c450 100644 --- a/MacPass/MPContextToolbarButton.m +++ b/MacPass/MPContextToolbarButton.m @@ -38,12 +38,12 @@ NSData *data = [NSKeyedArchiver archivedDataWithRootObject:[self cell]]; NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data]; MPSegmentedContextCell *cell = [[MPSegmentedContextCell alloc] initWithCoder:unarchiver]; - [self setCell:cell]; + self.cell = cell; - [self setFocusRingType:NSFocusRingTypeNone]; - [self setSegmentCount:2]; + self.focusRingType = NSFocusRingTypeNone; + self.segmentCount = 2; [cell setTrackingMode:NSSegmentSwitchTrackingMomentary]; - [self setSegmentStyle:NSSegmentStyleTexturedSquare]; + self.segmentStyle = NSSegmentStyleTexturedSquare; [cell setWidth:31 forSegment:0]; [cell setWidth:17 forSegment:1]; @@ -73,7 +73,7 @@ - (void)setSegmentCount:(NSInteger)count { if(count == 2) { - [super setSegmentCount:count]; + super.segmentCount = count; } } @@ -82,10 +82,18 @@ } - (void)showContextMenu:(id)sender { - NSPoint point = [self frame].origin; - point.x = [[self cell] widthForSegment:0]; - point.y = NSHeight([self frame]) + 3; + NSPoint point = self.frame.origin; + point.x = [self.cell widthForSegment:0]; + point.y = NSHeight(self.frame) + 3; [_contextMenu popUpMenuPositioningItem:nil atLocation:point inView:self]; } +- (void)setControlSize:(NSControlSize)controlSize { + self.cell.controlSize = controlSize; +} + +- (NSControlSize)controlSize { + return self.cell.controlSize; +} + @end diff --git a/MacPass/MPDocument+Search.m b/MacPass/MPDocument+Search.m index aff97b36..e605b2dc 100644 --- a/MacPass/MPDocument+Search.m +++ b/MacPass/MPDocument+Search.m @@ -113,12 +113,11 @@ NSString *const kMPDocumentSearchResultsKey = @"kMPDocumentSearchResul - (NSArray *)_findEntriesMatchingCurrentSearch { /* Filter double passwords */ if(MPIsFlagSetInOptions(MPEntrySearchDoublePasswords, self.searchContext.searchFlags)) { - __block NSMutableDictionary *passwordToEntryMap = [[NSMutableDictionary alloc] initWithCapacity:100]; + NSMutableDictionary *passwordToEntryMap = [[NSMutableDictionary alloc] initWithCapacity:100]; /* Build up a usage map */ - [[self.root searchableChildEntries] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - KPKEntry *entry = obj; + for(KPKEntry *entry in self.root.searchableChildEntries) { /* skip entries without passwords */ - if([entry.password length] > 0) { + if(entry.password.length > 0) { NSMutableSet *entrySet = passwordToEntryMap[entry.password]; if(entrySet) { [entrySet addObject:entry]; @@ -127,15 +126,15 @@ NSString *const kMPDocumentSearchResultsKey = @"kMPDocumentSearchResul passwordToEntryMap[entry.password] = [NSMutableSet setWithObject:entry]; } } - }]; + } /* check for usage count */ - __block NSMutableArray *doublePasswords = [[NSMutableArray alloc] init]; - [[passwordToEntryMap allKeys] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - NSSet *entrySet = passwordToEntryMap[obj]; - if([entrySet count] > 1) { - [doublePasswords addObjectsFromArray:[entrySet allObjects]]; + NSMutableArray *doublePasswords = [[NSMutableArray alloc] init]; + for(NSString *password in passwordToEntryMap.allKeys) { + NSSet *entrySet = passwordToEntryMap[password]; + if(entrySet.count > 1) { + [doublePasswords addObjectsFromArray:entrySet.allObjects]; } - }]; + } return doublePasswords; } if(MPIsFlagSetInOptions(MPEntrySearchExpiredEntries, self.searchContext.searchFlags)) { diff --git a/MacPass/MPReferenceBuilderViewController.m b/MacPass/MPReferenceBuilderViewController.m index d15cf123..7bad7162 100644 --- a/MacPass/MPReferenceBuilderViewController.m +++ b/MacPass/MPReferenceBuilderViewController.m @@ -20,13 +20,6 @@ return @"ReferenceBuilderView"; } -//- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { -// self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; -// if(self) { -// } -// return self; -//} - - (void)didLoadView { [self.searchKeyPopUpButton setMenu:[self _allocateAttributeItemMenu:YES withTitle:NSLocalizedString(@"SEARCH_VALUE", "")]]; [self.valuePopUpButton setMenu:[self _allocateAttributeItemMenu:NO withTitle:NSLocalizedString(@"OUTPUT_VALUE", "")]]; diff --git a/MacPass/MPSegmentedContextCell.m b/MacPass/MPSegmentedContextCell.m index a2376058..87e5594c 100644 --- a/MacPass/MPSegmentedContextCell.m +++ b/MacPass/MPSegmentedContextCell.m @@ -43,17 +43,17 @@ } - (SEL)action { - if([self selectedSegment] == 1) { + if(self.selectedSegment == 1) { return self.contextMenuAction; } - return [super action]; + return super.action; } - (id)target { - if([self selectedSegment] == 1) { + if(self.selectedSegment == 1) { return self.contextMenuTarget; } - return [super target]; + return super.target; } @end diff --git a/MacPass/MPToolbarButton.h b/MacPass/MPToolbarButton.h index a79d9181..6fea779d 100644 --- a/MacPass/MPToolbarButton.h +++ b/MacPass/MPToolbarButton.h @@ -25,8 +25,8 @@ @interface MPToolbarButton : NSButton /* This methods ensure, that the button get sized correctly if used as the view in a NSToolbarItem*/ + - (void)setControlSize:(NSControlSize)controlSize; - (NSControlSize)controlSize; - @end diff --git a/MacPass/MPToolbarButton.m b/MacPass/MPToolbarButton.m index 07065f32..7dcec7cd 100644 --- a/MacPass/MPToolbarButton.m +++ b/MacPass/MPToolbarButton.m @@ -27,38 +27,38 @@ - (id)initWithFrame:(NSRect)frameRect { self = [super initWithFrame:frameRect]; if(self) { - [self setFocusRingType:NSFocusRingTypeNone]; - [[self cell] setBezelStyle:NSTexturedRoundedBezelStyle]; - [[self cell] setImageScaling:NSImageScaleProportionallyDown]; + self.focusRingType = NSFocusRingTypeNone; + self.bezelStyle = NSTexturedRoundedBezelStyle; + [self.cell setImageScaling:NSImageScaleProportionallyDown]; [self setButtonType:NSMomentaryPushInButton]; - [self setImagePosition:NSImageOnly]; + self.imagePosition = NSImageOnly; } return self; } - (void)setControlSize:(NSControlSize)controlSize { - [[self cell] setControlSize:controlSize]; - NSImageRep *rep = [[self image] bestRepresentationForRect:NSMakeRect(0, 0, 100, 100) context:nil hints:nil]; + NSImageRep *rep = [self.image bestRepresentationForRect:NSMakeRect(0, 0, 100, 100) context:nil hints:nil]; CGFloat scale = rep.size.width / rep.size.height; switch (controlSize) { case NSRegularControlSize: - [[self image] setSize:NSMakeSize(16 * scale, 16)]; + self.image.size = NSMakeSize(16 * scale, 16); break; case NSSmallControlSize: - [[self image] setSize:NSMakeSize(14 * scale, 14)]; + self.image.size = NSMakeSize(14 * scale, 14); break; case NSMiniControlSize: - [[self image] setSize:NSMakeSize(8 * scale, 8)]; + self.image.size = NSMakeSize(8 * scale, 8); default: break; } + super.controlSize = controlSize; } - (NSControlSize)controlSize { - return [[self cell] controlSize]; + return self.cell.controlSize; } @end