KeePassKit API changes, undo/redo only for move/add/editing session

Signed-off-by: michael starke <michael.starke@hicknhack-software.com>
This commit is contained in:
michael starke
2015-08-03 17:15:04 +02:00
parent f042cc2bc4
commit fa4094ee01
5 changed files with 68 additions and 64 deletions

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="7706" systemVersion="14D136" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="7706" systemVersion="14E46" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7706"/>
@@ -27,27 +27,27 @@
<customView translatesAutoresizingMaskIntoConstraints="NO" id="2930" customClass="HNHGradientView">
<rect key="frame" x="0.0" y="0.0" width="278" height="30"/>
<subviews>
<button hidden="YES" verticalHuggingPriority="750" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="3109">
<rect key="frame" x="220" y="2" width="38" height="25"/>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="3109">
<rect key="frame" x="219" y="2" width="39" height="25"/>
<buttonCell key="cell" type="roundTextured" title="Edit" bezelStyle="texturedRounded" imagePosition="left" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="3110">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="toggleEdit:" target="-2" id="3143"/>
<action selector="beginEditingSelectedItem:" target="-1" id="DRJ-M6-PkP"/>
</connections>
</button>
<button hidden="YES" verticalHuggingPriority="750" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="3126">
<rect key="frame" x="156" y="2" width="56" height="25"/>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="3126">
<rect key="frame" x="154" y="2" width="57" height="25"/>
<buttonCell key="cell" type="roundTextured" title="Cancel" bezelStyle="texturedRounded" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="3127">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="toggleEdit:" target="-2" id="3144"/>
<action selector="cancelChangesToSelectedItem:" target="-1" id="Hg9-6o-dRD"/>
</connections>
</button>
<button hidden="YES" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="jBD-3D-knW">
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="jBD-3D-knW">
<rect key="frame" x="20" y="2" width="59" height="25"/>
<buttonCell key="cell" type="roundTextured" title="History" bezelStyle="texturedRounded" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="w1z-1n-b0m">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
@@ -77,8 +77,8 @@
<action selector="pickIcon:" target="-2" id="6wh-Ka-Thl"/>
</connections>
</imageView>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="249" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="3013">
<rect key="frame" x="58" y="627" width="202" height="17"/>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="249" translatesAutoresizingMaskIntoConstraints="NO" id="3013">
<rect key="frame" x="58" y="628" width="202" height="17"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" truncatesLastVisibleLine="YES" allowsUndo="NO" sendsActionOnEndEditing="YES" title="Label" usesSingleLineMode="YES" id="3014">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@@ -110,11 +110,11 @@
</tabViewItem>
<tabViewItem label="NoSelection" identifier="" id="2974">
<view key="view" id="2975">
<rect key="frame" x="0.0" y="0.0" width="278" height="283"/>
<rect key="frame" x="0.0" y="0.0" width="278" height="370"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField verticalHuggingPriority="750" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2985">
<rect key="frame" x="77" y="150" width="125" height="24"/>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="2985">
<rect key="frame" x="80" y="194" width="119" height="24"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="No Selection" id="2986">
<font key="font" metaFont="system" size="20"/>
<color key="textColor" name="controlShadowColor" catalog="System" colorSpace="catalog"/>
@@ -143,8 +143,8 @@
<rect key="frame" x="0.0" y="371" width="278" height="211"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="PzR-P9-3al">
<rect key="frame" x="18" y="192" width="35" height="14"/>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="PzR-P9-3al">
<rect key="frame" x="18" y="192" width="36" height="14"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Notes" id="hwn-UY-9Cr">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="disabledControlTextColor" catalog="System" colorSpace="catalog"/>

View File

@@ -467,7 +467,6 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) {
[_createdTextField setSelectable:edit];
[_modifiedTextField setEditable:edit];
[_modifiedTextField setSelectable:edit];
}
#pragma mark -

View File

@@ -24,7 +24,6 @@
- (IBAction)pickIcon:(id)sender;
- (IBAction)pickExpiryDate:(id)sender;
- (IBAction)toggleEdit:(id)sender;
/* Separate call to ensure all registered objects are in place */
- (void)regsiterNotificationsForDocument:(NSDocument *)document;

View File

