Extracted context menu operations into MPContextMenuHelper

Removed private declarations as they aren't needed for the compiler anymore
Fixed drawing order in MPPopupImageView
Fixed #7 Error occurred due to duplicate shortcut.
Copy Password now is bound to ⌘+⌥+C
This commit is contained in:
michael starke
2013-06-09 18:20:04 +02:00
parent 88ff8c79a0
commit 288d118184
18 changed files with 149 additions and 218 deletions

View File

@@ -7,7 +7,8 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
4C01C23C1764D1AA0016D5D0 /* KdbKeyPaths.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C01C23B1764D1460016D5D0 /* KdbKeyPaths.m */; }; 4C01C23F1764D2980016D5D0 /* KdbEntry+Undo.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C01C23E1764D2980016D5D0 /* KdbEntry+Undo.m */; };
4C01C2421764D8980016D5D0 /* MPContextMenuHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C01C2411764D8980016D5D0 /* MPContextMenuHelper.m */; };
4C1DDCDD1711ECEB00C98DA3 /* PasswordCreatorWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C1DDCDC1711ECEB00C98DA3 /* PasswordCreatorWindow.xib */; }; 4C1DDCDD1711ECEB00C98DA3 /* PasswordCreatorWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C1DDCDC1711ECEB00C98DA3 /* PasswordCreatorWindow.xib */; };
4C22040D1746ED160054C916 /* KdbGroup+Undo.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C22040C1746ED160054C916 /* KdbGroup+Undo.m */; }; 4C22040D1746ED160054C916 /* KdbGroup+Undo.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C22040C1746ED160054C916 /* KdbGroup+Undo.m */; };
4C25D58716CF0FAA00F6806C /* EntryView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C25D58616CF0FAA00F6806C /* EntryView.xib */; }; 4C25D58716CF0FAA00F6806C /* EntryView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C25D58616CF0FAA00F6806C /* EntryView.xib */; };
@@ -129,8 +130,10 @@
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
4C01C23A1764CDA20016D5D0 /* KdbKeyPaths.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KdbKeyPaths.h; sourceTree = "<group>"; }; 4C01C23D1764D2980016D5D0 /* KdbEntry+Undo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "KdbEntry+Undo.h"; sourceTree = "<group>"; };
4C01C23B1764D1460016D5D0 /* KdbKeyPaths.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KdbKeyPaths.m; sourceTree = "<group>"; }; 4C01C23E1764D2980016D5D0 /* KdbEntry+Undo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "KdbEntry+Undo.m"; sourceTree = "<group>"; };
4C01C2401764D8980016D5D0 /* MPContextMenuHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPContextMenuHelper.h; sourceTree = "<group>"; };
4C01C2411764D8980016D5D0 /* MPContextMenuHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPContextMenuHelper.m; sourceTree = "<group>"; };
4C1DDCDC1711ECEB00C98DA3 /* PasswordCreatorWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PasswordCreatorWindow.xib; sourceTree = "<group>"; }; 4C1DDCDC1711ECEB00C98DA3 /* PasswordCreatorWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PasswordCreatorWindow.xib; sourceTree = "<group>"; };
4C22040B1746ED160054C916 /* KdbGroup+Undo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "KdbGroup+Undo.h"; sourceTree = "<group>"; }; 4C22040B1746ED160054C916 /* KdbGroup+Undo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "KdbGroup+Undo.h"; sourceTree = "<group>"; };
4C22040C1746ED160054C916 /* KdbGroup+Undo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "KdbGroup+Undo.m"; sourceTree = "<group>"; }; 4C22040C1746ED160054C916 /* KdbGroup+Undo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "KdbGroup+Undo.m"; sourceTree = "<group>"; };
@@ -405,6 +408,8 @@
4C2C4C2516D3BCEA00D49295 /* KeePassLibAdditions */ = { 4C2C4C2516D3BCEA00D49295 /* KeePassLibAdditions */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
4C01C23D1764D2980016D5D0 /* KdbEntry+Undo.h */,
4C01C23E1764D2980016D5D0 /* KdbEntry+Undo.m */,
4C2C4C2A16D3BE3700D49295 /* KdbGroup+MPAdditions.h */, 4C2C4C2A16D3BE3700D49295 /* KdbGroup+MPAdditions.h */,
4C2C4C2B16D3BE3700D49295 /* KdbGroup+MPAdditions.m */, 4C2C4C2B16D3BE3700D49295 /* KdbGroup+MPAdditions.m */,
4CC1AEBC16D4467C006D2AAB /* KdbTree+MPAdditions.h */, 4CC1AEBC16D4467C006D2AAB /* KdbTree+MPAdditions.h */,
@@ -413,8 +418,6 @@
4C22040C1746ED160054C916 /* KdbGroup+Undo.m */, 4C22040C1746ED160054C916 /* KdbGroup+Undo.m */,
4C4A101017629DA900BBF2CA /* KdbGroup+KVOAdditions.h */, 4C4A101017629DA900BBF2CA /* KdbGroup+KVOAdditions.h */,
4C4A101117629DA900BBF2CA /* KdbGroup+KVOAdditions.m */, 4C4A101117629DA900BBF2CA /* KdbGroup+KVOAdditions.m */,
4C01C23A1764CDA20016D5D0 /* KdbKeyPaths.h */,
4C01C23B1764D1460016D5D0 /* KdbKeyPaths.m */,
); );
name = KeePassLibAdditions; name = KeePassLibAdditions;
sourceTree = "<group>"; sourceTree = "<group>";
@@ -430,6 +433,8 @@
4CBA2AB917074C07006D8139 /* MPSettingsHelper.m */, 4CBA2AB917074C07006D8139 /* MPSettingsHelper.m */,
4C5BF679175C01F300D53DF7 /* MPUppercaseStringValueTransformer.h */, 4C5BF679175C01F300D53DF7 /* MPUppercaseStringValueTransformer.h */,
4C5BF67A175C01F300D53DF7 /* MPUppercaseStringValueTransformer.m */, 4C5BF67A175C01F300D53DF7 /* MPUppercaseStringValueTransformer.m */,
4C01C2401764D8980016D5D0 /* MPContextMenuHelper.h */,
4C01C2411764D8980016D5D0 /* MPContextMenuHelper.m */,
); );
name = Helper; name = Helper;
sourceTree = "<group>"; sourceTree = "<group>";
@@ -937,7 +942,6 @@
isa = PBXSourcesBuildPhase; isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
4C01C23C1764D1AA0016D5D0 /* KdbKeyPaths.m in Sources */,
4C77E37315B84A240093A587 /* main.m in Sources */, 4C77E37315B84A240093A587 /* main.m in Sources */,
4CBA2ABA17074C07006D8139 /* MPSettingsHelper.m in Sources */, 4CBA2ABA17074C07006D8139 /* MPSettingsHelper.m in Sources */,
4C77E37A15B84A240093A587 /* MPAppDelegate.m in Sources */, 4C77E37A15B84A240093A587 /* MPAppDelegate.m in Sources */,
@@ -1024,6 +1028,8 @@
4C4A101217629DA900BBF2CA /* KdbGroup+KVOAdditions.m in Sources */, 4C4A101217629DA900BBF2CA /* KdbGroup+KVOAdditions.m in Sources */,
4CAF62FC1763604000CD7084 /* HNHBadgedTextFieldCell.m in Sources */, 4CAF62FC1763604000CD7084 /* HNHBadgedTextFieldCell.m in Sources */,
4C58BD4F176370B100B8178C /* HNHBadgedTextField.m in Sources */, 4C58BD4F176370B100B8178C /* HNHBadgedTextField.m in Sources */,
4C01C23F1764D2980016D5D0 /* KdbEntry+Undo.m in Sources */,
4C01C2421764D8980016D5D0 /* MPContextMenuHelper.m in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };

View File

@@ -1,20 +0,0 @@
//
// KdbKeyPaths.h
// MacPass
//
// Created by Michael Starke on 09.06.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#ifndef MacPass_KdbKeyPaths_h
#define MacPass_KdbKeyPaths_h
#import <Foundation/Foundation.h>
FOUNDATION_EXPORT NSString *const MPEntryKeyForTitle;// = @"title";
FOUNDATION_EXPORT NSString *const MPEntryKeyForUsername;// = @"username";
FOUNDATION_EXPORT NSString *const MPEntryKeyForUrl;// = @"url";
FOUNDATION_EXPORT NSString *const MPEntryKeyForPassword;// = @"password";
FOUNDATION_EXPORT NSString *const MPEntryKeyForNotes;// = @"notes";
#endif

View File

@@ -1,15 +0,0 @@
//
// KdbKeyPaths.m
// MacPass
//
// Created by Michael Starke on 09.06.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import "KdbKeyPaths.h"
NSString *const MPEntryKeyForTitle = @"title";
NSString *const MPEntryKeyForUsername = @"username";
NSString *const MPEntryKeyForUrl = @"url";
NSString *const MPEntryKeyForPassword = @"password";
NSString *const MPEntryKeyForNotes = @"notes";

View File

@@ -8,16 +8,6 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
typedef enum {
MPContextMenuCreate = 1<<0,
MPContextMenuDelete = 1<<1,
MPContextMenuCopy = 1<<2,
MPContextMenuMinimal = MPContextMenuCreate | MPContextMenuDelete,
MPContextMenuFull = MPContextMenuMinimal | MPContextMenuCopy,
}MPContextMenuItemsFlags;
@class MPDatabaseDocument;
@interface MPAppDelegate : NSObject <NSApplicationDelegate> @interface MPAppDelegate : NSObject <NSApplicationDelegate>
@property (retain) IBOutlet NSWindow *passwordCreatorWindow; @property (retain) IBOutlet NSWindow *passwordCreatorWindow;
@@ -26,10 +16,4 @@ typedef enum {
- (NSString *)applicationName; - (NSString *)applicationName;
/*
Creates an array of menuitems to be used as a menu
Automatically sets up actions, so you need to take care of the responder chain
*/
- (NSArray *)contextMenuItemsWithItems:(MPContextMenuItemsFlags)flags;
@end @end

