task: improve threading
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QHBoxLayout>
|
||||
#include <cmath>
|
||||
|
||||
#include "common/timecodefunctions.h"
|
||||
|
||||
@@ -80,7 +81,7 @@ void ElapsedCounterWidget::UpdateTimers()
|
||||
double ms_per_progress_unit = elapsed_ms / last_progress_;
|
||||
double remaining_progress = 1.0 - last_progress_;
|
||||
|
||||
remaining_ms = qRound64(ms_per_progress_unit * remaining_progress);
|
||||
remaining_ms = std::ceil(ms_per_progress_unit * remaining_progress);
|
||||
} else {
|
||||
elapsed_ms = 0;
|
||||
remaining_ms = 0;
|
||||
|
||||
@@ -37,8 +37,9 @@ public:
|
||||
|
||||
void SetProgress(double d);
|
||||
|
||||
void Start();
|
||||
public slots:
|
||||
void Start(qint64 start_time);
|
||||
void Start();
|
||||
|
||||
public slots:
|
||||
void Stop();
|
||||
|
||||
@@ -72,9 +72,9 @@ TaskViewItem::TaskViewItem(Task* task, QWidget *parent) :
|
||||
|
||||
// Set up elapsed timer
|
||||
status_stack_->setCurrentWidget(elapsed_timer_lbl_);
|
||||
elapsed_timer_lbl_->Start(task_->GetStartTime());
|
||||
|
||||
// Connect to the task
|
||||
connect(task_, &Task::Started, elapsed_timer_lbl_, qOverload<qint64>(&ElapsedCounterWidget::Start));
|
||||
connect(task_, &Task::ProgressChanged, this, &TaskViewItem::UpdateProgress);
|
||||
connect(cancel_btn_, &QPushButton::clicked, this, [this] { emit TaskCancelled(task_); });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user