mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-23 22:09:25 +00:00
More transitions to representedObject for ViewController
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10117" systemVersion="15G31" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10117"/>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10117" systemVersion="15G31" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10117"/>
|
||||
@@ -49,6 +49,11 @@
|
||||
<imageCell key="cell" alignment="left" imageScaling="proportionallyUpOrDown" image="NSActionTemplate" id="2999"/>
|
||||
<connections>
|
||||
<action selector="pickIcon:" target="-2" id="6wh-Ka-Thl"/>
|
||||
<binding destination="-2" name="value" keyPath="representedObject.iconImage" id="agf-eg-okr">
|
||||
<dictionary key="options">
|
||||
<bool key="NSConditionallySetsEnabled" value="NO"/>
|
||||
</dictionary>
|
||||
</binding>
|
||||
</connections>
|
||||
</imageView>
|
||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="249" translatesAutoresizingMaskIntoConstraints="NO" id="3013">
|
||||
@@ -58,6 +63,9 @@
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
<connections>
|
||||
<binding destination="-2" name="value" keyPath="representedObject.title" id="2ek-Ns-ybY"/>
|
||||
</connections>
|
||||
</textField>
|
||||
<splitView autosaveName="InspectorNotesSplitView" dividerStyle="thin" translatesAutoresizingMaskIntoConstraints="NO" id="3145">
|
||||
<rect key="frame" x="0.0" y="30" width="278" height="582"/>
|
||||
@@ -140,6 +148,14 @@
|
||||
<color key="insertionPointColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<size key="minSize" width="236" height="177"/>
|
||||
<size key="maxSize" width="463" height="10000000"/>
|
||||
<connections>
|
||||
<binding destination="-2" name="value" keyPath="representedObject.notes" id="E0d-ZH-Wbc">
|
||||
<dictionary key="options">
|
||||
<bool key="NSConditionallySetsEditable" value="NO"/>
|
||||
<string key="NSNoSelectionPlaceholder">No Selection</string>
|
||||
</dictionary>
|
||||
</binding>
|
||||
</connections>
|
||||
</textView>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
@@ -189,6 +205,7 @@
|
||||
</constraints>
|
||||
<point key="canvasLocation" x="268" y="-437"/>
|
||||
</customView>
|
||||
<userDefaultsController representsSharedInstance="YES" id="U5N-S2-0zc"/>
|
||||
</objects>
|
||||
<resources>
|
||||
<image name="NSActionTemplate" width="14" height="14"/>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10117" systemVersion="15G31" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10117"/>
|
||||
|
||||
@@ -60,7 +60,6 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) {
|
||||
|
||||
@implementation MPEntryInspectorViewController
|
||||
|
||||
static NSString *kMPContentBindingString1 = @"content.%@";
|
||||
static NSString *kMPContentBindingString2 = @"content.%@.%@";
|
||||
static NSString *kMPContentBindingString3 = @"content.%@.%@.%@";
|
||||
|
||||
@@ -194,7 +193,7 @@ static NSString *kMPContentBindingString3 = @"content.%@.%@.%@";
|
||||
if(row < 0) {
|
||||
return; // no selection
|
||||
}
|
||||
KPKBinary *binary = self.contentEntry.binaries[row];
|
||||
KPKBinary *binary = self.representedEntry.binaries[row];
|
||||
[self.representedEntry removeBinary:binary];
|
||||
}
|
||||
|
||||
@@ -205,8 +204,8 @@ static NSString *kMPContentBindingString3 = @"content.%@.%@.%@";
|
||||
|
||||
- (void)removeWindowAssociation:(id)sender {
|
||||
NSInteger row = self.windowAssociationsTableView.selectedRow;
|
||||
if(row > - 1 && row < [self.contentEntry.autotype.associations count]) {
|
||||
[self.representedEntry.autotype removeAssociation:self.contentEntry.autotype.associations[row]];
|
||||
if(row > - 1 && row < [self.representedEntry.autotype.associations count]) {
|
||||
[self.representedEntry.autotype removeAssociation:self.representedEntry.autotype.associations[row]];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,7 +312,7 @@ static NSString *kMPContentBindingString3 = @"content.%@.%@.%@";
|
||||
NSString *password = [controller generatedPassword];
|
||||
/* We should only use the password if there is actually one */
|
||||
if(password.length > 0) {
|
||||
self.contentEntry.password = [controller generatedPassword];
|
||||
self.representedEntry.password = [controller generatedPassword];
|
||||
}
|
||||
}
|
||||
/* TODO: Check for Icon wizard */
|
||||
@@ -371,39 +370,39 @@ static NSString *kMPContentBindingString3 = @"content.%@.%@.%@";
|
||||
|
||||
- (void)_bindEntry {
|
||||
[self.titleTextField bind:NSValueBinding
|
||||
toObject:self.entryController
|
||||
withKeyPath:[NSString stringWithFormat:kMPContentBindingString1, NSStringFromSelector(@selector(title))]
|
||||
toObject:self
|
||||
withKeyPath:[NSString stringWithFormat:@"%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(title))]
|
||||
options:@{ NSNullPlaceholderBindingOption: NSLocalizedString(@"NONE", "")} ];
|
||||
[self.passwordTextField bind:NSValueBinding
|
||||
toObject:self.entryController
|
||||
withKeyPath:[NSString stringWithFormat:kMPContentBindingString1, NSStringFromSelector(@selector(password))]
|
||||
toObject:self
|
||||
withKeyPath:[NSString stringWithFormat:@"%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(password))]
|
||||
options:@{ NSNullPlaceholderBindingOption: NSLocalizedString(@"NONE", "") }];
|
||||
[self.usernameTextField bind:NSValueBinding
|
||||
toObject:self.entryController
|
||||
withKeyPath:[NSString stringWithFormat:kMPContentBindingString1, NSStringFromSelector(@selector(username))]
|
||||
toObject:self
|
||||
withKeyPath:[NSString stringWithFormat:@"%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(username))]
|
||||
options:@{ NSNullPlaceholderBindingOption: NSLocalizedString(@"NONE", "") }];
|
||||
[self.URLTextField bind:NSValueBinding
|
||||
toObject:self.entryController
|
||||
withKeyPath:[NSString stringWithFormat:kMPContentBindingString1, NSStringFromSelector(@selector(url))]
|
||||
toObject:self
|
||||
withKeyPath:[NSString stringWithFormat:@"%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(url))]
|
||||
options:@{ NSNullPlaceholderBindingOption: NSLocalizedString(@"NONE", "")}];
|
||||
|
||||
|
||||
|
||||
[self.expiresCheckButton bind:NSTitleBinding
|
||||
toObject:self.entryController
|
||||
withKeyPath:[NSString stringWithFormat:kMPContentBindingString2, NSStringFromSelector(@selector(timeInfo)), NSStringFromSelector(@selector(expirationDate))]
|
||||
toObject:self
|
||||
withKeyPath:[NSString stringWithFormat:@"%@.%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(timeInfo)), NSStringFromSelector(@selector(expirationDate))]
|
||||
options:@{ NSValueTransformerNameBindingOption:MPExpiryDateValueTransformer }];
|
||||
[self.expiresCheckButton bind:NSValueBinding
|
||||
toObject:self.entryController
|
||||
withKeyPath:[NSString stringWithFormat:kMPContentBindingString2, NSStringFromSelector(@selector(timeInfo)), NSStringFromSelector(@selector(expires))]
|
||||
toObject:self
|
||||
withKeyPath:[NSString stringWithFormat:@"%@.%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(timeInfo)), NSStringFromSelector(@selector(expires))]
|
||||
options:nil];
|
||||
[self.tagsTokenField bind:NSValueBinding
|
||||
toObject:self.entryController
|
||||
withKeyPath:[NSString stringWithFormat:kMPContentBindingString1, NSStringFromSelector(@selector(tags))]
|
||||
toObject:self
|
||||
withKeyPath:[NSString stringWithFormat:@"%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(tags))]
|
||||
options:nil];
|
||||
[self.uuidTextField bind:NSValueBinding
|
||||
toObject:self.entryController
|
||||
withKeyPath:[NSString stringWithFormat:kMPContentBindingString2, NSStringFromSelector(@selector(uuid)), NSStringFromSelector(@selector(UUIDString))]
|
||||
toObject:self
|
||||
withKeyPath:[NSString stringWithFormat:@"%@.%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(uuid)), NSStringFromSelector(@selector(UUIDString))]
|
||||
options:@{ NSConditionallySetsEditableBindingOption: @NO }];
|
||||
self.uuidTextField.editable = NO;
|
||||
|
||||
@@ -414,37 +413,37 @@ static NSString *kMPContentBindingString3 = @"content.%@.%@.%@";
|
||||
|
||||
- (void)_bindAttachments {
|
||||
[_attachmentsController bind:NSContentArrayBinding
|
||||
toObject:self.entryController
|
||||
withKeyPath:[NSString stringWithFormat:kMPContentBindingString1, NSStringFromSelector(@selector(binaries))]
|
||||
toObject:self
|
||||
withKeyPath:[NSString stringWithFormat:@"%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(binaries))]
|
||||
options:nil];
|
||||
}
|
||||
|
||||
- (void)_bindCustomFields {
|
||||
[_customFieldsController bind:NSContentArrayBinding
|
||||
toObject:self.entryController
|
||||
withKeyPath:[NSString stringWithFormat:kMPContentBindingString1, NSStringFromSelector(@selector(customAttributes))]
|
||||
toObject:self
|
||||
withKeyPath:[NSString stringWithFormat:@"%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(customAttributes))]
|
||||
options:nil];
|
||||
}
|
||||
- (void)_bindAutotype {
|
||||
|
||||
[self.enableAutotypeCheckButton bind:NSValueBinding
|
||||
toObject:self.entryController
|
||||
withKeyPath:[NSString stringWithFormat:kMPContentBindingString2, NSStringFromSelector(@selector(autotype)), NSStringFromSelector(@selector(enabled))] options:nil];
|
||||
toObject:self
|
||||
withKeyPath:[NSString stringWithFormat:@"%@.%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(autotype)), NSStringFromSelector(@selector(enabled))] options:nil];
|
||||
[self.obfuscateAutotypeCheckButton bind:NSValueBinding
|
||||
toObject:self.entryController
|
||||
withKeyPath:[NSString stringWithFormat:kMPContentBindingString2, NSStringFromSelector(@selector(autotype)), NSStringFromSelector(@selector(obfuscateDataTransfer))]
|
||||
toObject:self
|
||||
withKeyPath:[NSString stringWithFormat:@"%@.%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(autotype)), NSStringFromSelector(@selector(obfuscateDataTransfer))]
|
||||
options:nil];
|
||||
[self.customEntrySequenceTextField bind:NSEnabledBinding
|
||||
toObject:self.entryController
|
||||
withKeyPath:[NSString stringWithFormat:kMPContentBindingString2, NSStringFromSelector(@selector(autotype)), NSStringFromSelector(@selector(enabled))]
|
||||
toObject:self
|
||||
withKeyPath:[NSString stringWithFormat:@"%@.%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(autotype)), NSStringFromSelector(@selector(enabled))]
|
||||
options:nil];
|
||||
[self.customEntrySequenceTextField bind:NSValueBinding
|
||||
toObject:self.entryController
|
||||
withKeyPath:[NSString stringWithFormat:kMPContentBindingString2, NSStringFromSelector(@selector(autotype)), NSStringFromSelector(@selector(defaultKeystrokeSequence))]
|
||||
toObject:self
|
||||
withKeyPath:[NSString stringWithFormat:@"%@.%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(autotype)), NSStringFromSelector(@selector(defaultKeystrokeSequence))]
|
||||
options:@{ NSValidatesImmediatelyBindingOption: @YES }];
|
||||
[_windowAssociationsController bind:NSContentArrayBinding
|
||||
toObject:self.entryController
|
||||
withKeyPath:[NSString stringWithFormat:kMPContentBindingString2, NSStringFromSelector(@selector(autotype)), NSStringFromSelector(@selector(associations))]
|
||||
toObject:self
|
||||
withKeyPath:[NSString stringWithFormat:@"%@.%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(autotype)), NSStringFromSelector(@selector(associations))]
|
||||
options:@{ NSSelectsAllWhenSettingContentBindingOption: @NO }];
|
||||
[self.windowTitleComboBox setStringValue:@""];
|
||||
[self.windowTitleComboBox bind:NSValueBinding
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#import "MPDocument.h"
|
||||
#import "MPPasteBoardController.h"
|
||||
#import "MPValueTransformerHelper.h"
|
||||
#import "MPObjectController.h"
|
||||
|
||||
#import "KeePassKit/KeePassKit.h"
|
||||
|
||||
@@ -19,7 +20,7 @@
|
||||
|
||||
//@property (nonatomic, weak) KPKGroup *group;
|
||||
@property (strong) NSPopover *popover;
|
||||
@property (strong) NSObjectController *groupController;
|
||||
@property (strong) MPObjectController *groupController;
|
||||
|
||||
@end
|
||||
|
||||
@@ -32,7 +33,7 @@
|
||||
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
|
||||
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
|
||||
if (self) {
|
||||
_groupController = [[NSObjectController alloc] init];
|
||||
_groupController = [[MPObjectController alloc] init];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -85,7 +86,6 @@
|
||||
|
||||
- (void)setupBindings:(MPDocument *)document {
|
||||
[self.groupController bind:NSContentObjectBinding toObject:self withKeyPath:NSStringFromSelector(@selector(representedObject)) options:nil];
|
||||
//[self.groupController bind:NSContentObjectBinding toObject:document withKeyPath:NSStringFromSelector(@selector(selectedGroup)) options:nil];
|
||||
}
|
||||
|
||||
- (void)_establishBindings {
|
||||
|
||||
@@ -10,4 +10,6 @@
|
||||
|
||||
@interface MPObjectController : NSObjectController
|
||||
|
||||
@property (weak) NSDocument *document;
|
||||
|
||||
@end
|
||||
|
||||
@@ -10,4 +10,34 @@
|
||||
|
||||
@implementation MPObjectController
|
||||
|
||||
//- (void)objectDidBeginEditing:(id)editor {
|
||||
// NSLog(@"objectDidBeginEditing:%@", editor);
|
||||
// [super objectDidBeginEditing:editor];
|
||||
//}
|
||||
//- (void)objectDidEndEditing:(id)editor {
|
||||
// NSLog(@"objectDidEndEditing:%@", editor);
|
||||
// [super objectDidEndEditing:editor];
|
||||
//}
|
||||
|
||||
- (void)discardEditing {
|
||||
[super discardEditing];
|
||||
}
|
||||
|
||||
- (BOOL)commitEditing {
|
||||
return [super commitEditing];
|
||||
}
|
||||
|
||||
|
||||
//- (BOOL)commitEditing {
|
||||
// return [super commitEditing];
|
||||
//}
|
||||
//
|
||||
//- (BOOL)commitEditingAndReturnError:(NSError * _Nullable __autoreleasing *)error {
|
||||
// return [super commitEditingAndReturnError:error];
|
||||
//}
|
||||
//
|
||||
//- (void)commitEditingWithDelegate:(id)delegate didCommitSelector:(SEL)didCommitSelector contextInfo:(void *)contextInfo {
|
||||
// [super commitEditingWithDelegate:delegate didCommitSelector:didCommitSelector contextInfo:contextInfo];
|
||||
//}
|
||||
|
||||
@end
|
||||
|
||||
@@ -196,7 +196,7 @@ typedef NS_ENUM(NSUInteger, MPPasswordRating) {
|
||||
if(!availableDefaults) {
|
||||
availableDefaults = [[NSMutableDictionary alloc] initWithCapacity:1];
|
||||
}
|
||||
availableDefaults[[self.entry.uuid UUIDString]] = entryDefaults;
|
||||
availableDefaults[[self.representedObject uuid].UUIDString] = entryDefaults;
|
||||
[[NSUserDefaults standardUserDefaults] setObject:availableDefaults forKey:kMPSettingsKeyPasswordDefaultsForEntry];
|
||||
}
|
||||
else if(!self.useEntryDefaults) {
|
||||
@@ -218,7 +218,7 @@ typedef NS_ENUM(NSUInteger, MPPasswordRating) {
|
||||
}
|
||||
NSMutableDictionary *availableDefaults = [[self _availableEntryDefaults] mutableCopy];
|
||||
NSAssert(availableDefaults, @"Password generator defaults for should be present!");
|
||||
[availableDefaults removeObjectForKey:[self.entry.uuid UUIDString]];
|
||||
[availableDefaults removeObjectForKey:[self.representedObject uuid].UUIDString];
|
||||
[[NSUserDefaults standardUserDefaults] setObject:availableDefaults forKey:kMPSettingsKeyPasswordDefaultsForEntry];
|
||||
self.useEntryDefaults = NO; /* Resetting the UI and Defaults is handled via the setter */
|
||||
[self _updateSetDefaultsButton:NO];
|
||||
|
||||
Reference in New Issue
Block a user