Show custom attribute key when copied into clipboard

This commit is contained in:
michael starke
2017-11-14 18:52:31 +01:00
parent adcd80b2ab
commit 4d4d611dd4
5 changed files with 27 additions and 2 deletions

View File

@@ -1,3 +1,3 @@
github "sparkle-project/Sparkle" ~> 1.18.1
github "MacPass/KeePassKit" ~> 1.7
github "MacPass/KeePassKit" ~> 1.7.1
github "mstarke/HNHUi" ~> 1.4.1

View File

@@ -1,3 +1,3 @@
github "MacPass/KeePassKit" "1.7"
github "MacPass/KeePassKit" "1.7.1"
github "mstarke/HNHUi" "1.4.1"
github "sparkle-project/Sparkle" "1.18.1"

View File

@@ -24,6 +24,15 @@
@class MPInspectorViewController;
/**
Determines the index of the custom Attribute from the a tag value
@param tag Tag value (e.g. from the input filed inside the table view row)
@return the row number of the custom attribute, if tag is no row then -1 is returned
*/
NSInteger MPCustomFieldIndexFromTag(NSInteger tag);
@interface MPCustomFieldTableViewDelegate : NSObject <NSTableViewDelegate>
@property (weak, nonatomic) id viewController;

View File

@@ -26,6 +26,12 @@
#import "HNHUi/HNHUi.h"
#import "KeePassKit/KeePassKit.h"
NSInteger MPCustomFieldTagOffset = 50000;
NSInteger MPCustomFieldIndexFromTag(NSInteger tag) {
return MAX(-1, tag - MPCustomFieldTagOffset);
}
@implementation MPCustomFieldTableViewDelegate
@@ -73,12 +79,16 @@
options:@{NSConditionallySetsEditableBindingOption: @NO }];
}
view.valueTextField.tag = (MPCustomFieldTagOffset + row);
view.valueTextField.delegate = self.viewController;
view.removeButton.target = self.viewController;
view.removeButton.action = @selector(removeCustomField:);
view.removeButton.tag = row;
view.observer = tableView.window.windowController.document;
return view;
}

View File

@@ -577,6 +577,12 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) {
else if(textField == self.titleTextField) {
name = NSLocalizedString(@"TITLE", "Displayed name when title field was copied");
}
else {
NSInteger index = MPCustomFieldIndexFromTag(textField.tag);
if(index > -1) {
name = [_customFieldsController.arrangedObjects[index] key];
}
}
[[MPPasteBoardController defaultController] copyObjects:@[value] overlayInfo:info name:name atView:self.view];
return NO;
}