mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-13 08:52:20 +00:00
allow for drag and drop on iconImageView to update custom icons
This commit is contained in:
@@ -235,7 +235,7 @@
|
||||
4CE298EB1795FC2A00DF7BDB /* MPEntryContextMenuDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CE298EA1795FC2A00DF7BDB /* MPEntryContextMenuDelegate.m */; };
|
||||
4CE30ACC1A312B7F0063FCC6 /* MPReferenceBuilderViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CE30ACB1A312B7F0063FCC6 /* MPReferenceBuilderViewController.m */; };
|
||||
4CE39ABF16ECE34A000FE29D /* MPIconSelectViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CE39ABE16ECE34A000FE29D /* MPIconSelectViewController.m */; };
|
||||
4CE39AC416ECE4F7000FE29D /* MPPopupImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CE39AC316ECE4F7000FE29D /* MPPopupImageView.m */; };
|
||||
4CE39AC416ECE4F7000FE29D /* MPIconImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CE39AC316ECE4F7000FE29D /* MPIconImageView.m */; };
|
||||
4CE3E62617AB0D2D00D9E4B4 /* MPAttachmentTableDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CE3E62517AB0D2D00D9E4B4 /* MPAttachmentTableDataSource.m */; };
|
||||
4CE501341BBC47F500FB819D /* MPTagsTokenFieldDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CE501331BBC47F500FB819D /* MPTagsTokenFieldDelegate.m */; };
|
||||
4CE5B54B173AFBA700207B39 /* MPDocument.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CE5B549173AFBA700207B39 /* MPDocument.m */; };
|
||||
@@ -705,8 +705,8 @@
|
||||
4CE30ACB1A312B7F0063FCC6 /* MPReferenceBuilderViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPReferenceBuilderViewController.m; sourceTree = "<group>"; };
|
||||
4CE39ABD16ECE34A000FE29D /* MPIconSelectViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPIconSelectViewController.h; sourceTree = "<group>"; };
|
||||
4CE39ABE16ECE34A000FE29D /* MPIconSelectViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPIconSelectViewController.m; sourceTree = "<group>"; };
|
||||
4CE39AC216ECE4F7000FE29D /* MPPopupImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPPopupImageView.h; sourceTree = "<group>"; };
|
||||
4CE39AC316ECE4F7000FE29D /* MPPopupImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPPopupImageView.m; sourceTree = "<group>"; };
|
||||
4CE39AC216ECE4F7000FE29D /* MPIconImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPIconImageView.h; sourceTree = "<group>"; };
|
||||
4CE39AC316ECE4F7000FE29D /* MPIconImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPIconImageView.m; sourceTree = "<group>"; };
|
||||
4CE3E62417AB0D2D00D9E4B4 /* MPAttachmentTableDataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPAttachmentTableDataSource.h; sourceTree = "<group>"; };
|
||||
4CE3E62517AB0D2D00D9E4B4 /* MPAttachmentTableDataSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPAttachmentTableDataSource.m; sourceTree = "<group>"; };
|
||||
4CE501321BBC47F500FB819D /* MPTagsTokenFieldDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPTagsTokenFieldDelegate.h; sourceTree = "<group>"; };
|
||||
@@ -886,8 +886,8 @@
|
||||
4CE8247416E2F2B900573141 /* MPOverlayView.m */,
|
||||
4CFC53BD16E94729007396BE /* MPShadowBox.h */,
|
||||
4CFC53BE16E94729007396BE /* MPShadowBox.m */,
|
||||
4CE39AC216ECE4F7000FE29D /* MPPopupImageView.h */,
|
||||
4CE39AC316ECE4F7000FE29D /* MPPopupImageView.m */,
|
||||
4CE39AC216ECE4F7000FE29D /* MPIconImageView.h */,
|
||||
4CE39AC316ECE4F7000FE29D /* MPIconImageView.m */,
|
||||
4C4A100D176286FD00BBF2CA /* MPTableView.h */,
|
||||
4C4A100E176286FD00BBF2CA /* MPTableView.m */,
|
||||
4C4FCE13177CFE6B00BBF7AE /* MPCustomFieldTableCellView.h */,
|
||||
@@ -1772,7 +1772,7 @@
|
||||
4C811C8316ECD06E00C4BAC6 /* MPKeyfilePathControlDelegate.m in Sources */,
|
||||
4CDA35751EBA0CF2003CD59F /* NSString+MPComposedCharacterAdditions.m in Sources */,
|
||||
4CE39ABF16ECE34A000FE29D /* MPIconSelectViewController.m in Sources */,
|
||||
4CE39AC416ECE4F7000FE29D /* MPPopupImageView.m in Sources */,
|
||||
4CE39AC416ECE4F7000FE29D /* MPIconImageView.m in Sources */,
|
||||
4C46B88517063A070046109A /* NSString+MPPasswordCreation.m in Sources */,
|
||||
4C5A11FE1708DE8700223D8A /* MPPasswordCreatorViewController.m in Sources */,
|
||||
4CE5B54B173AFBA700207B39 /* MPDocument.m in Sources */,
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
<color key="primaryBackgroundColor" name="windowBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
<connections>
|
||||
<outlet property="itemPrototype" destination="61" id="63"/>
|
||||
<outlet property="menu" destination="vS0-bP-ZyJ" id="nAW-cJ-Vzp"/>
|
||||
</connections>
|
||||
</collectionView>
|
||||
</subviews>
|
||||
@@ -158,20 +157,6 @@
|
||||
<constraint firstItem="MEC-x9-zrX" firstAttribute="top" secondItem="113" secondAttribute="top" id="uEr-Jk-Jfa"/>
|
||||
</constraints>
|
||||
</customView>
|
||||
<menu id="vS0-bP-ZyJ">
|
||||
<items>
|
||||
<menuItem title="Item 1" id="M2B-II-30N">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
</menuItem>
|
||||
<menuItem title="Item 2" id="Vc1-gW-L1b">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
</menuItem>
|
||||
<menuItem title="Item 3" id="cUN-GX-EWu">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
</menuItem>
|
||||
</items>
|
||||
<point key="canvasLocation" x="298" y="163"/>
|
||||
</menu>
|
||||
</objects>
|
||||
<resources>
|
||||
<image name="NSAddTemplate" width="11" height="11"/>
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="12120" systemVersion="16E195" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="12121" systemVersion="16G29" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="12120"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="12121"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
@@ -22,7 +21,7 @@
|
||||
<customView translatesAutoresizingMaskIntoConstraints="NO" id="2894">
|
||||
<rect key="frame" x="0.0" y="0.0" width="278" height="662"/>
|
||||
<subviews>
|
||||
<imageView translatesAutoresizingMaskIntoConstraints="NO" id="2998" customClass="MPPopupImageView">
|
||||
<imageView translatesAutoresizingMaskIntoConstraints="NO" id="2998" customClass="MPIconImageView">
|
||||
<rect key="frame" x="20" y="620" width="32" height="32"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="32" id="3027"/>
|
||||
@@ -31,16 +30,16 @@
|
||||
<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="enabled" keyPath="representedObject.isHistory" id="7Z5-A7-aqg">
|
||||
<dictionary key="options">
|
||||
<string key="NSValueTransformerName">NSNegateBoolean</string>
|
||||
</dictionary>
|
||||
</binding>
|
||||
<binding destination="-2" name="value" keyPath="representedObject.iconImage" id="agf-eg-okr">
|
||||
<dictionary key="options">
|
||||
<bool key="NSConditionallySetsEnabled" value="NO"/>
|
||||
</dictionary>
|
||||
</binding>
|
||||
<binding destination="-2" name="enabled" keyPath="representedObject.isHistory" id="7Z5-A7-aqg">
|
||||
<dictionary key="options">
|
||||
<string key="NSValueTransformerName">NSNegateBoolean</string>
|
||||
</dictionary>
|
||||
</binding>
|
||||
</connections>
|
||||
</imageView>
|
||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="249" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="3013">
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#import "MPEntryInspectorViewController.h"
|
||||
#import "MPEntryViewController.h"
|
||||
#import "MPDocumentWindowController.h"
|
||||
#import "MPIconSelectViewController.h"
|
||||
|
||||
@implementation MPActionHelper
|
||||
|
||||
|
||||
@@ -22,6 +22,12 @@
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface MPPopupImageView : NSImageView
|
||||
@protocol MPModelChangeObserving;
|
||||
@class KPKNode;
|
||||
|
||||
@interface MPIconImageView : NSImageView
|
||||
|
||||
@property (weak, nullable) id<MPModelChangeObserving> modelChangeObserver;
|
||||
@property (weak, nullable) KPKNode *node;
|
||||
|
||||
@end
|
||||
@@ -20,13 +20,15 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
#import "MPPopupImageView.h"
|
||||
#import "MPIconImageView.h"
|
||||
#import "MPModelChangeObserving.h"
|
||||
#import "MPDocument.h"
|
||||
|
||||
#define MPTRIANGLE_HEIGHT 8
|
||||
#define MPTRIANGLE_WIDTH 10
|
||||
#define MPTRIANGLE_OFFSET 2
|
||||
|
||||
@interface MPPopupImageView ()
|
||||
@interface MPIconImageView ()
|
||||
|
||||
@property (assign) BOOL showOverlay;
|
||||
|
||||
@@ -34,7 +36,7 @@
|
||||
|
||||
@end
|
||||
|
||||
@implementation MPPopupImageView
|
||||
@implementation MPIconImageView
|
||||
|
||||
- (id)initWithFrame:(NSRect)frameRect {
|
||||
self = [super initWithFrame:frameRect];
|
||||
@@ -57,7 +59,7 @@
|
||||
|
||||
if(self.showOverlay && self.enabled) {
|
||||
[[NSGraphicsContext currentContext] saveGraphicsState];
|
||||
|
||||
|
||||
NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:[self bounds] xRadius:4 yRadius:4];
|
||||
|
||||
NSShadow *shadow = [[NSShadow alloc] init];
|
||||
@@ -65,7 +67,7 @@
|
||||
shadow.shadowOffset = NSMakeSize(0, 0);
|
||||
shadow.shadowColor = [NSColor colorWithCalibratedWhite:0.2 alpha:1];
|
||||
[shadow set];
|
||||
|
||||
|
||||
[path addClip];
|
||||
[[NSColor colorWithCalibratedWhite:1 alpha:0.2] setFill];
|
||||
[path fill];
|
||||
@@ -96,6 +98,7 @@
|
||||
}
|
||||
|
||||
- (void)_setupView {
|
||||
[self registerForDraggedTypes:@[(NSString *)kUTTypeURL, (NSString *)kUTTypeFileURL]];
|
||||
/* Add tracking area for mouse events */
|
||||
NSTrackingArea *trackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds]
|
||||
options:(NSTrackingMouseEnteredAndExited | NSTrackingActiveInKeyWindow)
|
||||
@@ -104,4 +107,32 @@
|
||||
[self addTrackingArea:trackingArea];
|
||||
}
|
||||
|
||||
- (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender {
|
||||
return NSDragOperationCopy;
|
||||
}
|
||||
|
||||
- (void)setImage:(NSImage *)image {
|
||||
/*
|
||||
setImage is only called via drag'n'drop. We are bound so we ignore this.
|
||||
*/
|
||||
}
|
||||
|
||||
- (BOOL)performDragOperation:(id<NSDraggingInfo>)sender {
|
||||
NSPasteboard *pBoard = [sender draggingPasteboard];
|
||||
NSArray *urls = [pBoard readObjectsForClasses:@[NSURL.class] options:@{ NSPasteboardURLReadingFileURLsOnlyKey : @YES }];
|
||||
if(urls.count != 1) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
KPKIcon *icon = [[KPKIcon alloc] initWithImageAtURL:urls.firstObject];
|
||||
if(icon.image) {
|
||||
MPDocument *document = [NSDocumentController sharedDocumentController].currentDocument;
|
||||
[document.tree.metaData addCustomIcon:icon];
|
||||
}
|
||||
[self.modelChangeObserver willChangeModelProperty];
|
||||
self.node.iconUUID = icon.uuid;
|
||||
[self.modelChangeObserver didChangeModelProperty];
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -94,6 +94,11 @@
|
||||
[task resume];
|
||||
}
|
||||
|
||||
- (void)deleteIcon:(id)sender {
|
||||
|
||||
}
|
||||
|
||||
|
||||
- (void)_deleteIcon:(KPKIcon *)icon {
|
||||
NSUInteger iconIndex = [self.iconCollectionView.content indexOfObject:icon];
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#import "MPViewController.h"
|
||||
|
||||
@class HNHUIGradientView;
|
||||
@class MPPopupImageView;
|
||||
@class MPIconImageView;
|
||||
|
||||
@interface MPInspectorViewController : MPViewController <NSPopoverDelegate>
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
@property (weak) IBOutlet NSTextField *createdTextField;
|
||||
@property (weak) IBOutlet NSTextField *modifiedTextField;
|
||||
@property (weak) IBOutlet NSTextField *noSelectionInfo;
|
||||
@property (weak) IBOutlet MPPopupImageView *itemImageView;
|
||||
@property (weak) IBOutlet MPIconImageView *itemImageView;
|
||||
@property (weak) IBOutlet NSTextField *itemNameTextField;
|
||||
@property (weak) IBOutlet NSButton *saveChangesButton;
|
||||
@property (weak) IBOutlet NSButton *discardChangesButton;
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
#import "MPGroupInspectorViewController.h"
|
||||
#import "MPIconHelper.h"
|
||||
#import "MPIconSelectViewController.h"
|
||||
#import "MPIconImageView.h"
|
||||
#import "MPNotifications.h"
|
||||
#import "MPPopupImageView.h"
|
||||
#import "MPPluginDataViewController.h"
|
||||
|
||||
#import "KeePassKit/KeePassKit.h"
|
||||
@@ -135,6 +135,7 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
|
||||
object:document];
|
||||
|
||||
self.entryViewController.observer = document;
|
||||
self.itemImageView.modelChangeObserver = document;
|
||||
self.observer = document;
|
||||
|
||||
[self.entryViewController registerNotificationsForDocument:document];
|
||||
@@ -249,6 +250,7 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
|
||||
[self.groupViewController commitEditing];
|
||||
|
||||
self.representedObject = node;
|
||||
self.itemImageView.node = node;
|
||||
self.entryViewController.representedObject = node.asEntry;
|
||||
self.groupViewController.representedObject = node.asGroup;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user