1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 09:37:56 +00:00

Make sure the scheduler 24-hour format is double digits.

This commit is contained in:
Mitchell Livingston 2006-08-20 20:46:55 +00:00
parent eb026f1528
commit 0caa326038
2 changed files with 12 additions and 11 deletions

View file

@ -117,8 +117,7 @@
while ((torrent = [enumerator nextObject])) while ((torrent = [enumerator nextObject]))
size += [torrent size]; size += [torrent size];
[fSizeField setStringValue: [[NSString stringForFileSize: size] [fSizeField setStringValue: [[NSString stringForFileSize: size] stringByAppendingString: @" Total"]];
stringByAppendingString: @" Total"]];
} }
else else
{ {
@ -448,10 +447,8 @@
{ {
if (tableView == fPeerTable) if (tableView == fPeerTable)
return [fPeers count]; return [fPeers count];
else if (tableView == fFileTable)
return [fFiles count];
else else
return 0; return [fFiles count];
} }
- (id) tableView: (NSTableView *) tableView objectValueForTableColumn: (NSTableColumn *) column row: (int) row - (id) tableView: (NSTableView *) tableView objectValueForTableColumn: (NSTableColumn *) column row: (int) row
@ -553,8 +550,7 @@
NSEnumerator * enumerator = [fTorrents objectEnumerator]; NSEnumerator * enumerator = [fTorrents objectEnumerator];
float ratioLimit = [sender floatValue]; float ratioLimit = [sender floatValue];
if (![[sender stringValue] isEqualToString: [NSString stringWithFormat: @"%.2f", ratioLimit]] if (![[sender stringValue] isEqualToString: [NSString stringWithFormat: @"%.2f", ratioLimit]] || ratioLimit < 0)
|| ratioLimit < 0)
{ {
NSBeep(); NSBeep();
float ratioLimit = [[enumerator nextObject] ratioLimit]; //use first torrent float ratioLimit = [[enumerator nextObject] ratioLimit]; //use first torrent

View file

@ -174,11 +174,11 @@
[fSpeedLimitAutoCheck setState: speedLimitAuto]; [fSpeedLimitAutoCheck setState: speedLimitAuto];
int speedLimitAutoOnHour = [fDefaults integerForKey: @"SpeedLimitAutoOnHour"]; int speedLimitAutoOnHour = [fDefaults integerForKey: @"SpeedLimitAutoOnHour"];
[fSpeedLimitAutoOnField setIntValue: speedLimitAutoOnHour]; [fSpeedLimitAutoOnField setStringValue: [NSString stringWithFormat: @"%02d", speedLimitAutoOnHour]];
[fSpeedLimitAutoOnField setEnabled: speedLimitAuto]; [fSpeedLimitAutoOnField setEnabled: speedLimitAuto];
int speedLimitAutoOffHour = [fDefaults integerForKey: @"SpeedLimitAutoOffHour"]; int speedLimitAutoOffHour = [fDefaults integerForKey: @"SpeedLimitAutoOffHour"];
[fSpeedLimitAutoOffField setIntValue: speedLimitAutoOffHour]; [fSpeedLimitAutoOffField setStringValue: [NSString stringWithFormat: @"%02d", speedLimitAutoOffHour]];
[fSpeedLimitAutoOffField setEnabled: speedLimitAuto]; [fSpeedLimitAutoOffField setEnabled: speedLimitAuto];
//set ratio limit //set ratio limit
@ -512,16 +512,21 @@
NSString * key = (sender == fSpeedLimitAutoOnField) ? @"SpeedLimitAutoOnHour" : @"SpeedLimitAutoOffHour"; NSString * key = (sender == fSpeedLimitAutoOnField) ? @"SpeedLimitAutoOnHour" : @"SpeedLimitAutoOffHour";
int hour = [sender intValue]; 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]) || [fSpeedLimitAutoOnField intValue] == [fSpeedLimitAutoOffField intValue])
{ {
NSBeep(); NSBeep();
hour = [fDefaults integerForKey: key]; hour = [fDefaults integerForKey: key];
[sender setIntValue: hour]; [sender setStringValue: [NSString stringWithFormat: @"%02d", hour]];
} }
else else
[fDefaults setInteger: hour forKey: key]; [fDefaults setInteger: hour forKey: key];
[sender setStringValue: [NSString stringWithFormat: @"%02d", hour]]; //ensure number has 2 digits
[[NSNotificationCenter defaultCenter] postNotificationName: @"AutoSpeedLimitChange" object: self]; [[NSNotificationCenter defaultCenter] postNotificationName: @"AutoSpeedLimitChange" object: self];
} }