Added hotkeys for setting individual song ratings 0-5 stars.
authorKent Sutherland <ksuther@ithinksw.com>
Thu, 1 Jul 2004 02:48:47 +0000 (02:48 +0000)
committerKent Sutherland <ksuther@ithinksw.com>
Thu, 1 Jul 2004 02:48:47 +0000 (02:48 +0000)
English.lproj/Preferences.nib/keyedobjects.nib
MainController.m
PreferencesController.m

index d1689b0..e8852a5 100755 (executable)
Binary files a/English.lproj/Preferences.nib/keyedobjects.nib and b/English.lproj/Preferences.nib/keyedobjects.nib differ
index 8cb2643..2517c39 100755 (executable)
@@ -6,6 +6,7 @@
 #import <ITKit/ITHotKeyCenter.h>
 #import <ITKit/ITHotKey.h>
 #import <ITKit/ITKeyCombo.h>
 #import <ITKit/ITHotKeyCenter.h>
 #import <ITKit/ITHotKey.h>
 #import <ITKit/ITKeyCombo.h>
+#import <ITKit/ITCategory-NSMenu.h>
 #import "StatusWindow.h"
 #import "StatusWindowController.h"
 #import "StatusItemHack.h"
 #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]];
     }
         [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.");
 }
 
     ITDebugLog(@"Finished setting up hot keys.");
 }
 
@@ -1078,6 +1093,13 @@ static MainController *sharedController;
     NS_ENDHANDLER
 }
 
     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
 - (void)toggleLoop
 {
     NS_DURING
index 76bbc23..b1c2432 100755 (executable)
@@ -98,6 +98,12 @@ static PreferencesController *prefs = nil;
                                                        @"ToggleShuffle",
                                                        @"ToggleLoop",
                                                        @"PopupMenu",
                                                        @"ToggleShuffle",
                                                        @"ToggleLoop",
                                                        @"PopupMenu",
+                                                       @"SetRating0",
+                                                       @"SetRating1",
+                                                       @"SetRating2",
+                                                       @"SetRating3",
+                                                       @"SetRating4",
+                                                       @"SetRating5",
                                                        nil];
         
         hotKeyNamesArray = [[NSArray alloc] initWithObjects:@"Play/Pause",
                                                        nil];
         
         hotKeyNamesArray = [[NSArray alloc] initWithObjects:@"Play/Pause",
@@ -115,6 +121,12 @@ static PreferencesController *prefs = nil;
                                                        @"Toggle Shuffle",
                                                        @"Toggle Loop",
                                                        @"Pop-up status menu",
                                                        @"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;
                                                        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];
         [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
         [hotKeysTableView setDoubleAction:@selector(hotKeysTableViewDoubleClicked:)];
         
         //Change the launch player checkbox to the proper name