mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-13 08:52:20 +00:00
Using NSSplitViewController for main split view.
This commit is contained in:
@@ -43,6 +43,8 @@
|
||||
4C2057EE23CDF6F900C731EC /* MPPathCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C2057ED23CDF6F900C731EC /* MPPathCell.m */; };
|
||||
4C2057F423CF3BA600C731EC /* MPAutotypeEnvironment.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C2057F323CF3BA600C731EC /* MPAutotypeEnvironment.m */; };
|
||||
4C2057F723CF3E9A00C731EC /* NSRunningApplication+MPAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C2057F623CF3E9A00C731EC /* NSRunningApplication+MPAdditions.m */; };
|
||||
4C20E4C123E4753A00807FAE /* MPDocumentSplitViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C20E4BF23E4753A00807FAE /* MPDocumentSplitViewController.m */; };
|
||||
4C20E4C223E4753A00807FAE /* DocumentSplitView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C20E4C023E4753A00807FAE /* DocumentSplitView.xib */; };
|
||||
4C224B4217DFCB2400FF6AEE /* MPNumericalInputFormatter.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C224B4117DFCB2400FF6AEE /* MPNumericalInputFormatter.m */; };
|
||||
4C25703F1BF11C2300D39416 /* MPPluginPreferencesController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C25703D1BF11C2300D39416 /* MPPluginPreferencesController.m */; };
|
||||
4C25D58716CF0FAA00F6806C /* EntryView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C25D58616CF0FAA00F6806C /* EntryView.xib */; };
|
||||
@@ -411,6 +413,9 @@
|
||||
4C2057F323CF3BA600C731EC /* MPAutotypeEnvironment.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MPAutotypeEnvironment.m; sourceTree = "<group>"; };
|
||||
4C2057F523CF3E9A00C731EC /* NSRunningApplication+MPAdditions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSRunningApplication+MPAdditions.h"; sourceTree = "<group>"; };
|
||||
4C2057F623CF3E9A00C731EC /* NSRunningApplication+MPAdditions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSRunningApplication+MPAdditions.m"; sourceTree = "<group>"; };
|
||||
4C20E4BE23E4753A00807FAE /* MPDocumentSplitViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MPDocumentSplitViewController.h; sourceTree = "<group>"; };
|
||||
4C20E4BF23E4753A00807FAE /* MPDocumentSplitViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MPDocumentSplitViewController.m; sourceTree = "<group>"; };
|
||||
4C20E4C023E4753A00807FAE /* DocumentSplitView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = DocumentSplitView.xib; sourceTree = "<group>"; };
|
||||
4C21F29F195B3A48002D610D /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/MainMenu.strings; sourceTree = "<group>"; };
|
||||
4C224B4017DFCB2300FF6AEE /* MPNumericalInputFormatter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPNumericalInputFormatter.h; sourceTree = "<group>"; };
|
||||
4C224B4117DFCB2400FF6AEE /* MPNumericalInputFormatter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPNumericalInputFormatter.m; sourceTree = "<group>"; };
|
||||
@@ -1620,6 +1625,9 @@
|
||||
4CAD8AA322CF397B0090B2DD /* MPAutotypeDoctorReportViewController.h */,
|
||||
4CAD8AA422CF397B0090B2DD /* MPAutotypeDoctorReportViewController.m */,
|
||||
78E1F8B222E3A5D600E738AE /* AutotypeDoctorReportViewController.xib */,
|
||||
4C20E4BE23E4753A00807FAE /* MPDocumentSplitViewController.h */,
|
||||
4C20E4BF23E4753A00807FAE /* MPDocumentSplitViewController.m */,
|
||||
4C20E4C023E4753A00807FAE /* DocumentSplitView.xib */,
|
||||
);
|
||||
name = "View Controller";
|
||||
sourceTree = "<group>";
|
||||
@@ -1914,6 +1922,7 @@
|
||||
4C3826AF1AD04D8E007D7D67 /* 34_ConfigureTemplate.pdf in Resources */,
|
||||
4C3826BB1AD04D8E007D7D67 /* 47_PackageTemplate.pdf in Resources */,
|
||||
6021FE8D18E1617300C3BC51 /* PasswordCreatorView.xib in Resources */,
|
||||
4C20E4C223E4753A00807FAE /* DocumentSplitView.xib in Resources */,
|
||||
4C3826AC1AD04D8E007D7D67 /* 29_SecureTerminalTemplate.pdf in Resources */,
|
||||
4C3826741AD04BA5007D7D67 /* infoTemplate.pdf in Resources */,
|
||||
4C3826B11AD04D8E007D7D67 /* 36_ArchiveTemplate.pdf in Resources */,
|
||||
@@ -2051,6 +2060,7 @@
|
||||
4C81867D216664C70068DAFB /* MPPluginRepositoryItemVersionInfo.m in Sources */,
|
||||
4CDA35751EBA0CF2003CD59F /* NSString+MPComposedCharacterAdditions.m in Sources */,
|
||||
4CE39ABF16ECE34A000FE29D /* MPIconSelectViewController.m in Sources */,
|
||||
4C20E4C123E4753A00807FAE /* MPDocumentSplitViewController.m in Sources */,
|
||||
4CE39AC416ECE4F7000FE29D /* MPIconImageView.m in Sources */,
|
||||
4C46B88517063A070046109A /* NSString+MPPasswordCreation.m in Sources */,
|
||||
4C5A11FE1708DE8700223D8A /* MPPasswordCreatorViewController.m in Sources */,
|
||||
@@ -2766,7 +2776,7 @@
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
CODE_SIGN_IDENTITY = "";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
CURRENT_PROJECT_VERSION = 0.7.11;
|
||||
CURRENT_PROJECT_VERSION = "0.8-beta";
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
@@ -2788,7 +2798,7 @@
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
HEADER_SEARCH_PATHS = "$(SDKROOT)/usr/include/libxml2/**";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.13;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
OTHER_LDFLAGS = "-lxml2";
|
||||
SDKROOT = macosx;
|
||||
@@ -2821,7 +2831,7 @@
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
CODE_SIGN_IDENTITY = "";
|
||||
COPY_PHASE_STRIP = YES;
|
||||
CURRENT_PROJECT_VERSION = 0.7.11;
|
||||
CURRENT_PROJECT_VERSION = "0.8-beta";
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
@@ -2836,7 +2846,7 @@
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
HEADER_SEARCH_PATHS = "$(SDKROOT)/usr/include/libxml2/**";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.13;
|
||||
OTHER_LDFLAGS = "-lxml2";
|
||||
SDKROOT = macosx;
|
||||
WARNING_CFLAGS = "-Wpartial-availability";
|
||||
|
||||
19
MacPass/DocumentSplitView.xib
Normal file
19
MacPass/DocumentSplitView.xib
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11134" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11134"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="MPDocumentSplitViewController">
|
||||
<connections>
|
||||
<outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<customView id="Hz6-mo-xeY">
|
||||
<rect key="frame" x="0.0" y="0.0" width="480" height="272"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
</customView>
|
||||
</objects>
|
||||
</document>
|
||||
@@ -1,20 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13771" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="15705" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13771"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="15705"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="MPDocumentWindowController">
|
||||
<connections>
|
||||
<outlet property="splitView" destination="697" id="700"/>
|
||||
<outlet property="window" destination="1" id="501"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="DatabaseWindow" animationBehavior="default" tabbingMode="preferred" id="1">
|
||||
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="DatabaseWindow" animationBehavior="default" tabbingMode="preferred" id="1">
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
|
||||
<windowCollectionBehavior key="collectionBehavior" fullScreenPrimary="YES"/>
|
||||
<rect key="contentRect" x="196" y="240" width="700" height="500"/>
|
||||
@@ -23,10 +22,7 @@
|
||||
<rect key="frame" x="0.0" y="0.0" width="700" height="500"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</view>
|
||||
<point key="canvasLocation" x="54" y="51"/>
|
||||
<point key="canvasLocation" x="256" y="42"/>
|
||||
</window>
|
||||
<splitView autosaveName="" dividerStyle="thin" vertical="YES" translatesAutoresizingMaskIntoConstraints="NO" id="697">
|
||||
<rect key="frame" x="0.0" y="0.0" width="560" height="194"/>
|
||||
</splitView>
|
||||
</objects>
|
||||
</document>
|
||||
|
||||
30
MacPass/MPDocumentSplitViewController.h
Normal file
30
MacPass/MPDocumentSplitViewController.h
Normal file
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// MPDocumentSplitViewController.h
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 31.01.20.
|
||||
// Copyright © 2020 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class MPEntryViewController;
|
||||
@class MPInspectorViewController;
|
||||
@class MPOutlineViewController;
|
||||
@class MPDocument;
|
||||
|
||||
@interface MPDocumentSplitViewController : NSSplitViewController
|
||||
|
||||
@property (readonly, strong) MPEntryViewController *entryViewController;
|
||||
@property (readonly, strong) MPOutlineViewController *outlineViewController;
|
||||
@property (readonly, strong) MPInspectorViewController *inspectorViewController;
|
||||
|
||||
- (void)registerNotificationsForDocument:(MPDocument *)document;
|
||||
- (IBAction)toggleInspector:(id)sender;
|
||||
- (void)showOutline;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
84
MacPass/MPDocumentSplitViewController.m
Normal file
84
MacPass/MPDocumentSplitViewController.m
Normal file
@@ -0,0 +1,84 @@
|
||||
//
|
||||
// MPDocumentSplitViewController.m
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 31.01.20.
|
||||
// Copyright © 2020 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MPDocumentSplitViewController.h"
|
||||
#import "MPOutlineViewController.h"
|
||||
#import "MPEntryViewController.h"
|
||||
#import "MPInspectorViewController.h"
|
||||
#import "MPSettingsHelper.h"
|
||||
|
||||
@interface MPDocumentSplitViewController ()
|
||||
|
||||
@property (strong) MPEntryViewController *entryViewController;
|
||||
@property (strong) MPOutlineViewController *outlineViewController;
|
||||
@property (strong) MPInspectorViewController *inspectorViewController;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MPDocumentSplitViewController
|
||||
|
||||
- (NSNibName)nibName {
|
||||
return @"DocumentSplitView";
|
||||
|
||||
}
|
||||
|
||||
- (instancetype)initWithNibName:(NSNibName)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
|
||||
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
|
||||
if(self) {
|
||||
_outlineViewController = [[MPOutlineViewController alloc] init];
|
||||
_entryViewController = [[MPEntryViewController alloc] init];
|
||||
_inspectorViewController = [[MPInspectorViewController alloc] init];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
|
||||
self.splitView.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
self.splitView.autosaveName = @"SplitView";
|
||||
|
||||
NSSplitViewItem *outlineItem = [NSSplitViewItem sidebarWithViewController:self.outlineViewController];
|
||||
outlineItem.holdingPriority = NSLayoutPriorityDefaultLow + 2;
|
||||
outlineItem.canCollapse = NO;
|
||||
outlineItem.minimumThickness = 150;
|
||||
NSSplitViewItem *entries = [NSSplitViewItem splitViewItemWithViewController:self.entryViewController];
|
||||
entries.canCollapse = NO;
|
||||
entries.minimumThickness = 150;
|
||||
NSSplitViewItem *inspector = [NSSplitViewItem splitViewItemWithViewController:self.inspectorViewController];
|
||||
inspector.canCollapse = YES;
|
||||
inspector.minimumThickness = 200;
|
||||
inspector.holdingPriority = NSLayoutPriorityDefaultLow + 1;
|
||||
|
||||
[self addSplitViewItem:outlineItem];
|
||||
[self addSplitViewItem:entries];
|
||||
[self addSplitViewItem:inspector];
|
||||
|
||||
BOOL showInspector = [NSUserDefaults.standardUserDefaults boolForKey:kMPSettingsKeyShowInspector];
|
||||
inspector.collapsed = !showInspector;
|
||||
}
|
||||
|
||||
- (void)registerNotificationsForDocument:(MPDocument *)document {
|
||||
|
||||
[self.entryViewController registerNotificationsForDocument:document];
|
||||
[self.outlineViewController registerNotificationsForDocument:document];
|
||||
[self.inspectorViewController registerNotificationsForDocument:document];
|
||||
}
|
||||
|
||||
- (void)showOutline {
|
||||
// FIXME: do not require this to be called directly
|
||||
[self.outlineViewController showOutline];
|
||||
}
|
||||
|
||||
- (void)toggleInspector:(id)sender {
|
||||
NSSplitViewItem *inspector = [self splitViewItemForViewController:self.inspectorViewController];
|
||||
inspector.collapsed = !inspector.collapsed;
|
||||
[NSUserDefaults.standardUserDefaults setBool:!inspector.collapsed forKey:kMPSettingsKeyShowInspector];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -34,9 +34,6 @@
|
||||
@interface MPDocumentWindowController : NSWindowController <NSTouchBarDelegate>
|
||||
|
||||
@property (readonly, strong) MPPasswordInputController *passwordInputController;
|
||||
@property (readonly, strong) MPEntryViewController *entryViewController;
|
||||
@property (readonly, strong) MPOutlineViewController *outlineViewController;
|
||||
@property (readonly, strong) MPInspectorViewController *inspectorViewController;
|
||||
@property (readonly, strong) MPToolbarDelegate *toolbarDelegate;
|
||||
|
||||
@property (readonly, nonatomic, strong) NSSearchField *searchField;
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#import "MPDatabaseSettingsWindowController.h"
|
||||
#import "MPDocument.h"
|
||||
#import "MPDocumentWindowDelegate.h"
|
||||
#import "MPDocumentSplitViewController.h"
|
||||
#import "MPDuplicateEntryOptionsWindowController.h"
|
||||
#import "MPEntryViewController.h"
|
||||
#import "MPFixAutotypeWindowController.h"
|
||||
@@ -58,14 +59,11 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
|
||||
id _firstResponder;
|
||||
}
|
||||
|
||||
@property (strong) IBOutlet NSSplitView *splitView;
|
||||
|
||||
@property (strong) NSToolbar *toolbar;
|
||||
|
||||
@property (strong) MPPasswordInputController *passwordInputController;
|
||||
@property (strong) MPEntryViewController *entryViewController;
|
||||
@property (strong) MPOutlineViewController *outlineViewController;
|
||||
@property (strong) MPInspectorViewController *inspectorViewController;
|
||||
@property (strong) MPDocumentSplitViewController *splitViewController;
|
||||
|
||||
@property (strong) MPDatabaseSettingsWindowController *documentSettingsWindowController;
|
||||
@property (strong) MPDocumentWindowDelegate *documentWindowDelegate;
|
||||
@property (strong) MPPasswordEditWindowController *passwordEditWindowController;
|
||||
@@ -87,9 +85,7 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
|
||||
if( self ) {
|
||||
_firstResponder = nil;
|
||||
_toolbarDelegate = [[MPToolbarDelegate alloc] init];
|
||||
_outlineViewController = [[MPOutlineViewController alloc] init];
|
||||
_entryViewController = [[MPEntryViewController alloc] init];
|
||||
_inspectorViewController = [[MPInspectorViewController alloc] init];
|
||||
_splitViewController = [[MPDocumentSplitViewController alloc] init];
|
||||
_documentWindowDelegate = [[MPDocumentWindowDelegate alloc] init];
|
||||
}
|
||||
return self;
|
||||
@@ -108,15 +104,12 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
|
||||
|
||||
MPDocument *document = self.document;
|
||||
|
||||
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_didRevertDocument:) name:MPDocumentDidRevertNotifiation object:document];
|
||||
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_didUnlockDatabase:) name:MPDocumentDidUnlockDatabaseNotification object:document];
|
||||
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_didAddEntry:) name:MPDocumentDidAddEntryNotification object:document];
|
||||
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_didAddGroup:) name:MPDocumentDidAddGroupNotification object:document];
|
||||
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_didLockDatabase:) name:MPDocumentDidLockDatabaseNotification object:document];
|
||||
|
||||
[self.entryViewController registerNotificationsForDocument:document];
|
||||
[self.inspectorViewController registerNotificationsForDocument:document];
|
||||
[self.outlineViewController registerNotificationsForDocument:document];
|
||||
[self.splitViewController registerNotificationsForDocument:document];
|
||||
[self.toolbarDelegate registerNotificationsForDocument:document];
|
||||
|
||||
self.toolbar = [[NSToolbar alloc] initWithIdentifier:@"MainWindowToolbar"];
|
||||
@@ -131,23 +124,6 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
|
||||
self.window.toolbar = self.toolbar;
|
||||
self.toolbarDelegate.toolbar = self.toolbar;
|
||||
|
||||
self.splitView.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
|
||||
NSView *outlineView = self.outlineViewController.view;
|
||||
NSView *inspectorView = self.inspectorViewController.view;
|
||||
NSView *entryView = self.entryViewController.view;
|
||||
[self.splitView addSubview:outlineView];
|
||||
[self.splitView addSubview:entryView];
|
||||
[self.splitView addSubview:inspectorView];
|
||||
|
||||
[self.splitView setHoldingPriority:NSLayoutPriorityDefaultLow+2 forSubviewAtIndex:0];
|
||||
[self.splitView setHoldingPriority:NSLayoutPriorityDefaultLow+1 forSubviewAtIndex:2];
|
||||
|
||||
BOOL showInspector = [NSUserDefaults.standardUserDefaults boolForKey:kMPSettingsKeyShowInspector];
|
||||
if(!showInspector) {
|
||||
[inspectorView removeFromSuperview];
|
||||
}
|
||||
|
||||
if(document.encrypted) {
|
||||
[self showPasswordInput];
|
||||
}
|
||||
@@ -155,8 +131,6 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
|
||||
[self showEntries];
|
||||
}
|
||||
|
||||
self.splitView.autosaveName = @"SplitView";
|
||||
|
||||
/*
|
||||
TODO: Add display for database color?
|
||||
NSTitlebarAccessoryViewController *tbc = [[MPTitlebarColorAccessoryViewController alloc] init];
|
||||
@@ -169,40 +143,8 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
|
||||
return self.toolbarDelegate.searchField;
|
||||
}
|
||||
|
||||
- (void)_setContentViewController:(MPViewController *)viewController {
|
||||
|
||||
NSView *newContentView = nil;
|
||||
if(viewController && viewController.view) {
|
||||
newContentView = viewController.view;
|
||||
}
|
||||
NSView *contentView = self.window.contentView;
|
||||
NSView *oldSubView = nil;
|
||||
if(contentView.subviews.count == 1) {
|
||||
oldSubView = contentView.subviews.firstObject;
|
||||
}
|
||||
if(oldSubView == newContentView) {
|
||||
return; // View is already present
|
||||
}
|
||||
[oldSubView removeFromSuperviewWithoutNeedingDisplay];
|
||||
[contentView addSubview:newContentView];
|
||||
[contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[newContentView]|"
|
||||
options:0
|
||||
metrics:nil
|
||||
views:NSDictionaryOfVariableBindings(newContentView)]];
|
||||
|
||||
NSNumber *border = @([[self window] contentBorderThicknessForEdge:NSMinYEdge]);
|
||||
[contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[newContentView]-border-|"
|
||||
options:0
|
||||
metrics:NSDictionaryOfVariableBindings(border)
|
||||
views:NSDictionaryOfVariableBindings(newContentView)]];
|
||||
|
||||
[contentView layout];
|
||||
[self.window makeFirstResponder:viewController.reconmendedFirstResponder];
|
||||
}
|
||||
|
||||
#pragma mark MPDocument notifications
|
||||
- (void)_didRevertDocument:(NSNotification *)notification {
|
||||
[self.outlineViewController clearSelection];
|
||||
[self showPasswordInput];
|
||||
}
|
||||
|
||||
@@ -279,7 +221,7 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
|
||||
[openPanel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result) {
|
||||
if(result == NSFileHandlingPanelOKButton) {
|
||||
[document readXMLfromURL:openPanel.URL];
|
||||
[self.outlineViewController showOutline];
|
||||
[self.splitViewController showOutline];
|
||||
}
|
||||
}];
|
||||
}
|
||||
@@ -363,7 +305,7 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
|
||||
if(!self.passwordInputController) {
|
||||
self.passwordInputController = [[MPPasswordInputController alloc] init];
|
||||
}
|
||||
[self _setContentViewController:self.passwordInputController];
|
||||
self.contentViewController = self.passwordInputController;
|
||||
[self.passwordInputController requestPasswordWithMessage:message cancelLabel:nil completionHandler:^BOOL(NSString *password, NSURL *keyURL, BOOL didCancel, NSError *__autoreleasing *error) {
|
||||
if(didCancel) {
|
||||
return NO;
|
||||
@@ -469,27 +411,17 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
|
||||
}
|
||||
|
||||
- (void)pickExpiryDate:(id)sender {
|
||||
[self.inspectorViewController pickExpiryDate:sender];
|
||||
// FIXME: use propert responder chain
|
||||
[self.splitViewController.inspectorViewController pickExpiryDate:sender];
|
||||
}
|
||||
|
||||
- (void)showPluginData:(id)sender {
|
||||
[self.inspectorViewController showPluginData:sender];
|
||||
// FIXME: use propert responder chain
|
||||
[self.splitViewController.inspectorViewController showPluginData:sender];
|
||||
}
|
||||
|
||||
- (void)toggleInspector:(id)sender {
|
||||
NSView *inspectorView = self.inspectorViewController.view;
|
||||
BOOL inspectorWasVisible = [self _isInspectorVisible];
|
||||
if(inspectorWasVisible) {
|
||||
[inspectorView removeFromSuperview];
|
||||
}
|
||||
else {
|
||||
[self.splitView addSubview:inspectorView];
|
||||
[self.splitView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"[inspectorView(>=200)]"
|
||||
options:0
|
||||
metrics:nil
|
||||
views:NSDictionaryOfVariableBindings(inspectorView)]];
|
||||
}
|
||||
[[NSUserDefaults standardUserDefaults] setBool:!inspectorWasVisible forKey:kMPSettingsKeyShowInspector];
|
||||
[self.splitViewController toggleInspector:sender];
|
||||
}
|
||||
|
||||
- (void)performAutotypeForEntry:(id)sender {
|
||||
@@ -507,108 +439,58 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
|
||||
}
|
||||
|
||||
- (void)focusEntries:(id)sender {
|
||||
[self.window makeFirstResponder:[self.entryViewController reconmendedFirstResponder]];
|
||||
// FIXME: use propert responder chain
|
||||
[self.window makeFirstResponder:[self.splitViewController.entryViewController reconmendedFirstResponder]];
|
||||
}
|
||||
|
||||
- (void)focusGroups:(id)sender {
|
||||
[self.window makeFirstResponder:[self.outlineViewController reconmendedFirstResponder]];
|
||||
// FIXME: use propert responder chain
|
||||
[self.window makeFirstResponder:[self.splitViewController.outlineViewController reconmendedFirstResponder]];
|
||||
}
|
||||
|
||||
- (void)focusInspector:(id)sender {
|
||||
[self.window makeFirstResponder:[self.inspectorViewController reconmendedFirstResponder]];
|
||||
// FIXME: use propert responder chain
|
||||
[self.window makeFirstResponder:[self.splitViewController.inspectorViewController reconmendedFirstResponder]];
|
||||
}
|
||||
|
||||
- (void)showEntries {
|
||||
NSView *contentView = self.window.contentView;
|
||||
if(self.splitView == contentView) {
|
||||
return; // We are displaying the entries already
|
||||
}
|
||||
if(contentView.subviews.count == 1) {
|
||||
[contentView.subviews.firstObject removeFromSuperviewWithoutNeedingDisplay];
|
||||
}
|
||||
[contentView addSubview:self.splitView];
|
||||
NSView *outlineView = self.outlineViewController.view;
|
||||
NSView *inspectorView = self.inspectorViewController.view;
|
||||
NSView *entryView = self.entryViewController.view;
|
||||
|
||||
/*
|
||||
The current easy way to prevent layout hiccups is to add the inspector
|
||||
Add all needed constraints an then remove it again, if it was hidden
|
||||
*/
|
||||
BOOL removeInspector = NO;
|
||||
if(!inspectorView.superview) {
|
||||
[self.splitView addSubview:inspectorView];
|
||||
removeInspector = YES;
|
||||
}
|
||||
/* Maybe we should consider not double adding constraints */
|
||||
NSDictionary *views = NSDictionaryOfVariableBindings(outlineView, inspectorView, entryView, _splitView);
|
||||
[self.splitView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[outlineView(>=150)]-1-[entryView(>=150)]-1-[inspectorView(>=200)]|"
|
||||
options:0
|
||||
metrics:nil
|
||||
views:views]];
|
||||
[self.splitView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[outlineView]|"
|
||||
options:0
|
||||
metrics:nil
|
||||
views:views]];
|
||||
[self.splitView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[entryView(>=200)]|"
|
||||
options:0
|
||||
metrics:nil
|
||||
views:views]];
|
||||
[self.splitView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[inspectorView]|"
|
||||
options:0
|
||||
metrics:nil
|
||||
views:views]];
|
||||
|
||||
NSNumber *border = @([[self window] contentBorderThicknessForEdge:NSMinYEdge]);
|
||||
[contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[_splitView]-border-|"
|
||||
options:0
|
||||
metrics:NSDictionaryOfVariableBindings(border)
|
||||
views:views]];
|
||||
[contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[_splitView]|"
|
||||
options:0
|
||||
metrics:nil
|
||||
views:views]];
|
||||
[self.outlineViewController showOutline];
|
||||
|
||||
/* Restore the State the inspector view was in before the view change */
|
||||
if(removeInspector) {
|
||||
[inspectorView removeFromSuperview];
|
||||
}
|
||||
[contentView layoutSubtreeIfNeeded];
|
||||
self.contentViewController = self.splitViewController;
|
||||
[self.splitViewController showOutline];
|
||||
|
||||
}
|
||||
|
||||
- (void)showGroupInOutline:(id)sender {
|
||||
NSArray<KPKEntry *> *targetEntries = self.entryViewController.currentTargetEntries;
|
||||
NSArray<KPKEntry *> *targetEntries = self.splitViewController.entryViewController.currentTargetEntries;
|
||||
if(targetEntries.count != 1) {
|
||||
return;
|
||||
}
|
||||
[self.outlineViewController selectGroup:targetEntries.lastObject.parent];
|
||||
[self.splitViewController.outlineViewController selectGroup:targetEntries.lastObject.parent];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Actions forwarded to MPEntryViewController
|
||||
- (void)copyUsername:(id)sender {
|
||||
[self.entryViewController copyUsername:sender];
|
||||
[self.splitViewController.entryViewController copyUsername:sender];
|
||||
}
|
||||
|
||||
- (void)copyPassword:(id)sender {
|
||||
[self.entryViewController copyPassword:sender];
|
||||
[self.splitViewController.entryViewController copyPassword:sender];
|
||||
}
|
||||
|
||||
- (void)copyCustomAttribute:(id)sender {
|
||||
[self.entryViewController copyCustomAttribute:sender];
|
||||
[self.splitViewController.entryViewController copyCustomAttribute:sender];
|
||||
}
|
||||
|
||||
- (void)copyAsReference:(id)sender {
|
||||
[self.entryViewController copyAsReference:sender];
|
||||
[self.splitViewController.entryViewController copyAsReference:sender];
|
||||
}
|
||||
|
||||
- (void)copyURL:(id)sender {
|
||||
[self.entryViewController copyURL:sender];
|
||||
[self.splitViewController.entryViewController copyURL:sender];
|
||||
}
|
||||
|
||||
- (void)openURL:(id)sender {
|
||||
[self.entryViewController openURL:sender];
|
||||
[self.splitViewController.entryViewController openURL:sender];
|
||||
}
|
||||
|
||||
#pragma mark Validation
|
||||
@@ -690,8 +572,8 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
|
||||
#pragma mark UI Helper
|
||||
|
||||
- (BOOL)_isInspectorVisible {
|
||||
NSView *inspectorView = self.inspectorViewController.view;
|
||||
return (nil != inspectorView.superview);
|
||||
NSSplitViewItem *item = [self.splitViewController splitViewItemForViewController:self.splitViewController.inspectorViewController];
|
||||
return !item.isCollapsed;
|
||||
}
|
||||
|
||||
- (NSTouchBar *)makeTouchBar {
|
||||
|
||||
@@ -225,6 +225,7 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
|
||||
#pragma mark Notifications
|
||||
- (void)registerNotificationsForDocument:(MPDocument *)document {
|
||||
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_didAddGroup:) name:MPDocumentDidAddGroupNotification object:document];
|
||||
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_didRevertDocument:) name:MPDocumentDidRevertNotifiation object:document];
|
||||
}
|
||||
|
||||
- (void)clearSelection {
|
||||
@@ -268,6 +269,9 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
|
||||
[self.outlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:groupRow] byExtendingSelection:NO];
|
||||
[self.outlineView scrollRowToVisible:groupRow];
|
||||
}
|
||||
- (void)_didRevertDocument:(NSNotification *)notification {
|
||||
[self clearSelection];
|
||||
}
|
||||
|
||||
- (id)itemUnderMouse {
|
||||
NSPoint mouseLocation = [self.outlineView.window mouseLocationOutsideOfEventStream];
|
||||
|
||||
Reference in New Issue
Block a user