Added node expiration view controller

This commit is contained in:
Michael Starke
2021-10-23 23:31:43 +02:00
parent 98730e7f24
commit fc186aaf2c
5 changed files with 37 additions and 12 deletions

View File

@@ -7,10 +7,11 @@
//
#import <Cocoa/Cocoa.h>
#import "MPInspectorEditor.h"
NS_ASSUME_NONNULL_BEGIN
@interface MPNodeExpirationViewController : NSViewController
@interface MPNodeExpirationViewController : NSViewController <MPInspectorEditor>
@end

View File

@@ -7,24 +7,39 @@
//
#import "MPNodeExpirationViewController.h"
#import "MPInspectorViewController.h"
#import "MPValueTransformerHelper.h"
#import <KeePassKit/KeePassKit.h>
@interface MPNodeExpirationViewController ()
@property (nonatomic, readonly, strong) KPKTimeInfo *representedTimeInfo;
@property (strong) IBOutlet NSButton *expiredCheckButton;
@property (strong) IBOutlet NSButton *pickExpireDateButton;
@end
@implementation MPNodeExpirationViewController
@synthesize isEditor = _isEditor;
- (void)viewDidLoad {
[super viewDidLoad];
self.pickExpireDateButton.action = @selector(pickExpiryDate:);
[self _updateValues];
}
- (KPKTimeInfo *)representedTimeInfo {
if([self.representedObject isKindOfClass:KPKTimeInfo.class]) {
return self.representedObject;
}
return nil;
}
- (void)setRepresentedObject:(id)representedObject {
/*if(self.representedTimeInfo) {
[NSNotificationCenter.defaultCenter removeObserver:self name:KPKWillChangeTimeInfo object:self.representedTimeInfo];
[NSNotificationCenter.defaultCenter removeObserver:self name:KPKDidChangeTimeInfo object:self.representedTimeInfo];
if(self.representedTimeInfo) {
[NSNotificationCenter.defaultCenter removeObserver:self name:KPKWillChangeTimeInfoNotification object:self.representedTimeInfo];
[NSNotificationCenter.defaultCenter removeObserver:self name:KPKDidChangeTimeInfoNotification object:self.representedTimeInfo];
}
super.representedObject = representedObject;
if(self.representedTimeInfo) {
@@ -38,20 +53,27 @@
object:self.representedTimeInfo];
}
_isDefaultAttribute = self.representedAttribute.isDefault;
[self _updateValues];*/
[self _updateValues];
}
- (void)setIsEditor:(BOOL)isEditor {
[self _updateValues];
}
- (void)_updateValues {
self.view.hidden = self.representedTimeInfo.expires;
self.expiredCheckButton.state = HNHUIStateForBool(self.representedTimeInfo.expires);
NSValueTransformer *dateTransformer = [NSValueTransformer valueTransformerForName:MPExpiryDateValueTransformerName];
self.expiredCheckButton.title = [dateTransformer transformedValue:self.representedTimeInfo.expirationDate];
self.expiredCheckButton.enabled = self.isEditor;
self.pickExpireDateButton.enabled = self.isEditor;
}
- (void)_willChangeTimeInfo:(NSNotification *)notification {
}
- (void)_willChangeTimeInfo:(NSNotification *)notification {}
- (void)_didChangeTimeInfo:(NSNotification *)notification {
[self _updateValues];
}
@end

View File

@@ -8,6 +8,8 @@
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="MPNodeExpirationViewController">
<connections>
<outlet property="expiredCheckButton" destination="HAQ-Wk-M7P" id="C1J-nJ-Cdz"/>
<outlet property="pickExpireDateButton" destination="G7C-WZ-ad7" id="zvU-TW-Mar"/>
<outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
</connections>
</customObject>