Refactoring for document based application

This commit is contained in:
michael starke
2013-05-09 14:02:30 +02:00
parent 35c92fbf0b
commit c7596d49fe
16 changed files with 100 additions and 223 deletions

View File

@@ -81,7 +81,7 @@
4C77E37D15B84A240093A587 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C77E37B15B84A240093A587 /* MainMenu.xib */; };
4C7E832A172DE2F2002493D8 /* MPPasswordEditViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C7E8329172DE2F2002493D8 /* MPPasswordEditViewController.m */; };
4C811C8316ECD06E00C4BAC6 /* MPKeyfilePathControlDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C811C8216ECD06E00C4BAC6 /* MPKeyfilePathControlDelegate.m */; };
4C83814215BF4677001AE468 /* MPMainWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C83814115BF4677001AE468 /* MPMainWindowController.m */; };
4C83814215BF4677001AE468 /* MPDocumentWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C83814115BF4677001AE468 /* MPDocumentWindowController.m */; };
4C888C9016EB6C91003D34A1 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 4C888C8E16EB6C91003D34A1 /* Localizable.strings */; };
4C888C9316EB6F5E003D34A1 /* MPToolbarItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C888C9216EB6F5E003D34A1 /* MPToolbarItem.m */; };
4C888C9716EB754B003D34A1 /* MPActionHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C888C9616EB754B003D34A1 /* MPActionHelper.m */; };
@@ -90,7 +90,7 @@
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 */; };
4CA0B2FC15BCAF8600654E32 /* MPSettingsController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CA0B2FB15BCAF8600654E32 /* MPSettingsController.m */; };
4CA0B2FC15BCAF8600654E32 /* MPSettingsWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CA0B2FB15BCAF8600654E32 /* MPSettingsWindowController.m */; };
4CAC6F7816D2B54800D79D5E /* MPMainWindowSplitViewDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CAC6F7716D2B54800D79D5E /* MPMainWindowSplitViewDelegate.m */; };
4CACB72C16F7C9B600D47C9E /* KdbEntry+Copying.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CACB72B16F7C9B600D47C9E /* KdbEntry+Copying.m */; };
4CACB72F16F7CA5100D47C9E /* Kdb4Entry+Copying.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CACB72E16F7CA5100D47C9E /* Kdb4Entry+Copying.m */; };
@@ -112,7 +112,7 @@
4CD78ABE16D155FF00768A1D /* 09_IdentityTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4CD78AB916D155FF00768A1D /* 09_IdentityTemplate.pdf */; };
4CD78ABF16D155FF00768A1D /* 10_ContactTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4CD78ABA16D155FF00768A1D /* 10_ContactTemplate.pdf */; };
4CD78AC016D155FF00768A1D /* 11_CameraTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4CD78ABB16D155FF00768A1D /* 11_CameraTemplate.pdf */; };
4CD884B715BD47080042BBF8 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4CD884B615BD47080042BBF8 /* MainWindow.xib */; };
4CD884B715BD47080042BBF8 /* DocumentWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4CD884B615BD47080042BBF8 /* DocumentWindow.xib */; };
4CDF01A316D1B76700D0AC08 /* MPEntryViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CDF01A216D1B76700D0AC08 /* MPEntryViewController.m */; };
4CE39ABF16ECE34A000FE29D /* MPIconSelectViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CE39ABE16ECE34A000FE29D /* MPIconSelectViewController.m */; };
4CE39AC116ECE359000FE29D /* IconSelection.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4CE39AC016ECE359000FE29D /* IconSelection.xib */; };
@@ -262,8 +262,8 @@
4C7E8329172DE2F2002493D8 /* MPPasswordEditViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPPasswordEditViewController.m; sourceTree = "<group>"; };
4C811C8116ECD06E00C4BAC6 /* MPKeyfilePathControlDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPKeyfilePathControlDelegate.h; sourceTree = "<group>"; };
4C811C8216ECD06E00C4BAC6 /* MPKeyfilePathControlDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPKeyfilePathControlDelegate.m; sourceTree = "<group>"; };
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>"; };
4C83814015BF4677001AE468 /* MPDocumentWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPDocumentWindowController.h; sourceTree = "<group>"; };
4C83814115BF4677001AE468 /* MPDocumentWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPDocumentWindowController.m; sourceTree = "<group>"; };
4C888C8F16EB6C91003D34A1 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
4C888C9116EB6F5E003D34A1 /* MPToolbarItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPToolbarItem.h; sourceTree = "<group>"; };
4C888C9216EB6F5E003D34A1 /* MPToolbarItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPToolbarItem.m; sourceTree = "<group>"; };
@@ -276,8 +276,8 @@
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>"; };
4CA0B2F815BCAF6700654E32 /* MPGeneralSettingsController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPGeneralSettingsController.m; sourceTree = "<group>"; };
4CA0B2FA15BCAF8600654E32 /* MPSettingsController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPSettingsController.h; sourceTree = "<group>"; };
4CA0B2FB15BCAF8600654E32 /* MPSettingsController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPSettingsController.m; sourceTree = "<group>"; };
4CA0B2FA15BCAF8600654E32 /* MPSettingsWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPSettingsWindowController.h; sourceTree = "<group>"; };
4CA0B2FB15BCAF8600654E32 /* MPSettingsWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPSettingsWindowController.m; sourceTree = "<group>"; };
4CA0B30D15BCB6FD00654E32 /* MPSettingsTab.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MPSettingsTab.h; sourceTree = "<group>"; };
4CAC6F7616D2B54800D79D5E /* MPMainWindowSplitViewDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPMainWindowSplitViewDelegate.h; sourceTree = "<group>"; };
4CAC6F7716D2B54800D79D5E /* MPMainWindowSplitViewDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPMainWindowSplitViewDelegate.m; sourceTree = "<group>"; };
@@ -314,7 +314,7 @@
4CD78AB916D155FF00768A1D /* 09_IdentityTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = 09_IdentityTemplate.pdf; sourceTree = "<group>"; };
4CD78ABA16D155FF00768A1D /* 10_ContactTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = 10_ContactTemplate.pdf; sourceTree = "<group>"; };
4CD78ABB16D155FF00768A1D /* 11_CameraTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = 11_CameraTemplate.pdf; sourceTree = "<group>"; };
4CD884B615BD47080042BBF8 /* MainWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MainWindow.xib; sourceTree = "<group>"; };
4CD884B615BD47080042BBF8 /* DocumentWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = DocumentWindow.xib; sourceTree = "<group>"; };
4CDF01A116D1B76700D0AC08 /* MPEntryViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPEntryViewController.h; sourceTree = "<group>"; };
4CDF01A216D1B76700D0AC08 /* MPEntryViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPEntryViewController.m; sourceTree = "<group>"; };
4CE39ABD16ECE34A000FE29D /* MPIconSelectViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPIconSelectViewController.h; sourceTree = "<group>"; };
@@ -746,10 +746,10 @@
4CE8247016E2E96500573141 /* Window Controller */ = {
isa = PBXGroup;
children = (
4CA0B2FA15BCAF8600654E32 /* MPSettingsController.h */,
4CA0B2FB15BCAF8600654E32 /* MPSettingsController.m */,
4C83814015BF4677001AE468 /* MPMainWindowController.h */,
4C83814115BF4677001AE468 /* MPMainWindowController.m */,
4CA0B2FA15BCAF8600654E32 /* MPSettingsWindowController.h */,
4CA0B2FB15BCAF8600654E32 /* MPSettingsWindowController.m */,
4C83814015BF4677001AE468 /* MPDocumentWindowController.h */,
4C83814115BF4677001AE468 /* MPDocumentWindowController.m */,
4CE8246D16E2E93400573141 /* MPOverlayWindowController.h */,
4CE8246E16E2E93400573141 /* MPOverlayWindowController.m */,
);
@@ -770,7 +770,7 @@
4CE8247216E2E99F00573141 /* Windows */ = {
isa = PBXGroup;
children = (
4CD884B615BD47080042BBF8 /* MainWindow.xib */,
4CD884B615BD47080042BBF8 /* DocumentWindow.xib */,
4C431BCE16E2BAB000700A81 /* OverlayWindow.xib */,
4C1DDCDC1711ECEB00C98DA3 /* PasswordCreatorWindow.xib */,
);
@@ -836,7 +836,7 @@
4C77E37D15B84A240093A587 /* MainMenu.xib in Resources */,
4CA0B2ED15BCADAC00654E32 /* SettingsWindow.xib in Resources */,
4CA0B2F015BCADC800654E32 /* GeneralSettings.xib in Resources */,
4CD884B715BD47080042BBF8 /* MainWindow.xib in Resources */,
4CD884B715BD47080042BBF8 /* DocumentWindow.xib in Resources */,
4C6B0E8C16C9B99B00A9ED23 /* PasswordInputView.xib in Resources */,
4C25D58516CF0F8800F6806C /* WelcomeView.xib in Resources */,
4C25D58716CF0FAA00F6806C /* EntryView.xib in Resources */,
@@ -899,8 +899,8 @@
4CBA981815BA0DB600721965 /* MPDatabaseDocument.m in Sources */,
4CC6259115BA1C99002F5B11 /* MPOutlineViewDelegate.m in Sources */,
4CA0B2F915BCAF6700654E32 /* MPGeneralSettingsController.m in Sources */,
4CA0B2FC15BCAF8600654E32 /* MPSettingsController.m in Sources */,
4C83814215BF4677001AE468 /* MPMainWindowController.m in Sources */,
4CA0B2FC15BCAF8600654E32 /* MPSettingsWindowController.m in Sources */,
4C83814215BF4677001AE468 /* MPDocumentWindowController.m in Sources */,
4C669B7F16760ED100DD0774 /* AesInputStream.m in Sources */,
4C669B8016760ED100DD0774 /* AesOutputStream.m in Sources */,
4C669B8116760ED100DD0774 /* Arc4RandomStream.m in Sources */,

View File

@@ -2,10 +2,10 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
<data>
<int key="IBDocument.SystemTarget">1080</int>
<string key="IBDocument.SystemVersion">12C3103</string>
<string key="IBDocument.SystemVersion">12D78</string>
<string key="IBDocument.InterfaceBuilderVersion">3084</string>
<string key="IBDocument.AppKitVersion">1187.34</string>
<string key="IBDocument.HIToolboxVersion">625.00</string>
<string key="IBDocument.AppKitVersion">1187.37</string>
<string key="IBDocument.HIToolboxVersion">626.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="NS.object.0">3084</string>
@@ -26,7 +26,7 @@
</object>
<array class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
<object class="NSCustomObject" id="1001">
<string key="NSClassName">MPMainWindowController</string>
<string key="NSClassName">MPDocumentWindowController</string>
</object>
<object class="NSCustomObject" id="1003">
<string key="NSClassName">FirstResponder</string>
@@ -225,7 +225,7 @@
<boolean value="YES" key="1.IBNSWindowAutoPositionCentersVertical"/>
<string key="1.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="1.IBWindowTemplateEditedContentRect">{{357, 418}, {480, 270}}</string>
<integer value="1" key="1.NSWindowTemplate.visibleAtLaunch"/>
<boolean value="NO" key="1.NSWindowTemplate.visibleAtLaunch"/>
<string key="2.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="603.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="605.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -241,8 +241,19 @@
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
<object class="IBPartialClassDescription">
<string key="className">MPMainWindowController</string>
<string key="className">MPDocumentWindowController</string>
<string key="superclassName">NSWindowController</string>
<object class="NSMutableDictionary" key="actions">
<string key="NS.key.0">editPassword:</string>
<string key="NS.object.0">id</string>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
<string key="NS.key.0">editPassword:</string>
<object class="IBActionInfo" key="NS.object.0">
<string key="name">editPassword:</string>
<string key="candidateClassName">id</string>
</object>
</object>
<dictionary class="NSMutableDictionary" key="outlets">
<string key="contentView">NSView</string>
<string key="inspectorView">NSView</string>
@@ -279,7 +290,7 @@
</dictionary>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/MPMainWindowController.h</string>
<string key="minorKey">./Classes/MPDocumentWindowController.h</string>
</object>
</object>
</array>

View File

@@ -22,7 +22,6 @@ typedef enum {
@property (retain) IBOutlet NSWindow *passwordCreatorWindow;
- (IBAction)showMainWindow:(id)sender;
- (IBAction)showPasswordCreator:(id)sender;
- (NSString *)applicationName;
@@ -33,7 +32,4 @@ typedef enum {
*/
- (NSArray *)contextMenuItemsWithItems:(MPContextMenuItemsFlags)flags;
- (void)openDocument:(id)sender;
- (void)newDocument:(id)sender;
@end

View File

@@ -8,8 +8,8 @@
#import "MPAppDelegate.h"
#import "MPMainWindowController.h"
#import "MPSettingsController.h"
#import "MPDocumentWindowController.h"
#import "MPSettingsWindowController.h"
#import "MPDatabaseController.h"
#import "MPPasswordCreatorViewController.h"
#import "MPActionHelper.h"
@@ -18,8 +18,7 @@
@interface MPAppDelegate ()
@property (retain, nonatomic) MPSettingsController *settingsController;
@property (retain, nonatomic) MPMainWindowController *mainWindowController;
@property (retain, nonatomic) MPSettingsWindowController *settingsController;
@property (retain, nonatomic) MPPasswordCreatorViewController *passwordCreatorController;
- (IBAction)showPreferences:(id)sender;
@@ -33,14 +32,11 @@
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
self.mainWindowController = [[[MPMainWindowController alloc] init] autorelease];
[self.mainWindowController showWindow:[self.mainWindowController window]];
}
- (void)dealloc {
[_settingsController release];
[_mainWindowController release];
[_passwordCreatorController release];
[super dealloc];
}
@@ -50,24 +46,9 @@
}
#pragma mark Menu Actions
- (void)showMainWindow:(id)sender {
[self.mainWindowController showMainWindow:sender];
}
- (void)newDocument:(id)sender {
[self.mainWindowController showMainWindow:sender];
[self.mainWindowController newDocument:sender];
}
- (void)openDocument:(id)sender {
[self.mainWindowController showMainWindow:sender];
[self.mainWindowController openDocument:sender];
}
- (void)showPreferences:(id)sender {
if(self.settingsController == nil) {
self.settingsController = [[[MPSettingsController alloc] init] autorelease];
self.settingsController = [[[MPSettingsWindowController alloc] init] autorelease];
}
[self.settingsController showSettings];
}

View File

@@ -7,6 +7,7 @@
//
#import "MPDocument.h"
#import "MPDocumentWindowController.h"
#import "KdbLib.h"
#import "Kdb3Node.h"
#import "Kdb4Node.h"
@@ -51,14 +52,9 @@
}
- (void) makeWindowControllers {
}
- (NSString *)windowNibName
{
// Override returning the nib file name of the document
// If you need to use a subclass of NSWindowController or if your document supports multiple NSWindowControllers, you should remove this method and override -makeWindowControllers instead.
return @"MainWindow";
//return @"MPDocument";
MPDocumentWindowController *windowController = [[MPDocumentWindowController alloc] init];
[self addWindowController:windowController];
}
- (void)windowControllerDidLoadNib:(NSWindowController *)aController
@@ -85,6 +81,29 @@
- (BOOL)readFromURL:(NSURL *)url ofType:(NSString *)typeName error:(NSError **)outError {
self.file = url;
return YES;
// tell The window controller to display decrypt view
// - (void)openDocument:(id)sender {
//
// if(!self.passwordInputController) {
// self.passwordInputController = [[[MPPasswordInputController alloc] init] autorelease];
// }
//
// NSOpenPanel *openPanel = [NSOpenPanel openPanel];
// [openPanel setCanChooseDirectories:NO];
// [openPanel setCanChooseFiles:YES];
// [openPanel setCanCreateDirectories:NO];
// [openPanel setAllowsMultipleSelection:NO];
// [openPanel setAllowedFileTypes:@[ @"kdbx", @"kdb"]];
// [openPanel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result){
// if(result == NSFileHandlingPanelOKButton) {
// NSURL *file = [[openPanel URLs] lastObject];
// self.passwordInputController.fileURL = file;
// [self _setContentViewController:self.passwordInputController];
// }
// }];
// }
//
}
- (BOOL)decryptWithPassword:(NSString *)password keyFileURL:(NSURL *)keyFileURL {

View File

@@ -17,7 +17,7 @@
@class MPCreationViewController;
@interface MPMainWindowController : NSWindowController
@interface MPDocumentWindowController : NSWindowController
@property (readonly, retain) MPPasswordInputController *passwordInputController;
@property (readonly, retain) MPPasswordEditViewController *passwordEditController;
@@ -27,11 +27,6 @@
@property (readonly, retain) MPCreationViewController *creationViewController;
/* Document handling */
- (void)newDocument:(id)sender;
- (void)openDocument:(id)sender;
- (void)showEntries;
- (void)showMainWindow:(id)sender;
- (void)performFindPanelAction:(id)sender;

View File

@@ -6,7 +6,7 @@
// Copyright (c) 2012 HicknHack Software GmbH. All rights reserved.
//
#import "MPMainWindowController.h"
#import "MPDocumentWindowController.h"
#import "MPDatabaseController.h"
#import "MPDatabaseDocument.h"
#import "MPPasswordInputController.h"
@@ -18,7 +18,7 @@
#import "MPInspectorTabViewController.h"
#import "MPAppDelegate.h"
@interface MPMainWindowController ()
@interface MPDocumentWindowController ()
@property (assign) IBOutlet NSView *outlineView;
@property (assign) IBOutlet NSSplitView *splitView;
@@ -47,7 +47,7 @@
@end
@implementation MPMainWindowController
@implementation MPDocumentWindowController
-(id)init {
self = [super initWithWindowNibName:@"MainWindow" owner:self];
@@ -226,26 +226,6 @@
//[self showWindow:self.window];
}
- (void)openDocument:(id)sender {
if(!self.passwordInputController) {
self.passwordInputController = [[[MPPasswordInputController alloc] init] autorelease];
}
NSOpenPanel *openPanel = [NSOpenPanel openPanel];
[openPanel setCanChooseDirectories:NO];
[openPanel setCanChooseFiles:YES];
[openPanel setCanCreateDirectories:NO];
[openPanel setAllowsMultipleSelection:NO];
[openPanel setAllowedFileTypes:@[ @"kdbx", @"kdb"]];
[openPanel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result){
if(result == NSFileHandlingPanelOKButton) {
NSURL *file = [[openPanel URLs] lastObject];
self.passwordInputController.fileURL = file;
[self _setContentViewController:self.passwordInputController];
}
}];
}
- (void)clearOutlineSelection:(id)sender {
[self.outlineViewController clearSelection];
}
@@ -257,32 +237,6 @@
[self _setContentViewController:self.passwordEditController];
}
- (void)newDocument:(id)sender {
// if (!self.creationViewController) {
// self.creationViewController = [[[MPCreationViewController alloc] init] autorelease];
// }
//
// NSSavePanel *savePanel = [NSSavePanel savePanel];
// [savePanel setAllowedFileTypes:@[@"kdbx", @"kdb"]];
// [savePanel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result) {
// if (result == NSFileHandlingPanelOKButton) {
// NSURL *file = [savePanel URL];
// NSLog(@"Will create file at: %@", file);
// self.creationViewController.fileURL = file;
// [self _setContentViewController:self.creationViewController];
// }
// }];
}
- (void)saveDocument:(id)sender
{
NSLog(@"Attempting to save document");
if ([[MPDatabaseController defaultController].database save])
NSLog(@"Save successful");
else
NSLog(@"Save failed");
}
#pragma mark Helper
- (NSSearchField *)locateToolbarSearchField {

View File

@@ -12,7 +12,7 @@
#import "MPDatabaseController.h"
#import "MPDatabaseDocument.h"
#import "MPIconHelper.h"
#import "MPMainWindowController.h"
#import "MPDocumentWindowController.h"
#import "MPPasteBoardController.h"
#import "MPOverlayWindowController.h"
#import "KdbGroup+MPAdditions.h"
@@ -325,7 +325,7 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername";
return; // nothign to to
}
[((MPMainWindowController *)[[self.view window] windowController]) clearOutlineSelection:nil];
[((MPDocumentWindowController *)[[self.view window] windowController]) clearOutlineSelection:nil];
self.isStatusBarVisible = YES;
self.tableToTop.constant = [self.filterBar frame].size.height;

