Streamlined autoenable function a little.
This commit is contained in:
parent
cc66511f98
commit
e6d81110d9
|
@ -1266,23 +1266,14 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
||||||
== (offHour = [fDefaults integerForKey: @"SpeedLimitAutoOffHour"]))
|
== (offHour = [fDefaults integerForKey: @"SpeedLimitAutoOffHour"]))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BOOL rangeForOn = onHour < offHour;
|
BOOL shouldBeOn;
|
||||||
int min, max;
|
|
||||||
if (rangeForOn)
|
|
||||||
{
|
|
||||||
min = onHour;
|
|
||||||
max = offHour;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
min = offHour;
|
|
||||||
max = onHour;
|
|
||||||
}
|
|
||||||
|
|
||||||
int hour = [[NSCalendarDate calendarDate] hourOfDay];
|
int hour = [[NSCalendarDate calendarDate] hourOfDay];
|
||||||
BOOL inRange = hour >= min && hour < max;
|
if (onHour < offHour)
|
||||||
|
shouldBeOn = hour >= onHour && hour < offHour;
|
||||||
|
else
|
||||||
|
shouldBeOn = hour < offHour || hour >= onHour;
|
||||||
|
|
||||||
if ((!fSpeedLimitEnabled && (rangeForOn == inRange)) || (fSpeedLimitEnabled && (rangeForOn != inRange)))
|
if ((!fSpeedLimitEnabled && shouldBeOn) || (fSpeedLimitEnabled && !shouldBeOn))
|
||||||
{
|
{
|
||||||
[self toggleSpeedLimit: nil];
|
[self toggleSpeedLimit: nil];
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<key>IBEditorPositions</key>
|
<key>IBEditorPositions</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>153</key>
|
<key>153</key>
|
||||||
<string>119 348 584 311 0 0 1152 842 </string>
|
<string>285 423 582 311 0 0 1152 842 </string>
|
||||||
<key>28</key>
|
<key>28</key>
|
||||||
<string>58 372 582 290 0 0 1152 842 </string>
|
<string>58 372 582 290 0 0 1152 842 </string>
|
||||||
<key>41</key>
|
<key>41</key>
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue