-- (IBAction)cancelHotKey:(id)sender
-{
- ITDebugLog(@"Hot key canceled.");
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- [NSApp endSheet:keyComboPanel];
- [keyComboPanel orderOut:nil];
-}
-
-- (IBAction)clearHotKey:(id)sender
-{
- ITDebugLog(@"Hot key cleared.");
- [self setKeyCombo:[ITKeyCombo clearKeyCombo]];
-}
-
-- (IBAction)okHotKey:(id)sender
-{
- NSString *string = [combo description];
- NSEnumerator *enumerator = [hotKeysDictionary keyEnumerator];
- NSString *enumKey;
-
- ITDebugLog(@"Hot key ok'd, saving.");
-
- if (string == nil) {
- string = @"";
- }
-
- ITDebugLog(@"Checking for duplicate hot keys.");
- while ( (enumKey = [enumerator nextObject]) ) {
- if (![enumKey isEqualToString:currentHotKey]) {
- if (![combo isEqual:[ITKeyCombo clearKeyCombo]] &&
- [combo isEqual:[hotKeysDictionary objectForKey:enumKey]]) {
- [window setLevel:NSNormalWindowLevel];
- ITDebugLog(@"Duplicate hot key found: %@", enumKey);
- if ( NSRunAlertPanel(NSLocalizedString(@"duplicateCombo", @"Duplicate Key Combo") , NSLocalizedString(@"duplicateCombo_msg", @"The specified key combo is already in use..."), NSLocalizedString(@"replace", @"Replace"), NSLocalizedString(@"cancel", @"Cancel"), nil) ) {
- [hotKeysDictionary setObject:[ITKeyCombo clearKeyCombo] forKey:currentHotKey];
- if ([enumKey isEqualToString:@"PlayPause"]) {
- [playPauseButton setTitle:@"(None)"];
- } else if ([enumKey isEqualToString:@"NextTrack"]) {
- [nextTrackButton setTitle:@"(None)"];
- } else if ([enumKey isEqualToString:@"PrevTrack"]) {
- [previousTrackButton setTitle:@"(None)"];
- } else if ([enumKey isEqualToString:@"ShowPlayer"]) {
- [showPlayerButton setTitle:@"(None)"];
- } else if ([enumKey isEqualToString:@"TrackInfo"]) {
- [trackInfoButton setTitle:@"(None)"];
- } else if ([enumKey isEqualToString:@"UpcomingSongs"]) {
- [upcomingSongsButton setTitle:@"(None)"];
- } else if ([enumKey isEqualToString:@"IncrementVolume"]) {
- [volumeIncrementButton setTitle:@"(None)"];
- } else if ([enumKey isEqualToString:@"DecrementVolume"]) {
- [volumeDecrementButton setTitle:@"(None)"];
- } else if ([enumKey isEqualToString:@"IncrementRating"]) {
- [ratingIncrementButton setTitle:@"(None)"];
- } else if ([enumKey isEqualToString:@"DecrementRating"]) {
- [ratingDecrementButton setTitle:@"(None)"];
- } else if ([enumKey isEqualToString:@"ToggleShuffle"]) {
- [toggleShuffleButton setTitle:@"(None)"];
- } else if ([enumKey isEqualToString:@"ToggleLoop"]) {
- [toggleLoopButton setTitle:@"(None)"];
- }
- ITDebugLog(@"Saved hot key named %@.", enumKey);
- [df setObject:[[ITKeyCombo clearKeyCombo] plistRepresentation] forKey:enumKey];
- [hotKeysDictionary setObject:[ITKeyCombo clearKeyCombo] forKey:enumKey];
- } else {
- return;
- }
- [window setLevel:NSStatusWindowLevel];
- }
- }
- }
-
- ITDebugLog(@"Saved hot key named %@.", currentHotKey);
- [hotKeysDictionary setObject:combo forKey:currentHotKey];
- [df setObject:[combo plistRepresentation] forKey:currentHotKey];
-
- ITDebugLog(@"Setting button name.");
- if ([currentHotKey isEqualToString:@"PlayPause"]) {
- [playPauseButton setTitle:string];
- } else if ([currentHotKey isEqualToString:@"NextTrack"]) {
- [nextTrackButton setTitle:string];
- } else if ([currentHotKey isEqualToString:@"PrevTrack"]) {
- [previousTrackButton setTitle:string];
- } else if ([currentHotKey isEqualToString:@"ShowPlayer"]) {
- [showPlayerButton setTitle:string];
- } else if ([currentHotKey isEqualToString:@"TrackInfo"]) {
- [trackInfoButton setTitle:string];
- } else if ([currentHotKey isEqualToString:@"UpcomingSongs"]) {
- [upcomingSongsButton setTitle:string];
- } else if ([currentHotKey isEqualToString:@"IncrementVolume"]) {
- [volumeIncrementButton setTitle:string];
- } else if ([currentHotKey isEqualToString:@"DecrementVolume"]) {
- [volumeDecrementButton setTitle:string];
- } else if ([currentHotKey isEqualToString:@"IncrementRating"]) {
- [ratingIncrementButton setTitle:string];
- } else if ([currentHotKey isEqualToString:@"DecrementRating"]) {
- [ratingDecrementButton setTitle:string];
- } else if ([currentHotKey isEqualToString:@"ToggleShuffle"]) {
- [toggleShuffleButton setTitle:string];
- } else if ([currentHotKey isEqualToString:@"ToggleLoop"]) {
- [toggleLoopButton setTitle:string];
- }
- [controller setupHotKeys];
- [self cancelHotKey:sender];
-}
-