converting to properties

This commit is contained in:
michael starke
2017-08-30 11:17:10 +02:00
parent 258f165cee
commit 46b9b15338

View File

@@ -40,7 +40,7 @@
- (void)windowDidLoad {
[super windowDidLoad];
[self.togglePasswordButton bind:NSValueBinding toObject:self withKeyPath:NSStringFromSelector(@selector(showPassword)) options:nil];
[[self window] setDefaultButtonCell:[self.changePasswordButton cell]];
self.window.defaultButtonCell = self.changePasswordButton.cell;
MPDocument *document = self.document;
self.enablePassword = document.compositeKey.hasPassword;
}
@@ -94,8 +94,8 @@
}
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];
self.passwordTextField.placeholderString = passwordPlaceHolder;
self.passwordRepeatTextField.placeholderString = repeatPlaceHolder;
}
#pragma mark Actions
@@ -142,8 +142,8 @@
}
- (void)_verifyPasswordAndKey {
NSString *password = [self.passwordTextField stringValue];
NSString *repeat = [self.passwordRepeatTextField stringValue];
NSString *password = self.passwordTextField.stringValue;
NSString *repeat = self.passwordRepeatTextField.stringValue;
BOOL hasKey = (self.keyURL != nil);
BOOL keyOk = YES;
if(hasKey) {
@@ -163,19 +163,19 @@
self.hasValidPasswordOrKey = hasPasswordOrKey && passwordOk && keyOk;
if(!hasPasswordOrKey) {
[self.errorTextField setTextColor:[NSColor controlTextColor]];
[self.errorTextField setStringValue:NSLocalizedString(@"WARNING_NO_PASSWORD_OR_KEYFILE", "No Key or Password")];
self.errorTextField.textColor = NSColor.controlTextColor;
self.errorTextField.stringValue = NSLocalizedString(@"WARNING_NO_PASSWORD_OR_KEYFILE", "No Key or Password");
return; // all done
}
[self.errorTextField setTextColor:[NSColor redColor]];
self.errorTextField.textColor = NSColor.redColor;
if(!passwordOk && !keyOk ) {
[self.errorTextField setStringValue:NSLocalizedString(@"ERROR_PASSWORD_MISSMATCH_INVALID_KEYFILE", "Passwords do not match, keyfile is invalid")];
self.errorTextField.stringValue = NSLocalizedString(@"ERROR_PASSWORD_MISSMATCH_INVALID_KEYFILE", "Passwords do not match, keyfile is invalid");
}
else if(!passwordOk) {
[self.errorTextField setStringValue:NSLocalizedString(@"ERROR_PASSWORD_MISSMATCH", "Passwords do not match")];
self.errorTextField.stringValue = NSLocalizedString(@"ERROR_PASSWORD_MISSMATCH", "Passwords do not match");
}
else {
[self.errorTextField setStringValue:NSLocalizedString(@"ERROR_INVALID_KEYFILE", "Keyfile not valid")];
self.errorTextField.stringValue = NSLocalizedString(@"ERROR_INVALID_KEYFILE", "Keyfile not valid");
}
}