Lots of changes....
[MenuTunes.git] / PreferencesController.m
index 63e7101..4f43e26 100755 (executable)
@@ -1,5 +1,5 @@
 #import "PreferencesController.h"
-#import "MainController.h"
+#import "NewMainController.h"
 #import "HotKeyCenter.h"
 #import <ITKit/ITWindowPositioning.h>
 
@@ -95,41 +95,27 @@ static PreferencesController *prefs = nil;
 
 - (IBAction)changeGeneralSetting:(id)sender
 {
-    BOOL rebuildRequired = NO;
-
     if ( [sender tag] == 1010) {
         [self setLaunchesAtLogin:SENDER_STATE];
     } else if ( [sender tag] == 1020) {
         [df setBool:SENDER_STATE forKey:@"LaunchPlayerWithMT"];
     } else if ( [sender tag] == 1030) {
         [df setInteger:[sender intValue] forKey:@"SongsInAdvance"];
-        rebuildRequired = YES;
+
     } else if ( [sender tag] == 1040) {
         // This will not be executed.  Song info always shows the title of the song.
         // [df setBool:SENDER_STATE forKey:@"showName"];
-        // rebuildRequired = YES;
     } else if ( [sender tag] == 1050) {
         [df setBool:SENDER_STATE forKey:@"showArtist"];
-        rebuildRequired = YES;
     } else if ( [sender tag] == 1060) {
         [df setBool:SENDER_STATE forKey:@"showAlbum"];
-        rebuildRequired = YES;
     } else if ( [sender tag] == 1070) {
         [df setBool:SENDER_STATE forKey:@"showTime"];
-        rebuildRequired = YES;
     } else if ( [sender tag] == 1080) {
         [df setBool:SENDER_STATE forKey:@"showTrackNumber"];
-        rebuildRequired = YES;
     } else if ( [sender tag] == 1090) {
         [df setBool:SENDER_STATE forKey:@"showTrackRating"];
-        rebuildRequired = YES;
-    }
-
-    if ( rebuildRequired ) {
-        //[controller rebuildMenu];
-        // redraw song info status window, or upcoming songs here
     }
-
     [df synchronize];
 }
 
@@ -296,7 +282,6 @@ static PreferencesController *prefs = nil;
     NSString *string = [combo userDisplayRep];
     NSEnumerator *enumerator = [hotKeysDictionary keyEnumerator];
     NSString *enumKey;
-    BOOL duplicateCombo = NO;
     
     if (string == nil) {
         string = @"";
@@ -343,35 +328,45 @@ static PreferencesController *prefs = nil;
         }
     }
     
-    if (!duplicateCombo) {
-        [hotKeysDictionary setObject:combo forKey:currentHotKey];
-        [df setKeyCombo:combo forKey:currentHotKey];
-        
-        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:@"ToggleVisualizer"]) {
-            [visualizerButton 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];
-        }
+    [hotKeysDictionary setObject:combo forKey:currentHotKey];
+    [df setKeyCombo:combo forKey:currentHotKey];
+    
+    if ([currentHotKey isEqualToString:@"PlayPause"]) {
+        [playPauseButton setTitle:string];
+        [[HotKeyCenter sharedCenter] addHotKey:@"PlayPause" combo:combo target:[MainController sharedController] action:@selector(playPause)];
+    } else if ([currentHotKey isEqualToString:@"NextTrack"]) {
+        [nextTrackButton setTitle:string];
+        [[HotKeyCenter sharedCenter] addHotKey:@"NextTrack" combo:combo target:[MainController sharedController] action:@selector(nextSong)];
+    } else if ([currentHotKey isEqualToString:@"PrevTrack"]) {
+        [previousTrackButton setTitle:string];
+        [[HotKeyCenter sharedCenter] addHotKey:@"PrevTrack" combo:combo target:[MainController sharedController] action:@selector(prevSong)];
+    } else if ([currentHotKey isEqualToString:@"ToggleVisualizer"]) {
+        [visualizerButton setTitle:string];
+        //[[HotKeyCenter sharedCenter] addHotKey:@"ToggleVisualizer" combo:combo target:[MainController sharedController] selector:@selector(NULL)];
+    } else if ([currentHotKey isEqualToString:@"TrackInfo"]) {
+        [trackInfoButton setTitle:string];
+        [[HotKeyCenter sharedCenter] addHotKey:@"TrackInfo" combo:combo target:[MainController sharedController] action:@selector(showCurrentTrackInfo)];
+    } else if ([currentHotKey isEqualToString:@"UpcomingSongs"]) {
+        [upcomingSongsButton setTitle:string];
+        [[HotKeyCenter sharedCenter] addHotKey:@"UpcomingSongs" combo:combo target:[MainController sharedController] action:@selector(showUpcomingSongs)];
+    } else if ([currentHotKey isEqualToString:@"IncrementVolume"]) {
+        [volumeIncrementButton setTitle:string];
+        [[HotKeyCenter sharedCenter] addHotKey:@"IncrementVolume" combo:combo target:[MainController sharedController] action:@selector(incrementVolume)];
+    } else if ([currentHotKey isEqualToString:@"DecrementVolume"]) {
+        [volumeDecrementButton setTitle:string];
+        [[HotKeyCenter sharedCenter] addHotKey:@"DecrementVolume" combo:combo target:[MainController sharedController] action:@selector(decrementVolume)];
+    } else if ([currentHotKey isEqualToString:@"IncrementRating"]) {
+        [ratingIncrementButton setTitle:string];
+        [[HotKeyCenter sharedCenter] addHotKey:@"IncrementRating" combo:combo target:[MainController sharedController] action:@selector(incrementRating)];
+    } else if ([currentHotKey isEqualToString:@"DecrementRating"]) {
+        [ratingDecrementButton setTitle:string];
+        [[HotKeyCenter sharedCenter] addHotKey:@"DecrementRating" combo:combo target:[MainController sharedController] action:@selector(decrementRating)];
+    } else if ([currentHotKey isEqualToString:@"ToggleShuffle"]) {
+        [toggleShuffleButton setTitle:string];
+        [[HotKeyCenter sharedCenter] addHotKey:@"ToggleShuffle" combo:combo target:[MainController sharedController] action:@selector(toggleShuffle)];
+    } else if ([currentHotKey isEqualToString:@"ToggleLoop"]) {
+        [toggleLoopButton setTitle:string];
+        [[HotKeyCenter sharedCenter] addHotKey:@"ToggleLoop" combo:combo target:[MainController sharedController] action:@selector(toggleLoop)];
     }
     [self cancelHotKey:sender];
 }
@@ -606,6 +601,7 @@ static PreferencesController *prefs = nil;
     [nameCheckbox setEnabled:NO];  // Song info will ALWAYS show song title.
     [artistCheckbox setState:[df boolForKey:@"showArtist"] ? NSOnState : NSOffState];
     [trackTimeCheckbox setState:[df boolForKey:@"showTime"] ? NSOnState : NSOffState];
+    [trackNumberCheckbox setState:[df boolForKey:@"showTrackNumber"] ? NSOnState : NSOffState];
     
     // Set the launch at login checkbox state
     [df synchronize];