@@ -7,26 +7,27 @@
//
#import "MPInspectorViewController.h"
#import "MPIconHelper.h"
#import "MPDatePickingViewController.h"
#import "MPDocument.h"
#import "MPEditingSession.h"
#import "MPEntryInspectorViewController.h"
#import "MPGroupInspectorViewController.h"
#import "MPDocument.h"
#import "MPNotifications.h"
#import "MPIconHelper.h"
#import "MPIconSelectViewController.h"
#import "MPDatePickingViewController.h"
#import "MPNotifications.h"
#import "MPPopupImageView.h"
#import "NSDate+Humanized.h"
#import "KPKNode+IconImage.h"
#import "KPKEntry.h"
#import "KPKGroup.h"
#import "KPKTimeInfo.h"
#import "KPKTree.h"
#import "KPKMetaData.h"
#import "KPKGroup.h"
#import "KPKEntry.h"
#import "KPKNode.h"
#import "KPKTimeInfo.h"
#import "KPKNode+IconImage.h"
#import "HNHGradientView.h"
#import "MPPopupImageView.h"
typedef NS_ENUM(NSUInteger, MPContentTab) {
@@ -105,6 +106,12 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
[groupTabItem setInitialFirstResponder:groupView];
[[self view] layout];
/* Init edit and cancel buttons */
[self.editButton setAction:@selector(beginEditingSelectedItem:)];
[self.cancelEditButton setAction:@selector(cancelChangesToSelectedItem:)];
[self.cancelEditButton setHidden:YES];
[self _updateBindings:nil];
}
@@ -114,6 +121,21 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
name:MPDocumentCurrentItemChangedNotification
object:document];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(_didBeginEditingSelectedItem:)
name:MPDocumentDidBeginEditingSelectedItem
object:document];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(_didCancelOrCommitChangesToSelectedItem:)
name:MPDocumentDidCommitChangesToSelectedItem
object:document];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(_didCancelOrCommitChangesToSelectedItem:)
name:MPDocumentDidCancelChangesToSelectedItem
object:document];
[self.entryViewController regsiterNotificationsForDocument:document];
[self.entryViewController setupBindings:document];
@@ -163,38 +185,6 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
}
#pragma mark -
#pragma mark Click Edit Button
- (void)toggleEdit:(id)sender {
BOOL didCancel = sender == self.cancelEditButton;
MPDocument *document = [[self windowController] document];
if(document.selectedItem) {
/* TODO UndoManager handling */
[self.editButton setTitle:NSLocalizedString(@"EDIT_ITEM", "")];
[self.cancelEditButton setHidden:YES];
[self.entryViewController endEditing];
/*
We need to be careful to only undo the things we actually changed
otherwise we undo older actions
*/
if(didCancel) {
}
else {
}
}
else {
//[document.selectedItem beginEditSession];
[self.editButton setTitle:NSLocalizedString(@"SAVE_CHANGES", "")];
[self.cancelEditButton setHidden:NO];
[self.entryViewController beginEditing];
}
}
#pragma mark -
#pragma mark Popup
- (IBAction)pickIcon:(id)sender {
@@ -312,7 +302,7 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
- (void)_didChangeCurrentItem:(NSNotification *)notification {
MPDocument *document = [notification object];
if(!document.selectedItem) {
/* show empty tab and hide edit button */
/* show emty tab and hide edit button */
self.activeTab = MPEmptyTab;
}
else {
@@ -330,4 +320,20 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
/* disable the entry text fields whenever the entry selection changes */
//[self.entryViewController endEditing];
}
@end
- (void)_didBeginEditingSelectedItem:(NSNotification *)notification {
MPDocument *document = [notification object];
[self.editButton setAction:@selector(commitChangesToSelectedItem:)];
[self.editButton setTitle:NSLocalizedString(@"DONE", "")];
[self.cancelEditButton setHidden:NO];
[self _updateBindings:document.editingSession.node];
}
- (void)_didCancelOrCommitChangesToSelectedItem:(NSNotification *)notification {
MPDocument *document = [notification object];
[self.editButton setTitle:NSLocalizedString(@"EDIT", "")];
[self.cancelEditButton setHidden:YES];
[self.editButton setAction:@selector(beginEditingSelectedItem:)];
[self _updateBindings:document.selectedItem];
}
@end

View File

@@ -18,8 +18,8 @@
<rect key="frame" x="0.0" y="0.0" width="243" height="54"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<button misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="x9q-qY-Jy2">
<rect key="frame" x="69" y="8" width="133" height="18"/>
<button translatesAutoresizingMaskIntoConstraints="NO" id="x9q-qY-Jy2">
<rect key="frame" x="71" y="8" width="131" height="18"/>
<buttonCell key="cell" type="check" title="Show hidden files" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="FfY-KA-8IC">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
@@ -28,8 +28,8 @@
<action selector="toggleShowHiddenFiles:" target="-2" id="zq6-5l-C22"/>
</connections>
</button>
<button misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="I5Q-M2-Ha7">
<rect key="frame" x="69" y="28" width="105" height="18"/>
<button translatesAutoresizingMaskIntoConstraints="NO" id="I5Q-M2-Ha7">
<rect key="frame" x="71" y="28" width="102" height="18"/>
<buttonCell key="cell" type="check" title="Allow all files" bezelStyle="regularSquare" imagePosition="left" inset="2" id="tvV-1s-Be3">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>