mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 11:42:30 +00:00
using properties where possible
This commit is contained in:
@@ -196,14 +196,14 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
|
|||||||
if([fileType isEqualToString:MPLegacyDocumentUTI]) {
|
if([fileType isEqualToString:MPLegacyDocumentUTI]) {
|
||||||
if(document.tree.minimumVersion != KPKLegacyVersion) {
|
if(document.tree.minimumVersion != KPKLegacyVersion) {
|
||||||
NSAlert *alert = [[NSAlert alloc] init];
|
NSAlert *alert = [[NSAlert alloc] init];
|
||||||
[alert setAlertStyle:NSWarningAlertStyle];
|
alert.alertStyle = NSWarningAlertStyle;
|
||||||
[alert setMessageText:NSLocalizedString(@"WARNING_ON_LOSSY_SAVE", "")];
|
alert.messageText = NSLocalizedString(@"WARNING_ON_LOSSY_SAVE", "");
|
||||||
[alert setInformativeText:NSLocalizedString(@"WARNING_ON_LOSSY_SAVE_DESCRIPTION", "Informative Text displayed when saving would yield data loss")];
|
alert.informativeText = NSLocalizedString(@"WARNING_ON_LOSSY_SAVE_DESCRIPTION", "Informative Text displayed when saving would yield data loss");
|
||||||
|
|
||||||
[alert addButtonWithTitle:NSLocalizedString(@"SAVE_LOSSY", "Save lossy")];
|
[alert addButtonWithTitle:NSLocalizedString(@"SAVE_LOSSY", "Save lossy")];
|
||||||
[alert addButtonWithTitle:NSLocalizedString(@"CHANGE_FORMAT", "")];
|
[alert addButtonWithTitle:NSLocalizedString(@"CHANGE_FORMAT", "")];
|
||||||
[alert addButtonWithTitle:NSLocalizedString(@"CANCEL", "Cancel")];
|
[alert addButtonWithTitle:NSLocalizedString(@"CANCEL", "Cancel")];
|
||||||
|
|
||||||
//[[alert buttons][2] setKeyEquivalent:[NSString stringWithFormat:@"%c", 0x1b]];
|
|
||||||
[alert beginSheetModalForWindow:self.window
|
[alert beginSheetModalForWindow:self.window
|
||||||
modalDelegate:self
|
modalDelegate:self
|
||||||
didEndSelector:@selector(_dataLossOnSaveAlertDidEnd:returnCode:contextInfo:)
|
didEndSelector:@selector(_dataLossOnSaveAlertDidEnd:returnCode:contextInfo:)
|
||||||
@@ -232,7 +232,7 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* All set and good ready to save */
|
/* All set and good ready to save */
|
||||||
[[self document] saveDocument:sender];
|
[self.document saveDocument:sender];
|
||||||
}
|
}
|
||||||
- (void)saveDocumentAs:(id)sender {
|
- (void)saveDocumentAs:(id)sender {
|
||||||
self.passwordChangedBlock = nil;
|
self.passwordChangedBlock = nil;
|
||||||
@@ -297,6 +297,10 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)editPassword:(id)sender {
|
- (void)editPassword:(id)sender {
|
||||||
|
[self editPasswordWithCompetionHandler:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)editPasswordWithCompetionHandler:(void (^)(NSInteger result))handler {
|
||||||
if(!self.passwordEditWindowController) {
|
if(!self.passwordEditWindowController) {
|
||||||
self.passwordEditWindowController = [[MPPasswordEditWindowController alloc] init];
|
self.passwordEditWindowController = [[MPPasswordEditWindowController alloc] init];
|
||||||
self.passwordEditWindowController.delegate = self;
|
self.passwordEditWindowController.delegate = self;
|
||||||
@@ -422,7 +426,7 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
|
|||||||
NSView *entryView = self.entryViewController.view;
|
NSView *entryView = self.entryViewController.view;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The current easy way to prevent layout hiccups is to add the inspect
|
The current easy way to prevent layout hiccups is to add the inspector
|
||||||
Add all needed constraints an then remove it again, if it was hidden
|
Add all needed constraints an then remove it again, if it was hidden
|
||||||
*/
|
*/
|
||||||
BOOL removeInspector = NO;
|
BOOL removeInspector = NO;
|
||||||
@@ -488,12 +492,15 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
|
|||||||
MPDocument *document = [self document];
|
MPDocument *document = [self document];
|
||||||
if(document.shouldEnforcePasswordChange) {
|
if(document.shouldEnforcePasswordChange) {
|
||||||
NSAlert *alert = [[NSAlert alloc] init];
|
NSAlert *alert = [[NSAlert alloc] init];
|
||||||
[alert setAlertStyle:NSCriticalAlertStyle];
|
|
||||||
[alert setMessageText:NSLocalizedString(@"ENFORCE_PASSWORD_CHANGE_ALERT_TITLE", "")];
|
alert.alertStyle = NSCriticalAlertStyle;
|
||||||
[alert setInformativeText:NSLocalizedString(@"ENFORCE_PASSWORD_CHANGE_ALERT_DESCRIPTION", "")];
|
alert.messageText = NSLocalizedString(@"ENFORCE_PASSWORD_CHANGE_ALERT_TITLE", "");
|
||||||
|
alert.informativeText = NSLocalizedString(@"ENFORCE_PASSWORD_CHANGE_ALERT_DESCRIPTION", "");
|
||||||
|
|
||||||
[alert addButtonWithTitle:NSLocalizedString(@"CHANGE_PASSWORD_WITH_DOTS", "")];
|
[alert addButtonWithTitle:NSLocalizedString(@"CHANGE_PASSWORD_WITH_DOTS", "")];
|
||||||
[alert addButtonWithTitle:NSLocalizedString(@"CANCEL", "")];
|
[alert addButtonWithTitle:NSLocalizedString(@"CANCEL", "")];
|
||||||
[[alert buttons][1] setKeyEquivalent:[NSString stringWithFormat:@"%c", 0x1b]];
|
alert.buttons[1].keyEquivalent = [NSString stringWithFormat:@"%c", 0x1b];
|
||||||
|
|
||||||
[alert beginSheetModalForWindow:self.window
|
[alert beginSheetModalForWindow:self.window
|
||||||
modalDelegate:self
|
modalDelegate:self
|
||||||
didEndSelector:@selector(_enforcePasswordChangeAlertDidEnd:returnCode:contextInfo:)
|
didEndSelector:@selector(_enforcePasswordChangeAlertDidEnd:returnCode:contextInfo:)
|
||||||
@@ -501,12 +508,15 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
|
|||||||
}
|
}
|
||||||
else if(document.shouldRecommendPasswordChange) {
|
else if(document.shouldRecommendPasswordChange) {
|
||||||
NSAlert *alert = [[NSAlert alloc] init];
|
NSAlert *alert = [[NSAlert alloc] init];
|
||||||
[alert setAlertStyle:NSInformationalAlertStyle];
|
|
||||||
[alert setMessageText:NSLocalizedString(@"RECOMMEND_PASSWORD_CHANGE_ALERT_TITLE", "")];
|
alert.alertStyle = NSInformationalAlertStyle;
|
||||||
[alert setInformativeText:NSLocalizedString(@"RECOMMEND_PASSWORD_CHANGE_ALERT_DESCRIPTION", "")];
|
alert.messageText = NSLocalizedString(@"RECOMMEND_PASSWORD_CHANGE_ALERT_TITLE", "");
|
||||||
|
alert.informativeText = NSLocalizedString(@"RECOMMEND_PASSWORD_CHANGE_ALERT_DESCRIPTION", "");
|
||||||
|
|
||||||
[alert addButtonWithTitle:NSLocalizedString(@"CHANGE_PASSWORD_WITH_DOTS", "")];
|
[alert addButtonWithTitle:NSLocalizedString(@"CHANGE_PASSWORD_WITH_DOTS", "")];
|
||||||
[alert addButtonWithTitle:NSLocalizedString(@"CANCEL", "")];
|
[alert addButtonWithTitle:NSLocalizedString(@"CANCEL", "")];
|
||||||
[[alert buttons][1] setKeyEquivalent:[NSString stringWithFormat:@"%c", 0x1b]];
|
alert.buttons[1].keyEquivalent = [NSString stringWithFormat:@"%c", 0x1b];
|
||||||
|
|
||||||
[alert beginSheetModalForWindow:self.window
|
[alert beginSheetModalForWindow:self.window
|
||||||
modalDelegate:self
|
modalDelegate:self
|
||||||
didEndSelector:@selector(_recommentPasswordChangeAlertDidEnd:returnCode:contextInfo:)
|
didEndSelector:@selector(_recommentPasswordChangeAlertDidEnd:returnCode:contextInfo:)
|
||||||
@@ -519,14 +529,12 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
|
|||||||
switch(returnCode) {
|
switch(returnCode) {
|
||||||
case NSAlertFirstButtonReturn:
|
case NSAlertFirstButtonReturn:
|
||||||
/* Save lossy */
|
/* Save lossy */
|
||||||
[[self document] saveDocument:nil];
|
[self.document saveDocument:nil];
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case NSAlertSecondButtonReturn:
|
case NSAlertSecondButtonReturn:
|
||||||
/* Change Format */
|
[alert.window orderOut:nil];
|
||||||
//[[self document] setFileType:[MPDocument fileTypeForVersion:KPKXmlVersion]];
|
[self.document saveDocumentAs:nil];
|
||||||
[[alert window] orderOut:nil];
|
|
||||||
[[self document] saveDocumentAs:nil];
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case NSAlertThirdButtonReturn:
|
case NSAlertThirdButtonReturn:
|
||||||
@@ -562,8 +570,11 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
|
|||||||
self.passwordEditWindowController = nil;
|
self.passwordEditWindowController = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark -
|
- (void)_settingsSheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo {
|
||||||
#pragma mark UI Helper
|
/* cleanup the window controller */
|
||||||
|
[self.document removeWindowController:self.documentSettingsWindowController];
|
||||||
|
self.documentSettingsWindowController = nil;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)_showDatabaseSetting:(MPDatabaseSettingsTab)tab {
|
- (void)_showDatabaseSetting:(MPDatabaseSettingsTab)tab {
|
||||||
if(!self.documentSettingsWindowController) {
|
if(!self.documentSettingsWindowController) {
|
||||||
@@ -579,11 +590,8 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)_settingsSheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo {
|
#pragma mark -
|
||||||
/* cleanup the window controller */
|
#pragma mark UI Helper
|
||||||
[self.document removeWindowController:self.documentSettingsWindowController];
|
|
||||||
self.documentSettingsWindowController = nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL)_isInspectorVisible {
|
- (BOOL)_isInspectorVisible {
|
||||||
NSView *inspectorView = [self.inspectorViewController view];
|
NSView *inspectorView = [self.inspectorViewController view];
|
||||||
|
|||||||
@@ -96,7 +96,7 @@
|
|||||||
keyFileURL:self.keyPathControl.URL
|
keyFileURL:self.keyPathControl.URL
|
||||||
error:&error]) {
|
error:&error]) {
|
||||||
[self _showError:error];
|
[self _showError:error];
|
||||||
[[[self view] window] shakeWindow:nil];
|
[self.view.window shakeWindow:nil];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user