2
0

More Mac GUI work.

This commit is contained in:
Maarten Billemont 2014-06-24 10:47:04 -04:00
parent 31b667c7f7
commit 651a398798
2 changed files with 139 additions and 68 deletions

View File

@ -26,7 +26,12 @@
#define MPAlertIncorrectMP @"MPAlertIncorrectMP"
#define MPAlertCreateSite @"MPAlertCreateSite"
@implementation MPPasswordWindowController
@interface MPPasswordWindowController()
@property(nonatomic, copy) NSString *currentSiteText;
@end
@implementation MPPasswordWindowController { BOOL _skipTextChange; }
#pragma mark - Life
@ -47,7 +52,7 @@
[self fadeIn];
[self updateUser];
}];
[[NSNotificationCenter defaultCenter] addObserverForName:NSWindowDidResignMainNotification object:self.window
[[NSNotificationCenter defaultCenter] addObserverForName:NSApplicationWillResignActiveNotification object:nil
queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
[self fadeOut];
}];
@ -59,6 +64,10 @@
queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
[self updateUser];
}];
[self.elementsController observeKeyPath:@"selection"
withBlock:^(id from, id to, NSKeyValueChange cause, id _self) {
[self updateSelection];
}];
}
#pragma mark - NSResponder
@ -103,15 +112,24 @@
[self.elementsController selectNext:self];
return YES;
}
// if ([NSStringFromSelector( commandSelector ) rangeOfString:@"delete"].location == 0) {
// _skipTextChange = YES;
// return NO;
// }
}
return [self handleCommand:commandSelector];
}
- (IBAction)doSearchElements:(id)sender {
[self updateElements];
}
- (void)controlTextDidChange:(NSNotification *)note {
if (note.object == self.siteField) {
[self updateElements];
// if (note.object == self.siteField) {
// [self updateElements];
// Update the site content as the site name changes.
// if ([[NSApp currentEvent] type] == NSKeyDown &&
@ -125,7 +143,7 @@
// [self trySiteWithAction:NO];
// return;
// }
}
// }
}
#pragma mark - NSTextViewDelegate
@ -146,10 +164,8 @@
- (void)alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo {
if (contextInfo == MPAlertIncorrectMP) {
[self close];
if (contextInfo == MPAlertIncorrectMP)
return;
}
if (contextInfo == MPAlertCreateSite) {
switch (returnCode) {
case NSAlertFirstButtonReturn: {
@ -263,6 +279,27 @@
}];
}
- (void)updateSelection {
if (_skipTextChange) {
_skipTextChange = NO;
return;
}
NSString *selectedSiteName = self.selectedElement.siteName;
if (!selectedSiteName)
return;
NSString *querySiteText = [self.siteField.stringValue stringByReplacingCharactersInRange:self.siteField.currentEditor.selectedRange
withString:@""];
NSRange selectedSiteNameQueryRange = [selectedSiteName rangeOfString:querySiteText];
self.siteField.stringValue = selectedSiteName;
if (selectedSiteNameQueryRange.location == 0)
self.siteField.currentEditor.selectedRange = NSMakeRange(
selectedSiteNameQueryRange.length, selectedSiteName.length - selectedSiteNameQueryRange.length );
}
- (void)useSite {
MPElementModel *selectedElement = [self selectedElement];
@ -270,7 +307,7 @@
// Performing action while content is available. Copy it.
[self copyContent:selectedElement.content];
[self close];
[self fadeOut];
NSUserNotification *notification = [NSUserNotification new];
notification.title = @"Password Copied";
@ -317,6 +354,9 @@
- (void)fadeIn {
if ([self.window isOnActiveSpace] && self.window.alphaValue)
return;
CGWindowID windowID = (CGWindowID)[self.window windowNumber];
CGImageRef capturedImage = CGWindowListCreateImage( CGRectInfinite, kCGWindowListOptionOnScreenBelowWindow, windowID,
kCGWindowImageBoundsIgnoreFraming );
@ -343,8 +383,12 @@
- (void)fadeOut {
if (![NSApp isActive] && !self.window.alphaValue)
return;
[[NSAnimationContext currentContext] setCompletionHandler:^{
[self close];
[NSApp hide:self];
}];
[[NSAnimationContext currentContext] setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]];
[[self.window animator] setAlphaValue:0.0];

View File

@ -39,29 +39,55 @@
<ciFilter name="CIGaussianBlur">
<configuration>
<null key="inputImage"/>
<real key="inputRadius" value="40"/>
<real key="inputRadius" value="20"/>
</configuration>
</ciFilter>
<ciFilter name="CIColorControls">
<configuration>
<real key="inputBrightness" value="0.0"/>
<real key="inputContrast" value="1.1000000000000001"/>
<real key="inputBrightness" value="-0.29999999999999999"/>
<real key="inputContrast" value="1"/>
<null key="inputImage"/>
<real key="inputSaturation" value="0.0"/>
</configuration>
</ciFilter>
<ciFilter name="CIFalseColor">
<configuration>
<ciColor key="inputColor0" red="0.70196080207824707" green="0.70196080207824707" blue="0.70196080207824707" alpha="1"/>
<ciColor key="inputColor1" red="0.0" green="0.25098040699958801" blue="0.50196081399917603" alpha="1"/>
<null key="inputImage"/>
<real key="inputSaturation" value="2"/>
</configuration>
</ciFilter>
</contentFilters>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyUpOrDown" image="small-screen" id="ArA-2w-I56"/>
</imageView>
<scrollView focusRingType="none" borderType="none" autohidesScrollers="YES" horizontalLineScroll="37" horizontalPageScroll="10" verticalLineScroll="37" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Bme-XK-MMc" userLabel="Sites Table">
<rect key="frame" x="68" y="0.0" width="512" height="232"/>
<secureTextField focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="iGR-wo-ual" userLabel="Password Field">
<rect key="frame" x="18" y="243" width="612" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<shadow key="shadow">
<size key="offset" width="0.0" height="1"/>
<color key="color" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
</shadow>
<secureTextFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" focusRingType="none" alignment="center" usesSingleLineMode="YES" id="NcX-1Z-2OC">
<font key="font" metaFont="system" size="36"/>
<color key="textColor" name="highlightColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<allowedInputSourceLocales>
<string>NSAllRomanInputSourcesLocaleIdentifier</string>
</allowedInputSourceLocales>
</secureTextFieldCell>
<connections>
<outlet property="delegate" destination="-2" id="egd-Ny-IEz"/>
</connections>
</secureTextField>
<scrollView focusRingType="none" borderType="none" autohidesScrollers="YES" horizontalLineScroll="31" horizontalPageScroll="10" verticalLineScroll="31" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Bme-XK-MMc" userLabel="Sites Table">
<rect key="frame" x="68" y="0.0" width="512" height="203"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="e11-59-xSS">
<rect key="frame" x="0.0" y="0.0" width="512" height="232"/>
<rect key="frame" x="0.0" y="0.0" width="512" height="203"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="none" selectionHighlightStyle="sourceList" columnReordering="NO" columnResizing="NO" multipleSelection="NO" emptySelection="NO" autosaveColumns="NO" rowHeight="35" rowSizeStyle="automatic" viewBased="YES" id="xvJ-5c-vDp">
<rect key="frame" x="0.0" y="0.0" width="515" height="232"/>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="none" selectionHighlightStyle="sourceList" columnReordering="NO" columnResizing="NO" multipleSelection="NO" emptySelection="NO" autosaveColumns="NO" rowHeight="29" rowSizeStyle="automatic" viewBased="YES" id="xvJ-5c-vDp">
<rect key="frame" x="0.0" y="0.0" width="515" height="203"/>
<autoresizingMask key="autoresizingMask"/>
<size key="intercellSpacing" width="3" height="2"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
@ -81,15 +107,19 @@
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES"/>
<prototypeCellViews>
<tableCellView id="Rv8-uU-ieA">
<rect key="frame" x="1" y="1" width="512" height="35"/>
<rect key="frame" x="1" y="1" width="512" height="29"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="pTl-fc-MSY">
<rect key="frame" x="-2" y="0.0" width="516" height="35"/>
<rect key="frame" x="-2" y="0.0" width="516" height="29"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<shadow key="shadow">
<size key="offset" width="0.0" height="1"/>
<color key="color" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
</shadow>
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" alignment="center" title="apple.com" id="5Ug-eU-C9Y">
<font key="font" size="24" name="Baskerville-SemiBold"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<font key="font" size="24" name="HelveticaNeue-Thin"/>
<color key="textColor" name="highlightColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
@ -129,7 +159,7 @@
<constraint firstAttribute="width" constant="512" id="qfu-pO-SvM"/>
</constraints>
<scroller key="horizontalScroller" verticalHuggingPriority="750" horizontal="YES" id="8wr-pu-1lc">
<rect key="frame" x="0.0" y="216" width="512" height="16"/>
<rect key="frame" x="0.0" y="187" width="512" height="16"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="NO" id="mcf-ST-XXI">
@ -138,35 +168,44 @@
</scroller>
</scrollView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="OnR-s6-d4P" userLabel="Input Label">
<rect key="frame" x="215" y="298" width="219" height="13"/>
<rect key="frame" x="213" y="295" width="223" height="20"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" title="Enter Maarten Billemont's master password:" id="1Lb-d0-fQD">
<font key="font" metaFont="label"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<shadow key="shadow">
<size key="offset" width="0.0" height="1"/>
<color key="color" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
</shadow>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" title="Maarten Billemont's password for:" id="1Lb-d0-fQD">
<font key="font" size="14" name="HelveticaNeue"/>
<color key="textColor" name="highlightColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<searchField focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="CnS-iI-dhr" userLabel="Site Field">
<rect key="frame" x="68" y="240" width="512" height="50"/>
<rect key="frame" x="66" y="243" width="516" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<constraints>
<constraint firstAttribute="width" constant="512" id="rW7-Vq-4Xy"/>
</constraints>
<searchFieldCell key="cell" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" focusRingType="none" alignment="center" placeholderString="Site Name" drawsBackground="YES" id="ppl-2c-1E9">
<font key="font" size="36" name="Baskerville-Italic"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<shadow key="shadow">
<size key="offset" width="0.0" height="1"/>
<color key="color" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
</shadow>
<searchFieldCell key="cell" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" focusRingType="none" alignment="center" placeholderString="Site Name" id="ppl-2c-1E9">
<font key="font" size="36" name="HelveticaNeue-Thin"/>
<color key="textColor" name="highlightColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="0.0" colorSpace="calibratedRGB"/>
</searchFieldCell>
<connections>
<action selector="doSearchElements:" target="-2" id="31H-Rt-R87"/>
<outlet property="delegate" destination="-2" id="2WA-uI-asx"/>
</connections>
</searchField>
<button hidden="YES" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="vES-W5-m4x" userLabel="Type Button">
<rect key="frame" x="270" y="19" width="109" height="19"/>
<rect key="frame" x="278" y="19" width="92" height="20"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="recessed" title="Long Password" bezelStyle="recessed" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Fom-sN-EtZ">
<buttonCell key="cell" type="inline" title="Long Password" bezelStyle="inline" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Fom-sN-EtZ">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="systemBold" size="12"/>
<font key="font" size="11" name="HelveticaNeue-Medium"/>
</buttonCell>
<connections>
<binding destination="mcS-ik-b0n" name="hidden" keyPath="selection" id="zBN-72-q5B">
@ -178,36 +217,26 @@
</connections>
</button>
<customView hidden="YES" translatesAutoresizingMaskIntoConstraints="NO" id="d3u-Ze-9uf" userLabel="Counter Container">
<rect key="frame" x="387" y="18" width="29" height="22"/>
<rect key="frame" x="378" y="18" width="28" height="23"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<stepper horizontalHuggingPriority="750" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="XgA-Vl-CKh" userLabel="Counter Stepper">
<rect key="frame" x="-3" y="-3" width="19" height="27"/>
<rect key="frame" x="-3" y="-2" width="19" height="27"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<stepperCell key="cell" continuous="YES" alignment="left" maxValue="100" id="ikF-n4-xiI"/>
<connections>
<binding destination="mcS-ik-b0n" name="hidden" keyPath="selection" id="8KV-qr-Mqt">
<dictionary key="options">
<string key="NSValueTransformerName">NSIsNil</string>
</dictionary>
</binding>
<binding destination="mcS-ik-b0n" name="value" keyPath="selection.counter" id="qmm-6z-boy"/>
</connections>
</stepper>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="NvO-kt-eZ2" userLabel="Counter Field">
<rect key="frame" x="19" y="3" width="12" height="16"/>
<rect key="frame" x="19" y="3" width="11" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="1" id="dhQ-bJ-rn3">
<font key="font" metaFont="systemBold" size="12"/>
<font key="font" size="11" name="HelveticaNeue-Medium"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
<binding destination="mcS-ik-b0n" name="hidden" keyPath="selection" id="fAK-4u-0SB">
<dictionary key="options">
<string key="NSValueTransformerName">NSIsNil</string>
</dictionary>
</binding>
<binding destination="mcS-ik-b0n" name="value" keyPath="selection.counter" id="aA9-yw-cYE"/>
</connections>
</textField>
@ -225,6 +254,15 @@
<constraint firstItem="XgA-Vl-CKh" firstAttribute="leading" secondItem="d3u-Ze-9uf" secondAttribute="leading" id="vKj-dp-A0D"/>
</constraints>
<connections>
<binding destination="mcS-ik-b0n" name="hidden2" keyPath="selection.counter" previousBinding="YUg-F9-YTd" id="Jqu-U3-oiv">
<dictionary key="options">
<integer key="NSMultipleValuesPlaceholder" value="-1"/>
<integer key="NSNoSelectionPlaceholder" value="-1"/>
<integer key="NSNotApplicablePlaceholder" value="-1"/>
<integer key="NSNullPlaceholder" value="-1"/>
<string key="NSValueTransformerName">NSNegateBoolean</string>
</dictionary>
</binding>
<binding destination="mcS-ik-b0n" name="hidden" keyPath="selection" id="YUg-F9-YTd">
<dictionary key="options">
<string key="NSValueTransformerName">NSIsNil</string>
@ -233,11 +271,11 @@
</connections>
</customView>
<button hidden="YES" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="1Qo-iG-CQt" userLabel="Login Button">
<rect key="frame" x="255" y="47" width="139" height="19"/>
<rect key="frame" x="269" y="48" width="111" height="20"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="recessed" title="lhunath@lyndir.com" alternateTitle="Login Name" bezelStyle="recessed" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="QFo-9y-aVe">
<buttonCell key="cell" type="inline" title="lhunath@lyndir.com" alternateTitle="Login Name" bezelStyle="inline" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="QFo-9y-aVe">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="systemBold" size="12"/>
<font key="font" size="11" name="HelveticaNeue-Medium"/>
</buttonCell>
<connections>
<binding destination="mcS-ik-b0n" name="hidden" keyPath="selection" id="KRb-FF-ruz">
@ -245,24 +283,13 @@
<string key="NSValueTransformerName">NSIsNil</string>
</dictionary>
</binding>
<binding destination="mcS-ik-b0n" name="title" keyPath="selection.loginName" id="VU9-Uo-WlG"/>
<binding destination="mcS-ik-b0n" name="title" keyPath="selection.loginName" id="g1z-0F-hE9">
<dictionary key="options">
<string key="NSNullPlaceholder">Set Login Name</string>
</dictionary>
</binding>
</connections>
</button>
<secureTextField focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="iGR-wo-ual" userLabel="Password Field">
<rect key="frame" x="20" y="243" width="608" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<secureTextFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" focusRingType="none" alignment="center" drawsBackground="YES" usesSingleLineMode="YES" id="NcX-1Z-2OC">
<font key="font" metaFont="system" size="36"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<allowedInputSourceLocales>
<string>NSAllRomanInputSourcesLocaleIdentifier</string>
</allowedInputSourceLocales>
</secureTextFieldCell>
<connections>
<outlet property="delegate" destination="-2" id="egd-Ny-IEz"/>
</connections>
</secureTextField>
<progressIndicator hidden="YES" horizontalHuggingPriority="750" verticalHuggingPriority="750" maxValue="100" displayedWhenStopped="NO" bezeled="NO" indeterminate="YES" controlSize="small" style="spinning" translatesAutoresizingMaskIntoConstraints="NO" id="oSh-Ec-8Nf">
<rect key="frame" x="316" y="494" width="16" height="16"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
@ -270,7 +297,7 @@
</subviews>
<constraints>
<constraint firstAttribute="bottom" secondItem="Bme-XK-MMc" secondAttribute="bottom" id="1kJ-cV-fhc"/>
<constraint firstItem="Bme-XK-MMc" firstAttribute="top" secondItem="CnS-iI-dhr" secondAttribute="bottom" constant="8" symbolic="YES" id="1ta-BC-BdQ"/>
<constraint firstItem="Bme-XK-MMc" firstAttribute="top" secondItem="CnS-iI-dhr" secondAttribute="bottom" constant="40" id="1ta-BC-BdQ"/>
<constraint firstAttribute="bottom" secondItem="Bwc-sd-6gm" secondAttribute="bottom" id="3fF-7g-c6C"/>
<constraint firstItem="vES-W5-m4x" firstAttribute="centerX" secondItem="CnS-iI-dhr" secondAttribute="centerX" id="92S-HP-Vk7"/>
<constraint firstItem="CnS-iI-dhr" firstAttribute="top" secondItem="OnR-s6-d4P" secondAttribute="bottom" constant="8" symbolic="YES" id="CGj-SL-Qhp"/>