mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 11:42:30 +00:00
Autotype Hotkey refactorings
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?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>
|
<dependencies>
|
||||||
<deployment defaultVersion="1080" identifier="macosx"/>
|
<deployment defaultVersion="1080" identifier="macosx"/>
|
||||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="5056"/>
|
<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="enableGlobalAutotypeCheckbutton" destination="tik-Ar-FJg" id="d2f-69-2BP"/>
|
||||||
<outlet property="enableQuicklookCheckbutton" destination="LNw-5t-TS4" id="NRN-7y-W0e"/>
|
<outlet property="enableQuicklookCheckbutton" destination="LNw-5t-TS4" id="NRN-7y-W0e"/>
|
||||||
<outlet property="enableServerCheckbutton" destination="2" id="17"/>
|
<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"/>
|
<outlet property="view" destination="1" id="18"/>
|
||||||
</connections>
|
</connections>
|
||||||
</customObject>
|
</customObject>
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
@interface DDHotKey (Keydata)
|
@interface DDHotKey (Keydata)
|
||||||
|
|
||||||
|
+ (instancetype)defaultHotKey;
|
||||||
|
+ (instancetype)defaultHotKeyWithTask:(DDHotKeyTask)task;
|
||||||
- (NSData *)keyData;
|
- (NSData *)keyData;
|
||||||
- (instancetype)initWithKeyData:(NSData *)data taks:(DDHotKeyTask)task;
|
- (instancetype)initWithKeyData:(NSData *)data taks:(DDHotKeyTask)task;
|
||||||
- (instancetype)initWithKeyData:(NSData *)data;
|
- (instancetype)initWithKeyData:(NSData *)data;
|
||||||
|
|||||||
@@ -7,9 +7,18 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import "DDHotKey+Keydata.h"
|
#import "DDHotKey+Keydata.h"
|
||||||
|
#import <Carbon/Carbon.h>
|
||||||
|
|
||||||
@implementation DDHotKey (Keydata)
|
@implementation DDHotKey (Keydata)
|
||||||
|
|
||||||
|
+ (instancetype)defaultHotKey {
|
||||||
|
return [DDHotKey defaultHotKeyWithTask:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (instancetype)defaultHotKeyWithTask:(DDHotKeyTask)task {
|
||||||
|
return [[DDHotKey alloc] initWithKeyData:nil];
|
||||||
|
}
|
||||||
|
|
||||||
- (instancetype)initWithKeyData:(NSData *)data {
|
- (instancetype)initWithKeyData:(NSData *)data {
|
||||||
self = [self initWithKeyData:data taks:nil];
|
self = [self initWithKeyData:data taks:nil];
|
||||||
return self;
|
return self;
|
||||||
@@ -18,7 +27,10 @@
|
|||||||
- (instancetype)initWithKeyData:(NSData *)data taks:(DDHotKeyTask)task{
|
- (instancetype)initWithKeyData:(NSData *)data taks:(DDHotKeyTask)task{
|
||||||
NSUInteger modifierFlags;
|
NSUInteger modifierFlags;
|
||||||
unsigned short keyCode;
|
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];
|
self = [DDHotKey hotKeyWithKeyCode:keyCode modifierFlags:modifierFlags task:task];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ NSString *const kMPApplciationNameKey = @"applicationName";
|
|||||||
};
|
};
|
||||||
DDHotKey *storedHotkey;
|
DDHotKey *storedHotkey;
|
||||||
if(nil == self.hotKeyData) {
|
if(nil == self.hotKeyData) {
|
||||||
storedHotkey = [DDHotKey hotKeyWithKeyCode:kVK_ANSI_M modifierFlags:kCGEventFlagMaskControl|kCGEventFlagMaskAlternate task:aTask];
|
storedHotkey = [DDHotKey defaultHotKeyWithTask:aTask];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
storedHotkey = [[DDHotKey alloc] initWithKeyData:self.hotKeyData taks:aTask];
|
storedHotkey = [[DDHotKey alloc] initWithKeyData:self.hotKeyData taks:aTask];
|
||||||
|
|||||||
@@ -377,7 +377,7 @@ typedef void (^MPPasswordChangedBlock)(void);
|
|||||||
}
|
}
|
||||||
/* Maybe we should consider not double adding constraints */
|
/* Maybe we should consider not double adding constraints */
|
||||||
NSDictionary *views = NSDictionaryOfVariableBindings(outlineView, inspectorView, entryView, _splitView);
|
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
|
options:0
|
||||||
metrics:nil
|
metrics:nil
|
||||||
views:views]];
|
views:views]];
|
||||||
|
|||||||
@@ -9,10 +9,13 @@
|
|||||||
#import "MPViewController.h"
|
#import "MPViewController.h"
|
||||||
#import "MPSettingsTab.h"
|
#import "MPSettingsTab.h"
|
||||||
|
|
||||||
|
@class DDHotKeyTextField;
|
||||||
|
|
||||||
@interface MPIntegrationSettingsController : MPViewController <MPSettingsTab>
|
@interface MPIntegrationSettingsController : MPViewController <MPSettingsTab>
|
||||||
|
|
||||||
@property (weak) IBOutlet NSButton *enableServerCheckbutton;
|
@property (weak) IBOutlet NSButton *enableServerCheckbutton;
|
||||||
@property (weak) IBOutlet NSButton *enableGlobalAutotypeCheckbutton;
|
@property (weak) IBOutlet NSButton *enableGlobalAutotypeCheckbutton;
|
||||||
@property (weak) IBOutlet NSButton *enableQuicklookCheckbutton;
|
@property (weak) IBOutlet NSButton *enableQuicklookCheckbutton;
|
||||||
|
@property (weak) IBOutlet DDHotKeyTextField *hotKeyTextField;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -10,9 +10,13 @@
|
|||||||
#import "MPSettingsHelper.h"
|
#import "MPSettingsHelper.h"
|
||||||
#import "MPIconHelper.h"
|
#import "MPIconHelper.h"
|
||||||
|
|
||||||
|
#import "DDHotKeyCenter.h"
|
||||||
|
#import "DDHotKey+Keydata.h"
|
||||||
|
#import "DDHotKeyTextField.h"
|
||||||
|
|
||||||
@interface MPIntegrationSettingsController ()
|
@interface MPIntegrationSettingsController ()
|
||||||
|
|
||||||
@property (copy) NSData *globalAutotypeKeyData;
|
@property (nonatomic, copy) NSData *globalAutotypeKeyData;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@@ -45,7 +49,16 @@
|
|||||||
[self.enableGlobalAutotypeCheckbutton bind:NSValueBinding toObject:defaultsController withKeyPath:globalAutotypeKeyPath options:nil];
|
[self.enableGlobalAutotypeCheckbutton bind:NSValueBinding toObject:defaultsController withKeyPath:globalAutotypeKeyPath options:nil];
|
||||||
[self.enableQuicklookCheckbutton bind:NSValueBinding toObject:defaultsController withKeyPath:quicklookKeyPath options:nil];
|
[self.enableQuicklookCheckbutton bind:NSValueBinding toObject:defaultsController withKeyPath:quicklookKeyPath options:nil];
|
||||||
[self.globalAutotypeKeyData bind:NSValueBinding toObject:defaultsController withKeyPath:globalAutotypeDataKeyPath 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
|
@end
|
||||||
|
|||||||
Reference in New Issue
Block a user