diff options
| author | Teddy Wing | 2016-12-01 12:55:45 -0500 |
|---|---|---|
| committer | Teddy Wing | 2016-12-01 12:55:45 -0500 |
| commit | a2b75aae69c69148de6791c243429cc3e9f41d41 (patch) | |
| tree | ac755f40a74c4608036171986be915bc758c36e8 | |
| parent | 25e254a21668326a4241bdad6d3598d72c3bbfde (diff) | |
| download | Low-Battery-Yup-a2b75aae69c69148de6791c243429cc3e9f41d41.tar.bz2 | |
Show saved keyboard shortcut in the MASShortcutView
If a global keyboard shortcut has been stored in the `NSUserDefaults`,
display that in the shortcut selection widget.
| -rw-r--r-- | Low Battery Yup/AppDelegate.h | 1 | ||||
| -rw-r--r-- | Low Battery Yup/AppDelegate.m | 11 |
2 files changed, 11 insertions, 1 deletions
diff --git a/Low Battery Yup/AppDelegate.h b/Low Battery Yup/AppDelegate.h index a2c8ba9..3998e46 100644 --- a/Low Battery Yup/AppDelegate.h +++ b/Low Battery Yup/AppDelegate.h @@ -7,6 +7,7 @@ // #import <Cocoa/Cocoa.h> +#import <MASShortcut/MASShortcut.h> #import "ShortcutView.h" @interface AppDelegate : NSObject <NSApplicationDelegate> { diff --git a/Low Battery Yup/AppDelegate.m b/Low Battery Yup/AppDelegate.m index d90bc97..9f3e367 100644 --- a/Low Battery Yup/AppDelegate.m +++ b/Low Battery Yup/AppDelegate.m @@ -8,6 +8,8 @@ #import "AppDelegate.h" +static NSString *const kPreferenceGlobalShortcut = @"GlobalShortcut"; + @implementation AppDelegate - (void)dealloc @@ -17,7 +19,14 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { - + NSDictionary *saved_shortcut; + if ((saved_shortcut = [[NSUserDefaults standardUserDefaults] objectForKey:kPreferenceGlobalShortcut])) { + MASShortcut *shortcut = [MASShortcut + shortcutWithKeyCode:[[saved_shortcut objectForKey:@"keyCode"] unsignedIntegerValue] + modifierFlags:[[saved_shortcut objectForKey:@"modifierFlags"] unsignedIntegerValue]]; + + [_shortcut_view setShortcutValue:shortcut]; + } } @end |
