Implemented datePicking controller. Refactored popup handling in MPInspectorViewController

This commit is contained in:
michael starke
2014-03-17 00:07:25 +01:00
parent 6bbaccdb25
commit 51a59d73c6
12 changed files with 154 additions and 71 deletions

View File

@@ -1,12 +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 version="1070" defaultVersion="1080" identifier="macosx"/> <deployment version="1070" 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="MPDatePickingViewController"> <customObject id="-2" userLabel="File's Owner" customClass="MPDatePickingViewController">
<connections> <connections>
<outlet property="datePicker" destination="3" id="YOw-gi-A02"/>
<outlet property="presetPopupButton" destination="15" id="VJh-of-PEU"/>
<outlet property="view" destination="1" id="2"/> <outlet property="view" destination="1" id="2"/>
</connections> </connections>
</customObject> </customObject>
@@ -16,7 +18,7 @@
<rect key="frame" x="0.0" y="0.0" width="179" height="259"/> <rect key="frame" x="0.0" y="0.0" width="179" height="259"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews> <subviews>
<datePicker verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="3"> <datePicker horizontalHuggingPriority="750" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="3">
<rect key="frame" x="20" y="91" width="139" height="148"/> <rect key="frame" x="20" y="91" width="139" height="148"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<datePickerCell key="cell" borderStyle="bezel" alignment="left" datePickerStyle="clockAndCalendar" id="4"> <datePickerCell key="cell" borderStyle="bezel" alignment="left" datePickerStyle="clockAndCalendar" id="4">
@@ -24,7 +26,7 @@
<calendarDate key="date" timeIntervalSinceReferenceDate="-595929600" calendarFormat="%Y-%m-%d %H:%M:%S %z"> <calendarDate key="date" timeIntervalSinceReferenceDate="-595929600" calendarFormat="%Y-%m-%d %H:%M:%S %z">
<!--1982-02-12 08:00:00 -0800--> <!--1982-02-12 08:00:00 -0800-->
<timeZone key="timeZone" name="US/Pacific"> <timeZone key="timeZone" name="US/Pacific">
<mutableData key="data"> <data key="data">
VFppZgAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAC5AAAABAAAABCepkign7sVkKCGKqChmveQ VFppZgAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAC5AAAABAAAABCepkign7sVkKCGKqChmveQ
y4kaoNIj9HDSYSYQ1v50INiArZDa/tGg28CQENzes6DdqayQ3r6VoN+JjpDgnneg4WlwkOJ+WaDjSVKQ y4kaoNIj9HDSYSYQ1v50INiArZDa/tGg28CQENzes6DdqayQ3r6VoN+JjpDgnneg4WlwkOJ+WaDjSVKQ
5F47oOUpNJDmR1gg5xJREOgnOiDo8jMQ6gccIOrSFRDr5v4g7LH3EO3G4CDukdkQ76/8oPBxuxDxj96g 5F47oOUpNJDmR1gg5xJREOgnOiDo8jMQ6gccIOrSFRDr5v4g7LH3EO3G4CDukdkQ76/8oPBxuxDxj96g
@@ -42,7 +44,7 @@ f5gqkAABAAECAwEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEA
AQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEA AQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEA
AQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEA AQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEA
AQABAAEAAQAB//+dkAEA//+PgAAE//+dkAEI//+dkAEMUERUAFBTVABQV1QAUFBUAAAAAAEAAAABA AQABAAEAAQAB//+dkAEA//+PgAAE//+dkAEI//+dkAEMUERUAFBTVABQV1QAUFBUAAAAAAEAAAABA
</mutableData> </data>
</timeZone> </timeZone>
</calendarDate> </calendarDate>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
@@ -50,18 +52,12 @@ AQABAAEAAQAB//+dkAEA//+PgAAE//+dkAEI//+dkAEMUERUAFBTVABQV1QAUFBUAAAAAAEAAAABA
</datePickerCell> </datePickerCell>
</datePicker> </datePicker>
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="15"> <popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="15">
<rect key="frame" x="18" y="59" width="144" height="26"/> <rect key="frame" x="18" y="47" width="144" height="26"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" title="1 Week" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" id="16"> <popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" id="16">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/> <font key="font" metaFont="menu"/>
<menu key="menu" title="OtherViews" id="17"> <menu key="menu" title="OtherViews" id="17"/>
<items>
<menuItem title="1 Week" state="on" id="18"/>
<menuItem title="1 Month" id="19"/>
<menuItem title="1 Year" id="20"/>
</items>
</menu>
</popUpButtonCell> </popUpButtonCell>
</popUpButton> </popUpButton>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="25"> <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="25">
@@ -71,6 +67,9 @@ AQABAAEAAQAB//+dkAEA//+PgAAE//+dkAEI//+dkAEMUERUAFBTVABQV1QAUFBUAAAAAAEAAAABA
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/> <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
</buttonCell> </buttonCell>
<connections>
<action selector="useDate:" target="-2" id="34n-E5-FQq"/>
</connections>
</button> </button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="29"> <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="29">
<rect key="frame" x="20" y="18" width="56" height="25"/> <rect key="frame" x="20" y="18" width="56" height="25"/>
@@ -79,18 +78,23 @@ AQABAAEAAQAB//+dkAEA//+PgAAE//+dkAEI//+dkAEMUERUAFBTVABQV1QAUFBUAAAAAAEAAAABA
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/> <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
</buttonCell> </buttonCell>
<connections>
<action selector="cancel:" target="-2" id="eww-6g-58Z"/>
</connections>
</button> </button>
</subviews> </subviews>
<constraints> <constraints>
<constraint firstItem="3" firstAttribute="leading" secondItem="1" secondAttribute="leading" constant="20" symbolic="YES" id="13"/> <constraint firstItem="3" firstAttribute="leading" secondItem="1" secondAttribute="leading" constant="20" symbolic="YES" id="13"/>
<constraint firstItem="3" firstAttribute="top" secondItem="1" secondAttribute="top" constant="20" symbolic="YES" id="14"/> <constraint firstItem="3" firstAttribute="top" secondItem="1" secondAttribute="top" constant="20" symbolic="YES" id="14"/>
<constraint firstItem="15" firstAttribute="top" secondItem="3" secondAttribute="bottom" constant="8" id="21"/> <constraint firstItem="15" firstAttribute="top" secondItem="3" secondAttribute="bottom" constant="20" symbolic="YES" id="21"/>
<constraint firstItem="15" firstAttribute="leading" secondItem="1" secondAttribute="leading" constant="20" symbolic="YES" id="22"/> <constraint firstItem="15" firstAttribute="leading" secondItem="1" secondAttribute="leading" constant="20" symbolic="YES" id="22"/>
<constraint firstAttribute="trailing" secondItem="15" secondAttribute="trailing" constant="20" symbolic="YES" id="24"/> <constraint firstAttribute="trailing" secondItem="15" secondAttribute="trailing" constant="20" symbolic="YES" id="24"/>
<constraint firstAttribute="trailing" secondItem="25" secondAttribute="trailing" constant="20" symbolic="YES" id="27"/> <constraint firstAttribute="trailing" secondItem="25" secondAttribute="trailing" constant="20" symbolic="YES" id="27"/>
<constraint firstItem="29" firstAttribute="leading" secondItem="1" secondAttribute="leading" constant="20" symbolic="YES" id="35"/> <constraint firstItem="29" firstAttribute="leading" secondItem="1" secondAttribute="leading" constant="20" symbolic="YES" id="35"/>
<constraint firstAttribute="bottom" secondItem="25" secondAttribute="bottom" constant="20" symbolic="YES" id="36"/> <constraint firstAttribute="bottom" secondItem="25" secondAttribute="bottom" constant="20" symbolic="YES" id="36"/>
<constraint firstAttribute="bottom" secondItem="29" secondAttribute="bottom" constant="20" symbolic="YES" id="37"/> <constraint firstAttribute="trailing" secondItem="3" secondAttribute="trailing" constant="20" id="6Qs-OP-VRr"/>
<constraint firstItem="25" firstAttribute="centerY" secondItem="29" secondAttribute="centerY" id="M8N-5g-ClS"/>
<constraint firstItem="25" firstAttribute="top" secondItem="15" secondAttribute="bottom" constant="8" symbolic="YES" id="sxX-fk-xaJ"/>
</constraints> </constraints>
</customView> </customView>
</objects> </objects>

