- if ([setHotKey isEqualToString:@"PlayPause"]) {
- if (([combo isEqual:nextTrackCombo] || [combo isEqual:prevTrackCombo] ||
- [combo isEqual:trackInfoCombo] || [combo isEqual:upcomingSongsCombo] ||
- [combo isEqual:ratingIncrementCombo] || [combo isEqual:ratingDecrementCombo] ||
- [combo isEqual:volumeIncrementCombo] || [combo isEqual:volumeDecrementCombo] ||
- [combo isEqual:toggleLoopCombo] || [combo isEqual:toggleShuffleCombo]) &&
- !(([combo modifiers] == -1) && ([combo keyCode] == -1))) {
-
- [window setLevel:NSNormalWindowLevel];
- NSRunAlertPanel(@"Duplicate Key Combo", @"Please choose a unique key combo.", @"OK", nil, nil, nil);
- [window setLevel:NSStatusWindowLevel];
- return;
- }
- playPauseCombo = [combo copy];
- [playPauseButton setTitle:string];
- } else if ([setHotKey isEqualToString:@"NextTrack"]) {
- if (([combo isEqual:playPauseCombo] || [combo isEqual:prevTrackCombo] ||
- [combo isEqual:trackInfoCombo] || [combo isEqual:upcomingSongsCombo] ||
- [combo isEqual:ratingIncrementCombo] || [combo isEqual:ratingDecrementCombo] ||
- [combo isEqual:volumeIncrementCombo] || [combo isEqual:volumeDecrementCombo] ||
- [combo isEqual:toggleLoopCombo] || [combo isEqual:toggleShuffleCombo]) &&
- !(([combo modifiers] == -1) && ([combo keyCode] == -1))) {
-
- [window setLevel:NSNormalWindowLevel];
- NSRunAlertPanel(@"Duplicate Key Combo", @"Please choose a unique key combo.", @"OK", nil, nil, nil);
- [window setLevel:NSStatusWindowLevel];
- return;
- }
- nextTrackCombo = [combo copy];
- [nextTrackButton setTitle:string];
- } else if ([setHotKey isEqualToString:@"PrevTrack"]) {
- if (([combo isEqual:nextTrackCombo] || [combo isEqual:playPauseCombo] ||
- [combo isEqual:trackInfoCombo] || [combo isEqual:upcomingSongsCombo] ||
- [combo isEqual:ratingIncrementCombo] || [combo isEqual:ratingDecrementCombo] ||
- [combo isEqual:volumeIncrementCombo] || [combo isEqual:volumeDecrementCombo] ||
- [combo isEqual:toggleLoopCombo] || [combo isEqual:toggleShuffleCombo]) &&
- !(([combo modifiers] == -1) && ([combo keyCode] == -1))) {
-
- [window setLevel:NSNormalWindowLevel];
- NSRunAlertPanel(@"Duplicate Key Combo", @"Please choose a unique key combo.", @"OK", nil, nil, nil);
- [window setLevel:NSStatusWindowLevel];
- return;
- }
- prevTrackCombo = [combo copy];
- [previousTrackButton setTitle:string];
- } else if ([setHotKey isEqualToString:@"TrackInfo"]) {
- if (([combo isEqual:nextTrackCombo] || [combo isEqual:prevTrackCombo] ||
- [combo isEqual:playPauseCombo] || [combo isEqual:upcomingSongsCombo] ||
- [combo isEqual:ratingIncrementCombo] || [combo isEqual:ratingDecrementCombo] ||
- [combo isEqual:volumeIncrementCombo] || [combo isEqual:volumeDecrementCombo] ||
- [combo isEqual:toggleLoopCombo] || [combo isEqual:toggleShuffleCombo]) &&
- !(([combo modifiers] == -1) && ([combo keyCode] == -1))) {
-
- [window setLevel:NSNormalWindowLevel];
- NSRunAlertPanel(@"Duplicate Key Combo", @"Please choose a unique key combo.", @"OK", nil, nil, nil);
- [window setLevel:NSStatusWindowLevel];
- return;
- }
- trackInfoCombo = [combo copy];
- [trackInfoButton setTitle:string];
- } else if ([setHotKey isEqualToString:@"UpcomingSongs"]) {
- if (([combo isEqual:nextTrackCombo] || [combo isEqual:prevTrackCombo] ||
- [combo isEqual:trackInfoCombo] || [combo isEqual:playPauseCombo] ||
- [combo isEqual:ratingIncrementCombo] || [combo isEqual:ratingDecrementCombo] ||
- [combo isEqual:volumeIncrementCombo] || [combo isEqual:volumeDecrementCombo] ||
- [combo isEqual:toggleLoopCombo] || [combo isEqual:toggleShuffleCombo]) &&
- !(([combo modifiers] == -1) && ([combo keyCode] == -1))) {
-
- [window setLevel:NSNormalWindowLevel];
- NSRunAlertPanel(@"Duplicate Key Combo", @"Please choose a unique key combo.", @"OK", nil, nil, nil);
- [window setLevel:NSStatusWindowLevel];
- return;
- }
- upcomingSongsCombo = [combo copy];
- [upcomingSongsButton setTitle:string];
- //THE NEW COMBOS!
- } else if ([setHotKey isEqualToString:@"IncrementVolume"]) {
- if (([combo isEqual:nextTrackCombo] || [combo isEqual:prevTrackCombo] ||
- [combo isEqual:trackInfoCombo] || [combo isEqual:playPauseCombo] ||
- [combo isEqual:ratingIncrementCombo] || [combo isEqual:ratingDecrementCombo] ||
- [combo isEqual:upcomingSongsCombo] || [combo isEqual:volumeDecrementCombo] ||
- [combo isEqual:toggleLoopCombo] || [combo isEqual:toggleShuffleCombo]) &&
- !(([combo modifiers] == -1) && ([combo keyCode] == -1))) {
-
- [window setLevel:NSNormalWindowLevel];
- NSRunAlertPanel(@"Duplicate Key Combo", @"Please choose a unique key combo.", @"OK", nil, nil, nil);
- [window setLevel:NSStatusWindowLevel];
- return;
- }
- volumeIncrementCombo = [combo copy];
- [volumeIncrementButton setTitle:string];
- } else if ([setHotKey isEqualToString:@"DecrementVolume"]) {
- if (([combo isEqual:nextTrackCombo] || [combo isEqual:prevTrackCombo] ||
- [combo isEqual:trackInfoCombo] || [combo isEqual:playPauseCombo] ||
- [combo isEqual:ratingIncrementCombo] || [combo isEqual:ratingDecrementCombo] ||
- [combo isEqual:volumeIncrementCombo] || [combo isEqual:upcomingSongsCombo] ||
- [combo isEqual:toggleLoopCombo] || [combo isEqual:toggleShuffleCombo]) &&
- !(([combo modifiers] == -1) && ([combo keyCode] == -1))) {
-
- [window setLevel:NSNormalWindowLevel];
- NSRunAlertPanel(@"Duplicate Key Combo", @"Please choose a unique key combo.", @"OK", nil, nil, nil);
- [window setLevel:NSStatusWindowLevel];
- return;
- }
- volumeDecrementCombo = [combo copy];
- [volumeDecrementButton setTitle:string];
- } else if ([setHotKey isEqualToString:@"IncrementRating"]) {
- if (([combo isEqual:nextTrackCombo] || [combo isEqual:prevTrackCombo] ||
- [combo isEqual:trackInfoCombo] || [combo isEqual:playPauseCombo] ||
- [combo isEqual:upcomingSongsCombo] || [combo isEqual:ratingDecrementCombo] ||
- [combo isEqual:volumeIncrementCombo] || [combo isEqual:volumeDecrementCombo] ||
- [combo isEqual:toggleLoopCombo] || [combo isEqual:toggleShuffleCombo]) &&
- !(([combo modifiers] == -1) && ([combo keyCode] == -1))) {
-
- [window setLevel:NSNormalWindowLevel];
- NSRunAlertPanel(@"Duplicate Key Combo", @"Please choose a unique key combo.", @"OK", nil, nil, nil);
- [window setLevel:NSStatusWindowLevel];
- return;
- }
- ratingIncrementCombo = [combo copy];
- [ratingIncrementButton setTitle:string];
- } else if ([setHotKey isEqualToString:@"DecrementRating"]) {
- if (([combo isEqual:nextTrackCombo] || [combo isEqual:prevTrackCombo] ||
- [combo isEqual:trackInfoCombo] || [combo isEqual:playPauseCombo] ||
- [combo isEqual:ratingIncrementCombo] || [combo isEqual:upcomingSongsCombo] ||
- [combo isEqual:volumeIncrementCombo] || [combo isEqual:volumeDecrementCombo] ||
- [combo isEqual:toggleLoopCombo] || [combo isEqual:toggleShuffleCombo]) &&
- !(([combo modifiers] == -1) && ([combo keyCode] == -1))) {
-
- [window setLevel:NSNormalWindowLevel];
- NSRunAlertPanel(@"Duplicate Key Combo", @"Please choose a unique key combo.", @"OK", nil, nil, nil);
- [window setLevel:NSStatusWindowLevel];
- return;
- }
- ratingDecrementCombo = [combo copy];
- [ratingDecrementButton setTitle:string];
- } else if ([setHotKey isEqualToString:@"ToggleLoop"]) {
- if (([combo isEqual:nextTrackCombo] || [combo isEqual:prevTrackCombo] ||
- [combo isEqual:trackInfoCombo] || [combo isEqual:playPauseCombo] ||
- [combo isEqual:ratingIncrementCombo] || [combo isEqual:ratingDecrementCombo] ||
- [combo isEqual:volumeIncrementCombo] || [combo isEqual:volumeDecrementCombo] ||
- [combo isEqual:upcomingSongsCombo] || [combo isEqual:toggleShuffleCombo]) &&
- !(([combo modifiers] == -1) && ([combo keyCode] == -1))) {
-
- [window setLevel:NSNormalWindowLevel];
- NSRunAlertPanel(@"Duplicate Key Combo", @"Please choose a unique key combo.", @"OK", nil, nil, nil);
- [window setLevel:NSStatusWindowLevel];
- return;
+
+ while ( (enumKey = [enumerator nextObject]) ) {
+ if (![enumKey isEqualToString:currentHotKey]) {
+ if (![combo isEqual:[KeyCombo clearKeyCombo]] &&
+ [combo isEqual:[hotKeysDictionary objectForKey:enumKey]]) {
+ [window setLevel:NSNormalWindowLevel];
+ if ( NSRunAlertPanel(@"Duplicate Key Combo", @"The specified key combo is already in use...", @"Replace", @"Cancel", nil) ) {
+ [hotKeysDictionary setObject:[KeyCombo clearKeyCombo] forKey:currentHotKey];
+ if ([enumKey isEqualToString:@"PlayPause"]) {
+ [playPauseButton setTitle:@""];
+ } else if ([enumKey isEqualToString:@"NextTrack"]) {
+ [nextTrackButton setTitle:@""];
+ } else if ([enumKey isEqualToString:@"PrevTrack"]) {
+ [previousTrackButton setTitle:@""];
+ } else if ([enumKey isEqualToString:@"ToggleVisualizer"]) {
+ [visualizerButton setTitle:@""];
+ } else if ([enumKey isEqualToString:@"TrackInfo"]) {
+ [trackInfoButton setTitle:@""];
+ } else if ([enumKey isEqualToString:@"UpcomingSongs"]) {
+ [upcomingSongsButton setTitle:@""];
+ } else if ([enumKey isEqualToString:@"IncrementVolume"]) {
+ [volumeIncrementButton setTitle:@""];
+ } else if ([enumKey isEqualToString:@"DecrementVolume"]) {
+ [volumeDecrementButton setTitle:@""];
+ } else if ([enumKey isEqualToString:@"IncrementRating"]) {
+ [ratingIncrementButton setTitle:@""];
+ } else if ([enumKey isEqualToString:@"DecrementRating"]) {
+ [ratingDecrementButton setTitle:@""];
+ } else if ([enumKey isEqualToString:@"ToggleShuffle"]) {
+ [toggleShuffleButton setTitle:@""];
+ } else if ([enumKey isEqualToString:@"ToggleLoop"]) {
+ [toggleLoopButton setTitle:@""];
+ }
+ [df setKeyCombo:[KeyCombo clearKeyCombo] forKey:enumKey];
+ } else {
+ return;
+ }
+ [window setLevel:NSStatusWindowLevel];
+ }