mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 10:32:26 +00:00
removed obsolte code from MPInspectorBuilderViewController
This commit is contained in:
@@ -21,20 +21,14 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import "MPViewController.h"
|
#import "MPViewController.h"
|
||||||
|
#import <HNHUi/HNHUi.h>
|
||||||
@class HNHUIGradientView;
|
|
||||||
@class MPIconImageView;
|
@class MPIconImageView;
|
||||||
|
|
||||||
@interface MPInspectorViewController : MPViewController <NSPopoverDelegate>
|
@interface MPInspectorViewController : MPViewController <NSPopoverDelegate, HNHUITextViewDelegate>
|
||||||
|
|
||||||
@property (weak) IBOutlet HNHUIGradientView *bottomBar;
|
|
||||||
@property (weak) IBOutlet NSTextField *createdTextField;
|
|
||||||
@property (weak) IBOutlet NSTextField *modifiedTextField;
|
|
||||||
@property (weak) IBOutlet NSTextField *noSelectionInfo;
|
@property (weak) IBOutlet NSTextField *noSelectionInfo;
|
||||||
@property (weak) IBOutlet MPIconImageView *itemImageView;
|
@property (weak) IBOutlet MPIconImageView *itemImageView;
|
||||||
@property (weak) IBOutlet NSTextField *itemNameTextField;
|
@property (weak) IBOutlet NSTextField *itemNameTextField;
|
||||||
@property (weak) IBOutlet NSButton *saveChangesButton;
|
|
||||||
@property (weak) IBOutlet NSButton *discardChangesButton;
|
|
||||||
|
|
||||||
- (IBAction)pickIcon:(id)sender;
|
- (IBAction)pickIcon:(id)sender;
|
||||||
- (IBAction)pickExpiryDate:(id)sender;
|
- (IBAction)pickExpiryDate:(id)sender;
|
||||||
|
|||||||
@@ -30,15 +30,12 @@
|
|||||||
#import "MPIconImageView.h"
|
#import "MPIconImageView.h"
|
||||||
#import "MPNotifications.h"
|
#import "MPNotifications.h"
|
||||||
#import "MPPluginDataViewController.h"
|
#import "MPPluginDataViewController.h"
|
||||||
|
#import "MPPasteBoardController.h"
|
||||||
|
|
||||||
#import "KeePassKit/KeePassKit.h"
|
#import "KeePassKit/KeePassKit.h"
|
||||||
|
|
||||||
#import "KPKNode+IconImage.h"
|
#import "KPKNode+IconImage.h"
|
||||||
|
|
||||||
#import "HNHUi/HNHUi.h"
|
|
||||||
|
|
||||||
#import "NSDate+Humanized.h"
|
|
||||||
|
|
||||||
typedef NS_ENUM(NSUInteger, MPContentTab) {
|
typedef NS_ENUM(NSUInteger, MPContentTab) {
|
||||||
MPEntryTab,
|
MPEntryTab,
|
||||||
MPGroupTab,
|
MPGroupTab,
|
||||||
@@ -51,15 +48,12 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
|
|||||||
@property (strong) MPGroupInspectorViewController *groupViewController;
|
@property (strong) MPGroupInspectorViewController *groupViewController;
|
||||||
|
|
||||||
@property (strong) NSPopover *popover;
|
@property (strong) NSPopover *popover;
|
||||||
|
|
||||||
@property (nonatomic, strong) NSDate *modificationDate;
|
|
||||||
@property (nonatomic, strong) NSDate *creationDate;
|
|
||||||
@property (copy) NSString *expiryDateText;
|
@property (copy) NSString *expiryDateText;
|
||||||
|
|
||||||
@property (nonatomic, assign) NSUInteger activeTab;
|
@property (nonatomic, assign) NSUInteger activeTab;
|
||||||
@property (weak) IBOutlet NSTabView *tabView;
|
@property (weak) IBOutlet NSTabView *tabView;
|
||||||
@property (weak) IBOutlet NSSplitView *splitView;
|
@property (weak) IBOutlet NSSplitView *splitView;
|
||||||
@property (unsafe_unretained) IBOutlet NSTextView *notesTextView;
|
@property (unsafe_unretained) IBOutlet HNHUITextView *notesTextView;
|
||||||
|
|
||||||
@property BOOL didPushHistory;
|
@property BOOL didPushHistory;
|
||||||
|
|
||||||
@@ -92,8 +86,6 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)awakeFromNib {
|
- (void)awakeFromNib {
|
||||||
self.bottomBar.borderType = (HNHBorderTop|HNHBorderHighlight);
|
|
||||||
|
|
||||||
self.noSelectionInfo.cell.backgroundStyle = NSBackgroundStyleRaised;
|
self.noSelectionInfo.cell.backgroundStyle = NSBackgroundStyleRaised;
|
||||||
self.itemImageView.cell.backgroundStyle = NSBackgroundStyleRaised;
|
self.itemImageView.cell.backgroundStyle = NSBackgroundStyleRaised;
|
||||||
[self.tabView bind:NSSelectedIndexBinding toObject:self withKeyPath:NSStringFromSelector(@selector(activeTab)) options:nil];
|
[self.tabView bind:NSSelectedIndexBinding toObject:self withKeyPath:NSStringFromSelector(@selector(activeTab)) options:nil];
|
||||||
@@ -117,11 +109,7 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
|
|||||||
[groupTabView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[groupView]|" options:0 metrics:nil views:views]];
|
[groupTabView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[groupView]|" options:0 metrics:nil views:views]];
|
||||||
groupTabItem.initialFirstResponder = groupView;
|
groupTabItem.initialFirstResponder = groupView;
|
||||||
|
|
||||||
[self.view layout];
|
[self.view layout];}
|
||||||
|
|
||||||
self.discardChangesButton.hidden = YES;
|
|
||||||
self.saveChangesButton.hidden = YES;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)registerNotificationsForDocument:(MPDocument *)document {
|
- (void)registerNotificationsForDocument:(MPDocument *)document {
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
@@ -142,44 +130,37 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
|
|||||||
[self.groupViewController registerNotificationsForDocument:document];
|
[self.groupViewController registerNotificationsForDocument:document];
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark - Properties
|
||||||
#pragma mark Properties
|
|
||||||
- (void)setActiveTab:(NSUInteger)activeTab {
|
- (void)setActiveTab:(NSUInteger)activeTab {
|
||||||
if(_activeTab != activeTab) {
|
if(_activeTab != activeTab) {
|
||||||
_activeTab = activeTab;
|
_activeTab = activeTab;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setModificationDate:(NSDate *)modificationDate {
|
#pragma mark - TextViewDelegate
|
||||||
_modificationDate = modificationDate;
|
- (BOOL)textView:(NSTextView *)textView performAction:(SEL)action {
|
||||||
[self _updateDateStrings];
|
if(action == @selector(copy:)) {
|
||||||
}
|
MPPasteboardOverlayInfoType info = MPPasteboardOverlayInfoCustom;
|
||||||
|
NSMutableString *selectedString = [[NSMutableString alloc] initWithCapacity:MAX(1,textView.string.length)];
|
||||||
- (void)setCreationDate:(NSDate *)creationDate {
|
NSString *string = textView.string;
|
||||||
_creationDate = creationDate;
|
for(NSValue *rangeValue in textView.selectedRanges) {
|
||||||
[self _updateDateStrings];
|
if(rangeValue.rangeValue.length != 0) {
|
||||||
}
|
[selectedString appendString:[string substringWithRange:rangeValue.rangeValue]];
|
||||||
|
}
|
||||||
- (void)_updateDateStrings {
|
}
|
||||||
|
NSString *name = @"";
|
||||||
if(!self.creationDate || !self.modificationDate ) {
|
if(selectedString.length == 0) {
|
||||||
[self.modifiedTextField setStringValue:@""];
|
return YES;
|
||||||
[self.createdTextField setStringValue:@""];
|
}
|
||||||
return; // No dates, just clear
|
if(textView == self.notesTextView) {
|
||||||
|
name = NSLocalizedString(@"NOTES", "Displayed name when notes or part of notes was copied");
|
||||||
|
}
|
||||||
|
[[MPPasteBoardController defaultController] copyObjects:@[selectedString] overlayInfo:info name:name atView:self.view];
|
||||||
|
return NO;
|
||||||
}
|
}
|
||||||
|
return YES;
|
||||||
NSString *creationString = [self.creationDate humanized];
|
|
||||||
NSString *modificationString = [self.modificationDate humanized];
|
|
||||||
|
|
||||||
NSString *modifedAtTemplate = NSLocalizedString(@"MODIFED_AT_%@", @"Modifed at template string. %@ is replaced by locaized date and time");
|
|
||||||
NSString *createdAtTemplate = NSLocalizedString(@"CREATED_AT_%@", @"Created at template string. %@ is replaced by locaized date and time");
|
|
||||||
|
|
||||||
self.modifiedTextField.stringValue = [NSString stringWithFormat:modifedAtTemplate, modificationString];
|
|
||||||
self.createdTextField.stringValue = [NSString stringWithFormat:createdAtTemplate, creationString];
|
|
||||||
}
|
}
|
||||||
|
#pragma mark - Popup
|
||||||
#pragma mark -
|
|
||||||
#pragma mark Popup
|
|
||||||
- (IBAction)pickIcon:(id)sender {
|
- (IBAction)pickIcon:(id)sender {
|
||||||
NSAssert([sender isKindOfClass:NSView.class], @"");
|
NSAssert([sender isKindOfClass:NSView.class], @"");
|
||||||
[self _popupViewController:[[MPIconSelectViewController alloc] init] atView:sender];
|
[self _popupViewController:[[MPIconSelectViewController alloc] init] atView:sender];
|
||||||
@@ -209,16 +190,14 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark - NSPopover Delegate
|
||||||
#pragma mark NSPopover Delegate
|
|
||||||
|
|
||||||
- (void)popoverDidClose:(NSNotification *)notification {
|
- (void)popoverDidClose:(NSNotification *)notification {
|
||||||
/* clear out the popover */
|
/* clear out the popover */
|
||||||
self.popover = nil;
|
self.popover = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark - MPDocument Notifications
|
||||||
#pragma mark MPDocument Notifications
|
|
||||||
- (void)_willChangeModelProperty:(NSNotification *)notification {
|
- (void)_willChangeModelProperty:(NSNotification *)notification {
|
||||||
/* TODO use uuids for pushed item? */
|
/* TODO use uuids for pushed item? */
|
||||||
if(self.didPushHistory) {
|
if(self.didPushHistory) {
|
||||||
|
|||||||
Reference in New Issue
Block a user