aboutsummaryrefslogtreecommitdiffstats
path: root/Low Battery Yup
diff options
context:
space:
mode:
authorTeddy Wing2016-12-01 12:55:45 -0500
committerTeddy Wing2016-12-01 12:55:45 -0500
commita2b75aae69c69148de6791c243429cc3e9f41d41 (patch)
treeac755f40a74c4608036171986be915bc758c36e8 /Low Battery Yup
parent25e254a21668326a4241bdad6d3598d72c3bbfde (diff)
downloadLow-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.
Diffstat (limited to 'Low Battery Yup')
-rw-r--r--Low Battery Yup/AppDelegate.h1
-rw-r--r--Low Battery Yup/AppDelegate.m11
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