From b88045fbcece304f6efd435f9d7b00ffb278e84d Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Sat, 2 Mar 2019 10:59:51 -0800 Subject: [PATCH] track total render time and show when progress bar reaches 100% --- dialogs/exportdialog.cpp | 20 +++++++++++++++++++- dialogs/exportdialog.h | 2 ++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/dialogs/exportdialog.cpp b/dialogs/exportdialog.cpp index 45c457f34..0c977962b 100644 --- a/dialogs/exportdialog.cpp +++ b/dialogs/exportdialog.cpp @@ -549,16 +549,34 @@ void ExportDialog::export_action() { cancelled = false; + total_export_time_start = QDateTime::currentMSecsSinceEpoch(); + et->start(); } } void ExportDialog::update_progress_bar(int value, qint64 remaining_ms) { + if (value == 100) { + // if value is 100%, show total render time rather than remaining + remaining_ms = QDateTime::currentMSecsSinceEpoch() - total_export_time_start; + } + // convert ms to H:MM:SS int seconds = qFloor(remaining_ms*0.001)%60; int minutes = qFloor(remaining_ms/60000)%60; int hours = qFloor(remaining_ms/3600000); - progressBar->setFormat("%p% (ETA: " + QString::number(hours) + ":" + QString::number(minutes).rightJustified(2, '0') + ":" + QString::number(seconds).rightJustified(2, '0') + ")"); + + if (value == 100) { + // show value as "total" + progressBar->setFormat(tr("%p% (Total: %1:%2:%3)").arg(QString::number(hours), + QString::number(minutes).rightJustified(2, '0'), + QString::number(seconds).rightJustified(2, '0'))); + } else { + // show value as "remaining" + progressBar->setFormat(tr("%p% (ETA: %1:%2:%3)").arg(QString::number(hours), + QString::number(minutes).rightJustified(2, '0'), + QString::number(seconds).rightJustified(2, '0'))); + } progressBar->setValue(value); } diff --git a/dialogs/exportdialog.h b/dialogs/exportdialog.h index 78ec2c0e2..8daf27308 100644 --- a/dialogs/exportdialog.h +++ b/dialogs/exportdialog.h @@ -81,6 +81,8 @@ private: QGroupBox* videoGroupbox; QGroupBox* audioGroupbox; QComboBox* compressionTypeCombobox; + + qint64 total_export_time_start; }; #endif // EXPORTDIALOG_H