mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-21 08:19:28 +00:00
Extended icon editor
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
#import "MPEntryAttributeViewController.h"
|
||||
#import "MPEntryPasswordAttributeViewController.h"
|
||||
#import "MPNodeExpirationViewController.h"
|
||||
#import "MPNodeIconViewController.h"
|
||||
|
||||
#import "MPPrettyPasswordTransformer.h"
|
||||
#import "NSString+MPPasswordCreation.h"
|
||||
@@ -91,6 +92,7 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) {
|
||||
@property (strong) MPEntryAttributeViewController *urlEditorViewController;
|
||||
@property (strong) MPNodeExpirationViewController *expiresEditorViewController;
|
||||
@property (strong) MPEntryPasswordAttributeViewController *passwordEditorViewController;
|
||||
@property (strong) MPNodeIconViewController *iconViewController;
|
||||
|
||||
|
||||
@property (strong) MPTemporaryFileStorage *quicklookStorage;
|
||||
@@ -603,6 +605,10 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) {
|
||||
}
|
||||
|
||||
- (void)_setupAttributeEditors {
|
||||
self.iconViewController = [[MPNodeIconViewController alloc] init];
|
||||
self.iconViewController.isEditor = NO;
|
||||
[self.fieldsStackView addArrangedSubview:self.iconViewController.view];
|
||||
|
||||
self.titleEditorViewController = [[MPEntryAttributeViewController alloc] init];
|
||||
self.titleEditorViewController.isEditor = NO;
|
||||
[self.fieldsStackView addArrangedSubview:self.titleEditorViewController.view];
|
||||
@@ -630,6 +636,7 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) {
|
||||
}
|
||||
|
||||
- (void)_updateEditors {
|
||||
self.iconViewController.representedObject = self.representedObject;
|
||||
self.totpViewController.representedObject = self.representedObject;
|
||||
self.expiresEditorViewController.representedObject = self.representedEntry.timeInfo;
|
||||
|
||||
|
||||
@@ -9,8 +9,11 @@
|
||||
#import "MPNodeIconViewController.h"
|
||||
#import <KeePassKit/KeePassKit.h>
|
||||
|
||||
@interface MPNodeIconViewController ()
|
||||
#import "KPKNode+IconImage.h"
|
||||
|
||||
@interface MPNodeIconViewController ()
|
||||
@property (strong) IBOutlet NSImageView *imageView;
|
||||
@property (strong) IBOutlet NSTextField *textField;
|
||||
@end
|
||||
|
||||
@implementation MPNodeIconViewController
|
||||
@@ -19,10 +22,42 @@
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
self.imageView.cell.backgroundStyle = NSBackgroundStyleRaised;
|
||||
self.textField.placeholderString = NSLocalizedString(@"NO_TITLE", @"Fallback to items with no title");
|
||||
}
|
||||
|
||||
- (void)setRepresentedObject:(id)representedObject {
|
||||
|
||||
// FIXME: register for correct notifications
|
||||
if(self.representedNode) {
|
||||
KPKNode *node = self.representedNode;
|
||||
if(node.asEntry) {
|
||||
[NSNotificationCenter.defaultCenter removeObserver:self name:KPKWillChangeEntryNotification object:self.representedObject];
|
||||
[NSNotificationCenter.defaultCenter removeObserver:self name:KPKDidChangeEntryNotification object:self.representedObject];
|
||||
}
|
||||
else if(node.asGroup) {
|
||||
[NSNotificationCenter.defaultCenter removeObserver:self name:KPKWillChangeGroupNotification object:self.representedObject];
|
||||
[NSNotificationCenter.defaultCenter removeObserver:self name:KPKDidChangeGroupNotification object:self.representedObject];
|
||||
}
|
||||
else {
|
||||
NSLog(@"Inconsitant state for notification handling");
|
||||
}
|
||||
}
|
||||
super.representedObject = representedObject;
|
||||
if(self.representedNode) {
|
||||
KPKNode *node = self.representedNode;
|
||||
if(node.asEntry) {
|
||||
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_willChangeNode:) name:KPKWillChangeEntryNotification object:self.representedObject];
|
||||
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_didChangeNode:) name:KPKDidChangeEntryNotification object:self.representedObject];
|
||||
}
|
||||
else if(node.asGroup) {
|
||||
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_willChangeNode:) name:KPKWillChangeGroupNotification object:self.representedObject];
|
||||
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_didChangeNode:) name:KPKDidChangeGroupNotification object:self.representedObject];
|
||||
}
|
||||
else {
|
||||
NSLog(@"Inconsitant state for notification handling");
|
||||
}
|
||||
}
|
||||
[self _updateValues];
|
||||
}
|
||||
|
||||
- (KPKNode *)representedNode {
|
||||
@@ -32,11 +67,24 @@
|
||||
return nil;
|
||||
}
|
||||
|
||||
/*
|
||||
- (void)commitChanges {
|
||||
<#code#>
|
||||
- (void)_updateValues {
|
||||
self.imageView.image = self.representedNode.iconImage;
|
||||
self.textField.stringValue = self.representedNode.title.length > 0 ? self.representedNode.title : @"";
|
||||
}
|
||||
|
||||
- (void)commitChanges {
|
||||
// fixme
|
||||
}
|
||||
|
||||
|
||||
- (void)_willChangeNode:(NSNotification *)notification {
|
||||
|
||||
}
|
||||
|
||||
- (void)_didChangeNode:(NSNotification *)notification {
|
||||
[self _updateValues];
|
||||
}
|
||||
/*
|
||||
- (BOOL)commitEditingAndReturnError:(NSError *__autoreleasing _Nullable * _Nullable)error {
|
||||
<#code#>
|
||||
}
|
||||
|
||||
@@ -8,33 +8,43 @@
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="MPNodeIconViewController">
|
||||
<connections>
|
||||
<outlet property="imageView" destination="7kO-Kv-UI5" id="rTv-Pp-R1I"/>
|
||||
<outlet property="textField" destination="xou-fD-adZ" id="n93-XV-5dq"/>
|
||||
<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"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="495" height="32"/>
|
||||
<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"/>
|
||||
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="7kO-Kv-UI5">
|
||||
<rect key="frame" x="0.0" y="0.0" width="32" height="32"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="48" id="VD7-b8-cKP"/>
|
||||
<constraint firstAttribute="height" constant="48" id="g13-f2-0hR"/>
|
||||
<constraint firstAttribute="width" constant="32" id="VD7-b8-cKP"/>
|
||||
<constraint firstAttribute="height" constant="32" id="g13-f2-0hR"/>
|
||||
</constraints>
|
||||
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyUpOrDown" image="NSActionTemplate" id="09t-w3-euN"/>
|
||||
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyUpOrDown" id="09t-w3-euN"/>
|
||||
</imageView>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="xou-fD-adZ">
|
||||
<rect key="frame" x="38" y="8" width="439" height="16"/>
|
||||
<textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="aKF-2z-5ob">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
</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"/>
|
||||
<constraint firstItem="xou-fD-adZ" firstAttribute="centerY" secondItem="7kO-Kv-UI5" secondAttribute="centerY" id="0C4-8O-cQb"/>
|
||||
<constraint firstAttribute="bottom" secondItem="7kO-Kv-UI5" secondAttribute="bottom" id="DhE-aA-Ovp"/>
|
||||
<constraint firstItem="xou-fD-adZ" firstAttribute="leading" secondItem="7kO-Kv-UI5" secondAttribute="trailing" constant="8" symbolic="YES" id="Elf-Iw-tmF"/>
|
||||
<constraint firstItem="7kO-Kv-UI5" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" id="axe-Q2-16O"/>
|
||||
<constraint firstItem="7kO-Kv-UI5" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" id="nCQ-tS-CIv"/>
|
||||
<constraint firstAttribute="trailing" secondItem="xou-fD-adZ" secondAttribute="trailing" constant="20" symbolic="YES" id="qYf-Ov-k32"/>
|
||||
</constraints>
|
||||
<point key="canvasLocation" x="24" y="40.5"/>
|
||||
<point key="canvasLocation" x="231.5" y="-13.5"/>
|
||||
</customView>
|
||||
</objects>
|
||||
<resources>
|
||||
<image name="NSActionTemplate" width="15" height="15"/>
|
||||
</resources>
|
||||
</document>
|
||||
|
||||
Reference in New Issue
Block a user