diff --git a/MacPass/FilterBar.xib b/MacPass/FilterBar.xib index 566bfa80..a7c0f5a5 100644 --- a/MacPass/FilterBar.xib +++ b/MacPass/FilterBar.xib @@ -2,10 +2,10 @@ 1080 - 12C3103 + 12D78 3084 - 1187.34 - 625.00 + 1187.37 + 626.00 com.apple.InterfaceBuilder.CocoaPlugin 3084 @@ -894,10 +894,10 @@ NSView NSButton NSTextField + NSSearchField NSButton NSButton NSButton - NSView NSLayoutConstraint NSLayoutConstraint @@ -918,6 +918,10 @@ filterLabelTextField NSTextField + + filterSearchField + NSSearchField + filterTitleButton NSButton @@ -930,10 +934,6 @@ filterUsernameButton NSButton - - pathBar - NSView - tableToBottom NSLayoutConstraint diff --git a/MacPass/MPDocumentWindowController.h b/MacPass/MPDocumentWindowController.h index 0b5787df..8ca00817 100644 --- a/MacPass/MPDocumentWindowController.h +++ b/MacPass/MPDocumentWindowController.h @@ -36,6 +36,5 @@ Clears the Search filter */ - (void)toggleInspector:(id)sender; -- (void)toggleOutlineView:(id)sender; @end diff --git a/MacPass/MPDocumentWindowController.m b/MacPass/MPDocumentWindowController.m index 8a9cd5e8..e8c70ee0 100644 --- a/MacPass/MPDocumentWindowController.m +++ b/MacPass/MPDocumentWindowController.m @@ -41,10 +41,8 @@ @property (retain) MPMainWindowSplitViewDelegate *splitViewDelegate; - (void)_setContentViewController:(MPViewController *)viewController; +- (void)_setOutlineVisible:(BOOL)isVisible; -/* window reszing and content checks */ -- (BOOL)_windowsIsLargeEnoughForInspectorView; -- (void)_resizeWindowForInspectorView; @end @@ -57,18 +55,13 @@ _toolbarDelegate = [[MPToolbarDelegate alloc] init]; _outlineViewController = [[MPOutlineViewController alloc] init]; _inspectorTabViewController = [[MPInspectorTabViewController alloc] init]; - _splitViewDelegate = [[MPMainWindowSplitViewDelegate alloc] init]; _passwordEditController = [[MPPasswordEditViewController alloc] init]; - - [[NSBundle mainBundle] loadNibNamed:@"WelcomeView" owner:self topLevelObjects:NULL]; - [self.welcomeView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; } return self; } - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; - [_welcomeView release]; [_toolbar release]; [_passwordInputController release]; @@ -88,10 +81,6 @@ { [super windowDidLoad]; - [[self.welcomeText cell] setBackgroundStyle:NSBackgroundStyleRaised]; - CGFloat minWidht = MPMainWindowSplitViewDelegateMinimumContentWidth + MPMainWindowSplitViewDelegateMinimumOutlineWidth + [self.splitView dividerThickness]; - [self.window setMinSize:NSMakeSize( minWidht, 400)]; - _toolbar = [[NSToolbar alloc] initWithIdentifier:@"MainWindowToolbar"]; [self.toolbar setAllowsUserCustomization:YES]; [self.toolbar setDelegate:self.toolbarDelegate]; @@ -113,14 +102,14 @@ [self.splitView replaceSubview:self.inspectorView with:[self.inspectorTabViewController view]]; [self.inspectorTabViewController updateResponderChain]; - [self.splitView adjustSubviews]; - [self toggleInspector:nil]; - - [self _setContentViewController:nil]; + [self _setOutlineVisible:NO]; MPDocument *document = [self document]; if(!document.isDecrypted) { [self showPasswordInput]; } + else { + [self editPassword:nil]; + } } - (void)_setContentViewController:(MPViewController *)viewController { @@ -157,36 +146,31 @@ [self.window makeFirstResponder:[viewController reconmendedFirstResponder]]; } +- (void)_setOutlineVisible:(BOOL)isVisible { + self.outlineViewController.isVisible = isVisible; +} + #pragma mark Actions - (void)toggleInspector:(id)sender { - NSView *inspectorView = [self.splitView subviews][MPSplitViewInspectorViewIndex]; - const BOOL collapsed = [self.splitView isSubviewCollapsed:inspectorView]; - if(collapsed) { - if( NO == [self _windowsIsLargeEnoughForInspectorView]) { - [self _resizeWindowForInspectorView]; - } - CGFloat splitterPosition = [self.splitView frame].size.width - MPMainWindowSplitViewDelegateMinimumInspectorWidth; - [self.splitView setPosition:splitterPosition ofDividerAtIndex:MPSplitViewInspectorDividerIndex]; + if(self.inspectorTabViewController) { + [self.inspectorTabViewController toggleVisible]; } - else { - CGFloat splitterPosition = [self.splitView frame].size.width; - [self.splitView setPosition:splitterPosition ofDividerAtIndex:MPSplitViewInspectorDividerIndex]; - } - [inspectorView setHidden:!collapsed]; } - (void)performFindPanelAction:(id)sender { [self.entryViewController showFilter:sender]; } + + - (void)toggleOutlineView:(id)sender { - + [self _setOutlineVisible:!self.outlineViewController.isVisible]; } - (BOOL)validateMenuItem:(NSMenuItem *)menuItem { SEL menuAction = [menuItem action]; - if(menuAction == @selector(toggleOutlineView:)) { + if(menuAction == @selector(main:)) { NSView *outlineView = [self.splitView subviews][MPSplitViewOutlineViewIndex]; BOOL outlineIsHidden = [self.splitView isSubviewCollapsed:outlineView]; NSString *title = outlineIsHidden ? NSLocalizedString(@"SHOW_OUTLINE_VIEW", @"") : NSLocalizedString(@"HIDE_OUTLINE_VIEW", @"Hide the Outline View"); @@ -240,24 +224,6 @@ return nil; } -- (BOOL)_windowsIsLargeEnoughForInspectorView { - return ( MPMainWindowSplitViewDelegateMinimumInspectorWidth - < ([self.splitView frame].size.width - - MPMainWindowSplitViewDelegateMinimumContentWidth - - MPMainWindowSplitViewDelegateMinimumOutlineWidth - - 2 * [self.splitView dividerThickness]) ); -} - -- (void)_resizeWindowForInspectorView { - NSRect frame = [self.window frame]; - NSView *outlinView = [self.splitView subviews][MPSplitViewOutlineViewIndex]; - NSView *contentView = [self.splitView subviews][MPSplitViewContentViewIndex]; - - CGFloat outlineWidth = [self.splitView isSubviewCollapsed:outlinView] ? 0 : [outlinView frame].size.width; - frame.size.width = outlineWidth + [contentView frame].size.width + MPMainWindowSplitViewDelegateMinimumInspectorWidth; - [self.window setFrame:frame display:YES animate:YES]; -} - #pragma mark Notifications - (void)showEntries { if(!self.entryViewController) { @@ -265,6 +231,7 @@ } [self _setContentViewController:self.entryViewController]; [self.outlineViewController showOutline]; + [self _setOutlineVisible:YES]; } @end diff --git a/MacPass/MPEntryViewController.m b/MacPass/MPEntryViewController.m index 9b85a28a..2660661a 100644 --- a/MacPass/MPEntryViewController.m +++ b/MacPass/MPEntryViewController.m @@ -169,6 +169,16 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername"; [self.entryTable bind:NSSortDescriptorsBinding toObject:self.entryArrayController withKeyPath:@"sortDescriptors" options:nil]; [parentColumn setHidden:YES]; + + + NSLayoutConstraint *widthConstraint = [NSLayoutConstraint constraintWithItem:[self view] + attribute:NSLayoutAttributeWidth + relatedBy:NSLayoutRelationGreaterThanOrEqual + toItem:nil + attribute:NSLayoutAttributeNotAnAttribute + multiplier:1 + constant:300]; + [[self view] addConstraint:widthConstraint]; } #pragma mark NSTableViewDelgate diff --git a/MacPass/MPInspectorTabViewController.h b/MacPass/MPInspectorTabViewController.h index 058accf8..d9595ea7 100644 --- a/MacPass/MPInspectorTabViewController.h +++ b/MacPass/MPInspectorTabViewController.h @@ -26,6 +26,7 @@ @property (assign) IBOutlet NSButton *openURLButton; @property (assign) IBOutlet NSButton *showPasswordCreator; +- (void)toggleVisible; - (IBAction)togglePasswordDisplay:(id)sender; - (void)hideImagePopup:(id)sender; diff --git a/MacPass/MPInspectorTabViewController.m b/MacPass/MPInspectorTabViewController.m index c397164b..c82ea8e2 100644 --- a/MacPass/MPInspectorTabViewController.m +++ b/MacPass/MPInspectorTabViewController.m @@ -16,13 +16,17 @@ #import "KdbLib.h" #import "KdbEntry+Undo.h" -@interface MPInspectorTabViewController () +@interface MPInspectorTabViewController () { + BOOL _visible; +} @property (assign) NSUInteger selectedTabIndex; @property (assign, nonatomic) KdbEntry *selectedEntry; @property (assign, nonatomic) KdbGroup *selectedGroup; @property (assign) BOOL showsEntry; @property (retain) NSPopover *iconPopup; +@property (retain) NSLayoutConstraint *showConstraint; +@property (retain) NSLayoutConstraint *hideConstraint; - (void)_didChangeSelectedEntry:(NSNotification *)notification; - (void)_didChangeSelectedGroup:(NSNotification *)notification; @@ -79,9 +83,33 @@ name:MPOutlineViewDidChangeGroupSelection object:nil]; + self.showConstraint = [NSLayoutConstraint constraintWithItem:[self view] attribute:NSLayoutAttributeWidth + relatedBy:NSLayoutRelationGreaterThanOrEqual + toItem:nil + attribute:NSLayoutAttributeNotAnAttribute + multiplier:1 + constant:300]; + self.hideConstraint = [NSLayoutConstraint constraintWithItem:[self view] attribute:NSLayoutAttributeWidth + relatedBy:NSLayoutRelationEqual + toItem:nil + attribute:NSLayoutAttributeNotAnAttribute + multiplier:1 + constant:0]; + + [self.view addConstraint:self.showConstraint]; + [self _clearContent]; } +- (void)toggleVisible { + const BOOL isVisible = [[self view] frame].size.width > 0; + NSLayoutConstraint *add = isVisible ? self.hideConstraint : self.showConstraint; + NSLayoutConstraint *remove = isVisible ? self.showConstraint : self.hideConstraint; + [[self view] removeConstraint:remove]; + [[self view] addConstraint:add]; + [[self view] layout]; +} + - (void)_updateContent { if(self.showsEntry && self.selectedEntry) { [self _showEntry]; diff --git a/MacPass/MPOutlineViewController.h b/MacPass/MPOutlineViewController.h index eb7d9c1e..b44b8fc4 100644 --- a/MacPass/MPOutlineViewController.h +++ b/MacPass/MPOutlineViewController.h @@ -13,6 +13,7 @@ @interface MPOutlineViewController : MPViewController @property (retain, readonly) MPOutlineViewDelegate *outlineDelegate; +@property (assign, nonatomic) BOOL isVisible; - (void)clearSelection; - (void)showOutline; diff --git a/MacPass/MPOutlineViewController.m b/MacPass/MPOutlineViewController.m index 939df76a..c9f45ad8 100644 --- a/MacPass/MPOutlineViewController.m +++ b/MacPass/MPOutlineViewController.m @@ -20,6 +20,8 @@ @property (retain) MPOutlineDataSource *datasource; @property (retain) MPOutlineViewDelegate *outlineDelegate; @property (retain) NSMenu *menu; +@property (retain) NSLayoutConstraint *showConstraint; +@property (retain) NSLayoutConstraint *hideConstraint; - (void)_didUpdateData:(NSNotification *)notification; @@ -37,6 +39,7 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { + _isVisible = YES; self.outlineDelegate = [[[MPOutlineViewDelegate alloc] init] autorelease]; self.datasource = [[[MPOutlineDataSource alloc] init] autorelease]; @@ -45,7 +48,7 @@ name:MPDocumentDidAddGroupNotification object:[[self windowController] document]]; - + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_didUpdateData:) name:MPDocumentDidDelteGroupNotification @@ -70,6 +73,24 @@ [self.outlineView setDelegate:self.outlineDelegate]; [self.outlineView setMenu:[self _contextMenu]]; [self.outlineView setAllowsEmptySelection:YES]; + + self.showConstraint = [NSLayoutConstraint constraintWithItem:[self view] + attribute:NSLayoutAttributeWidth + relatedBy:NSLayoutRelationGreaterThanOrEqual + toItem:nil + attribute:NSLayoutAttributeNotAnAttribute + multiplier:1 + constant:200]; + + self.hideConstraint = [NSLayoutConstraint constraintWithItem:[self view] + attribute:NSLayoutAttributeWidth + relatedBy:NSLayoutRelationEqual + toItem:nil + attribute:NSLayoutAttributeNotAnAttribute + multiplier:1 + constant:0]; + [[self view] addConstraint:self.showConstraint]; + } - (void)showOutline { @@ -82,6 +103,16 @@ [self.outlineView deselectAll:nil]; } +- (void)setIsVisible:(BOOL)isVisible { + if(_isVisible == isVisible) { + return; // nichts zu tun + } + [[self view] removeConstraint:(isVisible ? self.hideConstraint : self.showConstraint)]; + [[self view] addConstraint:(isVisible ? self.showConstraint : self.hideConstraint)]; + _isVisible = isVisible; +} + + - (NSMenu *)_contextMenu { NSMenu *menu = [[NSMenu alloc] init]; NSArray *items = [(MPAppDelegate *)[NSApp delegate] contextMenuItemsWithItems:MPContextMenuMinimal]; diff --git a/MacPass/MacPass-Info.plist b/MacPass/MacPass-Info.plist index 389e5030..90fe4764 100644 --- a/MacPass/MacPass-Info.plist +++ b/MacPass/MacPass-Info.plist @@ -46,7 +46,7 @@ CFBundleSignature ???? CFBundleVersion - 6AE + 6E0 LSMinimumSystemVersion ${MACOSX_DEPLOYMENT_TARGET} NSHumanReadableCopyright diff --git a/MacPass/OutlineView.xib b/MacPass/OutlineView.xib index ea98b025..81a7ca55 100644 --- a/MacPass/OutlineView.xib +++ b/MacPass/OutlineView.xib @@ -2,10 +2,10 @@ 1080 - 12C60 + 12D78 3084 - 1187.34 - 625.00 + 1187.37 + 626.00 com.apple.InterfaceBuilder.CocoaPlugin 3084 @@ -759,7 +759,7 @@ - 194 + 195 diff --git a/MacPass/PasswordInputView.xib b/MacPass/PasswordInputView.xib index 64de928b..0d7799c7 100644 --- a/MacPass/PasswordInputView.xib +++ b/MacPass/PasswordInputView.xib @@ -43,7 +43,7 @@ NSApplication - + 268 @@ -252,6 +252,7 @@ 268 {{209, 50}, {74, 32}} + _NS:9 {250, 250} YES @@ -273,6 +274,7 @@ {362, 268} + NSView