diff --git a/QCAppDelegate.m b/QCAppDelegate.m index 5a6e53e..0d24a5e 100644 --- a/QCAppDelegate.m +++ b/QCAppDelegate.m @@ -20,29 +20,6 @@ + (void)initialize { nil]]; } -- (void)updateHotKeys { - PTHotKeyCenter *hotKeyCenter = [PTHotKeyCenter sharedCenter]; - NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; - - for (PTHotKey *each in registeredHotKeys) { - [hotKeyCenter unregisterHotKey:each]; - } - - [registeredHotKeys removeAllObjects]; - - for (NSMenuItem *each in [self validatedEditorMenuItems:NULL]) { - id eachKeyComboPlist = [userDefaults objectForKey:[each representedObject]]; - if (eachKeyComboPlist) { - PTKeyCombo *keyCombo = [[[PTKeyCombo alloc] initWithPlistRepresentation:eachKeyComboPlist] autorelease]; - PTHotKey *hotKey = [[PTHotKey alloc] initWithIdentifier:[each representedObject] keyCombo:keyCombo]; - [hotKey setTarget:self]; - [hotKey setAction:@selector(beginQuickCursorEdit:)]; - [hotKeyCenter registerHotKey:hotKey]; - [registeredHotKeys addObject:hotKey]; - } - } -} - - (NSArray *)validatedEditorMenuItems:(SEL)action { static NSArray *cachedMenuItems = nil; @@ -81,6 +58,29 @@ - (NSArray *)validatedEditorMenuItems:(SEL)action { return results; } +- (void)updateHotKeys { + PTHotKeyCenter *hotKeyCenter = [PTHotKeyCenter sharedCenter]; + NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; + + for (PTHotKey *each in registeredHotKeys) { + [hotKeyCenter unregisterHotKey:each]; + } + + [registeredHotKeys removeAllObjects]; + + for (NSMenuItem *each in [self validatedEditorMenuItems:NULL]) { + id eachKeyComboPlist = [userDefaults objectForKey:[each representedObject]]; + if (eachKeyComboPlist) { + PTKeyCombo *keyCombo = [[[PTKeyCombo alloc] initWithPlistRepresentation:eachKeyComboPlist] autorelease]; + PTHotKey *hotKey = [[PTHotKey alloc] initWithIdentifier:[each representedObject] keyCombo:keyCombo]; + [hotKey setTarget:self]; + [hotKey setAction:@selector(beginQuickCursorEdit:)]; + [hotKeyCenter registerHotKey:hotKey]; + [registeredHotKeys addObject:hotKey]; + } + } +} + - (BOOL)validateMenuItem:(NSMenuItem *)anItem { if ([anItem action] == @selector(beginQuickCursorEdit:)) { id keyComboPlist = [[NSUserDefaults standardUserDefaults] objectForKey:[anItem representedObject]]; @@ -119,8 +119,8 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { registeredHotKeys = [[NSMutableArray alloc] init]; if (!AXAPIEnabled()) { - NSString *message = BLocalizedString(@"QuickCursor requires that the Accessibility API be enabled. Would you like to launch System Preferences so that you can turn on \"Enable access for assistive devices\".", nil); - NSUInteger result = NSRunAlertPanel(message, @"", BLocalizedString(@"OK", nil), BLocalizedString(@"Quit QuickCursor", nil), BLocalizedString(@"Cancel", nil)); + NSString *message = NSLocalizedString(@"QuickCursor requires that the Accessibility API be enabled. Would you like to launch System Preferences so that you can turn on \"Enable access for assistive devices\".", nil); + NSUInteger result = NSRunAlertPanel(message, @"", NSLocalizedString(@"OK", nil), NSLocalizedString(@"Quit QuickCursor", nil), NSLocalizedString(@"Cancel", nil)); switch (result) { case NSAlertDefaultReturn: @@ -137,13 +137,11 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { NSImage *image = [NSImage imageNamed:@"StatusItemIcon"]; [image setTemplate:YES]; [quickCursorStatusItem setImage:image]; - [quickCursorStatusItem setTarget:self]; - [quickCursorStatusItem setAction:@selector(beginQuickCursorEdit:)]; [quickCursorStatusItem setHighlightMode:YES]; NSMenu *quickCursorMenu = [[[NSMenu alloc] init] autorelease]; - [quickCursorMenu addItemWithTitle:BLocalizedString(@"Edit In...", nil) action:NULL keyEquivalent:@""]; + [quickCursorMenu addItemWithTitle:NSLocalizedString(@"Edit In...", nil) action:NULL keyEquivalent:@""]; for (NSMenuItem *each in [self validatedEditorMenuItems:@selector(beginQuickCursorEdit:)]) { [quickCursorMenu addItem:each]; @@ -151,21 +149,21 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { [quickCursorMenu addItem:[NSMenuItem separatorItem]]; - NSMenuItem *aboutMenuItem = [[[NSMenuItem alloc] initWithTitle:BLocalizedString(@"About", nil) action:@selector(showAbout:) keyEquivalent:@""] autorelease]; + NSMenuItem *aboutMenuItem = [[[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"About", nil) action:@selector(showAbout:) keyEquivalent:@""] autorelease]; [aboutMenuItem setTarget:self]; [quickCursorMenu addItem:aboutMenuItem]; - NSMenuItem *preferencesMenuItem = [[[NSMenuItem alloc] initWithTitle:BLocalizedString(@"Preferences...", nil) action:@selector(showPreferences:) keyEquivalent:@""] autorelease]; + NSMenuItem *preferencesMenuItem = [[[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Preferences...", nil) action:@selector(showPreferences:) keyEquivalent:@""] autorelease]; [preferencesMenuItem setTarget:self]; [quickCursorMenu addItem:preferencesMenuItem]; - NSMenuItem *helpMenuItem = [[[NSMenuItem alloc] initWithTitle:BLocalizedString(@"QuickCursor Help", nil) action:@selector(showPreferences:) keyEquivalent:@""] autorelease]; + NSMenuItem *helpMenuItem = [[[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"QuickCursor Help", nil) action:@selector(showPreferences:) keyEquivalent:@""] autorelease]; [helpMenuItem setTarget:self]; [quickCursorMenu addItem:helpMenuItem]; [quickCursorMenu addItem:[NSMenuItem separatorItem]]; - NSMenuItem *quitMenuItem = [[[NSMenuItem alloc] initWithTitle:BLocalizedString(@"Quit", nil) action:@selector(terminate:) keyEquivalent:@""] autorelease]; + NSMenuItem *quitMenuItem = [[[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Quit", nil) action:@selector(terminate:) keyEquivalent:@""] autorelease]; [quitMenuItem setTarget:NSApp]; [quickCursorMenu addItem:quitMenuItem]; @@ -232,11 +230,11 @@ - (IBAction)beginQuickCursorEdit:(id)sender { [[ODBEditor sharedODBEditor] setEditorBundleIdentifier:bundleID]; [[ODBEditor sharedODBEditor] editString:value options:[NSDictionary dictionaryWithObject:editorCustomPath forKey:ODBEditorCustomPathKey] forClient:self context:context]; } else { - [[NSAlert alertWithMessageText:BLocalizedString(@"Could not edit text", nil) - defaultButton:BLocalizedString(@"OK", nil) + [[NSAlert alertWithMessageText:NSLocalizedString(@"Could not edit text", nil) + defaultButton:NSLocalizedString(@"OK", nil) alternateButton:nil otherButton:nil - informativeTextWithFormat:BLocalizedString(@"QuickCursor could not find any text to edit. Make sure that a text view has keyboard focus, and then try again.", nil)] runModal]; + informativeTextWithFormat:NSLocalizedString(@"QuickCursor could not find any text to edit. Make sure that a text view has keyboard focus, and then try again.", nil)] runModal]; } } diff --git a/QCUIElement.h b/QCUIElement.h index 5167e34..ca91736 100644 --- a/QCUIElement.h +++ b/QCUIElement.h @@ -7,7 +7,6 @@ // #import -#import @interface QCUIElement : NSObject {