Added MPToolbarButton to handle small control size in Toolbar

EntryEditView now gets displayed (without any functionality)
This commit is contained in:
michael starke
2013-02-26 20:57:25 +01:00
parent 2e8d35a432
commit 361b405825
22 changed files with 1274 additions and 436 deletions

View File

@@ -25,6 +25,7 @@
4C586FA216D07F6A00E7DB57 /* 02_MessageBoxWarningTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4C586FA116D07F6A00E7DB57 /* 02_MessageBoxWarningTemplate.pdf */; };
4C61EA0316D2FD0800AC519E /* MPOutlineViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C61EA0216D2FD0800AC519E /* MPOutlineViewController.m */; };
4C61EA0516D2FFE200AC519E /* OutlineView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C61EA0416D2FFE200AC519E /* OutlineView.xib */; };
4C65C79C16DD283900E32CFF /* MPToolbarButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C65C79B16DD283900E32CFF /* MPToolbarButton.m */; };
4C65FAE916D16DDB006E0577 /* MPPasswordInputController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C65FAE716D16DDB006E0577 /* MPPasswordInputController.m */; };
4C669B7F16760ED100DD0774 /* AesInputStream.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C669B3116760ED100DD0774 /* AesInputStream.m */; };
4C669B8016760ED100DD0774 /* AesOutputStream.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C669B3316760ED100DD0774 /* AesOutputStream.m */; };
@@ -72,6 +73,7 @@
4C77E37D15B84A240093A587 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C77E37B15B84A240093A587 /* MainMenu.xib */; };
4C83814215BF4677001AE468 /* MPMainWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C83814115BF4677001AE468 /* MPMainWindowController.m */; };
4C8FECC816D57E3200BF26CF /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C8FECC716D57E3200BF26CF /* QuartzCore.framework */; };
4C920E2A16DCDFA00083839B /* MPLoggerProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C920E2916DCDFA00083839B /* MPLoggerProxy.m */; };
4CA0B2ED15BCADAC00654E32 /* SettingsWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4CA0B2EC15BCADAC00654E32 /* SettingsWindow.xib */; };
4CA0B2F015BCADC800654E32 /* GeneralSettings.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4CA0B2EF15BCADC800654E32 /* GeneralSettings.xib */; };
4CA0B2F915BCAF6700654E32 /* MPGeneralSettingsController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CA0B2F815BCAF6700654E32 /* MPGeneralSettingsController.m */; };
@@ -125,6 +127,8 @@
4C61EA0116D2FD0800AC519E /* MPOutlineViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPOutlineViewController.h; sourceTree = "<group>"; };
4C61EA0216D2FD0800AC519E /* MPOutlineViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPOutlineViewController.m; sourceTree = "<group>"; };
4C61EA0416D2FFE200AC519E /* OutlineView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = OutlineView.xib; sourceTree = "<group>"; };
4C65C79A16DD283900E32CFF /* MPToolbarButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPToolbarButton.h; sourceTree = "<group>"; };
4C65C79B16DD283900E32CFF /* MPToolbarButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPToolbarButton.m; sourceTree = "<group>"; };
4C65FAE616D16DDB006E0577 /* MPPasswordInputController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPPasswordInputController.h; sourceTree = "<group>"; };
4C65FAE716D16DDB006E0577 /* MPPasswordInputController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPPasswordInputController.m; sourceTree = "<group>"; };
4C669B3016760ED100DD0774 /* AesInputStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AesInputStream.h; sourceTree = "<group>"; };
@@ -222,6 +226,8 @@
4C83814015BF4677001AE468 /* MPMainWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPMainWindowController.h; sourceTree = "<group>"; };
4C83814115BF4677001AE468 /* MPMainWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPMainWindowController.m; sourceTree = "<group>"; };
4C8FECC716D57E3200BF26CF /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
4C920E2816DCDFA00083839B /* MPLoggerProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPLoggerProxy.h; sourceTree = "<group>"; };
4C920E2916DCDFA00083839B /* MPLoggerProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPLoggerProxy.m; sourceTree = "<group>"; };
4CA0B2EC15BCADAC00654E32 /* SettingsWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SettingsWindow.xib; sourceTree = "<group>"; };
4CA0B2EF15BCADC800654E32 /* GeneralSettings.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = GeneralSettings.xib; sourceTree = "<group>"; };
4CA0B2F715BCAF6700654E32 /* MPGeneralSettingsController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPGeneralSettingsController.h; sourceTree = "<group>"; };
@@ -300,6 +306,8 @@
4C16854316D704980027ECBC /* MPPathBar.m */,
4C6DA0F716D81B8A0011224B /* MPPathBarItemView.h */,
4C6DA0F816D81B8A0011224B /* MPPathBarItemView.m */,
4C65C79A16DD283900E32CFF /* MPToolbarButton.h */,
4C65C79B16DD283900E32CFF /* MPToolbarButton.m */,
);
name = Views;
sourceTree = "<group>";
@@ -320,6 +328,8 @@
children = (
4C2E382116D1421B00037A9D /* MPIconHelper.h */,
4C2E382216D1421B00037A9D /* MPIconHelper.m */,
4C920E2816DCDFA00083839B /* MPLoggerProxy.h */,
4C920E2916DCDFA00083839B /* MPLoggerProxy.m */,
);
name = Helper;
sourceTree = "<group>";
@@ -792,6 +802,8 @@
4CF5D49616D5B6E900CB78BD /* MPEntryEditController.m in Sources */,
4C16854416D704980027ECBC /* MPPathBar.m in Sources */,
4C6DA0F916D81B8A0011224B /* MPPathBarItemView.m in Sources */,
4C920E2A16DCDFA00083839B /* MPLoggerProxy.m in Sources */,
4C65C79C16DD283900E32CFF /* MPToolbarButton.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

File diff suppressed because it is too large Load Diff

View File

@@ -37,7 +37,7 @@
<string key="NSClassName">NSApplication</string>
</object>
<object class="NSCustomView" id="1005">
<reference key="NSNextResponder"/>
<nil key="NSNextResponder"/>
<int key="NSvFlags">268</int>
<array class="NSMutableArray" key="NSSubviews">
<object class="NSButton" id="113591000">
@@ -45,7 +45,6 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{496, 5}, {42, 17}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="791616402">
@@ -73,7 +72,6 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{188, 5}, {38, 17}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="113591000"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="NSEnabled">YES</bool>
@@ -102,7 +100,6 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{104, 5}, {76, 17}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="340435610"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="NSEnabled">YES</bool>
@@ -127,7 +124,6 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{5, 6}, {44, 14}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="7073340"/>
<string key="NSReuseIdentifierKey">_NS:1535</string>
<bool key="NSEnabled">YES</bool>
@@ -168,7 +164,6 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{54, 4}, {42, 19}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="902262560"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="NSEnabled">YES</bool>
@@ -190,8 +185,6 @@
</object>
</array>
<string key="NSFrameSize">{546, 28}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="906526407"/>
<string key="NSClassName">MPGradientView</string>
</object>
@@ -206,30 +199,6 @@
</object>
<int key="connectionID">48</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">toggleFilterSpace:</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="7073340"/>
</object>
<int key="connectionID">49</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">toggleFilterSpace:</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="902262560"/>
</object>
<int key="connectionID">50</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">toggleFilterSpace:</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="340435610"/>
</object>
<int key="connectionID">51</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">filterTitleButton</string>
@@ -278,6 +247,30 @@
</object>
<int key="connectionID">76</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">_toggleFilterSpace:</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="902262560"/>
</object>
<int key="connectionID">77</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">_toggleFilterSpace:</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="340435610"/>
</object>
<int key="connectionID">78</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">_toggleFilterSpace:</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="7073340"/>
</object>
<int key="connectionID">79</int>
</object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
@@ -710,7 +703,7 @@
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">76</int>
<int key="maxID">79</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">

View File

@@ -28,6 +28,7 @@ APPKIT_EXTERN NSString *const MPDatabaseControllerDatabaseKey;
@property (retain, readonly, nonatomic) MPDatabaseDocument *database;
+ (MPDatabaseController *)defaultController;
+ (BOOL)hasOpenDatabase;
//- (MPDatabaseDocument *)createDatabase:(MPDatabaseVersion )version password:(NSString *)password keyfile:(NSURL *)key;
- (MPDatabaseDocument *)openDatabase:(NSURL *)file password:(NSString *)password keyfile:(NSURL *)key;

View File

@@ -31,6 +31,10 @@ NSString *const MPDatabaseControllerDatabaseKey = @"MPDatabaseControllerDatabase
return sharedInstance;
}
+ (BOOL)hasOpenDatabase {
return (nil != [MPDatabaseController defaultController].database);
}
- (id)init
{
self = [super init];

View File

@@ -7,7 +7,12 @@
//
#import "MPViewController.h"
@class KdbNode;
@interface MPEntryEditController : MPViewController
@property (retain) id selectedItem;
- (IBAction)save:(id)sender;
@end

View File

@@ -7,21 +7,42 @@
//
#import "MPEntryEditController.h"
#import "MPMainWindowController.h"
@interface MPEntryEditController ()
@property (assign) IBOutlet NSButton *cancelButton;
@end
@implementation MPEntryEditController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
- (id)init {
return [self initWithNibName:@"EntryEditView" bundle:nil];
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Initialization code here.
}
return self;
}
- (void)dealloc {
self.selectedItem = nil;
[super dealloc];
}
- (NSResponder *)reconmendedFirstResponder {
return self.cancelButton;
}
#pragma mark Actions
- (IBAction)save:(id)sender {
MPMainWindowController *controller = [[self.view window] windowController];
[controller showEntries];
}
@end

View File

@@ -59,19 +59,19 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername";
@property (assign, nonatomic) MPFilterModeType filterMode;
@property (retain, nonatomic) NSDictionary *filterButtonToMode;
- (IBAction)toggleFilterSpace:(id)sender;
- (IBAction)_toggleFilterSpace:(id)sender;
- (BOOL)shouldFilterURLs;
- (BOOL)shouldFilterTitles;
- (BOOL)shouldFilterUsernames;
- (BOOL)_shouldFilterURLs;
- (BOOL)_shouldFilterTitles;
- (BOOL)_shouldFilterUsernames;
- (BOOL)hasFilter;
- (void)updateFilter;
- (void)setupFilterBar;
- (void)setupPathBar;
- (void)didChangeGroupSelectionInOutlineView:(NSNotification *)notification;
- (void)showFilterBarAnimated:(BOOL)animate;
- (void)hideStatusBarAnimated:(BOOL)animate;
- (void)_didChangeGroupSelectionInOutlineView:(NSNotification *)notification;
- (void)_showFilterBarAnimated:(BOOL)animate;
- (void)_hideStatusBarAnimated:(BOOL)animate;
@end
@@ -93,7 +93,7 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername";
} retain];
_entryArrayController = [[NSArrayController alloc] init];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(didChangeGroupSelectionInOutlineView:)
selector:@selector(_didChangeGroupSelectionInOutlineView:)
name:MPOutlineViewDidChangeGroupSelection
object:nil];
}
@@ -111,7 +111,7 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername";
- (void)didLoadView {
[self.view setWantsLayer:YES];
[self hideStatusBarAnimated:NO];
[self _hideStatusBarAnimated:NO];
[self.entryTable setDelegate:self];
@@ -179,7 +179,7 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername";
}
#pragma mark Notifications
- (void)didChangeGroupSelectionInOutlineView:(NSNotification *)notification {
- (void)_didChangeGroupSelectionInOutlineView:(NSNotification *)notification {
if([self hasFilter]) {
return;
@@ -216,25 +216,25 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername";
- (void)clearFilter {
self.filter = nil;
[[self.entryTable tableColumnWithIdentifier:MPEntryTableParentColumnIdentifier] setHidden:YES];
[self hideStatusBarAnimated:YES];
[self _hideStatusBarAnimated:YES];
}
- (void)updateFilter {
MPDatabaseDocument *openDatabase = [MPDatabaseController defaultController].database;
if(openDatabase) {
[self showFilterBarAnimated:YES];
[self _showFilterBarAnimated:YES];
dispatch_queue_t backgroundQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(backgroundQueue, ^{
NSMutableArray *prediactes = [NSMutableArray arrayWithCapacity:3];
if( [self shouldFilterTitles] ) {
if( [self _shouldFilterTitles] ) {
[prediactes addObject:[NSPredicate predicateWithFormat:@"SELF.title CONTAINS[cd] %@", self.filter]];
}
if( [self shouldFilterUsernames] ) {
if( [self _shouldFilterUsernames] ) {
[prediactes addObject:[NSPredicate predicateWithFormat:@"SELF.username CONTAINS[cd] %@", self.filter]];
}
if( [self shouldFilterURLs] ) {
if( [self _shouldFilterURLs] ) {
[prediactes addObject:[NSPredicate predicateWithFormat:@"SELF.url CONTAINS[cd] %@", self.filter]];
}
NSPredicate *fullFilter = [NSCompoundPredicate orPredicateWithSubpredicates:prediactes];
@@ -275,7 +275,7 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername";
#pragma mark Animation
- (void)showFilterBarAnimated:(BOOL)animate {
- (void)_showFilterBarAnimated:(BOOL)animate {
animate = NO;
@@ -285,9 +285,9 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername";
/*
Make sure the buttons are set correctyl every time
*/
[self.filterTitleButton setState:[self shouldFilterTitles] ? NSOnState : NSOffState];
[self.filterURLButton setState:[self shouldFilterURLs] ? NSOnState : NSOffState ];
[self.filterUsernameButton setState:[self shouldFilterUsernames] ? NSOnState : NSOffState];
[self.filterTitleButton setState:[self _shouldFilterTitles] ? NSOnState : NSOffState];
[self.filterURLButton setState:[self _shouldFilterURLs] ? NSOnState : NSOffState ];
[self.filterUsernameButton setState:[self _shouldFilterUsernames] ? NSOnState : NSOffState];
if(self.isStatusBarVisible) {
return; // nothign to to
@@ -315,7 +315,7 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername";
}
}
- (void)hideStatusBarAnimated:(BOOL)animate {
- (void)_hideStatusBarAnimated:(BOOL)animate {
animate = NO;
@@ -342,7 +342,7 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername";
#pragma mark Actions
- (void)toggleFilterSpace:(id)sender {
- (void)_toggleFilterSpace:(id)sender {
NSButton *button = sender;
NSNumber *value = self.filterButtonToMode[[button identifier]];
MPFilterModeType toggledMode = (MPFilterModeType)[value intValue];
@@ -371,15 +371,15 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername";
}
}
- (BOOL)shouldFilterTitles {
- (BOOL)_shouldFilterTitles {
return ( MPFilterNone != (self.filterMode & MPFilterTitles));
}
- (BOOL)shouldFilterURLs {
- (BOOL)_shouldFilterURLs {
return ( MPFilterNone != (self.filterMode & MPFilterUrls));
}
- (BOOL)shouldFilterUsernames {
- (BOOL)_shouldFilterUsernames {
return ( MPFilterNone != (self.filterMode & MPFilterUsernames));
}

View File

@@ -14,7 +14,7 @@
@property (retain) NSGradient *activeGradient;
@property (retain) NSGradient *inactiveGradient;
- (void)refreshActiveState;
- (void)_refreshActiveState;
@end
@@ -66,8 +66,8 @@
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidResignKeyNotification object:[self window]];
}
if(newWindow) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshActiveState) name:NSWindowDidBecomeKeyNotification object:newWindow];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshActiveState) name:NSWindowDidResignKeyNotification object:newWindow];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_refreshActiveState) name:NSWindowDidBecomeKeyNotification object:newWindow];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_refreshActiveState) name:NSWindowDidResignKeyNotification object:newWindow];
}
}
@@ -76,7 +76,7 @@
[super viewWillMoveToWindow:newWindow];
}
- (void)refreshActiveState {
- (void)_refreshActiveState {
self.isRenderedActive = [[self window] isKeyWindow];
}

16
MacPass/MPLoggerProxy.h Normal file
View File

@@ -0,0 +1,16 @@
//
// MPLoggerProxy.h
// MacPass
//
// Created by michael starke on 26.02.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface MPLoggerProxy : NSObject
@property (retain) id original;
- (id)initWithOriginal:(id) value;
@end

35
MacPass/MPLoggerProxy.m Normal file
View File

@@ -0,0 +1,35 @@
//
// MPLoggerProxy.m
// MacPass
//
// Created by michael starke on 26.02.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import "MPLoggerProxy.h"
@implementation MPLoggerProxy
- (id) initWithOriginal:(id)value {
if (self = [super init]) {
self.original = value;
}
return self;
}
- (NSMethodSignature *)methodSignatureForSelector:(SEL)sel {
NSMethodSignature *sig = [super methodSignatureForSelector:sel];
if(!sig)
{
sig = [self.original methodSignatureForSelector:sel];
}
return sig;
}
- (void)forwardInvocation:(NSInvocation *)inv {
NSLog(@"[%@ %@] %@ %@", self.original, inv,[inv methodSignature],
NSStringFromSelector([inv selector]));
[inv invokeWithTarget:self.original];
}
@end

View File

@@ -17,10 +17,4 @@
- (void)performFindPanelAction:(id)sender;
- (void)clearOutlineSelection:(id)sender;
/*
Sets the content View controller
@param viewController - use nil to reset to welcome screen
*/
- (void)setContentViewController:(MPViewController *)viewController;
@end

View File

@@ -13,6 +13,7 @@
#import "MPToolbarDelegate.h"
#import "MPOutlineViewController.h"
#import "MPMainWindowSplitViewDelegate.h"
#import "MPEntryEditController.h"
@interface MPMainWindowController ()
@@ -26,13 +27,15 @@
@property (retain) MPPasswordInputController *passwordInputController;
@property (retain) MPEntryViewController *entryViewController;
@property (retain) MPEntryEditController *entryEditController;
@property (retain) MPOutlineViewController *outlineViewController;
@property (retain) MPToolbarDelegate *toolbarDelegate;
@property (retain) MPMainWindowSplitViewDelegate *splitViewDelegate;
- (void)collapseOutlineView;
- (void)expandOutlineView;
- (void)_collapseOutlineView;
- (void)_expandOutlineView;
- (void)_setContentViewController:(MPViewController *)viewController;
@end
@@ -64,6 +67,7 @@
self.passwordInputController = nil;
self.entryViewController = nil;
self.entryEditController = nil;
self.outlineViewController = nil;
self.toolbarDelegate = nil;
@@ -95,11 +99,11 @@
[self.splitView replaceSubview:self.outlineView with:[self.outlineViewController view]];
[self.splitView adjustSubviews];
[self setContentViewController:nil];
[self collapseOutlineView];
[self _setContentViewController:nil];
[self _collapseOutlineView];
}
- (void)setContentViewController:(MPViewController *)viewController {
- (void)_setContentViewController:(MPViewController *)viewController {
NSView *newContentView = self.welcomeView;
if(viewController && viewController.view) {
newContentView = viewController.view;
@@ -132,14 +136,14 @@
[self.window makeFirstResponder:[viewController reconmendedFirstResponder]];
}
- (void)collapseOutlineView {
- (void)_collapseOutlineView {
NSView *outlineView = [self.splitView subviews][0];
if(![outlineView isHidden]) {
[self.splitView setPosition:0 ofDividerAtIndex:0];
}
}
- (void)expandOutlineView {
- (void)_expandOutlineView {
NSView *outlineView = [self.splitView subviews][0];
if([outlineView isHidden]) {
[self.splitView setPosition:MPMainWindowSplitViewDelegateMinimumOutlineWidth ofDividerAtIndex:0];
@@ -172,7 +176,7 @@
if(result == NSFileHandlingPanelOKButton) {
NSURL *file = [[openPanel URLs] lastObject];
self.passwordInputController.fileURL = file;
[self setContentViewController:self.passwordInputController];
[self _setContentViewController:self.passwordInputController];
}
}];
}
@@ -196,6 +200,22 @@
[self.outlineViewController clearSelection];
}
- (void)showEditForm:(id)sender {
if( ![MPDatabaseController hasOpenDatabase] ) {
return; // No database open - nothing to do;
}
if(!self.entryEditController) {
self.entryEditController = [[[MPEntryEditController alloc] init] autorelease];
}
//find active selection
self.entryEditController.selectedItem = nil;
[self _setContentViewController:self.entryEditController];
}
#pragma mark Helper
- (NSSearchField *)locateToolbarSearchField {
for(NSToolbarItem *toolbarItem in [[self.window toolbar] items]) {
NSView *view = [toolbarItem view];
@@ -213,11 +233,11 @@
}
- (void)showEntries {
[self expandOutlineView];
[self _expandOutlineView];
if(!self.entryViewController) {
_entryViewController = [[MPEntryViewController alloc] init];
}
[self setContentViewController:self.entryViewController];
[self _setContentViewController:self.entryViewController];
}
- (IBAction)changedFileType:(id)sender {

View File

@@ -13,23 +13,23 @@ const CGFloat MPMainWindowSplitViewDelegateMinimumContentWidth = 400.0;
@interface MPMainWindowSplitViewDelegate ()
- (NSView *)leftView:(NSSplitView *)splitView;
- (NSView *)rightView:(NSSplitView *)splitView;
- (NSView *)_leftView:(NSSplitView *)splitView;
- (NSView *)_rightView:(NSSplitView *)splitView;
@end
@implementation MPMainWindowSplitViewDelegate
- (NSView *)leftView:(NSSplitView *)splitView {
- (NSView *)_leftView:(NSSplitView *)splitView {
return [splitView subviews][0];
}
- (NSView *)rightView:(NSSplitView *)splitView {
- (NSView *)_rightView:(NSSplitView *)splitView {
return [splitView subviews][1];
}
- (BOOL)splitView:(NSSplitView *)splitView canCollapseSubview:(NSView *)subview {
return (subview == [self leftView:splitView]);
return (subview == [self _leftView:splitView]);
}
- (CGFloat)splitView:(NSSplitView *)splitView constrainMinCoordinate:(CGFloat)proposedMinimumPosition ofSubviewAt:(NSInteger)dividerIndex {
@@ -45,8 +45,8 @@ const CGFloat MPMainWindowSplitViewDelegateMinimumContentWidth = 400.0;
NSSize newSize = [splitView frame].size;
const CGFloat dividierThickness = [splitView dividerThickness];
NSView *leftView = [self leftView:splitView];
NSView *rightView = [self rightView:splitView];
NSView *leftView = [self _leftView:splitView];
NSView *rightView = [self _rightView:splitView];
CGFloat leftWidth = [leftView isHidden] ? 0.0 : [leftView frame].size.width;
NSRect newRightFrame = NSMakeRect(leftWidth + dividierThickness, 0, newSize.width - leftWidth - dividierThickness, newSize.height);

View File

@@ -21,9 +21,9 @@
@property (retain) NSMenu *menu;
- (void)didOpenDocument:(NSNotification *)notification;
- (void)setupMenu;
- (void)addEntry:(id)sender;
- (void)_didOpenDocument:(NSNotification *)notification;
- (void)_setupMenu;
- (void)_addEntry:(id)sender;
@end
@@ -40,10 +40,10 @@
self.datasource = [[[MPOutlineDataSource alloc] init] autorelease];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(didOpenDocument:)
selector:@selector(_didOpenDocument:)
name:MPDatabaseControllerDidLoadDatabaseNotification
object:nil];
[self setupMenu];
[self _setupMenu];
}
return self;
@@ -65,7 +65,7 @@
[self.outlineView setAllowsEmptySelection:YES];
}
- (void)didOpenDocument:(NSNotification *)notification {
- (void)_didOpenDocument:(NSNotification *)notification {
[self.outlineView reloadData];
MPDatabaseController *dbContoller = [MPDatabaseController defaultController];
if(dbContoller.database) {
@@ -77,7 +77,7 @@
[self.outlineView deselectAll:nil];
}
- (void)setupMenu {
- (void)_setupMenu {
NSMenu *menu = [[NSMenu allocWithZone:[NSMenu menuZone]] init];
[menu addItemWithTitle:@"Add Group" action:@selector(addEntry:) keyEquivalent:@""];
[menu addItem: [NSMenuItem separatorItem]];
@@ -90,7 +90,7 @@
[menu release];
}
- (void)addEntry:(id)sender {
- (void)_addEntry:(id)sender {
NSLog(@"Add Entry");
}

View File

@@ -13,9 +13,9 @@
@property (assign) IBOutlet NSSecureTextField *passwordTextField;
- (IBAction)selectKeyFile:(id)sender;
- (IBAction)open:(id)sender;
- (void)showError;
- (IBAction)_selectKeyFile:(id)sender;
- (IBAction)_open:(id)sender;
- (void)_showError;
@end
@@ -34,22 +34,22 @@
return self.passwordTextField;
}
- (IBAction)selectKeyFile:(id)sender {
- (IBAction)_selectKeyFile:(id)sender {
}
- (IBAction)open:(id)sender {
- (IBAction)_open:(id)sender {
NSString *password = [self.passwordTextField stringValue];
[self.passwordTextField setStringValue:@""];
MPDatabaseDocument *document = [[MPDatabaseController defaultController] openDatabase:self.fileURL
password:password
keyfile:nil];
if(!document) {
[self showError];
[self _showError];
}
}
- (void)showError {
- (void)_showError {
NSLog(@"Something went wrong");
}
@end

18
MacPass/MPToolbarButton.h Normal file
View File

@@ -0,0 +1,18 @@
//
// MPButton.h
// MacPass
//
// Created by michael starke on 26.02.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@interface MPToolbarButton : NSButton
/* This methods ensure, that the button get sized correctly if used as the view in a NSToolbarItem*/
- (void)setControlSize:(NSControlSize)controlSize;
- (NSControlSize)controlSize;
@end

36
MacPass/MPToolbarButton.m Normal file
View File

@@ -0,0 +1,36 @@
//
// MPButton.m
// MacPass
//
// Created by michael starke on 26.02.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import "MPToolbarButton.h"
@implementation MPToolbarButton
- (void)setControlSize:(NSControlSize)controlSize {
[[self cell] setControlSize:controlSize];
switch (controlSize) {
case NSRegularControlSize:
[[self image] setSize:NSMakeSize(16, 16)];
break;
case NSSmallControlSize:
[[self image] setSize:NSMakeSize(14, 14)];
break;
case NSMiniControlSize:
[[self image] setSize:NSMakeSize(8, 8)];
default:
break;
}
}
- (NSControlSize)controlSize {
return [[self cell] controlSize];
}
@end

View File

@@ -10,6 +10,7 @@
#import "MPIconHelper.h"
#import "MPMainWindowController.h"
#import "MPPathBar.h"
#import "MPToolbarButton.h"
NSString *const MPToolbarItemAddGroup = @"AddGroup";
NSString *const MPToolbarItemAddEntry = @"AddEntry";
@@ -20,6 +21,7 @@ NSString *const MPToolbarItemSearch = @"Search";
@interface MPToolbarDelegate()
@property (retain) NSMutableDictionary *toolbarItems;
@property (retain) NSArray *toolbarIdentifiers;
@property (retain) NSDictionary *toolbarImages;
@@ -34,6 +36,7 @@ NSString *const MPToolbarItemSearch = @"Search";
if (self) {
self.toolbarIdentifiers = @[ MPToolbarItemAddEntry, MPToolbarItemDelete, MPToolbarItemEdit, MPToolbarItemAddGroup, MPToolbarItemAction, NSToolbarFlexibleSpaceItemIdentifier, MPToolbarItemSearch ];
self.toolbarImages = [self createToolbarImages];
self.toolbarItems = [[NSMutableDictionary alloc] initWithCapacity:[self.toolbarIdentifiers count]];
}
return self;
}
@@ -42,11 +45,14 @@ NSString *const MPToolbarItemSearch = @"Search";
{
self.toolbarIdentifiers = nil;
self.toolbarImages = nil;
self.toolbarItems = nil;
[super dealloc];
}
- (NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag {
NSToolbarItem *item = [[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier];
- (NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag {
NSToolbarItem *item = self.toolbarItems[itemIdentifier];
if(!item) {
item = [[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier];
[item setAction:@selector(toolbarItemPressed:)];
NSString *label = NSLocalizedString(itemIdentifier, @"");
[item setLabel:label];
@@ -85,23 +91,24 @@ NSString *const MPToolbarItemSearch = @"Search";
Cleanup
*/
[menuItem release];
[menu release];
[menu release];
[item setView:popupButton];
[popupButton release];
}
else {
NSButton *button = [[NSButton alloc] initWithFrame:NSMakeRect(0, 0, 32, 32)];
NSButton *button = [[MPToolbarButton alloc] initWithFrame:NSMakeRect(0, 0, 32, 32)];
[[button cell] setBezelStyle:NSTexturedRoundedBezelStyle];
[[button cell] setImageScaling:NSImageScaleProportionallyDown];
[button setTitle:itemIdentifier];
[button setButtonType:NSMomentaryPushInButton];
NSImage *image = self.toolbarImages[itemIdentifier];
[image setSize:NSMakeSize(16, 16)];
[button setImage:image];
[button setImagePosition:NSImageOnly];
[button sizeToFit];
if([itemIdentifier isEqualToString:MPToolbarItemDelete]) {
if([itemIdentifier isEqualToString:MPToolbarItemEdit]) {
[button setTarget:nil];
[button setAction:@selector(clearOutlineSelection:)];
[button setAction:@selector(showEditForm:)];
}
NSRect fittingRect = [button frame];
@@ -110,7 +117,10 @@ NSString *const MPToolbarItemSearch = @"Search";
[item setView:button];
[button release];
}
return [item autorelease];
self.toolbarItems[itemIdentifier] = item;
[item release];
}
return item;
}
- (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar*)toolbar {

View File

@@ -21,7 +21,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>310</string>
<string>34B</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSHumanReadableCopyright</key>

View File

@@ -39,7 +39,7 @@
<string key="NSClassName">NSApplication</string>
</object>
<object class="NSCustomView" id="1005">
<reference key="NSNextResponder"/>
<nil key="NSNextResponder"/>
<int key="NSvFlags">268</int>
<array class="NSMutableArray" key="NSSubviews">
<object class="NSSecureTextField" id="219521947">
@@ -47,7 +47,6 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{128, 163}, {191, 22}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="NSEnabled">YES</bool>
<object class="NSSecureTextFieldCell" key="NSCell" id="160320867">
@@ -91,7 +90,6 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{228, 127}, {97, 32}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="769513826"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="NSEnabled">YES</bool>
@@ -116,8 +114,6 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{59, 166}, {64, 17}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<string key="NSReuseIdentifierKey">_NS:1535</string>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="108091909">
@@ -150,7 +146,6 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{77, 136}, {46, 17}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="723622123"/>
<string key="NSReuseIdentifierKey">_NS:1535</string>
<bool key="NSEnabled">YES</bool>
@@ -171,7 +166,6 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{251, 71}, {74, 32}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="736946738">
@@ -192,8 +186,6 @@
</object>
</array>
<string key="NSFrameSize">{447, 347}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="662046682"/>
<string key="NSClassName">NSView</string>
</object>
@@ -208,22 +200,6 @@
</object>
<int key="connectionID">143</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">selectKeyFile:</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="723622123"/>
</object>
<int key="connectionID">152</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">open:</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="769513826"/>
</object>
<int key="connectionID">154</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">passwordTextField</string>
@@ -232,6 +208,22 @@
</object>
<int key="connectionID">196</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">_selectKeyFile:</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="723622123"/>
</object>
<int key="connectionID">198</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">_open:</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="769513826"/>
</object>
<int key="connectionID">199</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">nextKeyView</string>
@@ -335,6 +327,22 @@
<float key="scoringTypeFloat">40</float>
<int key="contentType">3</int>
</object>
<object class="IBNSLayoutConstraint" id="957344773">
<reference key="firstItem" ref="333885704"/>
<int key="firstAttribute">10</int>
<int key="relation">0</int>
<reference key="secondItem" ref="723622123"/>
<int key="secondAttribute">10</int>
<float key="multiplier">1</float>
<object class="IBLayoutConstant" key="constant">
<double key="value">0.0</double>
</object>
<float key="priority">1000</float>
<reference key="containingView" ref="1005"/>
<int key="scoringType">6</int>
<float key="scoringTypeFloat">24</float>
<int key="contentType">2</int>
</object>
<object class="IBNSLayoutConstraint" id="207368608">
<reference key="firstItem" ref="219521947"/>
<int key="firstAttribute">5</int>
@@ -415,22 +423,6 @@
<float key="scoringTypeFloat">24</float>
<int key="contentType">2</int>
</object>
<object class="IBNSLayoutConstraint" id="957344773">
<reference key="firstItem" ref="333885704"/>
<int key="firstAttribute">10</int>
<int key="relation">0</int>
<reference key="secondItem" ref="723622123"/>
<int key="secondAttribute">10</int>
<float key="multiplier">1</float>
<object class="IBLayoutConstant" key="constant">
<double key="value">0.0</double>
</object>
<float key="priority">1000</float>
<reference key="containingView" ref="1005"/>
<int key="scoringType">6</int>
<float key="scoringTypeFloat">24</float>
<int key="contentType">2</int>
</object>
<object class="IBNSLayoutConstraint" id="72942573">
<reference key="firstItem" ref="662046682"/>
<int key="firstAttribute">6</int>
@@ -623,15 +615,15 @@
<string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="-3.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<array class="NSMutableArray" key="1.IBNSViewMetadataConstraints">
<array key="1.IBNSViewMetadataConstraints">
<reference ref="781301592"/>
<reference ref="72942573"/>
<reference ref="957344773"/>
<reference ref="151404172"/>
<reference ref="937587174"/>
<reference ref="679367678"/>
<reference ref="649511608"/>
<reference ref="207368608"/>
<reference ref="957344773"/>
<reference ref="862589174"/>
<reference ref="1041224580"/>
<reference ref="1001566026"/>
@@ -674,7 +666,7 @@
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">197</int>
<int key="maxID">199</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">

View File

@@ -49,7 +49,7 @@
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1920, 1058}}</string>
<string key="NSScreenRect">{{0, 0}, {2560, 1418}}</string>
<string key="NSMaxSize">{10000000000000, 10000000000000}</string>
<bool key="NSWindowIsRestorable">YES</bool>
</object>
@@ -120,7 +120,7 @@
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">80</int>
<int key="maxID">89</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">