View File

@@ -8,12 +8,9 @@
#import "MPAppDelegate.h" #import "MPAppDelegate.h"
#import "MPDocumentWindowController.h"
#import "MPSettingsWindowController.h" #import "MPSettingsWindowController.h"
#import "MPPasswordCreatorViewController.h" #import "MPPasswordCreatorViewController.h"
#import "MPActionHelper.h"
#import "MPSettingsHelper.h" #import "MPSettingsHelper.h"
#import "NSString+MPPasswordCreation.h"
#import "MPUppercaseStringValueTransformer.h" #import "MPUppercaseStringValueTransformer.h"
@interface MPAppDelegate () @interface MPAppDelegate ()
@@ -65,71 +62,4 @@
[self.passwordCreatorWindow makeKeyAndOrderFront:self.passwordCreatorWindow]; [self.passwordCreatorWindow makeKeyAndOrderFront:self.passwordCreatorWindow];
} }
- (NSArray *)contextMenuItemsWithItems:(MPContextMenuItemsFlags)flags {
BOOL insertCreate = (0 != (flags & MPContextMenuCreate));
BOOL insertDelete = (0 != (flags & MPContextMenuDelete));
BOOL insertCopy = (0 != (flags & MPContextMenuCopy));
NSMutableArray *items = [NSMutableArray arrayWithCapacity:7];
if(insertCreate) {
NSMenuItem *newGroup = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"ADD_GROUP", @"")
action:[MPActionHelper actionOfType:MPActionAddGroup]
keyEquivalent:@"G"];
NSMenuItem *newEntry = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"ADD_ENTRY", @"")
action:[MPActionHelper actionOfType:MPActionAddEntry]
keyEquivalent:@"E"];
[items addObjectsFromArray:@[ newGroup, newEntry ]];
[newEntry release];
[newGroup release];
}
if(insertDelete) {
if([items count] > 0) {
[items addObject:[NSMenuItem separatorItem]];
}
NSMenuItem *delete = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"DELETE", @"")
action:[MPActionHelper actionOfType:MPActionDelete]
keyEquivalent:@""];
[items addObject:delete];
[delete release];
}
if(insertCopy) {
if([items count] > 0) {
[items addObject:[NSMenuItem separatorItem]];
}
NSMenuItem *copyUsername = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"COPY_USERNAME", @"")
action:[MPActionHelper actionOfType:MPActionCopyUsername]
keyEquivalent:@"C"];
NSMenuItem *copyPassword = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"COPY_PASSWORD", @"")
action:[MPActionHelper actionOfType:MPActionCopyPassword]
keyEquivalent:@"c"];
NSMenu *urlMenu = [[NSMenu alloc] init];
NSMenuItem *urlItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"URL", @"")
action:0
keyEquivalent:@""];
[urlItem setSubmenu:urlMenu];
[urlMenu release];
NSMenuItem *copyURL = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"COPY_URL", @"")
action:[MPActionHelper actionOfType:MPActionCopyURL]
keyEquivalent:@"u"];
NSMenuItem *openURL = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"OPEN_URL", @"")
action:[MPActionHelper actionOfType:MPActionOpenURL]
keyEquivalent:@"U"];
[urlMenu addItem:copyURL];
[urlMenu addItem:openURL];
[openURL release];
[copyURL release];
[items addObjectsFromArray:@[ copyUsername, copyPassword, urlItem]];
[urlItem release];
[copyPassword release];
[copyUsername release];
}
return items;
}
@end @end

