From: Kent Sutherland Date: Thu, 1 Jul 2004 02:48:47 +0000 (+0000) Subject: Added hotkeys for setting individual song ratings 0-5 stars. X-Git-Tag: v1.4~27 X-Git-Url: http://git.ithinksw.org/MenuTunes.git/commitdiff_plain/1527a78c2e1b1cc525a5c4621077844989aab6fd?ds=inline Added hotkeys for setting individual song ratings 0-5 stars. --- diff --git a/English.lproj/Preferences.nib/keyedobjects.nib b/English.lproj/Preferences.nib/keyedobjects.nib index d1689b0..e8852a5 100755 Binary files a/English.lproj/Preferences.nib/keyedobjects.nib and b/English.lproj/Preferences.nib/keyedobjects.nib differ diff --git a/MainController.m b/MainController.m index 8cb2643..2517c39 100755 --- a/MainController.m +++ b/MainController.m @@ -6,6 +6,7 @@ #import #import #import +#import #import "StatusWindow.h" #import "StatusWindowController.h" #import "StatusItemHack.h" @@ -810,6 +811,20 @@ static MainController *sharedController; [hotKey setAction:@selector(popupMenu)]; [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]]; } + + int i; + for (i = 0; i <= 5; i++) { + NSString *curName = [NSString stringWithFormat:@"SetRating%i", i]; + if ([df objectForKey:curName] != nil) { + ITDebugLog(@"Setting up set rating %i hot key.", i); + hotKey = [[ITHotKey alloc] init]; + [hotKey setName:curName]; + [hotKey setKeyCombo:[ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:curName]]]; + [hotKey setTarget:self]; + [hotKey setAction:@selector(setRating:)]; + [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]]; + } + } ITDebugLog(@"Finished setting up hot keys."); } @@ -1078,6 +1093,13 @@ static MainController *sharedController; NS_ENDHANDLER } +- (void)setRating:(ITHotKey *)sender +{ + float rating = ([[sender name] characterAtIndex:9] - 48) / 5.0; + [self selectSongRating:rating]; + [statusWindowController showRatingWindowWithRating:rating]; +} + - (void)toggleLoop { NS_DURING diff --git a/PreferencesController.m b/PreferencesController.m index 76bbc23..b1c2432 100755 --- a/PreferencesController.m +++ b/PreferencesController.m @@ -98,6 +98,12 @@ static PreferencesController *prefs = nil; @"ToggleShuffle", @"ToggleLoop", @"PopupMenu", + @"SetRating0", + @"SetRating1", + @"SetRating2", + @"SetRating3", + @"SetRating4", + @"SetRating5", nil]; hotKeyNamesArray = [[NSArray alloc] initWithObjects:@"Play/Pause", @@ -115,6 +121,12 @@ static PreferencesController *prefs = nil; @"Toggle Shuffle", @"Toggle Loop", @"Pop-up status menu", + [NSString stringWithUTF8String:"Set Rating: ☆☆☆☆☆"], + [NSString stringWithUTF8String:"Set Rating: ★☆☆☆☆"], + [NSString stringWithUTF8String:"Set Rating: ★★☆☆☆"], + [NSString stringWithUTF8String:"Set Rating: ★★★☆☆"], + [NSString stringWithUTF8String:"Set Rating: ★★★★☆"], + [NSString stringWithUTF8String:"Set Rating: ★★★★★"], nil]; hotKeysDictionary = [[NSMutableDictionary alloc] init]; controller = nil; @@ -194,6 +206,7 @@ static PreferencesController *prefs = nil; [self setupUI]; // Sets up additional UI [window setDelegate:self]; [menuTableView reloadData]; + [hotKeysTableView reloadData]; [hotKeysTableView setDoubleAction:@selector(hotKeysTableViewDoubleClicked:)]; //Change the launch player checkbox to the proper name