From 3db0e55b8fa149b7d3ef0e97df0bdde97a96736e Mon Sep 17 00:00:00 2001 From: michael starke Date: Mon, 6 Nov 2017 11:52:35 +0100 Subject: [PATCH] moved reference builder popup code to entry inspector --- MacPass/MPAutotypeBuilderViewController.h | 5 ++++- MacPass/MPAutotypeBuilderViewController.m | 5 ++--- MacPass/MPEntryInspectorViewController.h | 2 ++ MacPass/MPEntryInspectorViewController.m | 23 +++++++++++++++++++++-- MacPass/MPIconSelectViewController.m | 2 +- MacPass/MPInspectorViewController.h | 1 - MacPass/MPInspectorViewController.m | 12 ------------ 7 files changed, 30 insertions(+), 20 deletions(-) diff --git a/MacPass/MPAutotypeBuilderViewController.h b/MacPass/MPAutotypeBuilderViewController.h index 3ff1ac58..b1b87c97 100644 --- a/MacPass/MPAutotypeBuilderViewController.h +++ b/MacPass/MPAutotypeBuilderViewController.h @@ -24,6 +24,9 @@ @interface MPAutotypeBuilderViewController : NSViewController -- (void)presentBuilderWithSequence:(NSString *)sequence; +/** + Populate the autotype builder with a sequence. + */ +@property (nonatomic,copy) NSString *sequence; @end diff --git a/MacPass/MPAutotypeBuilderViewController.m b/MacPass/MPAutotypeBuilderViewController.m index 46606f9f..800526af 100644 --- a/MacPass/MPAutotypeBuilderViewController.m +++ b/MacPass/MPAutotypeBuilderViewController.m @@ -69,9 +69,8 @@ self.commandBuilderTokenField.delegate = self; } -- (void)presentBuilderWithSequence:(NSString *)sequence { - // TODO: tokenize input sequence! - //self.commandBuilderTokenField.stringValue = sequence; +- (void)setSequence:(NSString *)sequence { + self.commandBuilderTokenField.stringValue = sequence; } - (IBAction)addCustomKeyPlaceholder:(id)sender { diff --git a/MacPass/MPEntryInspectorViewController.h b/MacPass/MPEntryInspectorViewController.h index 3d250e35..7a1e7e26 100644 --- a/MacPass/MPEntryInspectorViewController.h +++ b/MacPass/MPEntryInspectorViewController.h @@ -77,6 +77,8 @@ - (void)registerNotificationsForDocument:(MPDocument *)document; - (IBAction)showPasswordGenerator:(id)sender; +- (IBAction)showReferenceBuilder:(id)sender; +- (IBAction)showAutotypeBuilder:(id)sender; - (IBAction)saveAttachment:(id)sender; - (IBAction)addAttachment:(id)sender; diff --git a/MacPass/MPEntryInspectorViewController.m b/MacPass/MPEntryInspectorViewController.m index 0cef048c..df4eb5d7 100644 --- a/MacPass/MPEntryInspectorViewController.m +++ b/MacPass/MPEntryInspectorViewController.m @@ -29,6 +29,7 @@ #import "MPWindowAssociationsTableViewDelegate.h" #import "MPWindowTitleComboBoxDelegate.h" #import "MPAutotypeBuilderViewController.h" +#import "MPReferenceBuilderViewController.h" #import "NSString+MPPasswordCreation.h" @@ -317,11 +318,29 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) { #pragma mark - #pragma mark Popovers +- (IBAction)showReferenceBuilder:(id)sender { + NSView *location; + if([sender isKindOfClass:NSView.class]) { + location = sender; + } + else if([sender isKindOfClass:NSMenuItem.class]) { + location = [sender representedObject]; + } + [self _showPopopver:[[MPReferenceBuilderViewController alloc] init] atView:location onEdge:NSMinYEdge]; +} + - (IBAction)showAutotypeBuilder:(id)sender { - [sender setEnabled:NO]; + NSView *location; + if([sender isKindOfClass:NSButton.class]) { + location = sender; + [sender setEnabled:NO]; + } + if([sender isKindOfClass:NSMenuItem.class]){ + location = [sender representedObject]; + } MPAutotypeBuilderViewController *autotypeBuilder = [[MPAutotypeBuilderViewController alloc] init]; autotypeBuilder.representedObject = self.representedObject; - [self _showPopopver:autotypeBuilder atView:sender onEdge:NSMinYEdge]; + [self _showPopopver:autotypeBuilder atView:location onEdge:NSMinYEdge]; } - (IBAction)showPasswordGenerator:(id)sender { diff --git a/MacPass/MPIconSelectViewController.m b/MacPass/MPIconSelectViewController.m index 7d86257a..f010b548 100644 --- a/MacPass/MPIconSelectViewController.m +++ b/MacPass/MPIconSelectViewController.m @@ -120,7 +120,7 @@ typedef NS_ENUM(NSInteger, MPIconDownloadStatus) { if(error) { dispatch_async(dispatch_get_main_queue(), ^{ self.downloadStatus = MPIconDownloadStatusError; - [NSApp presentError:error]; + //[NSApp presentError:error]; }); } if(data.length > 0) { diff --git a/MacPass/MPInspectorViewController.h b/MacPass/MPInspectorViewController.h index 666367a0..bafd1254 100644 --- a/MacPass/MPInspectorViewController.h +++ b/MacPass/MPInspectorViewController.h @@ -39,7 +39,6 @@ - (IBAction)pickIcon:(id)sender; - (IBAction)pickExpiryDate:(id)sender; - (IBAction)showPluginData:(id)sender; -- (IBAction)showReferenceBuilder:(id)sender; /* Separate call to ensure all registered objects are in place */ - (void)registerNotificationsForDocument:(NSDocument *)document; diff --git a/MacPass/MPInspectorViewController.m b/MacPass/MPInspectorViewController.m index 907d69c5..28b9b09a 100644 --- a/MacPass/MPInspectorViewController.m +++ b/MacPass/MPInspectorViewController.m @@ -30,7 +30,6 @@ #import "MPIconImageView.h" #import "MPNotifications.h" #import "MPPluginDataViewController.h" -#import "MPReferenceBuilderViewController.h" #import "KeePassKit/KeePassKit.h" @@ -196,17 +195,6 @@ typedef NS_ENUM(NSUInteger, MPContentTab) { [self _popupViewController:[[MPPluginDataViewController alloc] init] atView:sender]; } -- (IBAction)showReferenceBuilder:(id)sender { - NSView *location; - if([sender isKindOfClass:NSView.class]) { - location = sender; - } - else if([sender isKindOfClass:NSMenuItem.class]) { - location = [sender representedObject]; - } - [self _popupViewController:[[MPReferenceBuilderViewController alloc] init] atView:location]; -} - - (void)_popupViewController:(MPViewController *)vc atView:(NSView *)view { if(self.popover) { return; // Popover still active, abort