View File

@@ -589,9 +589,12 @@
</connections> </connections>
</button> </button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="8"> <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="8">
<rect key="frame" x="169" y="128" width="63" height="19"/> <rect key="frame" x="201" y="128" width="31" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="roundRect" title="Set Date" bezelStyle="roundedRect" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="77"> <constraints>
<constraint firstAttribute="width" constant="31" id="Ped-nx-uti"/>
</constraints>
<buttonCell key="cell" type="roundRect" bezelStyle="roundedRect" image="NSActionTemplate" imagePosition="only" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="77">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/> <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="cellTitle"/> <font key="font" metaFont="cellTitle"/>
</buttonCell> </buttonCell>

View File

@@ -9,6 +9,7 @@
<connections> <connections>
<outlet property="autotypePopupButton" destination="240" id="285"/> <outlet property="autotypePopupButton" destination="240" id="285"/>
<outlet property="contentView" destination="38" id="Dv7-1B-VeH"/> <outlet property="contentView" destination="38" id="Dv7-1B-VeH"/>
<outlet property="expireDateSelectButton" destination="4" id="KxN-kK-lan"/>
<outlet property="expiresCheckButton" destination="5" id="283"/> <outlet property="expiresCheckButton" destination="5" id="283"/>
<outlet property="searchPopupButton" destination="229" id="284"/> <outlet property="searchPopupButton" destination="229" id="284"/>
<outlet property="titleTextField" destination="23" id="35"/> <outlet property="titleTextField" destination="23" id="35"/>
@@ -55,9 +56,12 @@
</buttonCell> </buttonCell>
</button> </button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="4"> <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="4">
<rect key="frame" x="174" y="127" width="63" height="19"/> <rect key="frame" x="206" y="127" width="31" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="roundRect" title="Set Date" bezelStyle="roundedRect" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="33"> <constraints>
<constraint firstAttribute="width" constant="31" id="l5I-EF-dHs"/>
</constraints>
<buttonCell key="cell" type="roundRect" bezelStyle="roundedRect" image="NSActionTemplate" imagePosition="only" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="33">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/> <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="cellTitle"/> <font key="font" metaFont="cellTitle"/>
</buttonCell> </buttonCell>
@@ -153,5 +157,9 @@
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
</scroller> </scroller>
</scrollView> </scrollView>
<userDefaultsController representsSharedInstance="YES" id="ePk-k3-9qj"/>
</objects> </objects>
<resources>
<image name="NSActionTemplate" width="14" height="14"/>
</resources>
</document> </document>

