tasks now emit floats rather than integers

Simplifies code for tasks.
This commit is contained in:
itsmattkc
2020-05-19 02:44:38 +10:00
parent b9cd83eff1
commit cb383d760b
10 changed files with 28 additions and 11 deletions
+1 -1
View File
@@ -333,7 +333,7 @@ bool Decoder::HasConformedVersion(const AudioRenderingParams &params)
void Decoder::SignalProcessingProgress(const int64_t &ts)
{
if (stream()->duration() != AV_NOPTS_VALUE && stream()->duration() != 0) {
emit IndexProgress(qRound(100.0 * static_cast<double>(ts) / static_cast<double>(stream()->duration())));
emit IndexProgress(static_cast<double>(ts) / static_cast<double>(stream()->duration()));
}
}
+1 -1
View File
@@ -242,7 +242,7 @@ signals:
* @brief While indexing, this signal will provide progress as a percentage (0-100 inclusive) if
* available
*/
void IndexProgress(int);
void IndexProgress(double);
protected:
void SignalProcessingProgress(const int64_t& ts);
+5 -3
View File
@@ -77,12 +77,14 @@ void ProgressDialog::closeEvent(QCloseEvent *e)
#endif
}
void ProgressDialog::SetProgress(int value)
void ProgressDialog::SetProgress(double value)
{
bar_->setValue(value);
int percent = qRound(100.0 * value);
bar_->setValue(percent);
#ifdef Q_OS_WINDOWS
Core::instance()->main_window()->SetTaskbarButtonProgress(value, 100);
Core::instance()->main_window()->SetTaskbarButtonProgress(percent, 100);
#endif
}
+1 -1
View File
@@ -40,7 +40,7 @@ protected:
virtual void closeEvent(QCloseEvent *) override;
public slots:
void SetProgress(int value);
void SetProgress(double value);
signals:
void Cancelled();
+1 -1
View File
@@ -172,7 +172,7 @@ void RenderTask::Render(TimeRangeList range_to_cache, int divider)
// Signal process
counter++;
emit ProgressChanged(qRound(100.0 * static_cast<double>(counter) / static_cast<double>(nb_frames)));
emit ProgressChanged(static_cast<double>(counter) / static_cast<double>(nb_frames));
j = download_futures.erase(j);
} else {
+2 -2
View File
@@ -135,9 +135,9 @@ signals:
*
* @param p
*
* A value (percentage) between 0 and 100.
* A progress value between 0.0 and 1.0.
*/
void ProgressChanged(int p);
void ProgressChanged(double d);
private:
QString title_;
+6 -1
View File
@@ -60,7 +60,7 @@ TaskViewItem::TaskViewItem(Task* task, QWidget *parent) :
layout->addWidget(task_status_lbl_);
// Connect to the task
connect(task_, &Task::ProgressChanged, progress_bar_, &QProgressBar::setValue);
connect(task_, &Task::ProgressChanged, this, &TaskViewItem::UpdateProgress);
connect(cancel_btn_, &QPushButton::clicked, task_, &Task::Cancel, Qt::DirectConnection);
}
@@ -69,4 +69,9 @@ void TaskViewItem::Failed()
task_status_lbl_->setText(task_->GetError());
}
void TaskViewItem::UpdateProgress(double d)
{
progress_bar_->setValue(qRound(100.0 * d));
}
OLIVE_NAMESPACE_EXIT
+3
View File
@@ -55,6 +55,9 @@ private:
Task* task_;
private slots:
void UpdateProgress(double d);
};
OLIVE_NAMESPACE_EXIT
+6 -1
View File
@@ -72,10 +72,15 @@ void MainStatusBar::UpdateStatus()
}
bar_->setVisible(true);
connect(t, &Task::ProgressChanged, bar_, &QProgressBar::setValue);
connect(t, &Task::ProgressChanged, this, &MainStatusBar::SetProgressBarValue);
}
}
void MainStatusBar::SetProgressBarValue(double d)
{
bar_->setValue(qRound(100.0 * d));
}
void MainStatusBar::mouseDoubleClickEvent(QMouseEvent* e)
{
QStatusBar::mouseDoubleClickEvent(e);
+2
View File
@@ -48,6 +48,8 @@ protected:
private slots:
void UpdateStatus();
void SetProgressBarValue(double d);
private:
TaskManager* manager_;