moved overlay display to MPPasteboardController

content copied in text fields now gets purged if clear-clipboard is set to true
This commit is contained in:
michael starke
2017-10-26 18:30:56 +02:00
parent 37fc5241ce
commit 509d0c84b2
14 changed files with 208 additions and 154 deletions

View File

@@ -38,6 +38,7 @@
#import "MPTemporaryFileStorageCenter.h"
#import "MPActionHelper.h"
#import "MPSettingsHelper.h"
#import "MPPasteBoardController.h"
#import "MPArrayController.h"
@@ -511,6 +512,41 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) {
}
#pragma mark -
#pragma mark HNHUITextFieldDelegate
- (NSMenu *)textField:(NSTextField *)textField textView:(NSTextView *)view menu:(NSMenu *)menu {
return menu;
}
- (BOOL)textField:(NSTextField *)textField textView:(NSTextView *)textView performAction:(SEL)action {
if(action == @selector(copy:)) {
MPPasteboardOverlayInfoType info = MPPasteboardOverlayInfoCustom;
NSString *value = textField.stringValue;
NSString *name = @"";
if(nil == value) {
return YES;
}
if(textField == self.usernameTextField) {
info = MPPasteboardOverlayInfoUsername;
}
else if(textField == self.passwordTextField) {
info = MPPasteboardOverlayInfoPassword;
}
else if(textField == self.URLTextField) {
info = MPPasteboardOverlayInfoURL;
}
else if(textField == self.uuidTextField) {
name = NSLocalizedString(@"UUID", "Displayed name when uuid field was copied");
}
else if(textField == self.titleTextField) {
name = NSLocalizedString(@"TITLE", "Displayed name when title field was copied");
}
[[MPPasteBoardController defaultController] copyObjects:@[value] overlayInfo:info name:name atView:self.view];
return NO;
}
return YES;
}
- (IBAction)toggleExpire:(NSButton*)sender {
if([sender state] == NSOnState && [self.representedEntry.timeInfo.expirationDate isEqualToDate:[NSDate distantFuture]]) {
[NSApp sendAction:self.pickExpireDateButton.action to:nil from:self.pickExpireDateButton];