mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-19 02:39:21 +00:00
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:
@@ -22,6 +22,7 @@
|
||||
|
||||
#import "MPPasteBoardController.h"
|
||||
#import "MPSettingsHelper.h"
|
||||
#import "MPOverlayWindowController.h"
|
||||
|
||||
/* Notifications */
|
||||
NSString *const MPPasteBoardControllerDidCopyObjects = @"com.hicknhack.macpass.MPPasteBoardControllerDidCopyObjects";
|
||||
@@ -105,6 +106,37 @@ NSString *const MPPasteBoardControllerDidClearClipboard = @"com.hicknhack.macpas
|
||||
self.isEmpty = NO;
|
||||
}
|
||||
|
||||
- (void)copyObjects:(NSArray<id<NSPasteboardWriting>> *)objects overlayInfo:(MPPasteboardOverlayInfoType)overlayInfoType name:(NSString *)name atView:(NSView *)view{
|
||||
if(!objects) {
|
||||
return;
|
||||
}
|
||||
[MPPasteBoardController.defaultController copyObjects:objects];
|
||||
NSImage *infoImage = nil;
|
||||
NSString *infoText = nil;
|
||||
switch(overlayInfoType) {
|
||||
case MPPasteboardOverlayInfoPassword:
|
||||
infoImage = [[NSBundle mainBundle] imageForResource:@"00_PasswordTemplate"];
|
||||
infoText = NSLocalizedString(@"COPIED_PASSWORD", @"Password was copied to the pasteboard");
|
||||
break;
|
||||
|
||||
case MPPasteboardOverlayInfoURL:
|
||||
infoImage = [[NSBundle mainBundle] imageForResource:@"01_PackageNetworkTemplate"];
|
||||
infoText = NSLocalizedString(@"COPIED_URL", @"URL was copied to the pasteboard");
|
||||
break;
|
||||
|
||||
case MPPasteboardOverlayInfoUsername:
|
||||
infoImage = [[NSBundle mainBundle] imageForResource:@"09_IdentityTemplate"];
|
||||
infoText = NSLocalizedString(@"COPIED_USERNAME", @"Username was copied to the pasteboard");
|
||||
break;
|
||||
|
||||
case MPPasteboardOverlayInfoCustom:
|
||||
infoImage = [[NSBundle mainBundle] imageForResource:@"00_PasswordTemplate"];
|
||||
infoText = [NSString stringWithFormat:NSLocalizedString(@"COPIED_FIELD_%@", "Field name that was copied to the pasteboard"), name];
|
||||
break;
|
||||
}
|
||||
[[MPOverlayWindowController sharedController] displayOverlayImage:infoImage label:infoText atView:view];
|
||||
}
|
||||
|
||||
- (void)_clearPasteboardContents {
|
||||
/* Only clear stuff we might have put there */
|
||||
if(!self.isEmpty) {
|
||||
|
||||
Reference in New Issue
Block a user