mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 10:32:26 +00:00
Autotype Hotkey refactorings
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="5056" systemVersion="13D65" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="5056" systemVersion="13E28" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<deployment defaultVersion="1080" identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="5056"/>
|
||||
@@ -10,6 +10,7 @@
|
||||
<outlet property="enableGlobalAutotypeCheckbutton" destination="tik-Ar-FJg" id="d2f-69-2BP"/>
|
||||
<outlet property="enableQuicklookCheckbutton" destination="LNw-5t-TS4" id="NRN-7y-W0e"/>
|
||||
<outlet property="enableServerCheckbutton" destination="2" id="17"/>
|
||||
<outlet property="hotKeyTextField" destination="Kvg-he-3c8" id="c7p-1F-zth"/>
|
||||
<outlet property="view" destination="1" id="18"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -7,9 +7,18 @@
|
||||
//
|
||||
|
||||
#import "DDHotKey+Keydata.h"
|
||||
#import <Carbon/Carbon.h>
|
||||
|
||||
@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 {
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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]];
|
||||
|
||||
@@ -9,10 +9,13 @@
|
||||
#import "MPViewController.h"
|
||||
#import "MPSettingsTab.h"
|
||||
|
||||
@class DDHotKeyTextField;
|
||||
|
||||
@interface MPIntegrationSettingsController : MPViewController <MPSettingsTab>
|
||||
|
||||
@property (weak) IBOutlet NSButton *enableServerCheckbutton;
|
||||
@property (weak) IBOutlet NSButton *enableGlobalAutotypeCheckbutton;
|
||||
@property (weak) IBOutlet NSButton *enableQuicklookCheckbutton;
|
||||
@property (weak) IBOutlet DDHotKeyTextField *hotKeyTextField;
|
||||
|
||||
@end
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user