mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-13 08:52:20 +00:00
Added duplicate group as context menu action
This commit is contained in:
@@ -28,6 +28,7 @@ typedef NS_ENUM(NSUInteger, MPActionType) {
|
||||
MPActionAddGroup, // Add a new group
|
||||
MPActionDuplicateEntry, // Simply duplicate an entry (including history)
|
||||
MPActionDuplicateEntryWithOptions, // Request user input on what to duplicate
|
||||
MPActionDuplicateGroup, // Duplicate the group and all it's children
|
||||
MPActionReverToHistoryEntry, // Restore an entry to an older state in history
|
||||
MPActionDelete, // Delete entry or group
|
||||
MPActionCopyUsername, // copy username to pasteboard
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
@(MPActionAddGroup): NSStringFromSelector(@selector(createGroup:)),
|
||||
@(MPActionDuplicateEntry): NSStringFromSelector(@selector(duplicateEntry:)),
|
||||
@(MPActionDuplicateEntryWithOptions): NSStringFromSelector(@selector(duplicateEntryWithOptions:)),
|
||||
@(MPActionDuplicateGroup): NSStringFromSelector(@selector(duplicateGroup:)),
|
||||
@(MPActionReverToHistoryEntry): NSStringFromSelector(@selector(revertToHistoryEntry:)),
|
||||
@(MPActionCopyPassword): NSStringFromSelector(@selector(copyPassword:)),
|
||||
@(MPActionCopyURL): NSStringFromSelector(@selector(copyURL:)),
|
||||
|
||||
@@ -31,7 +31,7 @@ typedef NS_OPTIONS(NSUInteger, MPContextMenuItemsFlags) {
|
||||
MPContextMenuAutotype = 1 << 5,
|
||||
MPContextMenuHistory = 1 << 6,
|
||||
MPContextMenuShowGroupInOutline = 1 << 7,
|
||||
MPContextMenuMinimal = MPContextMenuCreate | MPContextMenuDelete,
|
||||
MPContextMenuMinimal = MPContextMenuCreate | MPContextMenuDelete | MPContextMenuDuplicate,
|
||||
MPContextMenuFull = MPContextMenuMinimal | MPContextMenuCopy | MPContextMenuDuplicate | MPContextMenuAutotype | MPContextMenuHistory,
|
||||
MPContextMenuExtended = MPContextMenuFull | MPContextMenuTrash
|
||||
};
|
||||
|
||||
@@ -64,8 +64,11 @@ static void MPContextmenuHelperBeginSection(NSMutableArray *items) {
|
||||
NSMenuItem *duplicateEntyWithOptions = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"DUPLICATE_ENTRY_WITH_OPTIONS", @"Menu item to duplicate an entry with options how to duplicate. Will present a dialog.")
|
||||
action:[MPActionHelper actionOfType:MPActionDuplicateEntryWithOptions]
|
||||
keyEquivalent:@""];
|
||||
|
||||
[items addObjectsFromArray:@[ duplicateEntry, duplicateEntyWithOptions ]];
|
||||
NSMenuItem *duplicateGroup = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"DUPLICATE_GROUP", @"Menu item to directly diplicate a group")
|
||||
action:[MPActionHelper actionOfType:MPActionDuplicateGroup]
|
||||
keyEquivalent:@""];
|
||||
|
||||
[items addObjectsFromArray:@[ duplicateEntry, duplicateEntyWithOptions, duplicateGroup ]];
|
||||
|
||||
}
|
||||
if(insertDelete || insertTrash) {
|
||||
|
||||
@@ -165,7 +165,6 @@ FOUNDATION_EXPORT NSString *const MPDocumentGroupKey;
|
||||
- (void)deleteNode:(KPKNode *)node;
|
||||
- (void)duplicateEntryWithOptions:(KPKCopyOptions)options;
|
||||
|
||||
|
||||
#pragma mark Actions
|
||||
/**
|
||||
* Empties the Trash group. Removing all Groups and Entries inside. This action is not undo-able
|
||||
@@ -179,6 +178,7 @@ FOUNDATION_EXPORT NSString *const MPDocumentGroupKey;
|
||||
*/
|
||||
- (IBAction)createEntryFromTemplate:(id)sender;
|
||||
- (IBAction)duplicateEntry:(id)sender;
|
||||
- (IBAction)duplicateGroup:(id)sender;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -828,7 +828,16 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou
|
||||
KPKEntry *duplicate = [entry copyWithTitle:nil options:options];
|
||||
[duplicate addToGroup:entry.parent];
|
||||
}
|
||||
[self.undoManager setActionName:[NSString stringWithFormat:NSLocalizedString(@"DUPLICATE_ENTRIES_%ld", @"Action name for duplicating entries"), self.selectedEntries.count]];
|
||||
[self.undoManager setActionName:[NSString stringWithFormat:NSLocalizedString(@"DUPLICATE_ENTRIES_ACTION_NAME", @"Action name for duplicating entries"), self.selectedEntries.count]];
|
||||
}
|
||||
|
||||
- (void)duplicateGroup:(id)sender {
|
||||
for(KPKGroup *group in self.selectedGroups) {
|
||||
KPKGroup *duplicate = [group copyWithTitle:nil options:kKPKCopyOptionNone];
|
||||
/* if group is root group, add the duplicate below */
|
||||
[duplicate addToGroup:(group.parent ? group.parent : group)];
|
||||
}
|
||||
[self.undoManager setActionName:[NSString stringWithFormat:NSLocalizedString(@"DUPLICATE_GROUPS_ACTION_NAME", @"Action name for duplicating groups"), self.selectedGroups.count]];
|
||||
}
|
||||
|
||||
#pragma mark Validation
|
||||
@@ -886,6 +895,9 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou
|
||||
valid &= targetEntries.count > 0;
|
||||
valid &= !self.historyEntry;
|
||||
break;
|
||||
case MPActionDuplicateGroup:
|
||||
valid &= targetGroups.count > 0;
|
||||
break;
|
||||
case MPActionEmptyTrash:
|
||||
valid &= (self.trash.groups.count + self.trash.entries.count) > 0;
|
||||
break;
|
||||
|
||||
@@ -57,7 +57,7 @@ NSString *const _MPOutlineMenuTemplate = @"Template";
|
||||
|
||||
if( [item isKindOfClass:KPKGroup.class]) {
|
||||
KPKGroup *group = (KPKGroup *)item;
|
||||
MPDocument *document = [NSDocumentController sharedDocumentController].currentDocument;
|
||||
MPDocument *document = NSDocumentController.sharedDocumentController.currentDocument;
|
||||
if(group && document.root == group ) {
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<string>alle Zeichen ausgewählt</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>DUPLICATE_ENTRIES_%ld</key>
|
||||
<key>DUPLICATE_ENTRIES_ACTION_NAME</key>
|
||||
<dict>
|
||||
<key>NSStringLocalizedFormatKey</key>
|
||||
<string>%#@entries@</string>
|
||||
|
||||
@@ -304,7 +304,7 @@
|
||||
"DRAG_GROUP" = "Drag Group";
|
||||
|
||||
/* Action name for duplicating entries */
|
||||
"DUPLICATE_ENTRIES_%ld" = "Duplicate Entries %ld";
|
||||
"DUPLICATE_ENTRIES_ACTION_NAME" = "Duplicate Entries";
|
||||
|
||||
/* Menu item to directly diplicate an entry */
|
||||
"DUPLICATE_ENTRY" = "Duplicate Entry";
|
||||
@@ -312,6 +312,12 @@
|
||||
/* Menu item to duplicate an entry with options how to duplicate. Will present a dialog. */
|
||||
"DUPLICATE_ENTRY_WITH_OPTIONS" = "Duplicate Entry…";
|
||||
|
||||
/* Menu item to directly diplicate a group */
|
||||
"DUPLICATE_GROUP" = "Duplicate Group";
|
||||
|
||||
/* Action name for duplicating groups */
|
||||
"DUPLICATE_GROUPS_ACTION_NAME" = "Duplicate Group";
|
||||
|
||||
/* Menu item in the database outline context menu to change the template group
|
||||
Menu item on the add entry context menu to edit template groups */
|
||||
"EDIT_TEMPLATE_GROUP" = "Edit Entry Template Group";
|
||||
|
||||
@@ -2,6 +2,22 @@
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>DUPLICATE_GROUPS_ACTION_NAME</key>
|
||||
<dict>
|
||||
<key>NSStringLocalizedFormatKey</key>
|
||||
<string>%#@groups@</string>
|
||||
<key>groups</key>
|
||||
<dict>
|
||||
<key>NSStringFormatValueTypeKey</key>
|
||||
<string>ld</string>
|
||||
<key>NSStringFormatSpecTypeKey</key>
|
||||
<string>NSStringPluralRuleType</string>
|
||||
<key>one</key>
|
||||
<string>Duplicate Group</string>
|
||||
<key>other</key>
|
||||
<string>Duplicate Groups</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>%ld_CHARACTERS_TO_PICK_REMAINING</key>
|
||||
<dict>
|
||||
<key>NSStringLocalizedFormatKey</key>
|
||||
@@ -20,7 +36,7 @@
|
||||
<string>All characters picked</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>DUPLICATE_ENTRIES_%ld</key>
|
||||
<key>DUPLICATE_ENTRIES_ACTION_NAME</key>
|
||||
<dict>
|
||||
<key>NSStringLocalizedFormatKey</key>
|
||||
<string>%#@entries@</string>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<string>Todos los caracteres seleccionados</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>DUPLICATE_ENTRIES_%ld</key>
|
||||
<key>DUPLICATE_ENTRIES_ACTION_NAME</key>
|
||||
<dict>
|
||||
<key>NSStringLocalizedFormatKey</key>
|
||||
<string>%#@entries@</string>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<string>Tous les caractères ont été choisis</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>DUPLICATE_ENTRIES_%ld</key>
|
||||
<key>DUPLICATE_ENTRIES_ACTION_NAME</key>
|
||||
<dict>
|
||||
<key>NSStringLocalizedFormatKey</key>
|
||||
<string>%#@entries@</string>
|
||||
@@ -31,7 +31,7 @@
|
||||
<key>NSStringFormatValueTypeKey</key>
|
||||
<string>ld</string>
|
||||
<key>one</key>
|
||||
<string>Dupliquer l'entrée</string>
|
||||
<string>Dupliquer l'entrée</string>
|
||||
<key>other</key>
|
||||
<string>Dupliquer les entrées</string>
|
||||
<key>zero</key>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<string>Alle tekens gekozen</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>DUPLICATE_ENTRIES_%ld</key>
|
||||
<key>DUPLICATE_ENTRIES_ACTION_NAME</key>
|
||||
<dict>
|
||||
<key>NSStringLocalizedFormatKey</key>
|
||||
<string>%#@entries@</string>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<string>Wybrano wszystkie znaki</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>DUPLICATE_ENTRIES_%ld</key>
|
||||
<key>DUPLICATE_ENTRIES_ACTION_NAME</key>
|
||||
<dict>
|
||||
<key>NSStringLocalizedFormatKey</key>
|
||||
<string>%#@wpisów@</string>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<string>Выбраны все символы</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>DUPLICATE_ENTRIES_%ld</key>
|
||||
<key>DUPLICATE_ENTRIES_ACTION_NAME</key>
|
||||
<dict>
|
||||
<key>NSStringLocalizedFormatKey</key>
|
||||
<string>%#@entries@</string>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<string>Alla tecken valda</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>DUPLICATE_ENTRIES_%ld</key>
|
||||
<key>DUPLICATE_ENTRIES_ACTION_NAME</key>
|
||||
<dict>
|
||||
<key>NSStringLocalizedFormatKey</key>
|
||||
<string>%#@entries@</string>
|
||||
|
||||
Reference in New Issue
Block a user