mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-13 08:52:20 +00:00
Added sanity checks to key file selection in unlock screen (fixes #1008)
This commit is contained in:
@@ -40,6 +40,7 @@
|
||||
4C1ECAE322CCD30F00F46069 /* MPAutotypeDoctor.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C1ECAE222CCD30F00F46069 /* MPAutotypeDoctor.m */; };
|
||||
4C1F7FA21E3A12E600D6A40E /* MPModifiedKey.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C1F7FA11E3A12E600D6A40E /* MPModifiedKey.m */; };
|
||||
4C1FA07B18231900003A3F8C /* MPDocument+Autotype.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C1FA07A18231900003A3F8C /* MPDocument+Autotype.m */; };
|
||||
4C2057EE23CDF6F900C731EC /* MPPathCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C2057ED23CDF6F900C731EC /* MPPathCell.m */; };
|
||||
4C224B4217DFCB2400FF6AEE /* MPNumericalInputFormatter.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C224B4117DFCB2400FF6AEE /* MPNumericalInputFormatter.m */; };
|
||||
4C25703F1BF11C2300D39416 /* MPPluginPreferencesController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C25703D1BF11C2300D39416 /* MPPluginPreferencesController.m */; };
|
||||
4C25D58716CF0FAA00F6806C /* EntryView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C25D58616CF0FAA00F6806C /* EntryView.xib */; };
|
||||
@@ -401,6 +402,9 @@
|
||||
4C1F7FA01E3A12E600D6A40E /* MPModifiedKey.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPModifiedKey.h; sourceTree = "<group>"; };
|
||||
4C1F7FA11E3A12E600D6A40E /* MPModifiedKey.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPModifiedKey.m; sourceTree = "<group>"; };
|
||||
4C1FA07A18231900003A3F8C /* MPDocument+Autotype.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "MPDocument+Autotype.m"; sourceTree = "<group>"; };
|
||||
4C2057EC23CDF6F900C731EC /* MPPathCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MPPathCell.h; sourceTree = "<group>"; };
|
||||
4C2057ED23CDF6F900C731EC /* MPPathCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MPPathCell.m; sourceTree = "<group>"; };
|
||||
4C2057EF23CDFC2000C731EC /* MPPathControl+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "MPPathControl+Private.h"; sourceTree = "<group>"; };
|
||||
4C21F29F195B3A48002D610D /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/MainMenu.strings; sourceTree = "<group>"; };
|
||||
4C224B4017DFCB2300FF6AEE /* MPNumericalInputFormatter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPNumericalInputFormatter.h; sourceTree = "<group>"; };
|
||||
4C224B4117DFCB2400FF6AEE /* MPNumericalInputFormatter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPNumericalInputFormatter.m; sourceTree = "<group>"; };
|
||||
@@ -1641,7 +1645,10 @@
|
||||
4C57AE1217BA422B00CA4F34 /* MPSegmentedContextCell.h */,
|
||||
4C57AE1317BA422B00CA4F34 /* MPSegmentedContextCell.m */,
|
||||
4CC59C2521AF0893005E8D6B /* MPPathControl.h */,
|
||||
4C2057EF23CDFC2000C731EC /* MPPathControl+Private.h */,
|
||||
4CC59C2621AF0893005E8D6B /* MPPathControl.m */,
|
||||
4C2057EC23CDF6F900C731EC /* MPPathCell.h */,
|
||||
4C2057ED23CDF6F900C731EC /* MPPathCell.m */,
|
||||
);
|
||||
name = Controls;
|
||||
sourceTree = "<group>";
|
||||
@@ -2115,6 +2122,7 @@
|
||||
4C0728BD17B5B7F7005A7DD9 /* MPPasswordEditWindowController.m in Sources */,
|
||||
4C0F647B17B6BC9C00D9522A /* MPSavePanelAccessoryViewController.m in Sources */,
|
||||
4C0949591FD6B89B004F2971 /* NSUserNotification+MPAdditions.m in Sources */,
|
||||
4C2057EE23CDF6F900C731EC /* MPPathCell.m in Sources */,
|
||||
4C3B42871F935316007B04FD /* MPDayCountFormatter.m in Sources */,
|
||||
3C0CDECF21CFEDD200B2A10B /* NSTextView+MPTouchBarExtension.m in Sources */,
|
||||
4C57AE1417BA422B00CA4F34 /* MPSegmentedContextCell.m in Sources */,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="15705" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.70"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="15705"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
@@ -10,6 +10,7 @@
|
||||
<connections>
|
||||
<outlet property="cancelButton" destination="2pb-ZG-spA" id="YrR-Yi-dnQ"/>
|
||||
<outlet property="enablePasswordCheckBox" destination="d8O-Ha-rrS" id="2AI-e9-sph"/>
|
||||
<outlet property="keyFileWarningTextField" destination="txI-yI-5nE" id="WhF-O8-fsZ"/>
|
||||
<outlet property="keyPathControl" destination="241" id="261"/>
|
||||
<outlet property="messageImageView" destination="262" id="726-wK-c2h"/>
|
||||
<outlet property="messageInfoTextField" destination="268" id="ahE-sq-QzR"/>
|
||||
@@ -22,10 +23,10 @@
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<customView horizontalCompressionResistancePriority="751" translatesAutoresizingMaskIntoConstraints="NO" id="1">
|
||||
<rect key="frame" x="0.0" y="0.0" width="508" height="392"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="508" height="526"/>
|
||||
<subviews>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="2">
|
||||
<rect key="frame" x="310" y="105" width="83" height="32"/>
|
||||
<rect key="frame" x="310" y="168" width="83" height="32"/>
|
||||
<buttonCell key="cell" type="push" title="Unlock" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="3">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
@@ -38,7 +39,7 @@ DQ
|
||||
</connections>
|
||||
</button>
|
||||
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="17">
|
||||
<rect key="frame" x="108" y="157" width="45" height="17"/>
|
||||
<rect key="frame" x="108" y="226" width="45" height="16"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Keyfile" id="18">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
@@ -46,13 +47,13 @@ DQ
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<pathControl verticalHuggingPriority="750" allowsExpansionToolTips="YES" translatesAutoresizingMaskIntoConstraints="NO" id="241" customClass="MPPathControl">
|
||||
<rect key="frame" x="156" y="153" width="197" height="25"/>
|
||||
<pathCell key="cell" selectable="YES" editable="YES" alignment="left" pathStyle="popUp" id="242">
|
||||
<rect key="frame" x="156" y="222" width="197" height="25"/>
|
||||
<pathCell key="cell" selectable="YES" editable="YES" alignment="left" pathStyle="popUp" id="242" customClass="MPPathCell">
|
||||
<font key="font" metaFont="system"/>
|
||||
</pathCell>
|
||||
</pathControl>
|
||||
<imageView translatesAutoresizingMaskIntoConstraints="NO" id="262">
|
||||
<rect key="frame" x="230" y="241" width="48" height="48"/>
|
||||
<rect key="frame" x="230" y="305" width="48" height="48"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="48" id="273"/>
|
||||
<constraint firstAttribute="width" constant="48" id="456"/>
|
||||
@@ -60,7 +61,7 @@ DQ
|
||||
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyUpOrDown" image="02_MessageBoxWarningTemplate" id="263"/>
|
||||
</imageView>
|
||||
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="268">
|
||||
<rect key="frame" x="199" y="216" width="110" height="17"/>
|
||||
<rect key="frame" x="199" y="281" width="110" height="16"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Wrong password!" id="269">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
@@ -68,7 +69,7 @@ DQ
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<secureTextField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="338" customClass="HNHUISecureTextField">
|
||||
<rect key="frame" x="159" y="184" width="191" height="24"/>
|
||||
<rect key="frame" x="159" y="253" width="191" height="20"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="191" id="389"/>
|
||||
</constraints>
|
||||
@@ -85,14 +86,14 @@ DQ
|
||||
</connections>
|
||||
</secureTextField>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="408">
|
||||
<rect key="frame" x="358" y="185" width="29" height="23"/>
|
||||
<rect key="frame" x="358" y="250" width="29" height="23"/>
|
||||
<buttonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" image="NSQuickLookTemplate" imagePosition="only" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="409">
|
||||
<behavior key="behavior" pushIn="YES" changeContents="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
</button>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="486">
|
||||
<rect key="frame" x="358" y="152" width="29" height="23"/>
|
||||
<rect key="frame" x="358" y="220" width="29" height="23"/>
|
||||
<buttonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" image="NSStopProgressTemplate" imagePosition="only" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="487">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
@@ -102,14 +103,14 @@ DQ
|
||||
</connections>
|
||||
</button>
|
||||
<button translatesAutoresizingMaskIntoConstraints="NO" id="d8O-Ha-rrS">
|
||||
<rect key="frame" x="72" y="187" width="81" height="18"/>
|
||||
<rect key="frame" x="72" y="254" width="81" height="18"/>
|
||||
<buttonCell key="cell" type="check" title="Password" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="IU9-5u-jn9">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
</button>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="2pb-ZG-spA">
|
||||
<rect key="frame" x="228" y="105" width="82" height="32"/>
|
||||
<rect key="frame" x="228" y="168" width="82" height="32"/>
|
||||
<buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="erj-mR-UyO">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
@@ -121,6 +122,14 @@ Gw
|
||||
<action selector="_submit:" target="-2" id="aVF-1d-1Hq"/>
|
||||
</connections>
|
||||
</button>
|
||||
<textField hidden="YES" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" setsMaxLayoutWidthAtFirstLayout="YES" translatesAutoresizingMaskIntoConstraints="NO" id="txI-yI-5nE">
|
||||
<rect key="frame" x="157" y="204" width="195" height="14"/>
|
||||
<textFieldCell key="cell" selectable="YES" title="key_file_warnig" id="f6J-5f-ZvP">
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="2" secondAttribute="bottom" constant="20" symbolic="YES" id="122"/>
|
||||
@@ -144,15 +153,18 @@ Gw
|
||||
<constraint firstItem="2" firstAttribute="trailing" secondItem="486" secondAttribute="trailing" id="496"/>
|
||||
<constraint firstItem="408" firstAttribute="leading" secondItem="338" secondAttribute="trailing" constant="8" symbolic="YES" id="7qE-8F-QgB"/>
|
||||
<constraint firstItem="2pb-ZG-spA" firstAttribute="baseline" secondItem="2" secondAttribute="baseline" id="9nK-MH-Ozs"/>
|
||||
<constraint firstItem="txI-yI-5nE" firstAttribute="trailing" secondItem="241" secondAttribute="trailing" id="AVL-HO-SMq"/>
|
||||
<constraint firstItem="17" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="1" secondAttribute="leading" constant="20" symbolic="YES" id="EOa-K4-v7J"/>
|
||||
<constraint firstItem="338" firstAttribute="leading" secondItem="d8O-Ha-rrS" secondAttribute="trailing" constant="8" symbolic="YES" id="KYs-Ia-SVl"/>
|
||||
<constraint firstItem="2pb-ZG-spA" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="1" secondAttribute="leading" constant="20" symbolic="YES" id="SUS-76-os4"/>
|
||||
<constraint firstItem="2" firstAttribute="top" secondItem="txI-yI-5nE" secondAttribute="bottom" constant="8" symbolic="YES" id="jJs-hc-O2O"/>
|
||||
<constraint firstItem="d8O-Ha-rrS" firstAttribute="centerY" secondItem="338" secondAttribute="centerY" id="kgB-jV-OGy"/>
|
||||
<constraint firstItem="2" firstAttribute="top" secondItem="486" secondAttribute="bottom" constant="20" symbolic="YES" id="v1K-wm-EeB"/>
|
||||
<constraint firstItem="txI-yI-5nE" firstAttribute="top" secondItem="241" secondAttribute="bottom" constant="8" symbolic="YES" id="lfg-eB-T2O"/>
|
||||
<constraint firstItem="txI-yI-5nE" firstAttribute="leading" secondItem="241" secondAttribute="leading" id="nGY-6Q-Vwy"/>
|
||||
<constraint firstItem="d8O-Ha-rrS" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="1" secondAttribute="leading" constant="20" symbolic="YES" id="vxq-YP-UhR"/>
|
||||
<constraint firstItem="2" firstAttribute="leading" secondItem="2pb-ZG-spA" secondAttribute="trailing" constant="12" id="ytJ-5Z-5rT"/>
|
||||
</constraints>
|
||||
<point key="canvasLocation" x="147" y="-80"/>
|
||||
<point key="canvasLocation" x="-127" y="-46"/>
|
||||
</customView>
|
||||
</objects>
|
||||
<resources>
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
@property (weak) IBOutlet MPPathControl *keyPathControl;
|
||||
@property (weak) IBOutlet NSImageView *messageImageView;
|
||||
@property (weak) IBOutlet NSTextField *messageInfoTextField;
|
||||
@property (strong) IBOutlet NSTextField *keyFileWarningTextField;
|
||||
@property (weak) IBOutlet NSButton *togglePasswordButton;
|
||||
@property (weak) IBOutlet NSButton *enablePasswordCheckBox;
|
||||
@property (weak) IBOutlet NSButton *unlockButton;
|
||||
@@ -50,6 +51,7 @@
|
||||
@property (assign) BOOL showPassword;
|
||||
@property (nonatomic, assign) BOOL enablePassword;
|
||||
@property (copy) passwordInputCompletionBlock completionHandler;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MPPasswordInputController
|
||||
@@ -72,6 +74,7 @@
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_didSetKeyURL:) name:MPPathControlDidSetURLNotification object:self.keyPathControl];
|
||||
self.messageImageView.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];
|
||||
@@ -108,7 +111,7 @@
|
||||
self.passwordTextField.placeholderString = NSLocalizedString(@"PASSWORD_INPUT_ENTER_PASSWORD", "Placeholder in the unlock-password input field if password is enabled");
|
||||
}
|
||||
else {
|
||||
self.passwordTextField.placeholderString = NSLocalizedString(@"PASSWORD_INPUT_NO_PASSWORD", "Placeholder in the unlock-password input field if password is disabled");
|
||||
self.passwordTextField.placeholderString = NSLocalizedString(@"PASSWORD_INPUT_NO_PASSWORD", "Placeholder in the unlock-password input field if password is disabled");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,4 +214,29 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)_didSetKeyURL:(NSNotification *)notification {
|
||||
if(notification.object != self.keyPathControl) {
|
||||
return; // wrong sender
|
||||
}
|
||||
NSDocument *document = (NSDocument *)self.windowController.document;
|
||||
NSData *keyFileData = [NSData dataWithContentsOfURL:self.keyPathControl.URL];
|
||||
KPKFileVersion keyFileVersion = [KPKFormat.sharedFormat fileVersionForData:keyFileData];
|
||||
BOOL isKdbDatabaseFile = (keyFileVersion.format != KPKDatabaseFormatUnknown);
|
||||
if(isKdbDatabaseFile) {
|
||||
if([document.fileURL isEqual:self.keyPathControl.URL]) {
|
||||
self.keyFileWarningTextField.stringValue = NSLocalizedString(@"ERROR_CURRENT_DATABASE_FILE_SELECTED_AS_KEY_FILE", "Error message displayed when the current database file is also set as the key file");
|
||||
self.keyFileWarningTextField.hidden = NO;
|
||||
}
|
||||
else {
|
||||
self.keyFileWarningTextField.stringValue = NSLocalizedString(@"ERROR_DATABASE_FILE_SELECTED_AS_KEY_FILE", "Error message displayed when a keepass database file is set as the key file");
|
||||
self.keyFileWarningTextField.hidden = NO;
|
||||
}
|
||||
}
|
||||
else {
|
||||
self.keyFileWarningTextField.stringValue = @"";
|
||||
self.keyFileWarningTextField.hidden = YES;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
17
MacPass/MPPathCell.h
Normal file
17
MacPass/MPPathCell.h
Normal file
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// MPPathCell.h
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 14.01.20.
|
||||
// Copyright © 2020 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface MPPathCell : NSPathCell
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
23
MacPass/MPPathCell.m
Normal file
23
MacPass/MPPathCell.m
Normal file
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// MPPathCell.m
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 14.01.20.
|
||||
// Copyright © 2020 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MPPathCell.h"
|
||||
#import "MPPathControl+Private.h"
|
||||
|
||||
@implementation MPPathCell
|
||||
|
||||
- (void)setURL:(NSURL *)URL {
|
||||
super.URL = URL;
|
||||
if([self.controlView isKindOfClass:MPPathControl.class]) {
|
||||
MPPathControl *pc = (MPPathControl *)self.controlView;
|
||||
[pc _postDidSetURLNotification];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
22
MacPass/MPPathControl+Private.h
Normal file
22
MacPass/MPPathControl+Private.h
Normal file
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// MPPathControl+Private.h
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 14.01.20.
|
||||
// Copyright © 2020 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import <AppKit/AppKit.h>
|
||||
|
||||
|
||||
#import "MPPathControl.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface MPPathControl ()
|
||||
|
||||
- (void)_postDidSetURLNotification;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -10,6 +10,8 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
APPKIT_EXTERN NSString *const MPPathControlDidSetURLNotification;
|
||||
|
||||
@interface MPPathControl : NSPathControl <NSPathControlDelegate>
|
||||
|
||||
- (IBAction)showOpenPanel:(id _Nullable)sender;
|
||||
|
||||
@@ -7,6 +7,11 @@
|
||||
//
|
||||
|
||||
#import "MPPathControl.h"
|
||||
#import "MPPathControl+Private.h"
|
||||
|
||||
#import "MPPathCell.h"
|
||||
|
||||
NSString *const MPPathControlDidSetURLNotification = @"MPPathControlDidSetURLNotification";
|
||||
|
||||
@implementation MPPathControl
|
||||
|
||||
@@ -25,15 +30,26 @@
|
||||
- (instancetype)initWithFrame:(NSRect)frameRect {
|
||||
self = [super initWithFrame:frameRect];
|
||||
self.delegate = self;
|
||||
[self _setupCell];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithCoder:(NSCoder *)coder {
|
||||
self = [super initWithCoder:coder];
|
||||
self.delegate = self;
|
||||
self.delegate = self;
|
||||
[self _setupCell];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)_setupCell {
|
||||
if([self.cell isKindOfClass:MPPathCell.class]) {
|
||||
return;
|
||||
}
|
||||
NSData *archive = [NSKeyedArchiver archivedDataWithRootObject:self.cell];
|
||||
NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:archive];
|
||||
self.cell = [[MPPathCell alloc] initWithCoder:unarchiver];
|
||||
}
|
||||
|
||||
- (void)willOpenMenu:(NSMenu *)menu withEvent:(NSEvent *)event {
|
||||
if(!self.URL) {
|
||||
[menu cancelTracking];
|
||||
@@ -59,7 +75,7 @@
|
||||
return;
|
||||
}
|
||||
if(@available(macOS 10.11, *)) {
|
||||
NSLog(@"Skipping 10.10 pathControl:willPopUpMenu");
|
||||
// skip
|
||||
}
|
||||
else {
|
||||
if(!self.URL) {
|
||||
@@ -78,4 +94,8 @@
|
||||
openPanel.prompt = NSLocalizedString(@"CHOOSE_FILE_BUTTON_TITLE", @"Button title in the key file selection dialog for selecting a key");
|
||||
}
|
||||
|
||||
- (void)_postDidSetURLNotification {
|
||||
[NSNotificationCenter.defaultCenter postNotificationName:MPPathControlDidSetURLNotification object:self];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user