diff --git a/platform-darwin/Source/Mac/MPSitesWindowController.m b/platform-darwin/Source/Mac/MPSitesWindowController.m index ee6b51a1..04b39eb2 100644 --- a/platform-darwin/Source/Mac/MPSitesWindowController.m +++ b/platform-darwin/Source/Mac/MPSitesWindowController.m @@ -394,7 +394,52 @@ }]; } -- (IBAction)changeType:(id)sender { +- (IBAction)changeDefaultType:(id)sender { + + MPSiteModel *site = self.selectedSite; + MPUserEntity *user = [MPMacAppDelegate get].activeUserForMainThread; + NSArray *types = [user.algorithm allTypes]; + [self.passwordTypesMatrix renewRows:(NSInteger)[types count] columns:1]; + for (NSUInteger t = 0; t < [types count]; ++t) { + MPResultType type = (MPResultType)[types[t] unsignedIntegerValue]; + NSString *title = [user.algorithm nameOfType:type]; + if (type & MPResultTypeClassTemplate) + title = strf( @"%@ – %@", [user.algorithm mpwTemplateForSiteNamed:site.name?: @"masterpassword.app" ofType:type + withCounter:site.counter?: MPCounterValueDefault + usingKey:[MPMacAppDelegate get].key], title ); + + NSButtonCell *cell = [self.passwordTypesMatrix cellAtRow:(NSInteger)t column:0]; + cell.tag = type; + cell.state = type == site.type? NSOnState: NSOffState; + cell.title = title; + } + + self.passwordTypesBox.title = strf( @"Choose a password type for new sites of %@:", user.name ); + + NSAlert *alert = [NSAlert new]; + [alert addButtonWithTitle:@"Save"]; + [alert addButtonWithTitle:@"Cancel"]; + [alert setMessageText:@"Change Default Type"]; + [alert setAccessoryView:self.passwordTypesBox]; + [alert layout]; + [alert beginSheetModalForWindow:self.window completionHandler:^(NSModalResponse returnCode) { + switch (returnCode) { + case NSAlertFirstButtonReturn: { + // "Save" button. + MPResultType type = (MPResultType)[self.passwordTypesMatrix.selectedCell tag]; + [MPMacAppDelegate managedObjectContextPerformBlock:^(NSManagedObjectContext *context) { + [[MPMacAppDelegate get] activeUserInContext:context].defaultType = type; + [context saveToStore]; + }]; + break; + } + default: + break; + } + }]; +} + +- (IBAction)changeSiteType:(id)sender { MPSiteModel *site = self.selectedSite; NSArray *types = [site.algorithm allTypes]; diff --git a/platform-darwin/Source/Mac/MPSitesWindowController.xib b/platform-darwin/Source/Mac/MPSitesWindowController.xib index b1b56ca7..b263f365 100644 --- a/platform-darwin/Source/Mac/MPSitesWindowController.xib +++ b/platform-darwin/Source/Mac/MPSitesWindowController.xib @@ -114,7 +114,7 @@ - + @@ -143,11 +143,11 @@ - ⑴ When you create an account on a site, open Master Password to create your account password. + ⑴ When you create an account on a site, open Master Password to create your account password. ⑵ Consider changing all your existing account passwords to the password Master Password creates for those sites. ⑶ To get the password for a site, just enter its domain name in the "site name" field (eg. "apple.com"). ⑷ When chosing a master password, make it easy but long (eg. a short sentence). -⑸ Tell *nobody* your master password. It's OK to share your site passwords with people you trust: they can be changed if necessary. +⑸ Tell *nobody* your master password. It's OK to share your site passwords with people you trust: they can be changed if necessary. @@ -310,7 +310,7 @@ - + @@ -568,7 +568,7 @@ Use the arrows ⇅ to navigate the list or esc ⎋ to exit. - + - + - + @@ -631,7 +631,7 @@ Use the arrows ⇅ to navigate the list or esc ⎋ to exit. +