This repository has been archived by the owner on Jan 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 833
/
SpectacleWindowActionController.m
108 lines (77 loc) · 3.34 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
#import "SpectacleWindowActionController.h"
#import "SpectacleWindowPositionManager.h"
#import "SpectacleHotKeyManager.h"
#import "SpectacleUtilities.h"
@implementation SpectacleWindowActionController
- (id)init {
if (self = [super init]) {
myWindowPositionManager = [SpectacleWindowPositionManager sharedManager];
myHotKeyManager = [SpectacleHotKeyManager sharedManager];
}
return self;
}
#pragma mark -
- (void)registerHotKeys {
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
NSMutableDictionary *hotKeysFromUserDefaults = [NSMutableDictionary dictionary];
for (NSString *hotKeyName in [SpectacleUtilities hotKeyNames]) {
[hotKeysFromUserDefaults setObject: [userDefaults dataForKey: hotKeyName] forKey: hotKeyName];
}
[myHotKeyManager registerHotKeys: [SpectacleUtilities hotKeysFromDictionary: hotKeysFromUserDefaults hotKeyTarget: self]];
}
#pragma mark -
- (IBAction)moveFrontMostWindowToCenter: (id)sender {
[myWindowPositionManager moveFrontMostWindowWithAction: SpectacleWindowActionCenter];
}
#pragma mark -
- (IBAction)moveFrontMostWindowToFullscreen: (id)sender {
[myWindowPositionManager moveFrontMostWindowWithAction: SpectacleWindowActionFullscreen];
}
#pragma mark -
- (IBAction)moveFrontMostWindowToLeftHalf: (id)sender {
[myWindowPositionManager moveFrontMostWindowWithAction: SpectacleWindowActionLeftHalf];
}
- (IBAction)moveFrontMostWindowToRightHalf: (id)sender {
[myWindowPositionManager moveFrontMostWindowWithAction: SpectacleWindowActionRightHalf];
}
- (IBAction)moveFrontMostWindowToTopHalf: (id)sender {
[myWindowPositionManager moveFrontMostWindowWithAction: SpectacleWindowActionTopHalf];
}
- (IBAction)moveFrontMostWindowToBottomHalf: (id)sender {
[myWindowPositionManager moveFrontMostWindowWithAction: SpectacleWindowActionBottomHalf];
}
#pragma mark -
- (IBAction)moveFrontMostWindowToUpperLeft: (id)sender {
[myWindowPositionManager moveFrontMostWindowWithAction: SpectacleWindowActionUpperLeft];
}
- (IBAction)moveFrontMostWindowToLowerLeft: (id)sender {
[myWindowPositionManager moveFrontMostWindowWithAction: SpectacleWindowActionLowerLeft];
}
#pragma mark -
- (IBAction)moveFrontMostWindowToUpperRight: (id)sender {
[myWindowPositionManager moveFrontMostWindowWithAction: SpectacleWindowActionUpperRight];
}
- (IBAction)moveFrontMostWindowToLowerRight: (id)sender {
[myWindowPositionManager moveFrontMostWindowWithAction: SpectacleWindowActionLowerRight];
}
#pragma mark -
- (IBAction)moveFrontMostWindowToLeftDisplay: (id)sender {
[myWindowPositionManager moveFrontMostWindowWithAction: SpectacleWindowActionLeftDisplay];
}
- (IBAction)moveFrontMostWindowToRightDisplay: (id)sender {
[myWindowPositionManager moveFrontMostWindowWithAction: SpectacleWindowActionRightDisplay];
}
- (IBAction)moveFrontMostWindowToTopDisplay: (id)sender {
[myWindowPositionManager moveFrontMostWindowWithAction: SpectacleWindowActionTopDisplay];
}
- (IBAction)moveFrontMostWindowToBottomDisplay: (id)sender {
[myWindowPositionManager moveFrontMostWindowWithAction: SpectacleWindowActionBottomDisplay];
}
#pragma mark -
- (IBAction)undoLastWindowAction: (id)sender {
[myWindowPositionManager undoLastWindowAction];
}
- (IBAction)redoLastWindowAction: (id)sender {
[myWindowPositionManager redoLastWindowAction];
}
@end