mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-25 10:09:28 +00:00
Extracted context menu operations into MPContextMenuHelper
Removed private declarations as they aren't needed for the compiler anymore Fixed drawing order in MPPopupImageView Fixed #7 Error occurred due to duplicate shortcut. Copy Password now is bound to ⌘+⌥+C
This commit is contained in:
@@ -8,12 +8,9 @@
|
||||
|
||||
#import "MPAppDelegate.h"
|
||||
|
||||
#import "MPDocumentWindowController.h"
|
||||
#import "MPSettingsWindowController.h"
|
||||
#import "MPPasswordCreatorViewController.h"
|
||||
#import "MPActionHelper.h"
|
||||
#import "MPSettingsHelper.h"
|
||||
#import "NSString+MPPasswordCreation.h"
|
||||
#import "MPUppercaseStringValueTransformer.h"
|
||||
|
||||
@interface MPAppDelegate ()
|
||||
@@ -65,71 +62,4 @@
|
||||
[self.passwordCreatorWindow makeKeyAndOrderFront:self.passwordCreatorWindow];
|
||||
}
|
||||
|
||||
- (NSArray *)contextMenuItemsWithItems:(MPContextMenuItemsFlags)flags {
|
||||
BOOL insertCreate = (0 != (flags & MPContextMenuCreate));
|
||||
BOOL insertDelete = (0 != (flags & MPContextMenuDelete));
|
||||
BOOL insertCopy = (0 != (flags & MPContextMenuCopy));
|
||||
|
||||
NSMutableArray *items = [NSMutableArray arrayWithCapacity:7];
|
||||
if(insertCreate) {
|
||||
|
||||
NSMenuItem *newGroup = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"ADD_GROUP", @"")
|
||||
action:[MPActionHelper actionOfType:MPActionAddGroup]
|
||||
keyEquivalent:@"G"];
|
||||
NSMenuItem *newEntry = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"ADD_ENTRY", @"")
|
||||
action:[MPActionHelper actionOfType:MPActionAddEntry]
|
||||
keyEquivalent:@"E"];
|
||||
|
||||
[items addObjectsFromArray:@[ newGroup, newEntry ]];
|
||||
[newEntry release];
|
||||
[newGroup release];
|
||||
}
|
||||
if(insertDelete) {
|
||||
if([items count] > 0) {
|
||||
[items addObject:[NSMenuItem separatorItem]];
|
||||
}
|
||||
NSMenuItem *delete = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"DELETE", @"")
|
||||
action:[MPActionHelper actionOfType:MPActionDelete]
|
||||
keyEquivalent:@""];
|
||||
[items addObject:delete];
|
||||
[delete release];
|
||||
}
|
||||
if(insertCopy) {
|
||||
if([items count] > 0) {
|
||||
[items addObject:[NSMenuItem separatorItem]];
|
||||
}
|
||||
NSMenuItem *copyUsername = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"COPY_USERNAME", @"")
|
||||
action:[MPActionHelper actionOfType:MPActionCopyUsername]
|
||||
keyEquivalent:@"C"];
|
||||
NSMenuItem *copyPassword = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"COPY_PASSWORD", @"")
|
||||
action:[MPActionHelper actionOfType:MPActionCopyPassword]
|
||||
keyEquivalent:@"c"];
|
||||
NSMenu *urlMenu = [[NSMenu alloc] init];
|
||||
NSMenuItem *urlItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"URL", @"")
|
||||
action:0
|
||||
keyEquivalent:@""];
|
||||
[urlItem setSubmenu:urlMenu];
|
||||
[urlMenu release];
|
||||
|
||||
NSMenuItem *copyURL = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"COPY_URL", @"")
|
||||
action:[MPActionHelper actionOfType:MPActionCopyURL]
|
||||
keyEquivalent:@"u"];
|
||||
NSMenuItem *openURL = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"OPEN_URL", @"")
|
||||
action:[MPActionHelper actionOfType:MPActionOpenURL]
|
||||
keyEquivalent:@"U"];
|
||||
[urlMenu addItem:copyURL];
|
||||
[urlMenu addItem:openURL];
|
||||
[openURL release];
|
||||
[copyURL release];
|
||||
|
||||
[items addObjectsFromArray:@[ copyUsername, copyPassword, urlItem]];
|
||||
[urlItem release];
|
||||
[copyPassword release];
|
||||
[copyUsername release];
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user