View File

@@ -0,0 +1,27 @@
//
// MPContextMenuHelper.h
// MacPass
//
// Created by Michael Starke on 09.06.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import <Cocoa/Cocoa.h>
typedef enum {
MPContextMenuCreate = 1<<0,
MPContextMenuDelete = 1<<1,
MPContextMenuCopy = 1<<2,
MPContextMenuMinimal = MPContextMenuCreate | MPContextMenuDelete,
MPContextMenuFull = MPContextMenuMinimal | MPContextMenuCopy,
} MPContextMenuItemsFlags;
@interface MPContextMenuHelper : NSTableCellView
/*
Creates an array of menuitems to be used as a menu
Automatically sets up actions, so you need to take care of the responder chain
*/
+ (NSArray *)contextMenuItemsWithItems:(MPContextMenuItemsFlags)flags;
@end

View File

@@ -0,0 +1,81 @@
//
// MPContextMenuHelper.m
// MacPass
//
// Created by Michael Starke on 09.06.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import "MPContextMenuHelper.h"
#import "MPActionHelper.h"
@implementation MPContextMenuHelper
+ (NSArray *)contextMenuItemsWithItems:(MPContextMenuItemsFlags)flags {
BOOL insertCreate = (0 != (flags & MPContextMenuCreate));
BOOL insertDelete = (0 != (flags & MPContextMenuDelete));
BOOL insertCopy = (0 != (flags & MPContextMenuCopy));
NSMutableArray *items = [NSMutableArray arrayWithCapacity:7];
if(insertCreate) {
NSMenuItem *newGroup = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"ADD_GROUP", @"")
action:[MPActionHelper actionOfType:MPActionAddGroup]
keyEquivalent:@"G"];
NSMenuItem *newEntry = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"ADD_ENTRY", @"")
action:[MPActionHelper actionOfType:MPActionAddEntry]
keyEquivalent:@"E"];
[items addObjectsFromArray:@[ newGroup, newEntry ]];
[newEntry release];
[newGroup release];
}
if(insertDelete) {
if([items count] > 0) {
[items addObject:[NSMenuItem separatorItem]];
}
NSMenuItem *delete = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"DELETE", @"")
action:[MPActionHelper actionOfType:MPActionDelete]
keyEquivalent:@""];
[items addObject:delete];
[delete release];
}
if(insertCopy) {
if([items count] > 0) {
[items addObject:[NSMenuItem separatorItem]];
}
NSMenuItem *copyUsername = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"COPY_USERNAME", @"")
action:[MPActionHelper actionOfType:MPActionCopyUsername]
keyEquivalent:@"C"];
NSMenuItem *copyPassword = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"COPY_PASSWORD", @"")
action:[MPActionHelper actionOfType:MPActionCopyPassword]
keyEquivalent:@"c"];
[copyPassword setKeyEquivalentModifierMask:[copyPassword keyEquivalentModifierMask] | NSAlternateKeyMask];
NSMenu *urlMenu = [[NSMenu alloc] init];
NSMenuItem *urlItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"URL", @"")
action:0
keyEquivalent:@""];
[urlItem setSubmenu:urlMenu];
[urlMenu release];
NSMenuItem *copyURL = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"COPY_URL", @"")
action:[MPActionHelper actionOfType:MPActionCopyURL]
keyEquivalent:@"u"];
NSMenuItem *openURL = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"OPEN_URL", @"")
action:[MPActionHelper actionOfType:MPActionOpenURL]
keyEquivalent:@"U"];
[urlMenu addItem:copyURL];
[urlMenu addItem:openURL];
[openURL release];
[copyURL release];
[items addObjectsFromArray:@[ copyUsername, copyPassword, urlItem]];
[urlItem release];
[copyPassword release];
[copyUsername release];
}
return items;
}
@end