View File

@@ -8,7 +8,7 @@
#import "MPPasswordEditViewController.h"
#import "MPKeyfilePathControlDelegate.h"
#import "MPMainWindowController.h"
#import "MPDocumentWindowController.h"
#import "MPDatabaseController.h"
#import "MPDatabaseDocument.h"
@@ -54,13 +54,13 @@
database.key = [self.keyfilePathControl URL];
database.password = [self.passwordTextField stringValue];
[database save];
MPMainWindowController *mainWindowController = (MPMainWindowController *)[[[self view] window] windowController];
MPDocumentWindowController *mainWindowController = (MPDocumentWindowController *)[[[self view] window] windowController];
[mainWindowController showEntries];
// save automatically?
}
- (IBAction)_cancel:(id)sender {
MPMainWindowController *mainWindowController = (MPMainWindowController *)[[[self view] window] windowController];
MPDocumentWindowController *mainWindowController = (MPDocumentWindowController *)[[[self view] window] windowController];
[mainWindowController showEntries];
}
@end

View File

@@ -10,7 +10,7 @@
@protocol MPSettingsTab;
@interface MPSettingsController : NSWindowController <NSToolbarDelegate>
@interface MPSettingsWindowController : NSWindowController <NSToolbarDelegate>
- (void)showSettings;
- (void)showSettingsTabWithIdentifier:(NSString *)identifier;

