From c75bd91b4c427ce7c673520f0fbcdd30ad3fe5f8 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 3 Sep 2009 16:50:02 -0400 Subject: Add timing info. --- dvdimage.cpp | 1 + imagegui.cpp | 16 ++++++++++++++++ imagegui.h | 5 +++++ 3 files changed, 22 insertions(+) diff --git a/dvdimage.cpp b/dvdimage.cpp index 7bccbec..35b7a7b 100644 --- a/dvdimage.cpp +++ b/dvdimage.cpp @@ -170,6 +170,7 @@ bool DVDImage::saveImageToDevice(const QString &dvdDevice, QIODevice &out) if (actblks < maxblks) break; } + emit extractProgress(blkno, discend); if (blkno < (int)discend) { qDebug() << "SHORT READ: only " << blkno << "of" << discend << "blocks copied"; diff --git a/imagegui.cpp b/imagegui.cpp index a248a1e..9d09de2 100644 --- a/imagegui.cpp +++ b/imagegui.cpp @@ -1,5 +1,6 @@ #include "imagegui.h" #include "dvdimage.h" +#include #include #include #include @@ -9,11 +10,26 @@ ImageGui::ImageGui() { DVDImage *dvdImage = new DVDImage; + m_first = true; connect(dvdImage, SIGNAL(extractProgress(int,int)), this, SLOT(extractProgress(int,int))); QtConcurrent::run(dvdImage, &DVDImage::saveImageToPath, QLatin1String("/dev/dvd"), QLatin1String("image.iso")); } void ImageGui::extractProgress(int current, int maximum) { + if (m_first) { + m_startTime.start(); + m_first = false; + } else { + long long currentBytes = (long long)current * DVDCSS_BLOCK_SIZE; + long long maximumBytes = (long long)maximum * DVDCSS_BLOCK_SIZE; + double bytesPerMillisecond = (double)currentBytes / (double)m_startTime.elapsed(); + long long millisecondsRemaining = (long long)((maximumBytes - currentBytes) / bytesPerMillisecond); + setWindowTitle(QString("AnyRip: %1 of %2 megabytes (%3 mb/s, %4 remaining)") + .arg(QString::number((double)currentBytes / 1024.0 / 1024.0, 'f', 2)) + .arg(QString::number((double)maximumBytes / 1024.0 / 1024.0, 'f', 2)) + .arg(QString::number(bytesPerMillisecond * (1000.0 / 1024.0 / 1024.0), 'f', 2)) + .arg(QTime().addMSecs(millisecondsRemaining).toString())); + } setMaximum(maximum); setValue(current); } diff --git a/imagegui.h b/imagegui.h index 98016ab..4c3680c 100644 --- a/imagegui.h +++ b/imagegui.h @@ -2,6 +2,7 @@ #define IMAGEGUI_H #include +#include class DVDImage; class ImageGui : public QProgressBar @@ -11,6 +12,10 @@ class ImageGui : public QProgressBar public: ImageGui(); +private: + QTime m_startTime; + bool m_first; + private slots: void extractProgress(int current, int maximum); }; -- cgit v1.2.3-59-g8ed1b