mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 05:52:58 +00:00
Fixed wrong names for redo-actions
This commit is contained in:
@@ -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];
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>2323</string>
|
||||
<string>2331</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user