#import "PreferencesController.h"
#import "MainController.h"
#import <ITKit/ITHotKeyCenter.h>
+#import <ITKit/ITKeyCombo.h>
#import <ITKit/ITWindowPositioning.h>
+#import <ITKit/ITKeyBroadcaster.h>
#define SENDER_STATE (([sender state] == NSOnState) ? YES : NO)
if ([currentHotKey isEqualToString:@"PlayPause"]) {
[playPauseButton setTitle:string];
- //[[ITHotKeyCenter sharedCenter] addHotKey:@"PlayPause" combo:combo target:[MainController sharedController] action:@selector(playPause)];
} else if ([currentHotKey isEqualToString:@"NextTrack"]) {
[nextTrackButton setTitle:string];
- //[[ITHotKeyCenter sharedCenter] addHotKey:@"NextTrack" combo:combo target:[MainController sharedController] action:@selector(nextSong)];
} else if ([currentHotKey isEqualToString:@"PrevTrack"]) {
[previousTrackButton setTitle:string];
- //[[ITHotKeyCenter sharedCenter] addHotKey:@"PrevTrack" combo:combo target:[MainController sharedController] action:@selector(prevSong)];
} else if ([currentHotKey isEqualToString:@"ShowPlayer"]) {
[showPlayerButton setTitle:string];
- //[[ITHotKeyCenter sharedCenter] addHotKey:@"ShowPlayer" combo:combo target:[MainController sharedController] action:@selector(showPlayer)];
} else if ([currentHotKey isEqualToString:@"TrackInfo"]) {
[trackInfoButton setTitle:string];
- //[[ITHotKeyCenter sharedCenter] addHotKey:@"TrackInfo" combo:combo target:[MainController sharedController] action:@selector(showCurrentTrackInfo)];
} else if ([currentHotKey isEqualToString:@"UpcomingSongs"]) {
[upcomingSongsButton setTitle:string];
- //[[ITHotKeyCenter sharedCenter] addHotKey:@"UpcomingSongs" combo:combo target:[MainController sharedController] action:@selector(showUpcomingSongs)];
} else if ([currentHotKey isEqualToString:@"IncrementVolume"]) {
[volumeIncrementButton setTitle:string];
- //[[ITHotKeyCenter sharedCenter] addHotKey:@"IncrementVolume" combo:combo target:[MainController sharedController] action:@selector(incrementVolume)];
} else if ([currentHotKey isEqualToString:@"DecrementVolume"]) {
[volumeDecrementButton setTitle:string];
- //[[ITHotKeyCenter sharedCenter] addHotKey:@"DecrementVolume" combo:combo target:[MainController sharedController] action:@selector(decrementVolume)];
} else if ([currentHotKey isEqualToString:@"IncrementRating"]) {
[ratingIncrementButton setTitle:string];
- //[[ITHotKeyCenter sharedCenter] addHotKey:@"IncrementRating" combo:combo target:[MainController sharedController] action:@selector(incrementRating)];
} else if ([currentHotKey isEqualToString:@"DecrementRating"]) {
[ratingDecrementButton setTitle:string];
- //[[ITHotKeyCenter sharedCenter] addHotKey:@"DecrementRating" combo:combo target:[MainController sharedController] action:@selector(decrementRating)];
} else if ([currentHotKey isEqualToString:@"ToggleShuffle"]) {
[toggleShuffleButton setTitle:string];
- //[[ITHotKeyCenter sharedCenter] addHotKey:@"ToggleShuffle" combo:combo target:[MainController sharedController] action:@selector(toggleShuffle)];
} else if ([currentHotKey isEqualToString:@"ToggleLoop"]) {
[toggleLoopButton setTitle:string];
- //[[ITHotKeyCenter sharedCenter] addHotKey:@"ToggleLoop" combo:combo target:[MainController sharedController] action:@selector(toggleLoop)];
}
[controller setupHotKeys];
[self cancelHotKey:sender];
{
[currentHotKey autorelease];
currentHotKey = [key copy];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyEvent:) name:@"KeyBroadcasterEvent" object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyEvent:) name:ITKeyBroadcasterKeyEvent object:nil];
[NSApp beginSheet:keyComboPanel modalForWindow:window modalDelegate:self didEndSelector:nil contextInfo:nil];
}
- (void)keyEvent:(NSNotification *)note
{
- NSDictionary *info = [note userInfo];
- short keyCode;
- long modifiers;
- ITKeyCombo *newCombo;
-
- keyCode = [[info objectForKey:@"KeyCode"] shortValue];
- modifiers = [[info objectForKey:@"Modifiers"] longValue];
-
- newCombo = [[ITKeyCombo alloc] initWithKeyCode:keyCode modifiers:modifiers];
- [self setKeyCombo:newCombo];
+ [self setKeyCombo:[[[note userInfo] objectForKey:@"keyCombo"] copy]];
}
- (void)setKeyCombo:(ITKeyCombo *)newCombo
[playPauseButton setTitle:[anItem description]];
} else {
[hotKeysDictionary setObject:[ITKeyCombo clearKeyCombo] forKey:@"PlayPause"];
+ [playPauseButton setTitle:[[ITKeyCombo clearKeyCombo] description]];
}
if ([df objectForKey:@"NextTrack"]) {
[nextTrackButton setTitle:[anItem description]];
} else {
[hotKeysDictionary setObject:[ITKeyCombo clearKeyCombo] forKey:@"NextTrack"];
+ [nextTrackButton setTitle:[[ITKeyCombo clearKeyCombo] description]];
}
if ([df objectForKey:@"PrevTrack"]) {
[previousTrackButton setTitle:[anItem description]];
} else {
[hotKeysDictionary setObject:[ITKeyCombo clearKeyCombo] forKey:@"PrevTrack"];
+ [previousTrackButton setTitle:[[ITKeyCombo clearKeyCombo] description]];
}
if ([df objectForKey:@"ShowPlayer"]) {
[showPlayerButton setTitle:[anItem description]];
} else {
[hotKeysDictionary setObject:[ITKeyCombo clearKeyCombo] forKey:@"ShowPlayer"];
+ [showPlayerButton setTitle:[[ITKeyCombo clearKeyCombo] description]];
}
if ([df objectForKey:@"TrackInfo"]) {
[trackInfoButton setTitle:[anItem description]];
} else {
[hotKeysDictionary setObject:[ITKeyCombo clearKeyCombo] forKey:@"TrackInfo"];
+ [trackInfoButton setTitle:[[ITKeyCombo clearKeyCombo] description]];
}
if ([df objectForKey:@"UpcomingSongs"]) {
[upcomingSongsButton setTitle:[anItem description]];
} else {
[hotKeysDictionary setObject:[ITKeyCombo clearKeyCombo] forKey:@"UpcomingSongs"];
+ [upcomingSongsButton setTitle:[[ITKeyCombo clearKeyCombo] description]];
}
if ([df objectForKey:@"IncrementVolume"]) {
[volumeIncrementButton setTitle:[anItem description]];
} else {
[hotKeysDictionary setObject:[ITKeyCombo clearKeyCombo] forKey:@"IncrementVolume"];
+ [volumeIncrementButton setTitle:[[ITKeyCombo clearKeyCombo] description]];
}
if ([df objectForKey:@"DecrementVolume"]) {
[volumeDecrementButton setTitle:[anItem description]];
} else {
[hotKeysDictionary setObject:[ITKeyCombo clearKeyCombo] forKey:@"DecrementVolume"];
+ [volumeDecrementButton setTitle:[[ITKeyCombo clearKeyCombo] description]];
}
if ([df objectForKey:@"IncrementRating"]) {
[ratingIncrementButton setTitle:[anItem description]];
} else {
[hotKeysDictionary setObject:[ITKeyCombo clearKeyCombo] forKey:@"IncrementRating"];
+ [ratingIncrementButton setTitle:[[ITKeyCombo clearKeyCombo] description]];
}
if ([df objectForKey:@"DecrementRating"]) {
[ratingDecrementButton setTitle:[anItem description]];
} else {
[hotKeysDictionary setObject:[ITKeyCombo clearKeyCombo] forKey:@"DecrementRating"];
+ [ratingDecrementButton setTitle:[[ITKeyCombo clearKeyCombo] description]];
}
if ([df objectForKey:@"ToggleLoop"]) {
[toggleLoopButton setTitle:[anItem description]];
} else {
[hotKeysDictionary setObject:[ITKeyCombo clearKeyCombo] forKey:@"ToggleLoop"];
+ [toggleLoopButton setTitle:[[ITKeyCombo clearKeyCombo] description]];
}
if ([df objectForKey:@"ToggleShuffle"]) {
[toggleShuffleButton setTitle:[anItem description]];
} else {
[hotKeysDictionary setObject:[ITKeyCombo clearKeyCombo] forKey:@"ToggleShuffle"];
+ [toggleShuffleButton setTitle:[[ITKeyCombo clearKeyCombo] description]];
}
// Check current track info buttons