diff --git a/MacPass/KdbEntry+Undo.m b/MacPass/KdbEntry+Undo.m
index 09b8fee5..8e69aaac 100644
--- a/MacPass/KdbEntry+Undo.m
+++ b/MacPass/KdbEntry+Undo.m
@@ -17,6 +17,13 @@ NSString *const MPEntryPasswordUndoableKey = @"passwordUndoable";
NSString *const MPEntryUrlUndoableKey = @"urlUndoable";
NSString *const MPEntryNotesUndoableKey = @"notesUndoable";
+#ifndef MPSetActionName
+#define MPSetActionName(key, comment) \
+if(![[self undoManager] isUndoing]) {\
+ [[self undoManager] setActionName:[[NSBundle mainBundle] localizedStringForKey:(key) value:@"" table:nil]];\
+}
+#endif
+
@implementation KdbEntry (Undo)
- (NSUndoManager *)undoManager {
@@ -43,38 +50,37 @@ NSString *const MPEntryNotesUndoableKey = @"notesUndoable";
return [self notes];
}
-
- (void)setTitleUndoable:(NSString *)title {
[[self undoManager] registerUndoWithTarget:self selector:@selector(setTitleUndoable:) object:self.title];
- [[self undoManager] setActionName:NSLocalizedString(@"UNDO_SET_TITLE", "Undo set title")];
+ MPSetActionName(@"SET_TITLE", "Set Title");
[self setLastModificationTime:[NSDate date]];
[self setTitle:title];
}
- (void)setUsernameUndoable:(NSString *)username {
[[self undoManager] registerUndoWithTarget:self selector:@selector(setUsernameUndoable:) object:self.username];
- [[self undoManager] setActionName:NSLocalizedString(@"UNDO_SET_USERNAME", "Undo set username")];
+ MPSetActionName(@"SET_USERNAME", "Undo set username");
[self setLastModificationTime:[NSDate date]];
[self setUsername:username];
}
- (void)setPasswordUndoable:(NSString *)password {
[[self undoManager] registerUndoWithTarget:self selector:@selector(setPasswordUndoable:) object:self.password];
- [[self undoManager] setActionName:NSLocalizedString(@"UNDO_SET_PASSWORT", "Undo set password")];
+ MPSetActionName(@"SET_PASSWORT", "Undo set password");
[self setLastModificationTime:[NSDate date]];
[self setPassword:password];
}
- (void)setUrlUndoable:(NSString *)url {
[[self undoManager] registerUndoWithTarget:self selector:@selector(setUrlUndoable:) object:self.url];
- [[self undoManager] setActionName:NSLocalizedString(@"UNDO_SET_URL", "Undo set URL")];
+ MPSetActionName(@"SET_URL", "Undo set URL");
[self setLastModificationTime:[NSDate date]];
[self setUrl:url];
}
- (void)setNotesUndoable:(NSString *)notes {
[[self undoManager] registerUndoWithTarget:self selector:@selector(setNotesUndoable:) object:self.notes];
- [[self undoManager] setActionName:NSLocalizedString(@"UNDO_SET_NOTES", "Undo set notes")];
+ MPSetActionName(@"SET_NOTES", "Set Notes");
[self setLastModificationTime:[NSDate date]];
[self setNotes:notes];
}
@@ -88,7 +94,8 @@ NSString *const MPEntryNotesUndoableKey = @"notesUndoable";
return; // We're not in our parents entries list
}
[[[self undoManager] prepareWithInvocationTarget:self.parent] addEntryUndoable:self atIndex:oldIndex];
- [[self undoManager] setActionName:@"Delete Entry"];
+ MPSetActionName(@"DELETE_ENTRY", "Delete Entry");
+ [[NSNotificationCenter defaultCenter] postNotificationName:@"" object:self userInfo:nil];
[self.parent removeObjectFromEntriesAtIndex:oldIndex];
}
@@ -101,7 +108,7 @@ NSString *const MPEntryNotesUndoableKey = @"notesUndoable";
return; // Not found in entries of parent!
}
[[[self undoManager] prepareWithInvocationTarget:self] moveToGroupUndoable:self.parent atIndex:oldIndex];
- [[self undoManager] setActionName:@"Move Entry"];
+ MPSetActionName(@"MOVE_ENTRY", "Move Entry")
[self.parent removeObjectFromEntriesAtIndex:oldIndex];
[group insertObject:self inEntriesAtIndex:index];
}
@@ -114,7 +121,7 @@ NSString *const MPEntryNotesUndoableKey = @"notesUndoable";
return; // Not found in entries of parent!
}
[[[self undoManager] prepareWithInvocationTarget:self] restoreFromTrashUndoable:self.parent atIndex:oldIndex];
- [[self undoManager] setActionName:@"Trash Entry"];
+ MPSetActionName(@"MOVE_ENTRY_TO_TRASH", "Move Entryo to Trash")
[self.parent removeObjectFromEntriesAtIndex:oldIndex];
[trash insertObject:self inEntriesAtIndex:index];
}
@@ -128,7 +135,7 @@ NSString *const MPEntryNotesUndoableKey = @"notesUndoable";
return; // Not found in entries of parent!
}
[[[self undoManager] prepareWithInvocationTarget:self] moveToTrashUndoable:self.parent atIndex:oldIndex];
- [[self undoManager] setActionName:@"Restore Entry"];
+ MPSetActionName(@"RESTORE_ENTRY", "Restore Entry from Trash")
[self.parent removeObjectFromEntriesAtIndex:oldIndex];
[group insertObject:self inEntriesAtIndex:index];
diff --git a/MacPass/KdbGroup+Undo.h b/MacPass/KdbGroup+Undo.h
index dfddcfc3..294925a6 100644
--- a/MacPass/KdbGroup+Undo.h
+++ b/MacPass/KdbGroup+Undo.h
@@ -22,6 +22,6 @@ APPKIT_EXTERN NSString *const MPGroupNameUndoableKey;
- (void)addEntryUndoable:(KdbEntry *)entry atIndex:(NSUInteger)index;
- (void)moveToGroupUndoable:(KdbGroup *)group atIndex:(NSUInteger)index;
- (void)moveToTrashUndoable:(KdbGroup *)trash atIndex:(NSUInteger)index;
-- (void)restoreFromTrahsUndoable:(KdbGroup *)group atIndex:(NSUInteger)index;
+- (void)restoreFromTrashUndoable:(KdbGroup *)group atIndex:(NSUInteger)index;
@end
diff --git a/MacPass/KdbGroup+Undo.m b/MacPass/KdbGroup+Undo.m
index 8980984f..51ad1b96 100644
--- a/MacPass/KdbGroup+Undo.m
+++ b/MacPass/KdbGroup+Undo.m
@@ -10,6 +10,13 @@
#import "KdbGroup+KVOAdditions.h"
#import "KdbEntry+Undo.h"
+#ifndef MPSetActionName
+#define MPSetActionName(key, comment) \
+if(![[self undoManager] isUndoing]) {\
+[[self undoManager] setActionName:[[NSBundle mainBundle] localizedStringForKey:(key) value:@"" table:nil]];\
+}
+#endif
+
NSString *const MPGroupNameUndoableKey = @"nameUndoable";
@implementation KdbGroup (Undo)
@@ -24,7 +31,7 @@ NSString *const MPGroupNameUndoableKey = @"nameUndoable";
- (void)setNameUndoable:(NSString *)newName {
[[self undoManager] registerUndoWithTarget:self selector:@selector(setNameUndoable:) object:self.name];
- [[self undoManager] setActionName:NSLocalizedString(@"UNDO_SET_NAME", "Undo set name")];
+ MPSetActionName(@"SET_NAME", "Set Name")
self.name = newName;
}
@@ -37,6 +44,7 @@ NSString *const MPGroupNameUndoableKey = @"nameUndoable";
return; // Inconsistent data
}
[[[self undoManager] prepareWithInvocationTarget:self.parent] addGroupUndoable:self atIndex:oldIndex];
+ MPSetActionName(@"DELETE_GROUP", "Delete Group")
[self.parent removeObjectFromGroupsAtIndex:[self.parent.groups indexOfObject:self]];
}
@@ -48,8 +56,7 @@ NSString *const MPGroupNameUndoableKey = @"nameUndoable";
return; // Wrong index!
}
[[[self undoManager] prepareWithInvocationTarget:group] deleteUndoable];
- //[[self undoManager] setActionName:NSLocalizedString(@"UNDO_ADD_GROUP", @"Create Group Undo")];
- [[self undoManager] setActionName:@"Add Group"];
+ MPSetActionName(@"ADD_GROUP", "Add Group")
[self insertObject:group inGroupsAtIndex:index];
}
@@ -61,7 +68,7 @@ NSString *const MPGroupNameUndoableKey = @"nameUndoable";
return; // Wrong index!
}
[[[self undoManager] prepareWithInvocationTarget:entry] deleteUndoable];
- [[self undoManager] setActionName:@"Add Entry"];
+ MPSetActionName(@"ADD_ENTRY", "Add Entry")
[self insertObject:entry inEntriesAtIndex:index];
}
@@ -74,7 +81,7 @@ NSString *const MPGroupNameUndoableKey = @"nameUndoable";
return; // We aren't in our parents groups list.
}
[[[self undoManager] prepareWithInvocationTarget:self] moveToGroupUndoable:self.parent atIndex:oldIndex];
- [[self undoManager] setActionName:@"Move Group"];
+ MPSetActionName(@"MOVE_GROUP", "Move Group")
[self.parent removeObjectFromGroupsAtIndex:oldIndex];
[group insertObject:self inGroupsAtIndex:index];
}
@@ -87,13 +94,13 @@ NSString *const MPGroupNameUndoableKey = @"nameUndoable";
if(index == NSNotFound) {
return; // We aren't in our parents groups list.
}
- [[[self undoManager] prepareWithInvocationTarget:self] restoreFromTrahsUndoable:self.parent atIndex:oldIndex];
- [[self undoManager] setActionName:@"Trash Group"];
+ [[[self undoManager] prepareWithInvocationTarget:self] restoreFromTrashUndoable:self.parent atIndex:oldIndex];
+ MPSetActionName(@"MOVE_TO_TRASH", @"Move to Trash")
[self.parent removeObjectFromGroupsAtIndex:oldIndex];
[trash insertObject:self inGroupsAtIndex:index];
}
-- (void)restoreFromTrahsUndoable:(KdbGroup *)group atIndex:(NSUInteger)index {
+- (void)restoreFromTrashUndoable:(KdbGroup *)group atIndex:(NSUInteger)index {
if(!self.parent || !group) {
return; // No target or origin
}
@@ -102,7 +109,7 @@ NSString *const MPGroupNameUndoableKey = @"nameUndoable";
return; // We aren't in our parents groups list.
}
[[[self undoManager] prepareWithInvocationTarget:self] moveToTrashUndoable:self.parent atIndex:oldIndex];
- [[self undoManager] setActionName:@"Restore Group"];
+ MPSetActionName(@"RESTORE_GROUP", "Restore from Trash")
[self.parent removeObjectFromGroupsAtIndex:oldIndex];
[group insertObject:self inGroupsAtIndex:index];
}
diff --git a/MacPass/MacPass-Info.plist b/MacPass/MacPass-Info.plist
index b67bad09..c36c1b4f 100644
--- a/MacPass/MacPass-Info.plist
+++ b/MacPass/MacPass-Info.plist
@@ -48,7 +48,7 @@
CFBundleSignature
????
CFBundleVersion
- 2323
+ 2331
LSMinimumSystemVersion
${MACOSX_DEPLOYMENT_TARGET}
NSHumanReadableCopyright
diff --git a/MacPass/en.lproj/Localizable.strings b/MacPass/en.lproj/Localizable.strings
index 7663fb92..8010651b 100644
Binary files a/MacPass/en.lproj/Localizable.strings and b/MacPass/en.lproj/Localizable.strings differ