forked from eczarny/spectacle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SpectacleWindowActionController.m
115 lines (82 loc) · 3.5 KB
/
SpectacleWindowActionController.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#import "SpectacleWindowActionController.h"
#import "SpectacleWindowPositionManager.h"
#import "SpectacleHotKeyManager.h"
#import "SpectacleUtilities.h"
#import "SpectacleConstants.h"
@implementation SpectacleWindowActionController
- (id)init {
if (self = [super init]) {
windowPositionManager = [SpectacleWindowPositionManager sharedManager];
hotKeyManager = [SpectacleHotKeyManager sharedManager];
}
return self;
}
#pragma mark -
- (void)registerHotKeys {
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
NSMutableDictionary *hotKeysFromUserDefaults = [NSMutableDictionary new];
for (NSString *hotKeyName in [SpectacleUtilities hotKeyNames]) {
hotKeysFromUserDefaults[hotKeyName] = [userDefaults dataForKey: hotKeyName];
}
NSArray *hotKeys = [SpectacleUtilities hotKeysFromDictionary: hotKeysFromUserDefaults action: ^(ZKHotKey *hotKey) {
[windowPositionManager moveFrontMostWindowWithAction: [windowPositionManager windowActionForHotKey: hotKey]];
}];
[hotKeyManager registerHotKeys: hotKeys];
}
#pragma mark -
- (IBAction)moveFrontMostWindowToCenter: (id)sender {
[windowPositionManager moveFrontMostWindowWithAction: SpectacleWindowActionCenter];
}
#pragma mark -
- (IBAction)moveFrontMostWindowToFullscreen: (id)sender {
[windowPositionManager moveFrontMostWindowWithAction: SpectacleWindowActionFullscreen];
}
#pragma mark -
- (IBAction)moveFrontMostWindowToLeftHalf: (id)sender {
[windowPositionManager moveFrontMostWindowWithAction: SpectacleWindowActionLeftHalf];
}
- (IBAction)moveFrontMostWindowToRightHalf: (id)sender {
[windowPositionManager moveFrontMostWindowWithAction: SpectacleWindowActionRightHalf];
}
- (IBAction)moveFrontMostWindowToTopHalf: (id)sender {
[windowPositionManager moveFrontMostWindowWithAction: SpectacleWindowActionTopHalf];
}
- (IBAction)moveFrontMostWindowToBottomHalf: (id)sender {
[windowPositionManager moveFrontMostWindowWithAction: SpectacleWindowActionBottomHalf];
}
#pragma mark -
- (IBAction)moveFrontMostWindowToUpperLeft: (id)sender {
[windowPositionManager moveFrontMostWindowWithAction: SpectacleWindowActionUpperLeft];
}
- (IBAction)moveFrontMostWindowToLowerLeft: (id)sender {
[windowPositionManager moveFrontMostWindowWithAction: SpectacleWindowActionLowerLeft];
}
#pragma mark -
- (IBAction)moveFrontMostWindowToUpperRight: (id)sender {
[windowPositionManager moveFrontMostWindowWithAction: SpectacleWindowActionUpperRight];
}
- (IBAction)moveFrontMostWindowToLowerRight: (id)sender {
[windowPositionManager moveFrontMostWindowWithAction: SpectacleWindowActionLowerRight];
}
#pragma mark -
- (IBAction)moveFrontMostWindowToNextDisplay: (id)sender {
[windowPositionManager moveFrontMostWindowWithAction: SpectacleWindowActionNextDisplay];
}
- (IBAction)moveFrontMostWindowToPreviousDisplay: (id)sender {
[windowPositionManager moveFrontMostWindowWithAction: SpectacleWindowActionPreviousDisplay];
}
#pragma mark -
- (IBAction)moveFrontMostWindowToNextThird: (id)sender {
[windowPositionManager moveFrontMostWindowWithAction: SpectacleWindowActionNextThird];
}
- (IBAction)moveFrontMostWindowToPreviousThird: (id)sender {
[windowPositionManager moveFrontMostWindowWithAction: SpectacleWindowActionPreviousThird];
}
#pragma mark -
- (IBAction)undoLastWindowAction: (id)sender {
[windowPositionManager undoLastWindowAction];
}
- (IBAction)redoLastWindowAction: (id)sender {
[windowPositionManager redoLastWindowAction];
}
@end