2006-09-04 18:06:23 +00:00
|
|
|
//
|
|
|
|
// HotKeyPane.m
|
|
|
|
// Preferences
|
|
|
|
//
|
2006-09-04 18:46:18 +00:00
|
|
|
// Created by Vincent Spader on 9/4/06.
|
|
|
|
// Copyright 2006 Vincent Spader. All rights reserved.
|
2006-09-04 18:06:23 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
#import "HotKeyPane.h"
|
2013-10-11 16:37:45 +00:00
|
|
|
#import "NDHotKey/NDHotKeyEvent.h"
|
|
|
|
#import "NDHotKey/NDKeyboardLayout.h"
|
|
|
|
#import "HotKeyControl.h"
|
2006-09-04 18:06:23 +00:00
|
|
|
|
|
|
|
@implementation HotKeyPane
|
|
|
|
|
2013-10-11 16:37:45 +00:00
|
|
|
static void setControlText(HotKeyControl* control, NSString* kcprop, NSString* mprop)
|
2009-03-08 01:49:50 +00:00
|
|
|
{
|
2013-10-11 16:37:45 +00:00
|
|
|
UInt16 keyCode = [[NSUserDefaults standardUserDefaults] integerForKey:kcprop];
|
|
|
|
NSUInteger modifiers = [[NSUserDefaults standardUserDefaults] integerForKey:mprop];
|
|
|
|
NSString *str = [[NDKeyboardLayout keyboardLayout] stringForKeyCode:keyCode modifierFlags:modifiers];
|
|
|
|
[control setStringValue:str];
|
2009-03-08 01:49:50 +00:00
|
|
|
}
|
|
|
|
|
2013-10-11 16:37:45 +00:00
|
|
|
- (void)awakeFromNib
|
2006-09-10 21:27:20 +00:00
|
|
|
{
|
2013-10-11 16:37:45 +00:00
|
|
|
setControlText(prevHotKeyControl, @"hotKeyPreviousKeyCode", @"hotKeyPreviousModifiers");
|
|
|
|
setControlText(nextHotKeyControl, @"hotKeyNextKeyCode", @"hotKeyNextModifiers");
|
|
|
|
setControlText(playHotKeyControl, @"hotKeyPlayKeyCode", @"hotKeyPlayModifiers");
|
|
|
|
setControlText(spamHotKeyControl, @"hotKeySpamKeyCode", @"hotKeySpamModifiers");
|
2006-09-10 21:27:20 +00:00
|
|
|
}
|
|
|
|
|
2013-10-11 16:37:45 +00:00
|
|
|
- (NSString *)title
|
2006-09-10 21:27:20 +00:00
|
|
|
{
|
2013-10-11 16:37:45 +00:00
|
|
|
return NSLocalizedStringFromTableInBundle(@"Hot Keys", nil, [NSBundle bundleForClass:[self class]], @"");
|
2006-09-10 21:27:20 +00:00
|
|
|
}
|
|
|
|
|
2013-10-11 16:37:45 +00:00
|
|
|
- (NSImage *)icon
|
2013-10-04 11:16:09 +00:00
|
|
|
{
|
2013-10-11 16:37:45 +00:00
|
|
|
return [[[NSImage alloc] initWithContentsOfFile:[[NSBundle bundleForClass:[self class]] pathForImageResource:@"hot_keys"]] autorelease];
|
2013-10-04 11:16:09 +00:00
|
|
|
}
|
|
|
|
|
2006-09-10 21:27:20 +00:00
|
|
|
- (IBAction) hotKeyChanged:(id)sender
|
|
|
|
{
|
2013-10-11 16:37:45 +00:00
|
|
|
if (sender == playHotKeyControl) {
|
|
|
|
[[NSUserDefaults standardUserDefaults] setInteger:[playHotKeyControl modifierFlags] forKey:@"hotKeyPlayModifiers"];
|
|
|
|
[[NSUserDefaults standardUserDefaults] setInteger:[playHotKeyControl keyCode] forKey:@"hotKeyPlayKeyCode"];
|
|
|
|
}
|
|
|
|
else if (sender == prevHotKeyControl) {
|
|
|
|
[[NSUserDefaults standardUserDefaults] setInteger:[prevHotKeyControl modifierFlags] forKey:@"hotKeyPreviousModifiers"];
|
|
|
|
[[NSUserDefaults standardUserDefaults] setInteger:[prevHotKeyControl keyCode] forKey:@"hotKeyPreviousKeyCode"];
|
|
|
|
}
|
|
|
|
else if (sender == nextHotKeyControl) {
|
|
|
|
[[NSUserDefaults standardUserDefaults] setInteger:[nextHotKeyControl modifierFlags] forKey:@"hotKeyNextModifiers"];
|
|
|
|
[[NSUserDefaults standardUserDefaults] setInteger:[nextHotKeyControl keyCode] forKey:@"hotKeyNextKeyCode"];
|
|
|
|
}
|
|
|
|
else if (sender == spamHotKeyControl) {
|
|
|
|
[[NSUserDefaults standardUserDefaults] setInteger:[nextHotKeyControl modifierFlags] forKey:@"hotKeySpamModifiers"];
|
|
|
|
[[NSUserDefaults standardUserDefaults] setInteger:[nextHotKeyControl keyCode] forKey:@"hotKeySpamKeyCode"];
|
|
|
|
}
|
2006-09-04 18:06:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|