diff --git a/MacPass/Base.lproj/PasswordInputView.xib b/MacPass/Base.lproj/PasswordInputView.xib index 2f2ddf44..f0172c59 100644 --- a/MacPass/Base.lproj/PasswordInputView.xib +++ b/MacPass/Base.lproj/PasswordInputView.xib @@ -78,7 +78,7 @@ DQ - + diff --git a/MacPass/MPPasswordEditWindowController.m b/MacPass/MPPasswordEditWindowController.m index 487a0200..dd2dc4ad 100644 --- a/MacPass/MPPasswordEditWindowController.m +++ b/MacPass/MPPasswordEditWindowController.m @@ -20,6 +20,7 @@ @property (nonatomic, weak) MPDocument *currentDocument; @property (nonatomic, assign) BOOL showPassword; +@property (nonatomic, assign) BOOL enablePassword; @property (nonatomic, assign) BOOL hasValidPasswordOrKey; @property (nonatomic, weak) NSURL *keyURL; @@ -42,6 +43,7 @@ [super windowDidLoad]; [self.togglePasswordButton bind:NSValueBinding toObject:self withKeyPath:@"showPassword" options:nil]; [[self window] setDefaultButtonCell:[self.changePasswordButton cell]]; + self.enablePassword = _currentDocument.compositeKey.hasPassword; } - (void)updateView { @@ -55,11 +57,13 @@ //self.keyURL = _currentDocument.key; NSDictionary *negateOption = @{ NSValueTransformerNameBindingOption : NSNegateBooleanTransformerName }; + [self.hasPasswordSwitchButton bind:NSValueBinding toObject:self withKeyPath:@"enablePassword" options:nil]; [self.passwordTextField bind:@"showPassword" toObject:self withKeyPath:@"showPassword" options:nil]; - [self.passwordTextField bind:NSEnabledBinding toObject:self.hasPasswordSwitchButton withKeyPath:@"cell.state" options:nil]; + [self.passwordTextField bind:NSEnabledBinding toObject:self withKeyPath:@"enablePassword" options:nil]; [self.togglePasswordButton bind:NSValueBinding toObject:self withKeyPath:@"showPassword" options:nil]; + [self.togglePasswordButton bind:NSEnabledBinding toObject:self withKeyPath:@"enablePassword" options:nil]; [self.passwordRepeatTextField bind:NSEnabledBinding toObject:self withKeyPath:@"showPassword" options:negateOption]; - [self.passwordRepeatTextField bind:NSEnabledBinding toObject:self.hasPasswordSwitchButton withKeyPath:@"cell.state" options:nil]; + [self.passwordRepeatTextField bind:NSEnabledBinding toObject:self withKeyPath:@"enablePassword" options:nil]; [self.errorTextField bind:NSHiddenBinding toObject:self withKeyPath:@"hasValidPasswordOrKey" options:nil]; [self.changePasswordButton bind:NSEnabledBinding toObject:self withKeyPath:@"hasValidPasswordOrKey" options:nil]; [self.keyfilePathControl bind:NSValueBinding toObject:self withKeyPath:@"keyURL" options:nil]; @@ -72,6 +76,7 @@ self.isDirty = NO; } +#pragma mark Properties - (void)setShowPassword:(BOOL)showPassword { if(_showPassword != showPassword) { _showPassword = showPassword; @@ -84,6 +89,15 @@ _keyURL = keyURL; [self _verifyPasswordAndKey]; } +- (void)setEnablePassword:(BOOL)enablePassword { + if(_enablePassword != enablePassword) { + _enablePassword = enablePassword; + } + NSString *passwordPlaceHolder = _enablePassword ? NSLocalizedString(@"PASSWORD_INPUT_ENTER_PASSWORD", "") : NSLocalizedString(@"PASSWORD_INPUT_NO_PASSWORD", ""); + NSString *repeatPlaceHolder = _enablePassword ? NSLocalizedString(@"PASSWORD_INPUT_REPEAT_PASSWORD", "") : NSLocalizedString(@"PASSWORD_INPUT_NO_PASSWORD", ""); + [[self.passwordTextField cell] setPlaceholderString:passwordPlaceHolder]; + [[self.passwordRepeatTextField cell] setPlaceholderString:repeatPlaceHolder]; +} #pragma mark Actions - (IBAction)save:(id)sender { diff --git a/MacPass/MPPasswordInputController.m b/MacPass/MPPasswordInputController.m index faa236f5..bbc50146 100644 --- a/MacPass/MPPasswordInputController.m +++ b/MacPass/MPPasswordInputController.m @@ -26,7 +26,7 @@ @property (weak) IBOutlet NSButton *enablePasswordCheckBox; @property (assign) BOOL showPassword; -@property (assign) BOOL enablePassword; +@property (nonatomic, assign) BOOL enablePassword; @end @@ -70,6 +70,19 @@ [self _reset]; } +#pragma mark Properties +- (void)setEnablePassword:(BOOL)enablePassword { + if(_enablePassword != enablePassword) { + _enablePassword = enablePassword; + if(!_enablePassword) { + [self.passwordTextField setStringValue:@""]; + } + } + NSString *placeHolderString = _enablePassword ? NSLocalizedString(@"PASSWORD_INPUT_ENTER_PASSWORD", "") : NSLocalizedString(@"PASSWORD_INPUT_NO_PASSWORD", ""); + [[self.passwordTextField cell] setPlaceholderString:placeHolderString]; +} + + #pragma mark - #pragma mark Private - (IBAction)_decrypt:(id)sender { diff --git a/MacPass/PasswordEditWindow.xib b/MacPass/PasswordEditWindow.xib index 0efb2247..094f50ad 100644 --- a/MacPass/PasswordEditWindow.xib +++ b/MacPass/PasswordEditWindow.xib @@ -87,7 +87,7 @@ - + @@ -108,7 +108,7 @@ - + diff --git a/MacPass/de.lproj/Localizable.strings b/MacPass/de.lproj/Localizable.strings index b54798a1..1a8d9641 100644 Binary files a/MacPass/de.lproj/Localizable.strings and b/MacPass/de.lproj/Localizable.strings differ diff --git a/MacPass/en.lproj/Localizable.strings b/MacPass/en.lproj/Localizable.strings index f36bec6b..cb8c5be7 100644 Binary files a/MacPass/en.lproj/Localizable.strings and b/MacPass/en.lproj/Localizable.strings differ