Fixed issue that resulted in password change button being disabled for empty password/keys after canceling the lossy save warning dialog

This commit is contained in:
michael starke
2013-09-04 23:55:56 +02:00
parent 2e5f03b515
commit add5074daa
3 changed files with 14 additions and 13 deletions

View File

@@ -413,6 +413,7 @@ typedef NS_ENUM(NSUInteger, MPAlertContext) {
if(changedPasswordOrKey && _saveAfterPasswordChange) { if(changedPasswordOrKey && _saveAfterPasswordChange) {
[self saveDocument:nil]; [self saveDocument:nil];
} }
_saveAfterPasswordChange = NO;
} }
#pragma mark Alert Delegate #pragma mark Alert Delegate

View File

@@ -15,12 +15,12 @@
#import "KPKTree.h" #import "KPKTree.h"
@interface MPPasswordEditWindowController () { @interface MPPasswordEditWindowController ()
MPDocument * __unsafe_unretained _document;
} @property (nonatomic, weak) MPDocument *currentDocument;
@property (nonatomic,assign) BOOL showPassword; @property (nonatomic, assign) BOOL showPassword;
@property (nonatomic,assign) BOOL hasValidPasswordOrKey; @property (nonatomic, assign) BOOL hasValidPasswordOrKey;
@property (nonatomic,weak) NSURL *keyURL; @property (nonatomic, weak) NSURL *keyURL;
@end @end
@@ -32,7 +32,7 @@
_allowsEmptyPasswordOrKey = YES; _allowsEmptyPasswordOrKey = YES;
_showPassword = NO; _showPassword = NO;
_hasValidPasswordOrKey = NO; _hasValidPasswordOrKey = NO;
_document = document; _currentDocument = document;
} }
return self; return self;
} }
@@ -47,9 +47,9 @@
return; return;
} }
self.showPassword = NO; self.showPassword = NO;
[self.passwordTextField setStringValue:_document.password ? _document.password : @""]; [self.passwordTextField setStringValue:_currentDocument.password ? _currentDocument.password : @""];
[self.passwordRepeatTextField setStringValue:[self.passwordTextField stringValue]]; [self.passwordRepeatTextField setStringValue:[self.passwordTextField stringValue]];
self.keyURL = _document.key; self.keyURL = _currentDocument.key;
NSDictionary *negateOption = @{ NSValueTransformerNameBindingOption : NSNegateBooleanTransformerName }; NSDictionary *negateOption = @{ NSValueTransformerNameBindingOption : NSNegateBooleanTransformerName };
[self.passwordTextField bind:@"showPassword" toObject:self withKeyPath:@"showPassword" options:nil]; [self.passwordTextField bind:@"showPassword" toObject:self withKeyPath:@"showPassword" options:nil];
@@ -82,8 +82,8 @@
#pragma mark Actions #pragma mark Actions
- (IBAction)save:(id)sender { - (IBAction)save:(id)sender {
_document.password = [self.passwordTextField stringValue]; _currentDocument.password = [self.passwordTextField stringValue];
_document.key = [self.keyfilePathControl URL]; _currentDocument.key = [self.keyfilePathControl URL];
[self dismissSheet:NSRunStoppedResponse]; [self dismissSheet:NSRunStoppedResponse];
if(self.delegate && [self.delegate respondsToSelector:@selector(didFinishPasswordEditing:)]) { if(self.delegate && [self.delegate respondsToSelector:@selector(didFinishPasswordEditing:)]) {
[self.delegate didFinishPasswordEditing:YES]; [self.delegate didFinishPasswordEditing:YES];
@@ -102,7 +102,7 @@
} }
- (IBAction)generateKey:(id)sender { - (IBAction)generateKey:(id)sender {
NSData *data = [NSData generateKeyfiledataForVersion:_document.tree.minimumVersion]; NSData *data = [NSData generateKeyfiledataForVersion:_currentDocument.tree.minimumVersion];
if(data) { if(data) {
NSSavePanel *savePanel = [NSSavePanel savePanel]; NSSavePanel *savePanel = [NSSavePanel savePanel];
[savePanel setAllowedFileTypes:@[@"key", @"xml"]]; [savePanel setAllowedFileTypes:@[@"key", @"xml"]];

View File

@@ -12,7 +12,7 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
/** /**
* Generic Windowcontroller to be used for sheets * Generic Windowcontroller to be used for sheets
* Subclasses are ablte to initalize their views within updateView * Subclasses are able to initalize their views within updateView
* and thus are able to reset themself befor being displayed as sheets * and thus are able to reset themself befor being displayed as sheets
*/ */
@interface MPSheetWindowController : NSWindowController @interface MPSheetWindowController : NSWindowController