diff --git a/MacPass.xcodeproj/project.pbxproj b/MacPass.xcodeproj/project.pbxproj index eda9cae1..10a6597b 100644 --- a/MacPass.xcodeproj/project.pbxproj +++ b/MacPass.xcodeproj/project.pbxproj @@ -222,6 +222,8 @@ 4C9328C8273E6A38000DCBEE /* MPTOTPSetupViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C9328CA273E6A38000DCBEE /* MPTOTPSetupViewController.xib */; }; 4C9328D0273E6A83000DCBEE /* MPTOTPViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C9328D2273E6A83000DCBEE /* MPTOTPViewController.xib */; }; 4C978E0D19AE54AB003067DF /* MPFlagsHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C978E0C19AE54AB003067DF /* MPFlagsHelper.m */; }; + 4C98A6CC27CFAB1900CD912F /* MPNodeIconViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C98A6CA27CFAB1900CD912F /* MPNodeIconViewController.m */; }; + 4C98A6CD27CFAB1900CD912F /* MPNodeIconViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C98A6CB27CFAB1900CD912F /* MPNodeIconViewController.xib */; }; 4C9BFFFB1FD19B5400264B16 /* MPPrettyPasswordTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C9BFFFA1FD19B5400264B16 /* MPPrettyPasswordTransformer.m */; }; 4CA08DA017A831B200A6544B /* MPAddEntryContextMenuDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CA08D9F17A831B200A6544B /* MPAddEntryContextMenuDelegate.m */; }; 4CA0B2ED15BCADAC00654E32 /* PreferencesWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4CA0B2EC15BCADAC00654E32 /* PreferencesWindow.xib */; }; @@ -779,6 +781,9 @@ 4C9328D6273E6A85000DCBEE /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/MPTOTPViewController.strings; sourceTree = ""; }; 4C978E0C19AE54AB003067DF /* MPFlagsHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPFlagsHelper.m; sourceTree = ""; }; 4C97CCEF1FA727DC00E58F8C /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; + 4C98A6C927CFAB1800CD912F /* MPNodeIconViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MPNodeIconViewController.h; sourceTree = ""; }; + 4C98A6CA27CFAB1900CD912F /* MPNodeIconViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MPNodeIconViewController.m; sourceTree = ""; }; + 4C98A6CB27CFAB1900CD912F /* MPNodeIconViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MPNodeIconViewController.xib; sourceTree = ""; }; 4C9BFFF91FD19B5400264B16 /* MPPrettyPasswordTransformer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MPPrettyPasswordTransformer.h; sourceTree = ""; }; 4C9BFFFA1FD19B5400264B16 /* MPPrettyPasswordTransformer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MPPrettyPasswordTransformer.m; sourceTree = ""; }; 4C9FE47423703DA50096A5EA /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; @@ -1515,6 +1520,9 @@ 4C59AC9A2722C12200F54B20 /* MPNodeExpirationViewController.h */, 4C59AC9B2722C12200F54B20 /* MPNodeExpirationViewController.m */, 4C59AC9C2722C12200F54B20 /* MPNodeExpirationViewController.xib */, + 4C98A6C927CFAB1800CD912F /* MPNodeIconViewController.h */, + 4C98A6CA27CFAB1900CD912F /* MPNodeIconViewController.m */, + 4C98A6CB27CFAB1900CD912F /* MPNodeIconViewController.xib */, ); name = Inspector; sourceTree = ""; @@ -2104,6 +2112,7 @@ 4C586F9E16D07ABD00E7DB57 /* 00_PasswordTemplate.pdf in Resources */, FA13910C1F9CD9EB0033D256 /* Localizable.stringsdict in Resources */, 4C586FA016D07D7200E7DB57 /* 01_PackageNetworkTemplate.pdf in Resources */, + 4C98A6CD27CFAB1900CD912F /* MPNodeIconViewController.xib in Resources */, 4CE4FFAD2746956F00789F75 /* MPGeneralDatabaseSettingsViewController.xib in Resources */, 4C3826CB1AD04D8E007D7D67 /* 64_AppleTemplate.pdf in Resources */, 4C3826AA1AD04D8E007D7D67 /* 27_NFSUnmountTemplate.pdf in Resources */, @@ -2396,6 +2405,7 @@ 4C57AE1417BA422B00CA4F34 /* MPSegmentedContextCell.m in Sources */, 4CE2961518429AA5005F01CE /* MPAutotypeKeyPress.m in Sources */, 4CE4FFAC2746956F00789F75 /* MPGeneralDatabaseSettingsViewController.m in Sources */, + 4C98A6CC27CFAB1900CD912F /* MPNodeIconViewController.m in Sources */, 4C32B0E71A1D4436007E12F1 /* KPKFormat+MPUTIDetection.m in Sources */, 4C5807781C64F67000E7171F /* NSString+MPHash.m in Sources */, 4CAAA8271D787B8B00CDE977 /* MPAutotypeBuilderViewController.m in Sources */, diff --git a/MacPass/Base.lproj/EntryInspectorView.xib b/MacPass/Base.lproj/EntryInspectorView.xib index 00c3eab3..1d83c0fe 100644 --- a/MacPass/Base.lproj/EntryInspectorView.xib +++ b/MacPass/Base.lproj/EntryInspectorView.xib @@ -277,7 +277,7 @@ - + diff --git a/MacPass/Base.lproj/InspectorView.xib b/MacPass/Base.lproj/InspectorView.xib index 3247d436..4397aa77 100644 --- a/MacPass/Base.lproj/InspectorView.xib +++ b/MacPass/Base.lproj/InspectorView.xib @@ -1,8 +1,8 @@ - + - + diff --git a/MacPass/MPDocument.m b/MacPass/MPDocument.m index 5a7d5187..02fb3c1f 100644 --- a/MacPass/MPDocument.m +++ b/MacPass/MPDocument.m @@ -147,6 +147,11 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou [self addWindowController:windowController]; } +- (void)canCloseDocumentWithDelegate:(id)delegate shouldCloseSelector:(nullable SEL)shouldCloseSelector contextInfo:(nullable void *)contextInfo { + + [super canCloseDocumentWithDelegate:delegate shouldCloseSelector:shouldCloseSelector contextInfo:contextInfo]; +} + - (BOOL)canAsynchronouslyWriteToURL:(NSURL *)url ofType:(NSString *)typeName forSaveOperation:(NSSaveOperationType)saveOperation { return YES; } diff --git a/MacPass/MPEntryAttributeViewController.m b/MacPass/MPEntryAttributeViewController.m index 12ad31b3..e5884075 100644 --- a/MacPass/MPEntryAttributeViewController.m +++ b/MacPass/MPEntryAttributeViewController.m @@ -105,17 +105,6 @@ NSString *nameForDefaultKey(NSString *key) { [self updateValues]; } --(void)commitChanges { - if(!self.isEditor) { - // do not commit changes if we are no editor! - } - // FIXME: better handling of key uniqueness - if(!_isDefaultAttribute) { - self.representedAttribute.key = self.keyTextField.stringValue; - } - self.representedAttribute.value = self.valueTextField.stringValue; -} - - (BOOL)textField:(NSTextField *)textField textView:(NSTextView *)textView performAction:(SEL)action { if(action != @selector(copy:)) { return YES; @@ -183,6 +172,47 @@ NSString *nameForDefaultKey(NSString *key) { self.valueTextField.selectable = YES; self.toggleProtectedButton.hidden = _isDefaultAttribute; self.removeButton.hidden = !self.isEditor ? YES : _isDefaultAttribute; + + // set draws background first, since bezeld might have side effects + self.valueTextField.drawsBackground = self.isEditor; + self.valueTextField.bordered = self.isEditor; + self.valueTextField.bezeled = self.isEditor; +} + +-(void)commitChanges { + if(!self.isEditor) { + // do not commit changes if we are no editor! + } + // FIXME: better handling of key uniqueness + if(!_isDefaultAttribute) { + self.representedAttribute.key = self.keyTextField.stringValue; + } + self.representedAttribute.value = self.valueTextField.stringValue; +} + +- (void)objectDidBeginEditing:(id)editor { + NSLog(@"%@: %@", NSStringFromClass(self.class), NSStringFromSelector(_cmd)); + [super objectDidBeginEditing:editor]; +} + +- (void)objectDidEndEditing:(id)editor { + NSLog(@"%@: %@", NSStringFromClass(self.class), NSStringFromSelector(_cmd)); + [super objectDidEndEditing:editor]; +} + +- (BOOL)commitEditing { + NSLog(@"%@: %@", NSStringFromClass(self.class), NSStringFromSelector(_cmd)); + return [super commitEditing]; +} + +- (BOOL)commitEditingAndReturnError:(NSError *__autoreleasing _Nullable *)error { + NSLog(@"%@: %@", NSStringFromClass(self.class), NSStringFromSelector(_cmd)); + return [super commitEditingAndReturnError:error]; +} + +- (void)commitEditingWithDelegate:(id)delegate didCommitSelector:(SEL)didCommitSelector contextInfo:(void *)contextInfo { + NSLog(@"%@: %@", NSStringFromClass(self.class), NSStringFromSelector(_cmd)); + [super commitEditingWithDelegate:delegate didCommitSelector:didCommitSelector contextInfo:contextInfo]; } @end diff --git a/MacPass/MPEntryInspectorViewController.m b/MacPass/MPEntryInspectorViewController.m index c965b154..818dc6f3 100644 --- a/MacPass/MPEntryInspectorViewController.m +++ b/MacPass/MPEntryInspectorViewController.m @@ -774,4 +774,5 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) { - (void)_didRemoveAttribute:(NSNotification *)notification { } + @end diff --git a/MacPass/MPEntryPasswordAttributeViewController.m b/MacPass/MPEntryPasswordAttributeViewController.m index d032d7da..b4f457ef 100644 --- a/MacPass/MPEntryPasswordAttributeViewController.m +++ b/MacPass/MPEntryPasswordAttributeViewController.m @@ -35,7 +35,6 @@ [welf textField:welf.passwordTextField textView:(NSTextView *)text performAction:@selector(copy:)]; } }; - } - (void)updateValues { diff --git a/MacPass/MPInspectorEditor.h b/MacPass/MPInspectorEditor.h index 1ec5b897..4605e66d 100644 --- a/MacPass/MPInspectorEditor.h +++ b/MacPass/MPInspectorEditor.h @@ -24,7 +24,7 @@ NS_ASSUME_NONNULL_BEGIN @end /// NodeInspectorEditors require the represented object to be a KPKNode -@protocol KPKNodeInspectorEditor +@protocol MPNodeInspectorEditor @required @property (nonatomic, nullable, readonly, strong) KPKNode *representedNode; @end diff --git a/MacPass/MPNodeIconViewController.h b/MacPass/MPNodeIconViewController.h new file mode 100644 index 00000000..50c86feb --- /dev/null +++ b/MacPass/MPNodeIconViewController.h @@ -0,0 +1,18 @@ +// +// MPNodeIconViewController.h +// MacPass +// +// Created by Michael Starke on 02.03.22. +// Copyright © 2022 HicknHack Software GmbH. All rights reserved. +// + +#import +#import "MPInspectorEditor.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface MPNodeIconViewController : NSViewController + +@end + +NS_ASSUME_NONNULL_END diff --git a/MacPass/MPNodeIconViewController.m b/MacPass/MPNodeIconViewController.m new file mode 100644 index 00000000..1b9ab458 --- /dev/null +++ b/MacPass/MPNodeIconViewController.m @@ -0,0 +1,49 @@ +// +// MPNodeIconViewController.m +// MacPass +// +// Created by Michael Starke on 02.03.22. +// Copyright © 2022 HicknHack Software GmbH. All rights reserved. +// + +#import "MPNodeIconViewController.h" +#import + +@interface MPNodeIconViewController () + +@end + +@implementation MPNodeIconViewController + +@synthesize isEditor = _isEditor; + +- (void)viewDidLoad { + [super viewDidLoad]; +} + +- (void)setRepresentedObject:(id)representedObject { + +} + +- (KPKNode *)representedNode { + if([self.representedObject isKindOfClass:KPKNode.class]) { + return (KPKNode *)self.representedObject; + } + return nil; +} + +/* +- (void)commitChanges { + <#code#> +} + +- (BOOL)commitEditingAndReturnError:(NSError *__autoreleasing _Nullable * _Nullable)error { + <#code#> +} + +- (void)encodeWithCoder:(nonnull NSCoder *)coder { + <#code#> +} +*/ + +@end diff --git a/MacPass/MPNodeIconViewController.xib b/MacPass/MPNodeIconViewController.xib new file mode 100644 index 00000000..41494c21 --- /dev/null +++ b/MacPass/MPNodeIconViewController.xib @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MacPass/MPTOTPViewController.m b/MacPass/MPTOTPViewController.m index f33eabc0..a4ce6228 100644 --- a/MacPass/MPTOTPViewController.m +++ b/MacPass/MPTOTPViewController.m @@ -97,4 +97,11 @@ self.toptValueTextField.stringValue = @""; } } + + +- (BOOL)commitEditing { + NSLog(@"%@: %@", NSStringFromClass(self.class), NSStringFromSelector(_cmd)); + return [super commitEditing]; +} + @end