mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-19 06:09:32 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user