View File

@@ -6,10 +6,10 @@
// Copyright (c) 2012 HicknHack Software GmbH. All rights reserved.
//
#import "MPSettingsController.h"
#import "MPSettingsWindowController.h"
#import "MPGeneralSettingsController.h"
@interface MPSettingsController ()
@interface MPSettingsWindowController ()
@property (retain, nonatomic) NSToolbar *toolbar;
@property (retain, nonatomic) NSMutableDictionary *settingsController;
@@ -21,7 +21,7 @@
@end
@implementation MPSettingsController
@implementation MPSettingsWindowController
-(id)init {
self = [super initWithWindowNibName:@"SettingsWindow"];

View File

@@ -8,7 +8,7 @@
#import <Foundation/Foundation.h>
@class MPMainWindowController;
@class MPDocumentWindowController;
@interface MPToolbarDelegate : NSObject <NSToolbarDelegate>

View File

@@ -15,6 +15,8 @@
<string>KeePass2 Database </string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>NSDocumentClass</key>
<string>MPDocument</string>
</dict>
<dict>
<key>CFBundleTypeExtensions</key>
@@ -44,7 +46,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>63C</string>
<string>647</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSHumanReadableCopyright</key>

View File

@@ -24,7 +24,7 @@
</object>
<array class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
<object class="NSCustomObject" id="1001">
<string key="NSClassName">MPSettingsController</string>
<string key="NSClassName">MPSettingsWindowController</string>
</object>
<object class="NSCustomObject" id="1003">
<string key="NSClassName">FirstResponder</string>
@@ -42,12 +42,10 @@
<nil key="NSViewClass"/>
<nil key="NSUserInterfaceItemIdentifier"/>
<object class="NSView" key="NSWindowView" id="1006">
<reference key="NSNextResponder"/>
<nil key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<array class="NSMutableArray" key="NSSubviews"/>
<string key="NSFrameSize">{350, 200}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1680, 1028}}</string>
<string key="NSMaxSize">{10000000000000, 10000000000000}</string>
@@ -122,18 +120,7 @@
<nil key="sourceID"/>
<int key="maxID">89</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
<object class="IBPartialClassDescription">
<string key="className">MPSettingsController</string>
<string key="superclassName">NSWindowController</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/MPSettingsController.h</string>
</object>
</object>
</array>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes"/>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>

