mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-22 17:39:24 +00:00
Added editor for node icons
This commit is contained in:
@@ -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 = "<group>"; };
|
||||
4C978E0C19AE54AB003067DF /* MPFlagsHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPFlagsHelper.m; sourceTree = "<group>"; };
|
||||
4C97CCEF1FA727DC00E58F8C /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||
4C98A6C927CFAB1800CD912F /* MPNodeIconViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MPNodeIconViewController.h; sourceTree = "<group>"; };
|
||||
4C98A6CA27CFAB1900CD912F /* MPNodeIconViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MPNodeIconViewController.m; sourceTree = "<group>"; };
|
||||
4C98A6CB27CFAB1900CD912F /* MPNodeIconViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MPNodeIconViewController.xib; sourceTree = "<group>"; };
|
||||
4C9BFFF91FD19B5400264B16 /* MPPrettyPasswordTransformer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MPPrettyPasswordTransformer.h; sourceTree = "<group>"; };
|
||||
4C9BFFFA1FD19B5400264B16 /* MPPrettyPasswordTransformer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MPPrettyPasswordTransformer.m; sourceTree = "<group>"; };
|
||||
4C9FE47423703DA50096A5EA /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||
@@ -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 = "<group>";
|
||||
@@ -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 */,
|
||||
|
||||
@@ -277,7 +277,7 @@
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="249" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="IpW-b2-jWu" customClass="HNHUITextField">
|
||||
<rect key="frame" x="20" y="48" width="251" height="21"/>
|
||||
<rect key="frame" x="22" y="48" width="247" height="21"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="Hml-NR-AeS">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="19455" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="19529" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="19455"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="19529"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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<NSEditor>)editor {
|
||||
NSLog(@"%@: %@", NSStringFromClass(self.class), NSStringFromSelector(_cmd));
|
||||
[super objectDidBeginEditing:editor];
|
||||
}
|
||||
|
||||
- (void)objectDidEndEditing:(id<NSEditor>)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
|
||||
|
||||
@@ -774,4 +774,5 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) {
|
||||
- (void)_didRemoveAttribute:(NSNotification *)notification {
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
[welf textField:welf.passwordTextField textView:(NSTextView *)text performAction:@selector(copy:)];
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
- (void)updateValues {
|
||||
|
||||
@@ -24,7 +24,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@end
|
||||
|
||||
/// NodeInspectorEditors require the represented object to be a KPKNode
|
||||
@protocol KPKNodeInspectorEditor <MPInspectorEditor>
|
||||
@protocol MPNodeInspectorEditor <MPInspectorEditor>
|
||||
@required
|
||||
@property (nonatomic, nullable, readonly, strong) KPKNode *representedNode;
|
||||
@end
|
||||
|
||||
18
MacPass/MPNodeIconViewController.h
Normal file
18
MacPass/MPNodeIconViewController.h
Normal file
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// MPNodeIconViewController.h
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 02.03.22.
|
||||
// Copyright © 2022 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "MPInspectorEditor.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface MPNodeIconViewController : NSViewController <MPNodeInspectorEditor>
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
49
MacPass/MPNodeIconViewController.m
Normal file
49
MacPass/MPNodeIconViewController.m
Normal file
@@ -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 <KeePassKit/KeePassKit.h>
|
||||
|
||||
@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
|
||||
40
MacPass/MPNodeIconViewController.xib
Normal file
40
MacPass/MPNodeIconViewController.xib
Normal file
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="19529" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="19529"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="MPNodeIconViewController">
|
||||
<connections>
|
||||
<outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<customView id="Hz6-mo-xeY">
|
||||
<rect key="frame" x="0.0" y="0.0" width="246" height="88"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<subviews>
|
||||
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="7kO-Kv-UI5" customClass="MPIconImageView">
|
||||
<rect key="frame" x="99" y="17" width="48" height="54"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="48" id="VD7-b8-cKP"/>
|
||||
<constraint firstAttribute="height" constant="48" id="g13-f2-0hR"/>
|
||||
</constraints>
|
||||
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyUpOrDown" image="NSActionTemplate" id="09t-w3-euN"/>
|
||||
</imageView>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstAttribute="bottom" secondItem="7kO-Kv-UI5" secondAttribute="bottom" constant="20" symbolic="YES" id="DhE-aA-Ovp"/>
|
||||
<constraint firstItem="7kO-Kv-UI5" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" constant="20" symbolic="YES" id="nCQ-tS-CIv"/>
|
||||
<constraint firstItem="7kO-Kv-UI5" firstAttribute="centerX" secondItem="Hz6-mo-xeY" secondAttribute="centerX" id="v1c-QL-UBe"/>
|
||||
</constraints>
|
||||
<point key="canvasLocation" x="24" y="40.5"/>
|
||||
</customView>
|
||||
</objects>
|
||||
<resources>
|
||||
<image name="NSActionTemplate" width="15" height="15"/>
|
||||
</resources>
|
||||
</document>
|
||||
@@ -97,4 +97,11 @@
|
||||
self.toptValueTextField.stringValue = @"";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (BOOL)commitEditing {
|
||||
NSLog(@"%@: %@", NSStringFromClass(self.class), NSStringFromSelector(_cmd));
|
||||
return [super commitEditing];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user