diff --git a/MacPass/Base.lproj/IntegrationSettings.xib b/MacPass/Base.lproj/IntegrationSettings.xib index a4ad7d45..f0d77e1f 100644 --- a/MacPass/Base.lproj/IntegrationSettings.xib +++ b/MacPass/Base.lproj/IntegrationSettings.xib @@ -1,5 +1,5 @@ - + @@ -10,6 +10,7 @@ + diff --git a/MacPass/DDHotKey+Keydata.h b/MacPass/DDHotKey+Keydata.h index f2c707ad..73697c44 100644 --- a/MacPass/DDHotKey+Keydata.h +++ b/MacPass/DDHotKey+Keydata.h @@ -10,6 +10,8 @@ @interface DDHotKey (Keydata) ++ (instancetype)defaultHotKey; ++ (instancetype)defaultHotKeyWithTask:(DDHotKeyTask)task; - (NSData *)keyData; - (instancetype)initWithKeyData:(NSData *)data taks:(DDHotKeyTask)task; - (instancetype)initWithKeyData:(NSData *)data; diff --git a/MacPass/DDHotKey+Keydata.m b/MacPass/DDHotKey+Keydata.m index e45c9991..e29bd887 100644 --- a/MacPass/DDHotKey+Keydata.m +++ b/MacPass/DDHotKey+Keydata.m @@ -7,9 +7,18 @@ // #import "DDHotKey+Keydata.h" +#import @implementation DDHotKey (Keydata) ++ (instancetype)defaultHotKey { + return [DDHotKey defaultHotKeyWithTask:nil]; +} + ++ (instancetype)defaultHotKeyWithTask:(DDHotKeyTask)task { + return [[DDHotKey alloc] initWithKeyData:nil]; +} + - (instancetype)initWithKeyData:(NSData *)data { self = [self initWithKeyData:data taks:nil]; return self; @@ -18,7 +27,10 @@ - (instancetype)initWithKeyData:(NSData *)data taks:(DDHotKeyTask)task{ NSUInteger modifierFlags; unsigned short keyCode; - if([self _getKeyCode:&keyCode modifierFlags:&modifierFlags fromData:data]) { + if(!data) { + self = [DDHotKey hotKeyWithKeyCode:kVK_ANSI_M modifierFlags:kCGEventFlagMaskControl|kCGEventFlagMaskAlternate task:task]; + } + else if([self _getKeyCode:&keyCode modifierFlags:&modifierFlags fromData:data]) { self = [DDHotKey hotKeyWithKeyCode:keyCode modifierFlags:modifierFlags task:task]; } else { diff --git a/MacPass/MPAutotypeDaemon.m b/MacPass/MPAutotypeDaemon.m index c94fe56d..e729779a 100644 --- a/MacPass/MPAutotypeDaemon.m +++ b/MacPass/MPAutotypeDaemon.m @@ -197,7 +197,7 @@ NSString *const kMPApplciationNameKey = @"applicationName"; }; DDHotKey *storedHotkey; if(nil == self.hotKeyData) { - storedHotkey = [DDHotKey hotKeyWithKeyCode:kVK_ANSI_M modifierFlags:kCGEventFlagMaskControl|kCGEventFlagMaskAlternate task:aTask]; + storedHotkey = [DDHotKey defaultHotKeyWithTask:aTask]; } else { storedHotkey = [[DDHotKey alloc] initWithKeyData:self.hotKeyData taks:aTask]; diff --git a/MacPass/MPDocumentWindowController.m b/MacPass/MPDocumentWindowController.m index 86151cef..107ce2f0 100644 --- a/MacPass/MPDocumentWindowController.m +++ b/MacPass/MPDocumentWindowController.m @@ -377,7 +377,7 @@ typedef void (^MPPasswordChangedBlock)(void); } /* Maybe we should consider not double adding constraints */ NSDictionary *views = NSDictionaryOfVariableBindings(outlineView, inspectorView, entryView, _splitView); - [self.splitView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[outlineView(>=150,<=250)]-1-[entryView(>=350)]-1-[inspectorView(>=200)]|" + [self.splitView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[outlineView(>=150)]-1-[entryView(>=350)]-1-[inspectorView(>=200)]|" options:0 metrics:nil views:views]]; diff --git a/MacPass/MPIntegrationSettingsController.h b/MacPass/MPIntegrationSettingsController.h index 170d8e24..f22a31ee 100644 --- a/MacPass/MPIntegrationSettingsController.h +++ b/MacPass/MPIntegrationSettingsController.h @@ -9,10 +9,13 @@ #import "MPViewController.h" #import "MPSettingsTab.h" +@class DDHotKeyTextField; + @interface MPIntegrationSettingsController : MPViewController @property (weak) IBOutlet NSButton *enableServerCheckbutton; @property (weak) IBOutlet NSButton *enableGlobalAutotypeCheckbutton; @property (weak) IBOutlet NSButton *enableQuicklookCheckbutton; +@property (weak) IBOutlet DDHotKeyTextField *hotKeyTextField; @end diff --git a/MacPass/MPIntegrationSettingsController.m b/MacPass/MPIntegrationSettingsController.m index 2ca34d27..418f4d1f 100644 --- a/MacPass/MPIntegrationSettingsController.m +++ b/MacPass/MPIntegrationSettingsController.m @@ -10,9 +10,13 @@ #import "MPSettingsHelper.h" #import "MPIconHelper.h" +#import "DDHotKeyCenter.h" +#import "DDHotKey+Keydata.h" +#import "DDHotKeyTextField.h" + @interface MPIntegrationSettingsController () -@property (copy) NSData *globalAutotypeKeyData; +@property (nonatomic, copy) NSData *globalAutotypeKeyData; @end @@ -45,7 +49,16 @@ [self.enableGlobalAutotypeCheckbutton bind:NSValueBinding toObject:defaultsController withKeyPath:globalAutotypeKeyPath options:nil]; [self.enableQuicklookCheckbutton bind:NSValueBinding toObject:defaultsController withKeyPath:quicklookKeyPath options:nil]; [self.globalAutotypeKeyData bind:NSValueBinding toObject:defaultsController withKeyPath:globalAutotypeDataKeyPath options:nil]; - } +#pragma mark Properties +- (void)setGlobalAutotypeKeyData:(NSData *)globalAutotypeKeyData { + if(![_globalAutotypeKeyData isEqualToData:globalAutotypeKeyData]) { + _globalAutotypeKeyData = [globalAutotypeKeyData copy]; + } + DDHotKey *hotKey = [[DDHotKey alloc] initWithKeyData:_globalAutotypeKeyData]; + self.hotKeyTextField.hotKey = hotKey; +} + + @end