Skip to content

Commit 3934ed1

Browse files
7134956bbogush
authored andcommitted
Qt: GUI: Add operation time estimate.
1 parent ccfe0e2 commit 3934ed1

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

qt/main_window.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <QMessageBox>
2323
#include <memory>
2424
#include <QTimer>
25+
#include <QTime>
2526

2627
#define HEADER_ADDRESS_WIDTH 80
2728
#define HEADER_HEX_WIDTH 340
@@ -720,7 +721,29 @@ void MainWindow::slotAboutDialog()
720721

721722
void MainWindow::setProgress(unsigned int progress)
722723
{
723-
statusBar()->showMessage(tr("Progress: %1%").arg(progress));
724+
static unsigned int old_progress = 100;
725+
QTime Qtime_passed, Qtime_total;
726+
727+
if(old_progress == progress)
728+
return;
729+
730+
old_progress = progress;
731+
732+
if(progress == 0)
733+
{
734+
timer.restart();
735+
Qtime_passed = QTime::fromMSecsSinceStartOfDay(0);
736+
Qtime_total = QTime::fromMSecsSinceStartOfDay(0);
737+
}
738+
else
739+
{
740+
Qtime_passed = QTime::fromMSecsSinceStartOfDay(timer.elapsed());
741+
Qtime_total = QTime::fromMSecsSinceStartOfDay(timer.elapsed() * 100 / progress);
742+
}
743+
statusBar()->showMessage(tr("Progress: %1% Passed: %2 Total: %3")
744+
.arg(progress)
745+
.arg(Qtime_passed.toString("hh:mm:ss"))
746+
.arg(Qtime_total.toString("hh:mm:ss")));
724747
}
725748

726749
void MainWindow::slotProgFirmwareUpdateCompleted(int status)

qt/main_window.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "spi_chip_db.h"
1313
#include <QMainWindow>
1414
#include <QVector>
15+
#include <QElapsedTimer>
1516

1617
namespace Ui {
1718
class MainWindow;
@@ -34,6 +35,7 @@ class MainWindow : public QMainWindow
3435
ParallelChipDb parallelChipDb;
3536
SpiChipDb spiChipDb;
3637
ChipDb *currentChipDb;
38+
QElapsedTimer timer;
3739

3840
void initBufTable();
3941
void resetBufTable();

0 commit comments

Comments
 (0)