mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-24 01:49:20 +00:00
Adopted new KeePassKit API, modernized Object-C syntax, optimized MPIconHelper
Signed-off-by: michael starke <michael.starke@hicknhack-software.com>
This commit is contained in:
@@ -541,7 +541,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey
|
||||
if(group == self.trash) {
|
||||
return; //Group is trash!
|
||||
}
|
||||
[group moveToGroup:self.trash atIndex:[self.trash.groups count]];
|
||||
[group moveToGroup:self.trash];
|
||||
[[self undoManager] setActionName:NSLocalizedString(@"TRASH_GROUP", "Move Group to Trash")];
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -28,17 +28,17 @@
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
NSDictionary *imageNames = [MPIconHelper availableIconNames];
|
||||
NSMutableArray *mutableIcons = [[NSMutableArray alloc] initWithCapacity:[imageNames count]];
|
||||
NSMutableArray *mutableIcons = [[NSMutableArray alloc] initWithCapacity:imageNames.count];
|
||||
|
||||
NSArray *sortedImageNames = [[imageNames allKeys] sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
|
||||
return [[imageNames objectForKey:obj1] compare:[imageNames objectForKey:obj2]];
|
||||
NSArray *sortedImageNames = [imageNames.allKeys sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
|
||||
return [imageNames[obj1] compare:imageNames[obj2]];
|
||||
}];
|
||||
|
||||
for(NSNumber *iconNumber in sortedImageNames) {
|
||||
if([iconNumber integerValue] > MPCustomIconTypeBegin) {
|
||||
if(iconNumber.integerValue > MPCustomIconTypeBegin) {
|
||||
continue; // Skip all non-db Keys
|
||||
}
|
||||
MPIconType iconType = (MPIconType)[iconNumber integerValue];
|
||||
MPIconType iconType = (MPIconType)iconNumber.integerValue;
|
||||
[mutableIcons addObject:[MPIconHelper icon:iconType]];
|
||||
}
|
||||
icons = [mutableIcons copy];
|
||||
@@ -52,19 +52,14 @@
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
NSDictionary *imageNames = [MPIconHelper availableIconNames];
|
||||
NSMutableArray *mutableIcons = [[NSMutableArray alloc] initWithCapacity:[imageNames count]];
|
||||
|
||||
NSArray *sortedImageNames = [[imageNames allKeys] sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
|
||||
return [[imageNames objectForKey:obj1] compare:[imageNames objectForKey:obj2]];
|
||||
}];
|
||||
|
||||
for(NSNumber *iconNumber in sortedImageNames) {
|
||||
if([iconNumber integerValue] > MPCustomIconTypeBegin) {
|
||||
continue; // Skip all non-db Keys
|
||||
}
|
||||
[mutableIcons addObject:iconNumber];
|
||||
}
|
||||
iconTypes = [mutableIcons copy];
|
||||
iconTypes = [sortedImageNames filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) {
|
||||
NSNumber *iconNumber = (NSNumber *)evaluatedObject;
|
||||
return (iconNumber.integerValue < MPCustomIconTypeBegin);
|
||||
}]];
|
||||
});
|
||||
return iconTypes;
|
||||
}
|
||||
|
||||
@@ -41,10 +41,10 @@ NSInteger const kMPDefaultIcon = -1;
|
||||
|
||||
- (void)didLoadView {
|
||||
//[[self.imageButton cell] setBackgroundStyle:NSBackgroundStyleLowered];
|
||||
[self.iconCollectionView setBackgroundColors:@[[NSColor clearColor]]];
|
||||
[self.iconCollectionView setSelectable:YES];
|
||||
[self.iconCollectionView setAllowsMultipleSelection:NO];
|
||||
[self.iconCollectionView setContent:[MPIconHelper databaseIcons]];
|
||||
self.iconCollectionView.backgroundColors = @[[NSColor clearColor]];
|
||||
self.iconCollectionView.selectable = YES;
|
||||
self.iconCollectionView.allowsMultipleSelection = NO;
|
||||
self.iconCollectionView.content = [MPIconHelper databaseIcons];
|
||||
}
|
||||
|
||||
- (IBAction)useDefault:(id)sender {
|
||||
@@ -66,9 +66,9 @@ NSInteger const kMPDefaultIcon = -1;
|
||||
- (IBAction)_selectImage:(id)sender {
|
||||
self.didCancel = NO;
|
||||
NSButton *button = sender;
|
||||
NSImage *image = [button image];
|
||||
NSUInteger buttonIndex = [[self.iconCollectionView content] indexOfObject:image];
|
||||
self.selectedIcon = [[MPIconHelper databaseIconTypes] [buttonIndex] integerValue];
|
||||
NSImage *image = button.image;
|
||||
NSUInteger buttonIndex = [self.iconCollectionView.content indexOfObject:image];
|
||||
self.selectedIcon = ((NSNumber *)[MPIconHelper databaseIconTypes][buttonIndex]).integerValue;
|
||||
[self.popover performClose:self];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user