Preparations to save global hotkey for auto type in preferences

This commit is contained in:
michael starke
2014-03-26 00:14:29 +01:00
parent bce6af80ce
commit 478be2b9d9
5 changed files with 54 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
//
// DDHotKey+Coding.h
// MacPass
//
// Created by Michael Starke on 25/03/14.
// Copyright (c) 2014 HicknHack Software GmbH. All rights reserved.
//
#import "DDHotKeyCenter.h"
@interface DDHotKey (Keydata)
- (NSData *)keyData;
- (instancetype)initWithKeyData:(NSData *)data;
@end

View File

@@ -0,0 +1,30 @@
//
// DDHotKey+Coding.m
// MacPass
//
// Created by Michael Starke on 25/03/14.
// Copyright (c) 2014 HicknHack Software GmbH. All rights reserved.
//
#import "DDHotKey+Keydata.h"
@implementation DDHotKey (Keydata)
- (instancetype)initWithKeyData:(NSData *)data {
NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data];
unsigned short keyCode = [unarchiver decodeIntForKey:NSStringFromSelector(@selector(keyCode))];
NSUInteger modiferFlags = [unarchiver decodeIntegerForKey:NSStringFromSelector(@selector(modifierFlags))];
self = [DDHotKey hotKeyWithKeyCode:keyCode modifierFlags:modiferFlags task:nil];
return self;
}
- (NSData *)keyData {
NSMutableData *data = [[NSMutableData alloc] init];
NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];
[archiver encodeInt:self.keyCode forKey:NSStringFromSelector(@selector(keyCode))];
[archiver encodeInteger:self.modifierFlags forKey:NSStringFromSelector(@selector(modifierFlags))];
[archiver finishEncoding];
return [data copy];
}
@end

View File

@@ -49,6 +49,7 @@ APPKIT_EXTERN NSString *const kMPSettingsKeyRememberKeyFilesForDatabases;
/* Autotype */
APPKIT_EXTERN NSString *const kMPSettingsKeySendCommandForControlKey;
APPKIT_EXTERN NSString *const kMPSettingsKeyEnableGlobalAutotype;
APPKIT_EXTERN NSString *const kMPSettingsKeyGlobalAutotypeKeyKey;
/* Search */
APPKIT_EXTERN NSString *const kMPSettingsKeyEntrySearchFilterMode;

View File

@@ -34,6 +34,7 @@ NSString *const kMPSettingsKeyRememberKeyFilesForDatabases = @"RememberKeyFiles
NSString *const kMPSettingsKeySendCommandForControlKey = @"SendCommandKeyForControlKey";
NSString *const kMPSettingsKeyEnableGlobalAutotype = @"EnableGlobalAutotype";
NSString *const kMPSettingsKeyGlobalAutotypeKeyKey = @"GlobalAutotypeKey";
NSString *const kMPSettingsKeyEntrySearchFilterMode = @"EntrySearchFilterMode";