View File

@@ -54,18 +54,15 @@ typedef NS_ENUM(NSUInteger, MPContextTab) {
[[NSNotificationCenter defaultCenter] removeObserver:self]; [[NSNotificationCenter defaultCenter] removeObserver:self];
} }
- (void)didLoadView { - (void)awakeFromNib {
[[self.filterLabelTextField cell] setBackgroundStyle:NSBackgroundStyleRaised]; [[self.filterLabelTextField cell] setBackgroundStyle:NSBackgroundStyleRaised];
self.historyBar.activeGradient = [[NSGradient alloc] initWithStartingColor:[NSColor redColor] endingColor:[NSColor greenColor]]; self.historyBar.activeGradient = [[NSGradient alloc] initWithStartingColor:[NSColor redColor] endingColor:[NSColor greenColor]];
/*
NSArray *activeColors = @[[NSColor colorWithCalibratedWhite:0.2 alpha:1],[NSColor colorWithCalibratedWhite:0.4 alpha:1]]; NSArray *activeColors = @[[NSColor colorWithCalibratedWhite:0.2 alpha:1],[NSColor colorWithCalibratedWhite:0.4 alpha:1]];
NSArray *inactiveColors = @[[NSColor colorWithCalibratedWhite:0.3 alpha:1],[NSColor colorWithCalibratedWhite:0.6 alpha:1]]; NSArray *inactiveColors = @[[NSColor colorWithCalibratedWhite:0.3 alpha:1],[NSColor colorWithCalibratedWhite:0.6 alpha:1]];
self.trashBar.activeGradient = [[NSGradient alloc] initWithColors:activeColors]; self.trashBar.activeGradient = [[NSGradient alloc] initWithColors:activeColors];
self.trashBar.inactiveGradient = [[NSGradient alloc] initWithColors:inactiveColors]; self.trashBar.inactiveGradient = [[NSGradient alloc] initWithColors:inactiveColors];
*/
[[self view] bind:NSSelectedIndexBinding toObject:self withKeyPath:@"activeTab" options:nil]; [[self view] bind:NSSelectedIndexBinding toObject:self withKeyPath:@"activeTab" options:nil];

View File

@@ -10,4 +10,11 @@
@interface MPDatePickingViewController : MPViewController @interface MPDatePickingViewController : MPViewController
@property (strong,readonly) NSDate *date;
@property (weak) IBOutlet NSDatePicker *datePicker;
@property (weak) IBOutlet NSPopUpButton *presetPopupButton;
- (IBAction)useDate:(id)sender;
- (IBAction)cancel:(id)sender;
@end @end

View File

@@ -8,8 +8,17 @@
#import "MPDatePickingViewController.h" #import "MPDatePickingViewController.h"
typedef NS_ENUM(NSUInteger, MPDatePresets) {
MPDatePresetTomorrow,
MPDatePresetOneWeek,
MPDatePresetOneMonth,
MPDatePresetOneYear,
};
@interface MPDatePickingViewController () @interface MPDatePickingViewController ()
@property (strong) NSDate *date;
@end @end
@implementation MPDatePickingViewController @implementation MPDatePickingViewController
@@ -19,11 +28,30 @@
return self; return self;
} }
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { - (void)awakeFromNib {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; NSMenu *presetMenu = [[NSMenu alloc] init];
if (self) { NSDictionary *dateItems = @{ @(MPDatePresetTomorrow): NSLocalizedString(@"TOMORROW", ""),
} @(MPDatePresetOneWeek): NSLocalizedString(@"ONE_WEEK", ""),
return self; @(MPDatePresetOneMonth): NSLocalizedString(@"ONE_MONTH", ""),
@(MPDatePresetOneYear): NSLocalizedString(@"ONE_YEAR", "") };
for(NSNumber *tagNumber in dateItems) {
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:dateItems[tagNumber] action:NULL keyEquivalent:@""];
[item setTag:[tagNumber integerValue]];
[presetMenu addItem:item];
} }
[self.presetPopupButton setMenu:presetMenu];
}
- (IBAction)useDate:(id)sender {
self.date = [self.datePicker dateValue];
id target = [NSApp targetForAction:@selector(performClose:)];
[target performClose:sender];
}
- (IBAction)cancel:(id)sender {
self.date = [NSDate distantFuture];
id target = [NSApp targetForAction:@selector(performClose:)];
[target performClose:sender];
}
@end @end

