From 9c0b4a327c2315bb6d27fe97dedad53e36e3c567 Mon Sep 17 00:00:00 2001 From: Paulo F. Andrade Date: Mon, 17 Feb 2014 15:09:41 +0000 Subject: Added support for secure coding --- MASShortcut.h | 2 +- MASShortcut.m | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/MASShortcut.h b/MASShortcut.h index 06507f6..515d659 100644 --- a/MASShortcut.h +++ b/MASShortcut.h @@ -30,7 +30,7 @@ enum { kMASShortcutGlyphSoutheastArrow = 0x2198, } MASShortcutGlyph; -@interface MASShortcut : NSObject +@interface MASShortcut : NSObject @property (nonatomic) NSUInteger keyCode; @property (nonatomic) NSUInteger modifierFlags; diff --git a/MASShortcut.m b/MASShortcut.m index 4e9888d..8790ac6 100644 --- a/MASShortcut.m +++ b/MASShortcut.m @@ -13,6 +13,11 @@ NSString *const MASShortcutModifierFlags = @"ModifierFlags"; #pragma mark - ++ (BOOL)supportsSecureCoding +{ + return YES; +} + - (void)encodeWithCoder:(NSCoder *)coder { [coder encodeInteger:(self.keyCode != NSNotFound ? (NSInteger)self.keyCode : - 1) forKey:MASShortcutKeyCode]; -- cgit v1.2.3 From da2773633059df112bd3c25fc8ae633f73c9f42b Mon Sep 17 00:00:00 2001 From: Paulo F. Andrade Date: Thu, 3 Apr 2014 11:25:28 +0100 Subject: Replaced call to deprecated NSRunCriticalAlertPanel API --- MASShortcutView.m | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/MASShortcutView.m b/MASShortcutView.m index ba28e47..17ad0f1 100644 --- a/MASShortcutView.m +++ b/MASShortcutView.m @@ -380,9 +380,13 @@ void *kUserDataHint = &kUserDataHint; [weakSelf activateEventMonitoring:NO]; NSString *format = NSLocalizedString(@"The key combination %@ cannot be used", @"Title for alert when shortcut is already used"); - NSRunCriticalAlertPanel([NSString stringWithFormat:format, shortcut], error.localizedDescription, - NSLocalizedString(@"OK", @"Alert button when shortcut is already used"), - nil, nil); + NSAlert *alert = [[NSAlert alloc] init]; + alert.alertStyle = NSCriticalAlertStyle; + alert.informativeText = [NSString stringWithFormat:format, shortcut]; + alert.messageText = error.localizedDescription; + [alert addButtonWithTitle:NSLocalizedString(@"OK", @"Alert button when shortcut is already used")]; + + [alert runModal]; weakSelf.shortcutPlaceholder = nil; [weakSelf activateResignObserver:YES]; [weakSelf activateEventMonitoring:YES]; -- cgit v1.2.3 From a5c2e159354c8474579d96971a9103f3f11c1e39 Mon Sep 17 00:00:00 2001 From: Paulo F. Andrade Date: Mon, 17 Feb 2014 15:09:41 +0000 Subject: Added support for secure coding --- MASShortcut.h | 2 +- MASShortcut.m | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/MASShortcut.h b/MASShortcut.h index 905ddaf..c9081a2 100644 --- a/MASShortcut.h +++ b/MASShortcut.h @@ -31,7 +31,7 @@ enum { kMASShortcutGlyphSoutheastArrow = 0x2198, } MASShortcutGlyph; -@interface MASShortcut : NSObject +@interface MASShortcut : NSObject @property (nonatomic) NSUInteger keyCode; @property (nonatomic) NSUInteger modifierFlags; diff --git a/MASShortcut.m b/MASShortcut.m index 5b94310..b217a98 100644 --- a/MASShortcut.m +++ b/MASShortcut.m @@ -13,6 +13,11 @@ NSString *const MASShortcutModifierFlags = @"ModifierFlags"; #pragma mark - ++ (BOOL)supportsSecureCoding +{ + return YES; +} + - (void)encodeWithCoder:(NSCoder *)coder { [coder encodeInteger:(self.keyCode != NSNotFound ? (NSInteger)self.keyCode : - 1) forKey:MASShortcutKeyCode]; -- cgit v1.2.3 From e53eed24bc6cc2856e732b16832730f6c2aa2827 Mon Sep 17 00:00:00 2001 From: Paulo F. Andrade Date: Wed, 17 Sep 2014 16:50:37 +0100 Subject: Implemented -initWithCoder: in MASShortcutView --- MASShortcutView.m | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/MASShortcutView.m b/MASShortcutView.m index f4eb8ff..b2d2531 100644 --- a/MASShortcutView.m +++ b/MASShortcutView.m @@ -42,15 +42,29 @@ { self = [super initWithFrame:frameRect]; if (self) { - _shortcutCell = [[[self.class shortcutCellClass] alloc] init]; - _shortcutCell.buttonType = NSPushOnPushOffButton; - _shortcutCell.font = [[NSFontManager sharedFontManager] convertFont:_shortcutCell.font toSize:BUTTON_FONT_SIZE]; - _enabled = YES; - [self resetShortcutCellStyle]; + [self commonInit]; + } + return self; +} + +- (id)initWithCoder:(NSCoder *)coder +{ + self = [super initWithCoder:coder]; + if (self) { + [self commonInit]; } return self; } +- (void)commonInit +{ + _shortcutCell = [[[self.class shortcutCellClass] alloc] init]; + _shortcutCell.buttonType = NSPushOnPushOffButton; + _shortcutCell.font = [[NSFontManager sharedFontManager] convertFont:_shortcutCell.font toSize:BUTTON_FONT_SIZE]; + _enabled = YES; + [self resetShortcutCellStyle]; +} + - (void)dealloc { [self activateEventMonitoring:NO]; -- cgit v1.2.3