View File

@@ -33,12 +33,13 @@ APPKIT_EXTERN NSString *const MPDocumentGroupKey;
- (id)initWithVersion:(MPDatabaseVersion)version; - (id)initWithVersion:(MPDatabaseVersion)version;
- (BOOL)decryptWithPassword:(NSString *)password keyFileURL:(NSURL *)keyFileURL; - (BOOL)decryptWithPassword:(NSString *)password keyFileURL:(NSURL *)keyFileURL;
/* Undoable Intiialization of elements */
- (KdbGroup *)createGroup:(KdbGroup *)parent; - (KdbGroup *)createGroup:(KdbGroup *)parent;
- (KdbEntry *)createEntry:(KdbGroup *)parent; - (KdbEntry *)createEntry:(KdbGroup *)parent;
- (void)deleteEntry:(KdbEntry *)entry; /*
- (void)deleteGroup:(KdbGroup *)group; Undoable movement of object
*/
- (void)moveGroup:(KdbGroup *)group toGroup:(KdbGroup *)target index:(NSInteger)index; - (void)moveGroup:(KdbGroup *)group toGroup:(KdbGroup *)target index:(NSInteger)index;
- (BOOL)group:(KdbGroup *)group isMoveableToGroup:(KdbGroup *)target; - (BOOL)group:(KdbGroup *)group isMoveableToGroup:(KdbGroup *)target;

