| 565 | } // ProgressTaskInfoPrivate::createItems |
| 566 | |
| 567 | void |
| 568 | ProgressTaskInfo::updateProgressBar(double totalProgress, |
| 569 | double subTaskProgress) |
| 570 | { |
| 571 | assert( QThread::currentThread() == qApp->thread() ); |
| 572 | totalProgress = MathUtils::clamp(totalProgress, 0., 1.); |
| 573 | subTaskProgress = MathUtils::clamp(subTaskProgress, 0., 1.); |
| 574 | |
| 575 | _imp->progressPercent = totalProgress * 100.; |
| 576 | if (_imp->progressBar) { |
| 577 | _imp->progressBar->setValue(_imp->progressPercent); |
| 578 | } |
| 579 | |
| 580 | |
| 581 | double timeElapsedSecs = _imp->timer->getTimeSinceCreation(); |
| 582 | _imp->timeRemaining = subTaskProgress == 0 ? 0 : timeElapsedSecs * (1. - subTaskProgress) / subTaskProgress; |
| 583 | |
| 584 | if ( !_imp->nameItem && !wasCanceled() ) { |
| 585 | ///Show the item if the total estimated time is gt NATRON_SHOW_PROGRESS_TOTAL_ESTIMATED_TIME_MS |
| 586 | //double totalTime = subTaskProgress == 0 ? 0 : timeElapsedSecs * 1. / subTaskProgress; |
| 587 | |
| 588 | // If we estimate that the task will be longer than NATRON_SHOW_PROGRESS_TOTAL_ESTIMATED_TIME_MS and it has been |
| 589 | // NATRON_PROGRESS_DIALOG_ETA_REFRESH_MS elapsed, show it |
| 590 | if ( (_imp->timeRemaining * 1000 > NATRON_SHOW_PROGRESS_TOTAL_ESTIMATED_TIME_MS) && |
| 591 | ( timeElapsedSecs * 1000 > NATRON_PROGRESS_DIALOG_ETA_REFRESH_MS) ) { |
| 592 | _imp->createItems(); |
| 593 | _imp->panel->onShowProgressPanelTimerTriggered(); |
| 594 | } |
| 595 | } |
| 596 | |
| 597 | if (!_imp->updatedProgressOnce && _imp->statusItem) { |
| 598 | _imp->updatedProgressOnce = true; |
| 599 | _imp->statusItem->setTextColor(Qt::green); |
| 600 | _imp->status = eProgressTaskStatusRunning; |
| 601 | _imp->statusItem->setText( tr("Running") ); |
| 602 | _imp->refreshButtons(); |
| 603 | } |
| 604 | |
| 605 | updateTaskBarProgress(_imp->status, _imp->progressPercent); |
| 606 | } |
| 607 | |
| 608 | void |
| 609 | ProgressTaskInfo::updateProgress(const int frame, |
no test coverage detected