mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 15:12:21 +00:00
Using bindings for iconImage for instant updates
Icon setting now gets registered via NSUndoManager Refactored iconId property
This commit is contained in:
Submodule KeePassKit updated: 1e2dead025...04a7747bd9
@@ -15,13 +15,13 @@
|
||||
@implementation KPKNode (IconImage)
|
||||
|
||||
+ (NSSet *)keyPathsForValuesAffectingIconImage {
|
||||
return [NSSet setWithArray:@[@"customIcon", @"icon"]];
|
||||
return [NSSet setWithArray:@[@"customIcon", @"iconId"]];
|
||||
}
|
||||
|
||||
- (NSImage *)iconImage {
|
||||
if(self.customIcon) {
|
||||
return self.customIcon.image;
|
||||
}
|
||||
return [MPIconHelper icon:(MPIconType)self.icon];
|
||||
return [MPIconHelper icon:(MPIconType)self.iconId];
|
||||
}
|
||||
@end
|
||||
|
||||
@@ -455,7 +455,7 @@ typedef NS_ENUM(NSUInteger, MPAlertType) {
|
||||
}
|
||||
KPKGroup *newGroup = [self.tree createGroup:parent];
|
||||
newGroup.name = NSLocalizedString(@"DEFAULT_GROUP_NAME", @"Title for a newly created group");
|
||||
newGroup.icon = MPIconFolder;
|
||||
newGroup.iconId = MPIconFolder;
|
||||
[parent addGroup:newGroup];
|
||||
NSDictionary *userInfo = @{ MPDocumentGroupKey : newGroup };
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentDidAddGroupNotification object:self userInfo:userInfo];
|
||||
@@ -607,7 +607,7 @@ typedef NS_ENUM(NSUInteger, MPAlertType) {
|
||||
BOOL wasEnabled = [self.undoManager isUndoRegistrationEnabled];
|
||||
[self.undoManager disableUndoRegistration];
|
||||
trash.name = NSLocalizedString(@"TRASH", @"Name for the trash group");
|
||||
trash.icon = MPIconTrash;
|
||||
trash.iconId = MPIconTrash;
|
||||
[self.tree.root addGroup:trash];
|
||||
if(wasEnabled) {
|
||||
[self.undoManager enableUndoRegistration];
|
||||
|
||||
@@ -237,12 +237,12 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell";
|
||||
view = [tableView makeViewWithIdentifier:_MPTableImageCellView owner:self];
|
||||
if( isTitleColumn ) {
|
||||
[[view textField] bind:NSValueBinding toObject:entry withKeyPath:@"title" options:nil];
|
||||
[[view imageView] setImage:entry.iconImage];
|
||||
[[view imageView] bind:NSValueBinding toObject:entry withKeyPath:@"iconImage" options:nil];
|
||||
}
|
||||
else {
|
||||
assert(entry.parent);
|
||||
[[view textField] bind:NSValueBinding toObject:entry.parent withKeyPath:@"name" options:nil];
|
||||
[[view imageView] setImage:entry.iconImage];
|
||||
[[view imageView] bind:NSValueBinding toObject:entry.parent withKeyPath:@"iconImage" options:nil];
|
||||
}
|
||||
}
|
||||
else if(isPasswordColum) {
|
||||
|
||||
@@ -179,11 +179,11 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
|
||||
BOOL useDefault = (viewController.selectedIcon == -1);
|
||||
switch (self.activeTab) {
|
||||
case MPGroupTab:
|
||||
document.selectedGroup.icon = useDefault ? MPIconFolder : viewController.selectedIcon;
|
||||
document.selectedGroup.iconId = useDefault ? [KPKGroup defaultIcon] : viewController.selectedIcon;
|
||||
break;
|
||||
|
||||
case MPEntryTab:
|
||||
document.selectedEntry.icon = useDefault ? MPIconPassword : viewController.selectedIcon;
|
||||
document.selectedEntry.iconId = useDefault ? [KPKEntry defaultIcon]: viewController.selectedIcon;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -196,9 +196,9 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
|
||||
KPKGroup *group = [item representedObject];
|
||||
view = [outlineView makeViewWithIdentifier:_MPOutlineViewDataViewIdentifier owner:self];
|
||||
|
||||
[view.imageView setImage:group.iconImage];
|
||||
[view.textField bind:NSValueBinding toObject:group withKeyPath:@"name" options:nil];
|
||||
[view.textField bind:@"count" toObject:group withKeyPath:@"entries.@count" options:nil];
|
||||
[[view imageView] bind:NSValueBinding toObject:group withKeyPath:@"iconImage" options:nil];
|
||||
[[view textField] bind:NSValueBinding toObject:group withKeyPath:@"name" options:nil];
|
||||
[[view textField] bind:@"count" toObject:group withKeyPath:@"entries.@count" options:nil];
|
||||
}
|
||||
|
||||
return view;
|
||||
|
||||
Reference in New Issue
Block a user