File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33#import " HotKeyService.h"
44#import " HotKey.h"
55
6+ @interface AppDelegate ()
7+
8+ @property (weak ) IBOutlet NSMenu *statusMenu;
9+ @property (strong ) NSStatusItem *statusItem;
10+
11+ @end
12+
613@implementation AppDelegate
714
815- (void )applicationDidFinishLaunching : (NSNotification *)aNotification {
916 [self setup ];
1017}
1118
19+ - (void )awakeFromNib {
20+ self.statusItem = [[NSStatusBar systemStatusBar ] statusItemWithLength: NSVariableStatusItemLength ];
21+ self.statusItem .menu = self.statusMenu ;
22+ self.statusItem .title = @" CodingKeys" ;
23+ // self.statusItem.image = [NSImage imageNamed:@"imageName"];
24+ self.statusItem .highlightMode = YES ;
25+ }
26+
1227- (void )setup {
1328 [self setupNotifications ];
1429 [self setupHotKeyService ];
@@ -69,4 +84,16 @@ - (void)didTriggerHotKey:(NSNotification *)notification {
6984 [[HotKeyService sharedService ] dispatchKeyEventForHotKey: mappedHotKey];
7085}
7186
87+ - (IBAction )settingsClicked : (id )sender {
88+ [[AppService sharedService ] openKeyMappings ];
89+ }
90+
91+ - (IBAction )aboutClicked : (id )sender {
92+ [[AppService sharedService ] openAboutURL ];
93+ }
94+
95+ - (IBAction )quitClicked : (id )sender {
96+ [NSApp terminate: self ];
97+ }
98+
7299@end
Original file line number Diff line number Diff line change 66
77- (BOOL )isAppRegistered : (NSString *)appName ;
88- (NSArray *)hotKeysForAppWithName : (NSString *)appName ;
9+ - (void )openKeyMappings ;
10+ - (void )openAboutURL ;
911
1012@end
Original file line number Diff line number Diff line change 22#import " HotKey.h"
33
44static NSString * const KeysFileName = @" keys" ;
5+ static NSString * const AboutURL = @" https://github.com/fe9lix/CodingKeys" ;
56
67@interface AppService ()
78
@@ -55,10 +56,8 @@ - (void)setup {
5556}
5657
5758- (NSArray *)loadKeyMappingsFile {
58- NSString *path = [[NSBundle mainBundle ] pathForResource: KeysFileName
59- ofType: @" json" ];
6059 NSError *error;
61- NSString *jsonString = [NSString stringWithContentsOfFile: path
60+ NSString *jsonString = [NSString stringWithContentsOfFile: [ self keysFilePath ]
6261 encoding: NSUTF8StringEncoding
6362 error: &error];
6463 NSData *jsonData = [jsonString dataUsingEncoding: NSUTF8StringEncoding];
@@ -68,6 +67,11 @@ - (NSArray *)loadKeyMappingsFile {
6867 error: nil ];
6968}
7069
70+ - (NSString *)keysFilePath {
71+ return [[NSBundle mainBundle ] pathForResource: KeysFileName
72+ ofType: @" json" ];
73+ }
74+
7175- (BOOL )isAppRegistered : (NSString *)appName {
7276 return self.hotKeysForAppName [appName] != nil ;
7377}
@@ -76,4 +80,12 @@ - (NSArray *)hotKeysForAppWithName:(NSString *)appName {
7680 return self.hotKeysForAppName [appName];
7781}
7882
83+ - (void )openKeyMappings {
84+ [[NSWorkspace sharedWorkspace ] openFile: [self keysFilePath ]];
85+ }
86+
87+ - (void )openAboutURL {
88+ [[NSWorkspace sharedWorkspace ] openURL: [NSURL URLWithString: AboutURL]];
89+ }
90+
7991@end
You can’t perform that action at this time.
0 commit comments