View File

@@ -2,10 +2,10 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
<data>
<int key="IBDocument.SystemTarget">1080</int>
<string key="IBDocument.SystemVersion">12C60</string>
<string key="IBDocument.SystemVersion">12D78</string>
<string key="IBDocument.InterfaceBuilderVersion">3084</string>
<string key="IBDocument.AppKitVersion">1187.34</string>
<string key="IBDocument.HIToolboxVersion">625.00</string>
<string key="IBDocument.AppKitVersion">1187.37</string>
<string key="IBDocument.HIToolboxVersion">626.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="NS.object.0">3084</string>
@@ -26,7 +26,7 @@
</object>
<array class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
<object class="NSCustomObject" id="1001">
<string key="NSClassName">MPMainWindowController</string>
<string key="NSClassName">MPDocumentWindowController</string>
</object>
<object class="NSCustomObject" id="1003">
<string key="NSClassName">FirstResponder</string>
@@ -35,7 +35,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="NSTextField" id="86698766">
@@ -43,8 +43,6 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{223, 214}, {152, 29}}</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="726130946">
@@ -81,8 +79,6 @@
</object>
</array>
<string key="NSFrameSize">{597, 456}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="86698766"/>
<string key="NSClassName">NSView</string>
</object>
@@ -227,43 +223,6 @@
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
<object class="IBPartialClassDescription">
<string key="className">MPMainWindowController</string>
<string key="superclassName">NSWindowController</string>
<dictionary class="NSMutableDictionary" key="outlets">
<string key="contentView">NSView</string>
<string key="outlineView">NSView</string>
<string key="splitView">NSSplitView</string>
<string key="welcomeText">NSTextField</string>
<string key="welcomeView">NSView</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
<object class="IBToOneOutletInfo" key="contentView">
<string key="name">contentView</string>
<string key="candidateClassName">NSView</string>
</object>
<object class="IBToOneOutletInfo" key="outlineView">
<string key="name">outlineView</string>
<string key="candidateClassName">NSView</string>
</object>
<object class="IBToOneOutletInfo" key="splitView">
<string key="name">splitView</string>
<string key="candidateClassName">NSSplitView</string>
</object>
<object class="IBToOneOutletInfo" key="welcomeText">
<string key="name">welcomeText</string>
<string key="candidateClassName">NSTextField</string>
</object>
<object class="IBToOneOutletInfo" key="welcomeView">
<string key="name">welcomeView</string>
<string key="candidateClassName">NSView</string>
</object>
</dictionary>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/MPMainWindowController.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSLayoutConstraint</string>
<string key="superclassName">NSObject</string>