View File

@@ -155,22 +155,6 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey";
return newGroup; return newGroup;
} }
- (void)deleteEntry:(KdbEntry *)entry {
if(entry.parent) {
NSDictionary *userInfo = @{ MPDocumentEntryKey : entry };
[[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentWillDeleteEntryNotification object:self userInfo:userInfo];
[entry.parent removeEntryUndoable:entry];
}
}
- (void)deleteGroup:(KdbGroup *)group {
if(group.parent) {
NSDictionary *userInfo = @{ MPDocumentEntryKey : group };
[[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentWillDelteGroupNotification object:self userInfo:userInfo];
[group.parent removeGroupUndoable:group];
}
}
- (void)moveGroup:(KdbGroup *)group toGroup:(KdbGroup *)target index:(NSInteger)index { - (void)moveGroup:(KdbGroup *)group toGroup:(KdbGroup *)target index:(NSInteger)index {
NSInteger oldIndex = [group.parent.groups indexOfObject:group]; NSInteger oldIndex = [group.parent.groups indexOfObject:group];
if(group.parent == target && oldIndex == index) { if(group.parent == target && oldIndex == index) {
@@ -178,13 +162,11 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey";
} }
[[[self undoManager] prepareWithInvocationTarget:self] moveGroup:group toGroup:group.parent index:oldIndex]; [[[self undoManager] prepareWithInvocationTarget:self] moveGroup:group toGroup:group.parent index:oldIndex];
[[self undoManager] setActionName:@"MOVE_GROUP"]; [[self undoManager] setActionName:@"MOVE_GROUP"];
[group retain]; // Might get freed in the process
[group.parent removeObjectFromGroupsAtIndex:oldIndex]; [group.parent removeObjectFromGroupsAtIndex:oldIndex];
if(index < 0 || index > [target.groups count] ) { if(index < 0 || index > [target.groups count] ) {
index = [target.groups count]; index = [target.groups count];
} }
[target insertObject:group inGroupsAtIndex:index]; [target insertObject:group inGroupsAtIndex:index];
[group release];
} }
- (BOOL)group:(KdbGroup *)group isMoveableToGroup:(KdbGroup *)target { - (BOOL)group:(KdbGroup *)group isMoveableToGroup:(KdbGroup *)target {

View File

@@ -18,6 +18,7 @@
#import "KdbGroup+MPAdditions.h" #import "KdbGroup+MPAdditions.h"
#import "KdbGroup+Undo.h" #import "KdbGroup+Undo.h"
#import "KdbEntry+Undo.h" #import "KdbEntry+Undo.h"
#import "MPContextMenuHelper.h"
NSString *const MPDidChangeSelectedEntryNotification = @"com.macpass.MPDidChangeSelectedEntryNotification"; NSString *const MPDidChangeSelectedEntryNotification = @"com.macpass.MPDidChangeSelectedEntryNotification";
@@ -71,27 +72,6 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername";
@property (assign, nonatomic) MPFilterModeType filterMode; @property (assign, nonatomic) MPFilterModeType filterMode;
@property (retain, nonatomic) NSDictionary *filterButtonToMode; @property (retain, nonatomic) NSDictionary *filterButtonToMode;
- (IBAction)_toggleFilterSpace:(id)sender;
- (BOOL)_shouldFilterURLs;
- (BOOL)_shouldFilterTitles;
- (BOOL)_shouldFilterUsernames;
- (BOOL)hasFilter;
- (BOOL)_showsFilterBar;
- (void)updateFilter;
- (void)updateFilterText:(id)sender;
- (void)setupFilterBar;
- (void)_setupEntryMenu;
/* Notification handling */
- (void)_didChangeGroupSelectionInOutlineView:(NSNotification *)notification;
- (void)_showFilterBarAnimated:(BOOL)animate;
- (void)_hideFilterBarAnimated:(BOOL)animate;
- (void)_columnDoubleClick:(id)sender;
- (void)_copyToPasteboard:(NSString *)data overlayInfo:(MPOVerlayInfoType)overlayInfoType;
- (KdbEntry *)_clickedOrSelectedEntry;
@end @end
@implementation MPEntryViewController @implementation MPEntryViewController
@@ -422,7 +402,7 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername";
- (void)_setupEntryMenu { - (void)_setupEntryMenu {
NSMenu *menu = [[NSMenu alloc] init]; NSMenu *menu = [[NSMenu alloc] init];
NSArray *items = [(MPAppDelegate *)[NSApp delegate] contextMenuItemsWithItems:MPContextMenuFull]; NSArray *items = [MPContextMenuHelper contextMenuItemsWithItems:MPContextMenuFull];
for(NSMenuItem *item in items) { for(NSMenuItem *item in items) {
[menu addItem:item]; [menu addItem:item];
} }

View File

@@ -15,7 +15,7 @@
#import "MPIconSelectViewController.h" #import "MPIconSelectViewController.h"
#import "KdbLib.h" #import "KdbLib.h"
#import "KdbGroup+Undo.h" #import "KdbGroup+Undo.h"
#import "KdbKeyPaths.h" #import "KdbEntry+Undo.h"
@interface MPInspectorViewController () { @interface MPInspectorViewController () {
BOOL _visible; BOOL _visible;
@@ -28,15 +28,6 @@
@property (retain) NSLayoutConstraint *showConstraint; @property (retain) NSLayoutConstraint *showConstraint;
@property (retain) NSLayoutConstraint *hideConstraint; @property (retain) NSLayoutConstraint *hideConstraint;
- (void)_didChangeSelectedEntry:(NSNotification *)notification;
- (void)_didChangeSelectedGroup:(NSNotification *)notification;
- (void)_updateContent;
- (void)_showGroup;
- (void)_showEntry;
- (void)_clearContent;
- (void)_setInputEnabled:(BOOL)enabled;
- (void)_showImagePopup:(id)sender;
@end @end
@implementation MPInspectorViewController @implementation MPInspectorViewController
@@ -96,13 +87,13 @@
} }
- (void)_showEntry { - (void)_showEntry {
[self.itemNameTextfield bind:NSValueBinding toObject:self.selectedEntry withKeyPath:MPEntryKeyForTitle options:nil]; [self.itemNameTextfield bind:NSValueBinding toObject:self.selectedEntry withKeyPath:MPEntryTitleUndoableKey options:nil];
[self.itemImageView setImage:[MPIconHelper icon:(MPIconType)self.selectedEntry.image ]]; [self.itemImageView setImage:[MPIconHelper icon:(MPIconType)self.selectedEntry.image ]];
[self.passwordTextField bind:NSValueBinding toObject:self.selectedEntry withKeyPath:MPEntryKeyForPassword options:nil]; [self.passwordTextField bind:NSValueBinding toObject:self.selectedEntry withKeyPath:MPEntryPasswordUndoableKey options:nil];
[self.usernameTextField bind:NSValueBinding toObject:self.selectedEntry withKeyPath:MPEntryKeyForUsername options:nil]; [self.usernameTextField bind:NSValueBinding toObject:self.selectedEntry withKeyPath:MPEntryUsernameUndoableKey options:nil];
[self.titleOrNameLabel setStringValue:NSLocalizedString(@"TITLE",@"")]; [self.titleOrNameLabel setStringValue:NSLocalizedString(@"TITLE",@"")];
[self.titleTextField bind:NSValueBinding toObject:self.selectedEntry withKeyPath:MPEntryKeyForTitle options:nil]; [self.titleTextField bind:NSValueBinding toObject:self.selectedEntry withKeyPath:MPEntryTitleUndoableKey options:nil];
[self.URLTextField bind:NSValueBinding toObject:self.selectedEntry withKeyPath:MPEntryKeyForUrl options:nil]; [self.URLTextField bind:NSValueBinding toObject:self.selectedEntry withKeyPath:MPEntryUrlUndoableKey options:nil];
[self _setInputEnabled:YES]; [self _setInputEnabled:YES];
} }

View File

@@ -54,12 +54,12 @@ NSString *const MPPasteBoardType = @"com.hicknhack.macpass.pasteboard";
accepted &= index != NSOutlineViewDropOnItemIndex; accepted &= index != NSOutlineViewDropOnItemIndex;
accepted &= index != [_draggedItem.parent.groups indexOfObject:_draggedItem]; accepted &= index != [_draggedItem.parent.groups indexOfObject:_draggedItem];
} }
info.animatesToDestination = YES;
MPDocument *document = [[[outlineView window] windowController] document]; MPDocument *document = [[[outlineView window] windowController] document];
accepted = [document group:_draggedItem isMoveableToGroup:target]; accepted = [document group:_draggedItem isMoveableToGroup:target];
if( accepted ) { if( accepted ) {
[document moveGroup:_draggedItem toGroup:target index:index]; [document moveGroup:_draggedItem toGroup:target index:index];
} }
info.animatesToDestination = !accepted;
return accepted; return accepted;
} }
@end @end

View File

@@ -12,6 +12,8 @@
#import "MPDocument.h" #import "MPDocument.h"
#import "MPAppDelegate.h" #import "MPAppDelegate.h"
#import "KdbLib.h" #import "KdbLib.h"
#import "KdbGroup+Undo.h"
#import "MPContextMenuHelper.h"
@interface MPOutlineViewController () { @interface MPOutlineViewController () {
@@ -25,11 +27,6 @@
@property (retain) MPOutlineViewDelegate *outlineDelegate; @property (retain) MPOutlineViewDelegate *outlineDelegate;
@property (retain) NSMenu *menu; @property (retain) NSMenu *menu;
- (void)_didUpdateData:(NSNotification *)notification;
- (NSMenu *)_contextMenu;
- (KdbGroup *)_clickedOrSelectedGroup;
@end @end
@implementation MPOutlineViewController @implementation MPOutlineViewController
@@ -45,17 +42,6 @@
_bindingEstablished = NO; _bindingEstablished = NO;
_outlineDelegate = [[MPOutlineViewDelegate alloc] init]; _outlineDelegate = [[MPOutlineViewDelegate alloc] init];
_datasource = [[MPOutlineDataSource alloc] init]; _datasource = [[MPOutlineDataSource alloc] init];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(_didUpdateData:)
name:MPDocumentDidAddGroupNotification
object:[[self windowController] document]];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(_didUpdateData:)
name:MPDocumentWillDelteGroupNotification
object:[[self windowController] document]];
} }
@@ -99,7 +85,7 @@
- (NSMenu *)_contextMenu { - (NSMenu *)_contextMenu {
NSMenu *menu = [[NSMenu alloc] init]; NSMenu *menu = [[NSMenu alloc] init];
NSArray *items = [(MPAppDelegate *)[NSApp delegate] contextMenuItemsWithItems:MPContextMenuMinimal]; NSArray *items = [MPContextMenuHelper contextMenuItemsWithItems:MPContextMenuMinimal];
for(NSMenuItem *item in items) { for(NSMenuItem *item in items) {
[menu addItem:item]; [menu addItem:item];
} }
@@ -132,15 +118,13 @@
if(group) { if(group) {
MPDocument *document = [[self windowController] document]; MPDocument *document = [[self windowController] document];
[document createEntry:group]; [document createEntry:group];
// Notify the the entry view about changes
} }
} }
- (void)deleteEntry:(id)sender { - (void)deleteEntry:(id)sender {
KdbGroup *group = [self _clickedOrSelectedGroup]; KdbGroup *group = [self _clickedOrSelectedGroup];
if(group) { if(group && group.parent) {
MPDocument *document = [[self windowController] document]; [group.parent removeGroupUndoable:group];
[document deleteGroup:group];
} }
} }
@@ -152,9 +136,4 @@
return [[self.outlineView itemAtRow:row] representedObject]; return [[self.outlineView itemAtRow:row] representedObject];
} }
- (void)_didUpdateData:(NSNotification *)notification {
[self.outlineView reloadData];
}
@end @end

