Added view to edit and display entry passwords

This commit is contained in:
Michael Starke
2021-10-19 00:57:11 +02:00
parent f28bcb527a
commit 83f8158b21
9 changed files with 210 additions and 31 deletions

View File

@@ -14,8 +14,6 @@
@interface MPEntryAttributeViewController () {
BOOL _isDefaultAttribute;
}
@property (strong) IBOutlet NSTextField *keyTextField;
@property (strong) IBOutlet HNHUITextField *valueTextField;
@property (readonly, nullable, strong) KPKAttribute *representedAttribute;
@end
@@ -45,8 +43,8 @@
self.valueTextField.placeholderString = placeHolder;
[super viewDidLoad];
[self _updateValues];
[self _updateEditing];
[self updateValues];
[self updateEditing];
__weak MPEntryAttributeViewController *welf = self;
self.valueTextField.copyActionBlock = ^void(NSTextField *tf) {
@@ -66,7 +64,7 @@
- (void)setIsEditor:(BOOL)isEditor {
_isEditor = isEditor;
[self _updateEditing];
[self updateEditing];
}
- (void)setRepresentedObject:(id)representedObject {
@@ -87,7 +85,7 @@
}
_isDefaultAttribute = self.representedAttribute.isDefault;
[self _updateValues];
[self updateValues];
}
- (BOOL)textField:(NSTextField *)textField textView:(NSTextView *)textView performAction:(SEL)action {
@@ -95,7 +93,6 @@
return YES;
}
// Only copy action
MPPasteboardOverlayInfoType info = MPPasteboardOverlayInfoCustom;
NSMutableString *selectedValue = [[NSMutableString alloc] init];
@@ -109,9 +106,10 @@
if([self.representedAttribute.key isEqual:kKPKUsernameKey]) {
info = MPPasteboardOverlayInfoUsername;
}
else if([self.representedAttribute.key isEqual:kKPKPasswordKey]) {
/*else if([self.representedAttribute.key isEqual:kKPKPasswordKey]) {
info = MPPasteboardOverlayInfoPassword;
}
*/
else if([self.representedAttribute.key isEqual:kKPKURLKey]) {
info = MPPasteboardOverlayInfoURL;
}
@@ -131,16 +129,16 @@
}
- (void)_didChangeAttribute:(NSNotification *)notification {
[self _updateValues];
[self updateValues];
}
- (void)_updateValues {
- (void)updateValues {
self.view.hidden = (!self.isEditor && self.representedAttribute.value.length == 0);
self.keyTextField.stringValue = self.representedAttribute.key ? self.representedAttribute.key : @"";
self.valueTextField.stringValue = self.representedAttribute.value ? self.representedAttribute.value : @"";
}
- (void)_updateEditing {
- (void)updateEditing {
self.keyTextField.editable = !_isDefaultAttribute && self.isEditor;
self.valueTextField.editable = self.isEditor;
self.keyTextField.selectable = YES;