diff --git a/MacPass/MPActionHelper.h b/MacPass/MPActionHelper.h
index 2d35e7df..98c22f76 100644
--- a/MacPass/MPActionHelper.h
+++ b/MacPass/MPActionHelper.h
@@ -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
diff --git a/MacPass/MPActionHelper.m b/MacPass/MPActionHelper.m
index dca564ec..69b405a9 100644
--- a/MacPass/MPActionHelper.m
+++ b/MacPass/MPActionHelper.m
@@ -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:)),
diff --git a/MacPass/MPContextMenuHelper.h b/MacPass/MPContextMenuHelper.h
index a6072221..9d46358b 100644
--- a/MacPass/MPContextMenuHelper.h
+++ b/MacPass/MPContextMenuHelper.h
@@ -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
};
diff --git a/MacPass/MPContextMenuHelper.m b/MacPass/MPContextMenuHelper.m
index 058cbb60..7304dc91 100644
--- a/MacPass/MPContextMenuHelper.m
+++ b/MacPass/MPContextMenuHelper.m
@@ -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) {
diff --git a/MacPass/MPDocument.h b/MacPass/MPDocument.h
index ce09967d..469e2a59 100644
--- a/MacPass/MPDocument.h
+++ b/MacPass/MPDocument.h
@@ -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
diff --git a/MacPass/MPDocument.m b/MacPass/MPDocument.m
index d6a54948..574bff14 100644
--- a/MacPass/MPDocument.m
+++ b/MacPass/MPDocument.m
@@ -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;
diff --git a/MacPass/MPOutlineContextMenuDelegate.m b/MacPass/MPOutlineContextMenuDelegate.m
index 5f1ce530..0165b19b 100644
--- a/MacPass/MPOutlineContextMenuDelegate.m
+++ b/MacPass/MPOutlineContextMenuDelegate.m
@@ -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 ) {
}
diff --git a/MacPass/de.lproj/Localizable.stringsdict b/MacPass/de.lproj/Localizable.stringsdict
index 37d23e10..09e5ae23 100644
--- a/MacPass/de.lproj/Localizable.stringsdict
+++ b/MacPass/de.lproj/Localizable.stringsdict
@@ -20,7 +20,7 @@
alle Zeichen ausgewählt
- DUPLICATE_ENTRIES_%ld
+ DUPLICATE_ENTRIES_ACTION_NAME
NSStringLocalizedFormatKey
%#@entries@
diff --git a/MacPass/en.lproj/Localizable.strings b/MacPass/en.lproj/Localizable.strings
index 4a6db4cb..f34cb98b 100644
--- a/MacPass/en.lproj/Localizable.strings
+++ b/MacPass/en.lproj/Localizable.strings
@@ -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";
diff --git a/MacPass/en.lproj/Localizable.stringsdict b/MacPass/en.lproj/Localizable.stringsdict
index e3db31f3..2d22e855 100644
--- a/MacPass/en.lproj/Localizable.stringsdict
+++ b/MacPass/en.lproj/Localizable.stringsdict
@@ -2,6 +2,22 @@
+ DUPLICATE_GROUPS_ACTION_NAME
+
+ NSStringLocalizedFormatKey
+ %#@groups@
+ groups
+
+ NSStringFormatValueTypeKey
+ ld
+ NSStringFormatSpecTypeKey
+ NSStringPluralRuleType
+ one
+ Duplicate Group
+ other
+ Duplicate Groups
+
+
%ld_CHARACTERS_TO_PICK_REMAINING
NSStringLocalizedFormatKey
@@ -20,7 +36,7 @@
All characters picked
- DUPLICATE_ENTRIES_%ld
+ DUPLICATE_ENTRIES_ACTION_NAME
NSStringLocalizedFormatKey
%#@entries@
diff --git a/MacPass/es.lproj/Localizable.stringsdict b/MacPass/es.lproj/Localizable.stringsdict
index e0d9317f..e15d340a 100644
--- a/MacPass/es.lproj/Localizable.stringsdict
+++ b/MacPass/es.lproj/Localizable.stringsdict
@@ -20,7 +20,7 @@
Todos los caracteres seleccionados
- DUPLICATE_ENTRIES_%ld
+ DUPLICATE_ENTRIES_ACTION_NAME
NSStringLocalizedFormatKey
%#@entries@
diff --git a/MacPass/fr.lproj/Localizable.stringsdict b/MacPass/fr.lproj/Localizable.stringsdict
index 82879e2f..ba5b773c 100644
--- a/MacPass/fr.lproj/Localizable.stringsdict
+++ b/MacPass/fr.lproj/Localizable.stringsdict
@@ -20,7 +20,7 @@
Tous les caractères ont été choisis
- DUPLICATE_ENTRIES_%ld
+ DUPLICATE_ENTRIES_ACTION_NAME
NSStringLocalizedFormatKey
%#@entries@
@@ -31,7 +31,7 @@
NSStringFormatValueTypeKey
ld
one
- Dupliquer l'entrée
+ Dupliquer l'entrée
other
Dupliquer les entrées
zero
diff --git a/MacPass/nl.lproj/Localizable.stringsdict b/MacPass/nl.lproj/Localizable.stringsdict
index 173f77b6..440b6eee 100644
--- a/MacPass/nl.lproj/Localizable.stringsdict
+++ b/MacPass/nl.lproj/Localizable.stringsdict
@@ -20,7 +20,7 @@
Alle tekens gekozen
- DUPLICATE_ENTRIES_%ld
+ DUPLICATE_ENTRIES_ACTION_NAME
NSStringLocalizedFormatKey
%#@entries@
diff --git a/MacPass/pl.lproj/Localizable.stringsdict b/MacPass/pl.lproj/Localizable.stringsdict
index 041de5fb..f79ae1b8 100644
--- a/MacPass/pl.lproj/Localizable.stringsdict
+++ b/MacPass/pl.lproj/Localizable.stringsdict
@@ -24,7 +24,7 @@
Wybrano wszystkie znaki
- DUPLICATE_ENTRIES_%ld
+ DUPLICATE_ENTRIES_ACTION_NAME
NSStringLocalizedFormatKey
%#@wpisów@
diff --git a/MacPass/ru.lproj/Localizable.stringsdict b/MacPass/ru.lproj/Localizable.stringsdict
index ada74a9c..70f08165 100644
--- a/MacPass/ru.lproj/Localizable.stringsdict
+++ b/MacPass/ru.lproj/Localizable.stringsdict
@@ -24,7 +24,7 @@
Выбраны все символы
- DUPLICATE_ENTRIES_%ld
+ DUPLICATE_ENTRIES_ACTION_NAME
NSStringLocalizedFormatKey
%#@entries@
diff --git a/MacPass/sv-SE.lproj/Localizable.stringsdict b/MacPass/sv-SE.lproj/Localizable.stringsdict
index 184de942..9fd3b244 100644
--- a/MacPass/sv-SE.lproj/Localizable.stringsdict
+++ b/MacPass/sv-SE.lproj/Localizable.stringsdict
@@ -20,7 +20,7 @@
Alla tecken valda
- DUPLICATE_ENTRIES_%ld
+ DUPLICATE_ENTRIES_ACTION_NAME
NSStringLocalizedFormatKey
%#@entries@