mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 11:42:30 +00:00
minor code improvements
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="12120" systemVersion="16F73" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11762"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="12120"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
@@ -32,10 +32,10 @@ DQ
|
||||
</string>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="_decrypt:" target="-2" id="295"/>
|
||||
<action selector="_submit:" target="-2" id="KZN-ap-nDc"/>
|
||||
</connections>
|
||||
</button>
|
||||
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="17">
|
||||
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="17">
|
||||
<rect key="frame" x="116" y="112" width="45" height="17"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Keyfile" id="18">
|
||||
<font key="font" metaFont="system"/>
|
||||
@@ -57,7 +57,7 @@ DQ
|
||||
</constraints>
|
||||
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyUpOrDown" image="02_MessageBoxWarningTemplate" id="263"/>
|
||||
</imageView>
|
||||
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="268">
|
||||
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="268">
|
||||
<rect key="frame" x="207" y="172" width="110" height="17"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Wrong password!" id="269">
|
||||
<font key="font" metaFont="system"/>
|
||||
@@ -65,7 +65,7 @@ DQ
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<secureTextField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="338" customClass="HNHUIRoundedSecureTextField">
|
||||
<secureTextField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="338" customClass="HNHUIRoundedSecureTextField">
|
||||
<rect key="frame" x="167" y="140" width="191" height="24"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="191" id="389"/>
|
||||
|
||||
@@ -283,6 +283,8 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou
|
||||
/* Set the flag in this call! */
|
||||
self.lockedForFileChange = YES;
|
||||
|
||||
/* TODO read file to check if changes took place! */
|
||||
|
||||
/* Dispatch the alert to the main queue */
|
||||
__weak MPDocument *welf = self;
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
||||
@@ -52,8 +52,8 @@
|
||||
}
|
||||
|
||||
- (void)didLoadView {
|
||||
[self.keyPathControl setDelegate:self.pathControlDelegate];
|
||||
[self.errorImageView setImage:[NSImage imageNamed:NSImageNameCaution]];
|
||||
self.keyPathControl.delegate = self.pathControlDelegate;
|
||||
self.errorImageView.image = [NSImage imageNamed:NSImageNameCaution];
|
||||
[self.passwordTextField bind:NSStringFromSelector(@selector(showPassword)) toObject:self withKeyPath:NSStringFromSelector(@selector(showPassword)) options:nil];
|
||||
[self.togglePasswordButton bind:NSValueBinding toObject:self withKeyPath:NSStringFromSelector(@selector(showPassword)) options:nil];
|
||||
[self.enablePasswordCheckBox bind:NSValueBinding toObject:self withKeyPath:NSStringFromSelector(@selector(enablePassword)) options:nil];
|
||||
@@ -76,22 +76,21 @@
|
||||
if(_enablePassword != enablePassword) {
|
||||
_enablePassword = enablePassword;
|
||||
if(!_enablePassword) {
|
||||
[self.passwordTextField setStringValue:@""];
|
||||
self.passwordTextField.stringValue = @"";
|
||||
}
|
||||
}
|
||||
NSString *placeHolderString = _enablePassword ? NSLocalizedString(@"PASSWORD_INPUT_ENTER_PASSWORD", "") : NSLocalizedString(@"PASSWORD_INPUT_NO_PASSWORD", "");
|
||||
[self.passwordTextField.cell setPlaceholderString:placeHolderString];
|
||||
((NSTextFieldCell *)self.passwordTextField.cell).placeholderString = placeHolderString;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Private
|
||||
- (IBAction)_decrypt:(id)sender {
|
||||
|
||||
NSError *error = nil;
|
||||
/* No password is different than an empty password */
|
||||
NSString *password = self.enablePassword ? self.passwordTextField.stringValue : nil;
|
||||
- (IBAction)_submit:(id)sender {
|
||||
if(self.completionHandler) {
|
||||
/* No password is different than an empty password */
|
||||
NSError *error = nil;
|
||||
NSString *password = self.enablePassword ? self.passwordTextField.stringValue : nil;
|
||||
if(!self.completionHandler(password, self.keyPathControl.URL, &error)) {
|
||||
[self _showError:error];
|
||||
[self.view.window shakeWindow:nil];
|
||||
@@ -105,31 +104,30 @@
|
||||
[self _selectKeyURL];
|
||||
}
|
||||
else {
|
||||
[self.keyPathControl setURL:nil];
|
||||
self.keyPathControl.URL = nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)_reset {
|
||||
self.showPassword = NO;
|
||||
self.enablePassword = YES;
|
||||
[self.passwordTextField setStringValue:@""];
|
||||
[self.errorInfoTextField setHidden:YES];
|
||||
[self.errorImageView setHidden:YES];
|
||||
self.passwordTextField.stringValue = @"";
|
||||
self.errorInfoTextField.hidden = YES;
|
||||
self.errorImageView.hidden = YES;
|
||||
[self resetKeyFile:self];
|
||||
}
|
||||
|
||||
- (void)_selectKeyURL {
|
||||
MPDocument *document = [[self windowController] document];
|
||||
[self.keyPathControl setURL:document.suggestedKeyURL];
|
||||
MPDocument *document = self.windowController.document;
|
||||
self.keyPathControl.URL = document.suggestedKeyURL;
|
||||
}
|
||||
|
||||
- (void)_showError:(NSError *)error {
|
||||
if(error) {
|
||||
NSString *errorMessage = [error descriptionForErrorCode];
|
||||
[self.errorInfoTextField setStringValue:errorMessage];
|
||||
self.errorInfoTextField.stringValue = error.descriptionForErrorCode;
|
||||
}
|
||||
[self.errorImageView setHidden:NO];
|
||||
[self.errorInfoTextField setHidden:NO];
|
||||
self.errorImageView.hidden = NO;
|
||||
self.errorInfoTextField.hidden = NO;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user