Changeset 740 for trunk/macosx
- Timestamp:
- Aug 8, 2006, 2:11:51 AM (16 years ago)
- Location:
- trunk/macosx
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/macosx/Controller.h
r721 r740 61 61 BOOL fSpeedLimitEnabled; 62 62 NSImage * fSpeedLimitNormalImage, * fSpeedLimitBlueImage, * fSpeedLimitGraphiteImage; 63 NSTimer * fSpeedLimitTimer; 63 64 64 65 IBOutlet ImageBackgroundView * fStatusBar; … … 147 148 148 149 - (void) toggleSpeedLimit: (id) sender; 150 - (void) autoSpeedLimit: (NSTimer *) timer; 149 151 150 152 - (void) setLimitGlobalEnabled: (id) sender; -
trunk/macosx/Controller.m
r735 r740 52 52 #define WINDOW_REGULAR_WIDTH 468.0 53 53 54 #define AUTO_SPEED_LIMIT_SECONDS 10.0 55 54 56 #define WEBSITE_URL @"http://transmission.m0k.org/" 55 57 #define FORUM_URL @"http://transmission.m0k.org/forum/" … … 345 347 [self showInfo: nil]; 346 348 349 //timer to auto toggle speed limit 350 fSpeedLimitTimer = [NSTimer scheduledTimerWithTimeInterval: AUTO_SPEED_LIMIT_SECONDS target: self 351 selector: @selector(autoSpeedLimit:) userInfo: nil repeats: YES]; 352 347 353 //timer to check for auto import every 15 seconds, must do after everything else is set up 348 354 fAutoImportTimer = [NSTimer scheduledTimerWithTimeInterval: 15.0 target: self … … 398 404 //stop timers 399 405 [fAutoImportTimer invalidate]; 406 [fSpeedLimitTimer invalidate]; 400 407 [fTimer invalidate]; 401 408 … … 1202 1209 } 1203 1210 1211 - (void) autoSpeedLimit: (NSTimer *) timer 1212 { 1213 BOOL autoOn, autoOff; 1214 if (!(autoOn = [fDefaults boolForKey: @"SpeedLimitAutoOn"]) 1215 && !(autoOff = [fDefaults boolForKey: @"SpeedLimitAutoOff"])) 1216 return; 1217 1218 //do nothing if time to turn on and off are equal 1219 int onHour, offHour; 1220 if ((onHour = [fDefaults integerForKey: @"SpeedLimitAutoOnHour"]) 1221 == (offHour = [fDefaults integerForKey: @"SpeedLimitAutoOffHour"]) && autoOn && autoOff) 1222 return; 1223 1224 NSCalendarDate * currentDate = [NSCalendarDate calendarDate]; 1225 //do nothing if not within first few seconds of hour 1226 if ([currentDate minuteOfHour] > 0 || [currentDate secondOfMinute] >= AUTO_SPEED_LIMIT_SECONDS) 1227 return; 1228 1229 if ([currentDate hourOfDay] == (fSpeedLimitEnabled ? offHour : onHour)) 1230 [self toggleSpeedLimit: nil]; 1231 } 1232 1204 1233 - (void) setLimitGlobalEnabled: (id) sender 1205 1234 { -
trunk/macosx/Defaults.plist
r735 r740 75 75 <key>SpeedLimit</key> 76 76 <false/> 77 <key>SpeedLimitAutoOff</key> 78 <false/> 79 <key>SpeedLimitAutoOffHour</key> 80 <integer>0</integer> 81 <key>SpeedLimitAutoOn</key> 82 <false/> 83 <key>SpeedLimitAutoOnHour</key> 84 <integer>12</integer> 77 85 <key>SpeedLimitDownloadLimit</key> 78 86 <integer>10</integer> -
trunk/macosx/English.lproj/PrefsWindow.nib/classes.nib
r737 r740 3 3 {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, 4 4 {CLASS = MenuButton; LANGUAGE = ObjC; SUPERCLASS = NSButton; }, 5 {CLASS = NSDatePicker; LANGUAGE = ObjC; SUPERCLASS = NSControl; }, 5 6 { 6 7 ACTIONS = { … … 9 10 setAutoImport = id; 10 11 setAutoSize = id; 12 setAutoSpeedLimitCheck = id; 13 setAutoSpeedLimitHour = id; 11 14 setBadge = id; 12 15 setDownloadLocation = id; … … 52 55 fRemoveDownloadingCheck = NSButton; 53 56 fSeedingSoundPopUp = NSPopUpButton; 57 fSpeedLimitAutoOffCheck = NSButton; 58 fSpeedLimitAutoOffField = NSTextField; 59 fSpeedLimitAutoOnCheck = NSButton; 60 fSpeedLimitAutoOnField = NSTextField; 54 61 fSpeedLimitDownloadField = NSTextField; 55 62 fSpeedLimitUploadField = NSTextField; -
trunk/macosx/English.lproj/PrefsWindow.nib/info.nib
r737 r740 8 8 <dict> 9 9 <key>153</key> 10 <string> 59 422 582 2170 0 1152 842 </string>10 <string>95 422 582 291 0 0 1152 842 </string> 11 11 <key>28</key> 12 12 <string>58 372 582 290 0 0 1152 842 </string> 13 13 <key>41</key> 14 <string> 84 320582 304 0 0 1152 842 </string>14 <string>138 419 582 304 0 0 1152 842 </string> 15 15 <key>66</key> 16 16 <string>179 527 582 104 0 0 1152 842 </string> … … 24 24 <key>IBOpenObjects</key> 25 25 <array> 26 <integer> 41</integer>26 <integer>153</integer> 27 27 </array> 28 28 <key>IBSystem Version</key> -
trunk/macosx/PrefsController.h
r737 r740 46 46 47 47 IBOutlet NSTextField * fUploadField, * fDownloadField, 48 * fSpeedLimitUploadField, * fSpeedLimitDownloadField; 49 IBOutlet NSButton * fUploadCheck, * fDownloadCheck; 48 * fSpeedLimitUploadField, * fSpeedLimitDownloadField, 49 * fSpeedLimitAutoOnField, * fSpeedLimitAutoOffField; 50 IBOutlet NSButton * fUploadCheck, * fDownloadCheck, 51 * fSpeedLimitAutoOnCheck, * fSpeedLimitAutoOffCheck; 50 52 51 53 IBOutlet NSTextField * fPortField; … … 82 84 - (void) setSpeedLimit: (id) sender; 83 85 86 - (void) setAutoSpeedLimitCheck: (id) sender; 87 - (void) setAutoSpeedLimitHour: (id) sender; 88 84 89 - (void) setLimit: (id) sender; 85 90 - (void) setLimitCheck: (id) sender; -
trunk/macosx/PrefsController.m
r737 r740 78 78 fHandle = handle; 79 79 80 [[self window] update]; //make sure nib is loaded right away 80 NSWindow * window = [self window]; 81 [window setDelegate: window]; 82 [window update]; //make sure nib is loaded right away 81 83 } 82 84 return self; … … 169 171 tr_setDownloadLimit(fHandle, checkDownload ? downloadLimit : -1); 170 172 } 173 174 //set auto speed limit 175 BOOL speedLimitAutoOn = [fDefaults boolForKey: @"SpeedLimitAutoOn"]; 176 int speedLimitAutoOnHour = [fDefaults integerForKey: @"SpeedLimitAutoOnHour"]; 177 178 [fSpeedLimitAutoOnCheck setState: speedLimitAutoOn]; 179 [fSpeedLimitAutoOnField setIntValue: speedLimitAutoOnHour]; 180 [fSpeedLimitAutoOnField setEnabled: speedLimitAutoOn]; 181 182 BOOL speedLimitAutoOff = [fDefaults boolForKey: @"SpeedLimitAutoOff"]; 183 int speedLimitAutoOffHour = [fDefaults integerForKey: @"SpeedLimitAutoOffHour"]; 184 185 [fSpeedLimitAutoOffCheck setState: speedLimitAutoOff]; 186 [fSpeedLimitAutoOffField setIntValue: speedLimitAutoOffHour]; 187 [fSpeedLimitAutoOffField setEnabled: speedLimitAutoOff]; 171 188 172 189 //set ratio limit … … 376 393 if (![fDefaults boolForKey: @"SpeedLimit"]) 377 394 { 395 int realLimit = [check state] ? limit : -1; 378 396 if (sender == fUploadField) 379 tr_setUploadLimit(fHandle, [fUploadCheck state] ? limit : -1);397 tr_setUploadLimit(fHandle, realLimit); 380 398 else 381 tr_setDownloadLimit(fHandle, [fDownloadCheck state] ? limit : -1);399 tr_setDownloadLimit(fHandle, realLimit); 382 400 } 383 401 … … 482 500 } 483 501 502 - (void) setAutoSpeedLimitCheck: (id) sender 503 { 504 NSString * key; 505 NSTextField * field; 506 if (sender == fSpeedLimitAutoOnCheck) 507 { 508 key = @"SpeedLimitAutoOn"; 509 field = fSpeedLimitAutoOnField; 510 } 511 else 512 { 513 key = @"SpeedLimitAutoOff"; 514 field = fSpeedLimitAutoOffField; 515 } 516 517 BOOL check = [sender state] == NSOnState; 518 [self setAutoSpeedLimitHour: field]; 519 [field setEnabled: check]; 520 521 [fDefaults setBool: check forKey: key]; 522 } 523 524 - (void) setAutoSpeedLimitHour: (id) sender 525 { 526 NSString * key = (sender == fSpeedLimitAutoOnField) ? @"SpeedLimitAutoOnHour" : @"SpeedLimitAutoOffHour"; 527 528 int hour = [sender intValue]; 529 if (![[sender stringValue] isEqualToString: [NSString stringWithFormat: @"%d", hour]] || hour < 0 || hour > 23) 530 { 531 NSBeep(); 532 hour = [fDefaults integerForKey: key]; 533 [sender setIntValue: hour]; 534 } 535 else 536 [fDefaults setInteger: hour forKey: key]; 537 } 538 484 539 - (void) setRatio: (id) sender 485 540 { … … 733 788 } 734 789 735 - (void) windowWillClose: (NSNotification *) notification736 {737 [[self window] makeFirstResponder: nil];738 }739 740 790 @end 741 791 -
trunk/macosx/PrefsWindow.m
r726 r740 27 27 @implementation PrefsWindow 28 28 29 - (void) keyDown: (NSEvent *) event29 - (void) keyDown: (NSEvent *) event 30 30 { 31 [super keyDown: event]; 31 32 if ([event keyCode] == 53) //esc key 32 33 [self close]; 33 34 } 34 35 36 - (void) windowWillClose: (NSNotification *) notification 37 { 38 [self makeFirstResponder: nil]; //essentially saves changes on window close 39 } 40 35 41 @end
Note: See TracChangeset
for help on using the changeset viewer.