View File

@@ -40,6 +40,7 @@ APPKIT_EXTERN NSString *const MPDocumentGroupKey;
@class KPKBinary; @class KPKBinary;
@class KPKAttribute; @class KPKAttribute;
@class KPKCompositeKey; @class KPKCompositeKey;
@class KPKNode;
typedef NS_OPTIONS(NSUInteger, MPEntrySearchFlags) { typedef NS_OPTIONS(NSUInteger, MPEntrySearchFlags) {
MPEntrySearchNone = 0, MPEntrySearchNone = 0,
@@ -79,7 +80,7 @@ typedef NS_OPTIONS(NSUInteger, MPEntrySearchFlags) {
*/ */
@property (nonatomic, weak) KPKEntry *selectedEntry; @property (nonatomic, weak) KPKEntry *selectedEntry;
@property (nonatomic, weak) KPKGroup *selectedGroup; @property (nonatomic, weak) KPKGroup *selectedGroup;
@property (nonatomic, weak) id selectedItem; @property (nonatomic, weak) KPKNode *selectedItem;
/* /*
Search - see MPDocument+Search for further details Search - see MPDocument+Search for further details

View File

@@ -367,7 +367,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey
self.selectedItem = selectedEntry; self.selectedItem = selectedEntry;
} }
- (void)setSelectedItem:(id)selectedItem { - (void)setSelectedItem:(KPKNode *)selectedItem {
if(_selectedItem != selectedItem) { if(_selectedItem != selectedItem) {
_selectedItem = selectedItem; _selectedItem = selectedItem;
[[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentCurrentItemChangedNotification object:self]; [[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentCurrentItemChangedNotification object:self];

View File

@@ -16,6 +16,7 @@
@property (weak) IBOutlet HNHRoundedTextField *titleTextField; @property (weak) IBOutlet HNHRoundedTextField *titleTextField;
@property (weak) IBOutlet NSButton *expiresCheckButton; @property (weak) IBOutlet NSButton *expiresCheckButton;
@property (weak) IBOutlet NSButton *expireDateSelectButton;
@property (weak) IBOutlet NSPopUpButton *searchPopupButton; @property (weak) IBOutlet NSPopUpButton *searchPopupButton;
@property (weak) IBOutlet NSPopUpButton *autotypePopupButton; @property (weak) IBOutlet NSPopUpButton *autotypePopupButton;

View File

@@ -11,6 +11,7 @@
#import "MPPasteBoardController.h" #import "MPPasteBoardController.h"
#import "KPKGroup.h" #import "KPKGroup.h"
#import "KPKTimeInfo.h"
#import "HNHScrollView.h" #import "HNHScrollView.h"
#import "HNHRoundedTextField.h" #import "HNHRoundedTextField.h"
@@ -18,6 +19,7 @@
@interface MPGroupInspectorViewController () @interface MPGroupInspectorViewController ()
@property (nonatomic, weak) KPKGroup *group; @property (nonatomic, weak) KPKGroup *group;
@property (strong) NSPopover *popover;
@end @end
@@ -34,7 +36,7 @@
return self; return self;
} }
- (void)didLoadView { - (void)awakeFromNib {
HNHScrollView *scrollView = (HNHScrollView *)[self view]; HNHScrollView *scrollView = (HNHScrollView *)[self view];
scrollView.actAsFlipped = NO; scrollView.actAsFlipped = NO;
@@ -53,11 +55,13 @@
views:views]]; views:views]];
[[self view] layoutSubtreeIfNeeded]; [[self view] layoutSubtreeIfNeeded];
/*
void(^copyBlock)(NSTextField *textField) = ^void(NSTextField *textField) { void(^copyBlock)(NSTextField *textField) = ^void(NSTextField *textField) {
[[MPPasteBoardController defaultController] copyObjects:@[ textField.stringValue ]]; [[MPPasteBoardController defaultController] copyObjects:@[ textField.stringValue ]];
}; };
self.titleTextField.copyActionBlock = copyBlock; self.titleTextField.copyActionBlock = copyBlock;
*/
} }
- (void)setupBindings:(MPDocument *)document { - (void)setupBindings:(MPDocument *)document {
@@ -73,8 +77,12 @@
- (void)_updateBindings { - (void)_updateBindings {
if(self.group) { if(self.group) {
[self.titleTextField bind:NSValueBinding toObject:self.group withKeyPath:@"name" options:nil]; [self.titleTextField bind:NSValueBinding toObject:self.group withKeyPath:NSStringFromSelector(@selector(name)) options:nil];
[self.expiresCheckButton bind:NSValueBinding toObject:self.group.timeInfo withKeyPath:@"expires" options:nil]; [self.expiresCheckButton bind:NSValueBinding toObject:self.group.timeInfo withKeyPath:NSStringFromSelector(@selector(expires)) options:nil];
[self.expireDateSelectButton bind:NSHiddenBinding
toObject:self.group.timeInfo
withKeyPath:NSStringFromSelector(@selector(expires))
options:@{ NSValueTransformerNameBindingOption : NSNegateBooleanTransformerName }];
[self.autotypePopupButton bind:NSSelectedTagBinding toObject:self.group withKeyPath:@"isAutoTypeEnabled" options:nil]; [self.autotypePopupButton bind:NSSelectedTagBinding toObject:self.group withKeyPath:@"isAutoTypeEnabled" options:nil];
[self.searchPopupButton bind:NSSelectedTagBinding toObject:self.group withKeyPath:@"isSearchEnabled" options:nil]; [self.searchPopupButton bind:NSSelectedTagBinding toObject:self.group withKeyPath:@"isSearchEnabled" options:nil];
} }
@@ -82,6 +90,7 @@
[self.titleTextField unbind:NSValueBinding]; [self.titleTextField unbind:NSValueBinding];
[self.expiresCheckButton unbind:NSValueBinding]; [self.expiresCheckButton unbind:NSValueBinding];
[self.expireDateSelectButton unbind:NSHiddenBinding];
[self.autotypePopupButton unbind:NSSelectedTagBinding]; [self.autotypePopupButton unbind:NSSelectedTagBinding];
[self.searchPopupButton unbind:NSSelectedTagBinding]; [self.searchPopupButton unbind:NSSelectedTagBinding];
} }

View File

@@ -23,6 +23,7 @@
@property (weak) IBOutlet NSButton *cancelEditButton; @property (weak) IBOutlet NSButton *cancelEditButton;
- (IBAction)showImagePopup:(id)sender; - (IBAction)showImagePopup:(id)sender;
- (IBAction)pickExpiryDate:(id)sender;
- (IBAction)toggleEdit:(id)sender; - (IBAction)toggleEdit:(id)sender;
/* Seperate call to ensure alle registered objects are in place */ /* Seperate call to ensure alle registered objects are in place */

View File

@@ -13,6 +13,7 @@
#import "MPDocument.h" #import "MPDocument.h"
#import "MPNotifications.h" #import "MPNotifications.h"
#import "MPIconSelectViewController.h" #import "MPIconSelectViewController.h"
#import "MPDatePickingViewController.h"
#import "NSDate+Humanized.h" #import "NSDate+Humanized.h"
#import "KPKNode+IconImage.h" #import "KPKNode+IconImage.h"
@@ -21,6 +22,8 @@
#import "KPKMetaData.h" #import "KPKMetaData.h"
#import "KPKGroup.h" #import "KPKGroup.h"
#import "KPKEntry.h" #import "KPKEntry.h"
#import "KPKNode.h"
#import "KPKTimeInfo.h"
#import "HNHGradientView.h" #import "HNHGradientView.h"
#import "MPPopupImageView.h" #import "MPPopupImageView.h"
@@ -34,11 +37,11 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
@interface MPInspectorViewController () { @interface MPInspectorViewController () {
MPEntryInspectorViewController *_entryViewController; MPEntryInspectorViewController *_entryViewController;
MPGroupInspectorViewController *_groupViewController; MPGroupInspectorViewController *_groupViewController;
NSPopover *_popover;
BOOL _isEditing; BOOL _isEditing;
} }
@property (strong) MPIconSelectViewController *iconSelectionViewController; @property (strong) MPIconSelectViewController *iconSelectionViewController;
@property (strong) NSPopover *popover;
@property (nonatomic, strong) NSDate *modificationDate; @property (nonatomic, strong) NSDate *modificationDate;
@property (nonatomic, strong) NSDate *creationDate; @property (nonatomic, strong) NSDate *creationDate;
@@ -203,25 +206,50 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
} }
- (void)popoverDidClose:(NSNotification *)notification { - (void)popoverDidClose:(NSNotification *)notification {
MPIconSelectViewController *viewController = (MPIconSelectViewController *)_popover.contentViewController; NSPopover *popover = [notification object];
if([popover.contentViewController isKindOfClass:[MPIconSelectViewController class]]) {
MPIconSelectViewController *viewController = (MPIconSelectViewController *)popover.contentViewController;
if(!viewController.didCancel) { if(!viewController.didCancel) {
[self _setIcon:viewController.selectedIcon];
}
}
if([popover.contentViewController isKindOfClass:[MPDatePickingViewController class]]) {
MPDatePickingViewController *viewController = (MPDatePickingViewController *)popover.contentViewController;
[self _setExpiryDate:viewController.date];
}
self.popover = nil;
}
- (IBAction)pickExpiryDate:(id)sender {
NSAssert(self.popover == nil, @"Popover hast to be niled out");
NSAssert([sender isKindOfClass:[NSView class]], @"");
self.popover = [[NSPopover alloc] init];
self.popover.delegate = self;
self.popover.behavior = NSPopoverBehaviorTransient;
self.popover.contentViewController = [[MPDatePickingViewController alloc] init];
[self.popover showRelativeToRect:NSZeroRect ofView:sender preferredEdge:NSMinYEdge];
}
- (void)_setIcon:(NSInteger)iconId {
MPDocument *document = [[self windowController] document]; MPDocument *document = [[self windowController] document];
BOOL useDefault = (viewController.selectedIcon == -1); BOOL useDefault = (iconId == -1);
switch (self.activeTab) { switch (self.activeTab) {
case MPGroupTab: case MPGroupTab:
document.selectedGroup.iconId = useDefault ? [KPKGroup defaultIcon] : viewController.selectedIcon; document.selectedGroup.iconId = useDefault ? [KPKGroup defaultIcon] : iconId;
break; break;
case MPEntryTab: case MPEntryTab:
document.selectedEntry.iconId = useDefault ? [KPKEntry defaultIcon]: viewController.selectedIcon; document.selectedEntry.iconId = useDefault ? [KPKEntry defaultIcon]: iconId;
break; break;
default: default:
break; break;
} }
} }
_popover = nil;
- (void)_setExpiryDate:(NSDate *)date {
MPDocument *document = [[self windowController] document];
document.selectedItem.timeInfo.expiryTime = date;
} }
#pragma mark - #pragma mark -
@@ -248,10 +276,6 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
} }
[self.itemImageView setHidden:NO]; [self.itemImageView setHidden:NO];
[self.itemNameTextField setHidden:NO]; [self.itemNameTextField setHidden:NO];
if([item respondsToSelector:@selector(notes)]) {
}
} }
#pragma mark - #pragma mark -