View File

@@ -40,7 +40,7 @@
- (void)drawRect:(NSRect)dirtyRect - (void)drawRect:(NSRect)dirtyRect
{ {
[super drawRect:dirtyRect];
if(self.showOverlay && [self isEnabled]) { if(self.showOverlay && [self isEnabled]) {
[[NSGraphicsContext currentContext] saveGraphicsState]; [[NSGraphicsContext currentContext] saveGraphicsState];
@@ -70,6 +70,7 @@
[shadow release]; [shadow release];
[[NSGraphicsContext currentContext] restoreGraphicsState]; [[NSGraphicsContext currentContext] restoreGraphicsState];
} }
[super drawRect:dirtyRect];
/* Draw Overlay */ /* Draw Overlay */
} }

View File

@@ -28,7 +28,7 @@ NSString *const kMPSettingsKeyOpenEmptyDatabaseOnLaunch = @"OpenEmptyDatabaseOnL
return @{ return @{
kMPSettingsKeyPasteboardClearTimeout: @10, kMPSettingsKeyPasteboardClearTimeout: @10,
kMPSettingsKeyClearPasteboardOnQuit: @YES, kMPSettingsKeyClearPasteboardOnQuit: @YES,
kMPSettingsKeyOpenEmptyDatabaseOnLaunch: @NO, kMPSettingsKeyOpenEmptyDatabaseOnLaunch: @YES,
}; };
} }

