mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 12:52:21 +00:00
fixed #161 settings to copy to clipboard on password creation are preserved. Default behaviour is to restore the last sate
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
#import "MPPasteBoardController.h"
|
#import "MPPasteBoardController.h"
|
||||||
#import "NSString+MPPasswordCreation.h"
|
#import "NSString+MPPasswordCreation.h"
|
||||||
#import "MPUniqueCharactersFormatter.h"
|
#import "MPUniqueCharactersFormatter.h"
|
||||||
|
#import "MPSettingsHelper.h"
|
||||||
|
|
||||||
typedef NS_ENUM(NSUInteger, MPPasswordRating) {
|
typedef NS_ENUM(NSUInteger, MPPasswordRating) {
|
||||||
MPPasswordTerrible = 10,
|
MPPasswordTerrible = 10,
|
||||||
@@ -19,7 +20,6 @@ typedef NS_ENUM(NSUInteger, MPPasswordRating) {
|
|||||||
MPPasswordStrong = 60
|
MPPasswordStrong = 60
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
0 - 20 Terrible
|
0 - 20 Terrible
|
||||||
@@ -43,7 +43,7 @@ typedef NS_ENUM(NSUInteger, MPPasswordRating) {
|
|||||||
@property (weak) IBOutlet NSTextField *passwordLengthTextField;
|
@property (weak) IBOutlet NSTextField *passwordLengthTextField;
|
||||||
@property (weak) IBOutlet NSTextField *customCharactersTextField;
|
@property (weak) IBOutlet NSTextField *customCharactersTextField;
|
||||||
@property (weak) IBOutlet NSSlider *passwordLengthSlider;
|
@property (weak) IBOutlet NSSlider *passwordLengthSlider;
|
||||||
@property (weak) IBOutlet NSButton *addPasswordToPasteboardButton;
|
@property (weak) IBOutlet NSButton *shouldCopyPasswordToPasteboardButton;
|
||||||
@property (weak) IBOutlet NSButton *upperCaseButton;
|
@property (weak) IBOutlet NSButton *upperCaseButton;
|
||||||
@property (weak) IBOutlet NSButton *lowerCaseButton;
|
@property (weak) IBOutlet NSButton *lowerCaseButton;
|
||||||
@property (weak) IBOutlet NSButton *numbersButton;
|
@property (weak) IBOutlet NSButton *numbersButton;
|
||||||
@@ -79,8 +79,7 @@ typedef NS_ENUM(NSUInteger, MPPasswordRating) {
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)awakeFromNib {
|
||||||
- (void)didLoadView {
|
|
||||||
[self.passwordLengthSlider setMinValue:MIN_PASSWORD_LENGTH];
|
[self.passwordLengthSlider setMinValue:MIN_PASSWORD_LENGTH];
|
||||||
[self.passwordLengthSlider setMaxValue:MAX_PASSWORD_LENGTH];
|
[self.passwordLengthSlider setMaxValue:MAX_PASSWORD_LENGTH];
|
||||||
[self.passwordLengthSlider setContinuous:YES];
|
[self.passwordLengthSlider setContinuous:YES];
|
||||||
@@ -97,12 +96,16 @@ typedef NS_ENUM(NSUInteger, MPPasswordRating) {
|
|||||||
[self.entropyTextField bind:NSValueBinding toObject:self withKeyPath:@"entropy" options:nil];
|
[self.entropyTextField bind:NSValueBinding toObject:self withKeyPath:@"entropy" options:nil];
|
||||||
|
|
||||||
[self.customCharactersTextField setDelegate:self];
|
[self.customCharactersTextField setDelegate:self];
|
||||||
[_customButton bind:NSValueBinding toObject:self withKeyPath:@"useCustomString" options:nil];
|
[self.customButton bind:NSValueBinding toObject:self withKeyPath:@"useCustomString" options:nil];
|
||||||
|
|
||||||
[_numbersButton setTag:MPPasswordCharactersNumbers];
|
NSString *copyToPasteBoardKeyPath = [MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyCopyGeneratedPasswordToClipboard];
|
||||||
[_upperCaseButton setTag:MPPasswordCharactersUpperCase];
|
NSUserDefaultsController *defaultsController = [NSUserDefaultsController sharedUserDefaultsController];
|
||||||
[_lowerCaseButton setTag:MPPasswordCharactersLowerCase];
|
[self.shouldCopyPasswordToPasteboardButton bind:NSValueBinding toObject:defaultsController withKeyPath:copyToPasteBoardKeyPath options:nil];
|
||||||
[_symbolsButton setTag:MPPasswordCharactersSymbols];
|
|
||||||
|
[self.numbersButton setTag:MPPasswordCharactersNumbers];
|
||||||
|
[self.upperCaseButton setTag:MPPasswordCharactersUpperCase];
|
||||||
|
[self.lowerCaseButton setTag:MPPasswordCharactersLowerCase];
|
||||||
|
[self.symbolsButton setTag:MPPasswordCharactersSymbols];
|
||||||
|
|
||||||
[self _resetCharacters];
|
[self _resetCharacters];
|
||||||
[self _generatePassword:nil];
|
[self _generatePassword:nil];
|
||||||
@@ -131,17 +134,18 @@ typedef NS_ENUM(NSUInteger, MPPasswordRating) {
|
|||||||
|
|
||||||
- (IBAction)_usePassword:(id)sender {
|
- (IBAction)_usePassword:(id)sender {
|
||||||
self.generatedPassword = _password;
|
self.generatedPassword = _password;
|
||||||
if([self.addPasswordToPasteboardButton state] == NSOnState) {
|
if([self.shouldCopyPasswordToPasteboardButton state] == NSOnState) {
|
||||||
[[MPPasteBoardController defaultController] copyObjects:@[_password]];
|
[[MPPasteBoardController defaultController] copyObjects:@[_password]];
|
||||||
}
|
}
|
||||||
|
/* Since we might be displayed inside a NSPopup or a NSWindow, search for the target */
|
||||||
id target = [NSApp targetForAction:@selector(performClose:)];
|
id target = [NSApp targetForAction:@selector(performClose:)];
|
||||||
[target performClose:nil];
|
[target performClose:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (IBAction)_cancel:(id)sender {
|
- (IBAction)_cancel:(id)sender {
|
||||||
|
/* Since we might be displayed inside a NSPopup or a NSWindow, search for the target */
|
||||||
id target = [NSApp targetForAction:@selector(performClose:)];
|
id target = [NSApp targetForAction:@selector(performClose:)];
|
||||||
[target performClose:nil];
|
[target performClose:nil];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
|
|||||||
@@ -53,6 +53,12 @@ APPKIT_EXTERN NSString *const kMPSettingsKeyEnableGlobalAutotype;
|
|||||||
/* Search */
|
/* Search */
|
||||||
APPKIT_EXTERN NSString *const kMPSettingsKeyEntrySearchFilterMode;
|
APPKIT_EXTERN NSString *const kMPSettingsKeyEntrySearchFilterMode;
|
||||||
|
|
||||||
|
/* Quicklook */
|
||||||
|
APPKIT_EXTERN NSString *const kMPSettingsKeyEnableQuicklookPreview;
|
||||||
|
|
||||||
|
/* Password Generation */
|
||||||
|
APPKIT_EXTERN NSString *const kMPSettingsKeyCopyGeneratedPasswordToClipboard;
|
||||||
|
|
||||||
typedef NS_ENUM(NSUInteger, MPPasswordEncoding) {
|
typedef NS_ENUM(NSUInteger, MPPasswordEncoding) {
|
||||||
MPPasswordEncodingUTF8,
|
MPPasswordEncodingUTF8,
|
||||||
MPPasswordEncodingASCII,
|
MPPasswordEncodingASCII,
|
||||||
|
|||||||
@@ -37,6 +37,10 @@ NSString *const kMPSettingsKeyEnableGlobalAutotype = @"EnableGlobalAuto
|
|||||||
|
|
||||||
NSString *const kMPSettingsKeyEntrySearchFilterMode = @"EntrySearchFilterMode";
|
NSString *const kMPSettingsKeyEntrySearchFilterMode = @"EntrySearchFilterMode";
|
||||||
|
|
||||||
|
NSString *const kMPSettingsKeyEnableQuicklookPreview = @"EnableQuicklookPreview";
|
||||||
|
|
||||||
|
NSString *const kMPSettingsKeyCopyGeneratedPasswordToClipboard = @"CopyGeneratedPasswordToClipboard";
|
||||||
|
|
||||||
@implementation MPSettingsHelper
|
@implementation MPSettingsHelper
|
||||||
|
|
||||||
+ (void)setupDefaults {
|
+ (void)setupDefaults {
|
||||||
@@ -73,6 +77,8 @@ NSString *const kMPSettingsKeyEntrySearchFilterMode = @"EntrySearchFilte
|
|||||||
kMPSettingsKeySendCommandForControlKey: @YES,
|
kMPSettingsKeySendCommandForControlKey: @YES,
|
||||||
kMPSettingsKeyEntrySearchFilterMode: @0,
|
kMPSettingsKeyEntrySearchFilterMode: @0,
|
||||||
kMPSettingsKeyEnableGlobalAutotype: @NO,
|
kMPSettingsKeyEnableGlobalAutotype: @NO,
|
||||||
|
kMPSettingsKeyEnableQuicklookPreview: @NO,
|
||||||
|
kMPSettingsKeyCopyGeneratedPasswordToClipboard: @NO,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="4514" systemVersion="13A603" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="5053" systemVersion="13C64" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<deployment defaultVersion="1080" identifier="macosx"/>
|
<deployment defaultVersion="1080" identifier="macosx"/>
|
||||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="4514"/>
|
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="5053"/>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<objects>
|
<objects>
|
||||||
<customObject id="-2" userLabel="File's Owner" customClass="MPPasswordCreatorViewController">
|
<customObject id="-2" userLabel="File's Owner" customClass="MPPasswordCreatorViewController">
|
||||||
<connections>
|
<connections>
|
||||||
<outlet property="_cancel" destination="613" id="622"/>
|
<outlet property="_cancel" destination="613" id="622"/>
|
||||||
<outlet property="_copyToPasswordCheckbutton" destination="500" id="562"/>
|
<outlet property="_copyToPasswordCheckbutton" destination="500" id="562"/>
|
||||||
<outlet property="addPasswordToPasteboardButton" destination="500" id="599"/>
|
|
||||||
<outlet property="customButton" destination="468" id="598"/>
|
<outlet property="customButton" destination="468" id="598"/>
|
||||||
<outlet property="customCharactersTextField" destination="411" id="479"/>
|
<outlet property="customCharactersTextField" destination="411" id="479"/>
|
||||||
<outlet property="entropyIndicator" destination="635" id="676"/>
|
<outlet property="entropyIndicator" destination="635" id="676"/>
|
||||||
@@ -20,6 +19,7 @@
|
|||||||
<outlet property="passwordLengthTextFiedl" destination="182" id="473"/>
|
<outlet property="passwordLengthTextFiedl" destination="182" id="473"/>
|
||||||
<outlet property="passwordLengthTextField" destination="182" id="481"/>
|
<outlet property="passwordLengthTextField" destination="182" id="481"/>
|
||||||
<outlet property="passwordTextField" destination="152" id="482"/>
|
<outlet property="passwordTextField" destination="152" id="482"/>
|
||||||
|
<outlet property="shouldCopyPasswordToPasteboardButton" destination="500" id="n2M-pB-2ol"/>
|
||||||
<outlet property="symbolsButton" destination="464" id="596"/>
|
<outlet property="symbolsButton" destination="464" id="596"/>
|
||||||
<outlet property="upperCaseButton" destination="452" id="592"/>
|
<outlet property="upperCaseButton" destination="452" id="592"/>
|
||||||
<outlet property="view" destination="1" id="2"/>
|
<outlet property="view" destination="1" id="2"/>
|
||||||
@@ -209,7 +209,7 @@
|
|||||||
<action selector="_cancel:" target="-2" id="623"/>
|
<action selector="_cancel:" target="-2" id="623"/>
|
||||||
</connections>
|
</connections>
|
||||||
</button>
|
</button>
|
||||||
<levelIndicator verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="635">
|
<levelIndicator verticalHuggingPriority="750" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="635">
|
||||||
<rect key="frame" x="90" y="174" width="186" height="16"/>
|
<rect key="frame" x="90" y="174" width="186" height="16"/>
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
<levelIndicatorCell key="cell" alignment="left" doubleValue="10" maxValue="90" warningValue="55" criticalValue="30" levelIndicatorStyle="continuousCapacity" id="636" customClass="HNHLevelIndicatorCell"/>
|
<levelIndicatorCell key="cell" alignment="left" doubleValue="10" maxValue="90" warningValue="55" criticalValue="30" levelIndicatorStyle="continuousCapacity" id="636" customClass="HNHLevelIndicatorCell"/>
|
||||||
@@ -223,16 +223,11 @@
|
|||||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||||
</textFieldCell>
|
</textFieldCell>
|
||||||
</textField>
|
</textField>
|
||||||
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="652">
|
<textField verticalHuggingPriority="750" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="652">
|
||||||
<rect key="frame" x="282" y="174" width="46" height="17"/>
|
<rect key="frame" x="282" y="174" width="46" height="17"/>
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="25000" id="653">
|
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="25000 bit" id="653">
|
||||||
<numberFormatter key="formatter" formatterBehavior="custom10_4" positiveFormat="# bit" negativeFormat="# bit" usesGroupingSeparator="NO" groupingSize="0" minimumIntegerDigits="0" maximumIntegerDigits="309" minimumFractionDigits="0" maximumFractionDigits="0" decimalSeparator="," groupingSeparator="." currencyDecimalSeparator="," positiveSuffix=" bit" negativeSuffix=" bit" id="681">
|
<numberFormatter key="formatter" formatterBehavior="custom10_4" positiveFormat="# bit" negativeFormat="# bit" usesGroupingSeparator="NO" paddingCharacter="*" groupingSize="0" minimumIntegerDigits="0" maximumIntegerDigits="309" decimalSeparator="," groupingSeparator="." currencyDecimalSeparator="," plusSign="+" minusSign="-" notANumberSymbol="NaN" perMillSymbol="‰" percentSymbol="%" exponentSymbol="E" positivePrefix="" positiveSuffix=" bit" negativePrefix="-" negativeSuffix=" bit" id="681"/>
|
||||||
<real key="roundingIncrement" value="0.0"/>
|
|
||||||
<metadata>
|
|
||||||
<bool key="localizesFormat" value="YES"/>
|
|
||||||
</metadata>
|
|
||||||
</numberFormatter>
|
|
||||||
<font key="font" metaFont="system"/>
|
<font key="font" metaFont="system"/>
|
||||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user