View File

@@ -519,15 +519,6 @@
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
</object>
<object class="NSMenuItem" id="174162306">
<reference key="NSMenu" ref="835318025"/>
<string key="NSTitle">Show Main Window</string>
<string key="NSKeyEquiv">0</string>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
</object>
<object class="NSMenuItem" id="523956698">
<reference key="NSMenu" ref="835318025"/>
<string key="NSTitle">Show Password Creator</string>
@@ -845,14 +836,6 @@
</object>
<int key="connectionID">1175</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">showMainWindow:</string>
<reference key="source" ref="976324537"/>
<reference key="destination" ref="174162306"/>
</object>
<int key="connectionID">1178</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">showPasswordCreator:</string>
@@ -1190,7 +1173,6 @@
<reference ref="575023229"/>
<reference ref="1011231497"/>
<reference ref="964160035"/>
<reference ref="174162306"/>
<reference ref="523956698"/>
</array>
<reference key="parent" ref="713487014"/>
@@ -1280,11 +1262,6 @@
<reference key="object" ref="964160035"/>
<reference key="parent" ref="835318025"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">1177</int>
<reference key="object" ref="174162306"/>
<reference key="parent" ref="835318025"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">1179</int>
<reference key="object" ref="43915532"/>
@@ -1313,7 +1290,6 @@
<string key="-3.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="112.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="1176.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="1177.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="1179.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="1181.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="1200.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -1442,22 +1418,19 @@
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">MPMainWindowController</string>
<string key="className">MPDocumentWindowController</string>
<string key="superclassName">NSWindowController</string>
<dictionary class="NSMutableDictionary" key="actions">
<string key="changedFileType:">id</string>
<string key="editPassword:">id</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="actionInfosByName">
<object class="IBActionInfo" key="changedFileType:">
<string key="name">changedFileType:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo" key="editPassword:">
<object class="NSMutableDictionary" key="actions">
<string key="NS.key.0">editPassword:</string>
<string key="NS.object.0">id</string>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
<string key="NS.key.0">editPassword:</string>
<object class="IBActionInfo" key="NS.object.0">
<string key="name">editPassword:</string>
<string key="candidateClassName">id</string>
</object>
</dictionary>
</object>
<dictionary class="NSMutableDictionary" key="outlets">
<string key="contentView">NSView</string>
<string key="inspectorView">NSView</string>
@@ -1494,7 +1467,7 @@
</dictionary>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/MPMainWindowController.h</string>
<string key="minorKey">./Classes/MPDocumentWindowController.h</string>
</object>
</object>
</array>