mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-13 08:52:20 +00:00
Show custom attribute key when copied into clipboard
This commit is contained in:
2
Cartfile
2
Cartfile
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user