View File

@@ -12,6 +12,7 @@
#import "MPToolbarButton.h" #import "MPToolbarButton.h"
#import "MPToolbarItem.h" #import "MPToolbarItem.h"
#import "MPActionHelper.h" #import "MPActionHelper.h"
#import "MPContextMenuHelper.h"
NSString *const MPToolbarItemLock = @"TOOLBAR_LOCK"; NSString *const MPToolbarItemLock = @"TOOLBAR_LOCK";
NSString *const MPToolbarItemAddGroup = @"TOOLBAR_ADD_GROUP"; NSString *const MPToolbarItemAddGroup = @"TOOLBAR_ADD_GROUP";
@@ -75,7 +76,7 @@ NSString *const MPToolbarItemInspector = @"TOOLBAR_INSPECTOR";
[actionImageItem setImage:self.toolbarImages[MPToolbarItemAction]]; [actionImageItem setImage:self.toolbarImages[MPToolbarItemAction]];
[menu addItem:actionImageItem]; [menu addItem:actionImageItem];
[actionImageItem release]; [actionImageItem release];
NSArray *menuItems = [(MPAppDelegate *)[NSApp delegate] contextMenuItemsWithItems:MPContextMenuFull]; NSArray *menuItems = [MPContextMenuHelper contextMenuItemsWithItems:MPContextMenuFull];
for(NSMenuItem *item in menuItems) { for(NSMenuItem *item in menuItems) {
[menu addItem:item]; [menu addItem:item];
} }

View File

@@ -24,8 +24,11 @@
return [[[self view] window] windowController]; return [[[self view] window] windowController];
} }
- (NSResponder *)reconmendedFirstResponder { #pragma mark Responder Chain
return nil;
- (BOOL)becomeFirstResponder {
NSLog(@"%@: about to become firt responder.", [self class]);
return YES;
} }
- (void)updateResponderChain { - (void)updateResponderChain {

View File

@@ -48,7 +48,7 @@
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>AEE</string> <string>B0A</string>
<key>LSMinimumSystemVersion</key> <key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string> <string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSHumanReadableCopyright</key> <key>NSHumanReadableCopyright</key>