From 0caa326038dd7f3f98a4f7b26fbfaee5314b07a0 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Sun, 20 Aug 2006 20:46:55 +0000 Subject: [PATCH] Make sure the scheduler 24-hour format is double digits. --- macosx/InfoWindowController.m | 10 +++------- macosx/PrefsController.m | 13 +++++++++---- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/macosx/InfoWindowController.m b/macosx/InfoWindowController.m index e1e32bfbf..eae8f4214 100644 --- a/macosx/InfoWindowController.m +++ b/macosx/InfoWindowController.m @@ -117,8 +117,7 @@ while ((torrent = [enumerator nextObject])) size += [torrent size]; - [fSizeField setStringValue: [[NSString stringForFileSize: size] - stringByAppendingString: @" Total"]]; + [fSizeField setStringValue: [[NSString stringForFileSize: size] stringByAppendingString: @" Total"]]; } else { @@ -448,10 +447,8 @@ { if (tableView == fPeerTable) return [fPeers count]; - else if (tableView == fFileTable) - return [fFiles count]; else - return 0; + return [fFiles count]; } - (id) tableView: (NSTableView *) tableView objectValueForTableColumn: (NSTableColumn *) column row: (int) row @@ -553,8 +550,7 @@ NSEnumerator * enumerator = [fTorrents objectEnumerator]; float ratioLimit = [sender floatValue]; - if (![[sender stringValue] isEqualToString: [NSString stringWithFormat: @"%.2f", ratioLimit]] - || ratioLimit < 0) + if (![[sender stringValue] isEqualToString: [NSString stringWithFormat: @"%.2f", ratioLimit]] || ratioLimit < 0) { NSBeep(); float ratioLimit = [[enumerator nextObject] ratioLimit]; //use first torrent diff --git a/macosx/PrefsController.m b/macosx/PrefsController.m index ff0fa6a29..d0807b80b 100644 --- a/macosx/PrefsController.m +++ b/macosx/PrefsController.m @@ -174,11 +174,11 @@ [fSpeedLimitAutoCheck setState: speedLimitAuto]; int speedLimitAutoOnHour = [fDefaults integerForKey: @"SpeedLimitAutoOnHour"]; - [fSpeedLimitAutoOnField setIntValue: speedLimitAutoOnHour]; + [fSpeedLimitAutoOnField setStringValue: [NSString stringWithFormat: @"%02d", speedLimitAutoOnHour]]; [fSpeedLimitAutoOnField setEnabled: speedLimitAuto]; int speedLimitAutoOffHour = [fDefaults integerForKey: @"SpeedLimitAutoOffHour"]; - [fSpeedLimitAutoOffField setIntValue: speedLimitAutoOffHour]; + [fSpeedLimitAutoOffField setStringValue: [NSString stringWithFormat: @"%02d", speedLimitAutoOffHour]]; [fSpeedLimitAutoOffField setEnabled: speedLimitAuto]; //set ratio limit @@ -512,16 +512,21 @@ NSString * key = (sender == fSpeedLimitAutoOnField) ? @"SpeedLimitAutoOnHour" : @"SpeedLimitAutoOffHour"; int hour = [sender intValue]; - if (![[sender stringValue] isEqualToString: [NSString stringWithFormat: @"%d", hour]] || hour < 0 || hour > 23 + + //allow numbers under ten in the format 0x + if (!([[sender stringValue] isEqualToString: [NSString stringWithFormat: @"%d", hour]] + || [[sender stringValue] isEqualToString: [NSString stringWithFormat: @"%02d", hour]]) || hour < 0 || hour > 23 || [fSpeedLimitAutoOnField intValue] == [fSpeedLimitAutoOffField intValue]) { NSBeep(); hour = [fDefaults integerForKey: key]; - [sender setIntValue: hour]; + [sender setStringValue: [NSString stringWithFormat: @"%02d", hour]]; } else [fDefaults setInteger: hour forKey: key]; + [sender setStringValue: [NSString stringWithFormat: @"%02d", hour]]; //ensure number has 2 digits + [[NSNotificationCenter defaultCenter] postNotificationName: @"AutoSpeedLimitChange" object: self]; }