Improved "Add Entry" workflow (issue #156)

- New entry is automatically scrolled to and selected
- Title textfield is automatically focused
- Pre-generate a password using the deault password creation settings
This commit is contained in:
James Hurst
2014-08-05 20:46:42 -04:00
parent 6ddce76b0d
commit 5ff911b824
6 changed files with 56 additions and 1 deletions

View File

@@ -13,6 +13,8 @@
#import "MPAttachmentTableDataSource.h"
#import "MPWindowAssociationsTableViewDelegate.h"
#import "NSString+MPPasswordCreation.h"
#import "MPDocument.h"
#import "MPIconHelper.h"
#import "MPValueTransformerHelper.h"
@@ -119,6 +121,17 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) {
}
}
- (void)regsiterNotificationsForDocument:(MPDocument *)document {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(_didAddItem:)
name:MPDocumentItemAddedNotification
object:document];
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
#pragma mark -
#pragma mark Actions
@@ -418,4 +431,28 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) {
}
#pragma mark -
#pragma mark MPDocument Notifications
- (void)_didAddItem:(NSNotification *)notification {
[self.tabView selectTabViewItemAtIndex:MPEntryTabGeneral];
/* generate and pre-fill password using default password creation settings */
NSUInteger passwordLength = [[NSUserDefaults standardUserDefaults] integerForKey:kMPSettingsKeyDefaultPasswordLength];
MPPasswordCharacterFlags characterFlags = [[NSUserDefaults standardUserDefaults] integerForKey:kMPSettingsKeyPasswordCharacterFlags];
BOOL useCustomString = [[NSUserDefaults standardUserDefaults] boolForKey:kMPSettingsKeyPasswordUseCustomString];
NSString *customString = [[NSUserDefaults standardUserDefaults] stringForKey:kMPSettingsKeyPasswordCustomString];
if(useCustomString) {
if([customString length] > 0) {
[self.passwordTextField setStringValue:[customString passwordWithLength:passwordLength]];
}
}
else {
[self.passwordTextField setStringValue:[NSString passwordWithCharactersets:characterFlags length:passwordLength]];
}
[self.titleTextField becomeFirstResponder];
}
@end