Changeset 330 for trunk/Cocoa/AntiRSI/AntiRSI.m
- Timestamp:
- 08/06/07 19:01:05 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cocoa/AntiRSI/AntiRSI.m
r329 r330 279 279 micro_pause_t += tick_time; 280 280 work_break_t += tick_time; 281 if (idle_time < 1) { 282 session_t += tick_time; 283 } 281 284 micro_pause_taking_t = 0; 282 285 if (work_break_taking_t > 0) { … … 338 341 if (idle_time < 1 && !slack) { 339 342 micro_pause_taking_t = 0; 343 session_t += tick_time; 340 344 } 341 345 342 346 // update window 343 [progress setDoubleValue:micro_pause_taking_t]; 344 [self drawTimeLeft:micro_pause_duration - micro_pause_taking_t]; 345 [self drawNextBreak:work_break_period - work_break_t]; 346 347 // if user likes to be interrupted 348 if (lock_focus) { 349 [NSApp activateIgnoringOtherApps:YES]; 350 [main_window makeKeyAndOrderFront:self]; 351 } 352 347 [self updateBreakWindowDuration:micro_pause_duration progress:micro_pause_taking_t 348 nextBreak:work_break_period - work_break_t]; 349 353 350 // check if we done enough 354 351 if (micro_pause_taking_t > micro_pause_duration) { … … 375 372 if (idle_time >= 2 || work_break_taking_t < 3) { 376 373 work_break_taking_t += tick_time; 377 } 374 } else if (idle_time < 1) { 375 session_t += tick_time; 376 } 378 377 379 378 // draw window 380 [progress setDoubleValue:work_break_taking_t / 60 - 0.5]; 381 [self drawTimeLeft:work_break_duration - work_break_taking_t]; 382 [self drawNextBreak:work_break_period + work_break_duration - work_break_taking_t]; 383 384 // if user likes to be interrupted 385 if (lock_focus) { 386 [NSApp activateIgnoringOtherApps:YES]; 387 [main_window makeKeyAndOrderFront:self]; 388 } 379 [self updateBreakWindowDuration:work_break_duration progress:work_break_taking_t 380 nextBreak:work_break_period + work_break_duration - work_break_taking_t]; 389 381 390 382 // and check if we done enough … … 404 396 // draw dock image 405 397 if (draw_dock_image) [self drawDockImage]; 398 } 399 400 // dock image 401 - (NSMenu *)applicationDockMenu:(NSApplication *)sender; 402 { 403 [session_time_item setTitle:[self sessionTimeString]]; 404 return dock_menu; 406 405 } 407 406 … … 522 521 } 523 522 524 // diplays time left 525 - (void)drawTimeLeft:(double)seconds 526 { 527 [time setStringValue:[NSString stringWithFormat:@"%d:%02d", lrint(seconds) / 60, lrint(seconds) % 60]]; 528 } 529 530 // displays next break 531 - (void)drawNextBreak:(int)seconds 532 { 533 int minutes = round(seconds / 60.0) ; 523 - (NSString *)sessionTimeString; 524 { 525 return [NSString stringWithFormat:@"Session: %d:%02d:%02d", (int)session_t / 3600, (int)session_t / 60, lrint(session_t) % 60]; 526 } 527 528 - (void)updateBreakWindowDuration:(double)duration progress:(double)progress_t nextBreak:(double)nextBreak; 529 { 530 // progress 531 [progress setDoubleValue:duration >= 60 ? (progress_t / 60 - 0.5) : progress_t]; 532 533 // time left 534 double timeLeft = duration - progress_t; 535 [time setStringValue:[NSString stringWithFormat:@"%d:%02d", (int)timeLeft / 60, lrint(timeLeft) % 60]]; 536 537 // cumulative typing time in this session (e.g. today) 538 [session_time setStringValue:[self sessionTimeString]]; 539 540 // next break 541 int minutes = round(nextBreak / 60.0); 534 542 535 543 // nice hours, minutes ... … … 540 548 [next_break setStringValue:[NSString stringWithFormat:@"next break in %d minutes", minutes]]; 541 549 } 550 551 // if user likes to be interrupted 552 if (lock_focus) { 553 [NSApp activateIgnoringOtherApps:YES]; 554 [main_window makeKeyAndOrderFront:self]; 555 } 542 556 } 543 557 … … 597 611 } 598 612 613 - (IBAction)resetSession:(id)sender; 614 { 615 if (s_normal != state) { 616 [self endBreak]; 617 } 618 session_t = 0; 619 } 620 599 621 // validate menu items 600 622 - (BOOL)validateMenuItem:(NSMenuItem *)anItem 601 623 { 602 if ([ [anItem title] isEqualToString:@"Take Break Now"] && state == s_normal) {624 if ([anItem action] == @selector(breakNow:) && state == s_normal) 603 625 return YES; 604 } 605 606 if ([[anItem title] isEqualToString:@"Postpone Break"] && state == s_taking_work_break) { 626 627 if ([anItem action] == @selector(postpone:) && state == s_taking_work_break) 607 628 return YES; 608 } 609 610 if ([[anItem title] isEqualToString:@"AntiRSI Help"]) { 629 630 if ([anItem action] == @selector(resetSession:)) 611 631 return YES; 612 } 613 632 633 if ([anItem action] == @selector(gotoWebsite:)) 634 return YES; 635 636 if ([anItem action] == @selector(checkForUpdate:)) 637 return YES; 638 614 639 return NO; 615 640 }
Note:
See TracChangeset
for help on using the changeset viewer.