-
Notifications
You must be signed in to change notification settings - Fork 84
/
PreferencesWindowController.m
65 lines (49 loc) · 2.19 KB
/
PreferencesWindowController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//
// PreferencesWindowController.m
// Thyme
//
// Created by João on 3/18/13.
//
//
#import "PreferencesWindowController.h"
@interface PreferencesWindowController ()
- (void)onWindowResignKey;
@end
@implementation PreferencesWindowController
@synthesize startPauseShortcutRecorder;
@synthesize restartShortcutRecorder;
@synthesize finishShortcutRecorder;
@synthesize pauseOnSleepButton;
@synthesize pauseOnScreensaverButton;
@synthesize askForTagOnFinishButton;
- (id)initWithWindow:(NSWindow *)window
{
self = [super initWithWindow:window];
if (self) {
// Initialization code here.
}
return self;
}
- (void)windowDidLoad
{
[super windowDidLoad];
NSUserDefaultsController *defaults = [NSUserDefaultsController sharedUserDefaultsController];
[self.startPauseShortcutRecorder bind:NSValueBinding toObject:defaults withKeyPath:@"values.startPause" options:nil];
[self.restartShortcutRecorder bind:NSValueBinding toObject:defaults withKeyPath:@"values.restart" options:nil];
[self.finishShortcutRecorder bind:NSValueBinding toObject:defaults withKeyPath:@"values.finish" options:nil];
[self.pauseOnSleepButton bind:NSValueBinding toObject:defaults withKeyPath:@"values.pauseOnSleep" options:nil];
[self.pauseOnScreensaverButton bind:NSValueBinding toObject:defaults withKeyPath:@"values.pauseOnScreensaver" options:nil];
[self.askForTagOnFinishButton bind:NSValueBinding toObject:defaults withKeyPath:@"values.askForTagOnFinishButton" options:nil];
[self.startPauseShortcutRecorder clearButtonRect];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onWindowResignKey) name:NSWindowDidResignKeyNotification object:nil];
}
- (void)onWindowResignKey {
[self.window close];
}
#pragma mark SRRecorderControlDelegate
- (BOOL)shortcutRecorder:(SRRecorderControl *)aRecorder canRecordShortcut:(NSDictionary *)aShortcut {
return !SRShortcutEqualToShortcut([self.startPauseShortcutRecorder objectValue], aShortcut) &&
!SRShortcutEqualToShortcut([self.restartShortcutRecorder objectValue], aShortcut) &&
!SRShortcutEqualToShortcut([self.finishShortcutRecorder objectValue], aShortcut);
}
@end