@@ -97,11 +97,19 @@ void CFrmDownload::slotUpdateWidget()
9797 qreal totalBytes = m_pDownload->totalBytes ();
9898 qreal receivedBytes = m_pDownload->receivedBytes ();
9999 qreal bytesPerSecond = 0 ; // Initialized to 0 for a reasonable default value
100-
100+ int remaining = 0 ;
101+ QString szRemaining;
101102 // Check for division by zero
102103 if (m_timeAdded.elapsed () != 0 )
103104 bytesPerSecond = receivedBytes / m_timeAdded.elapsed () * 1000 ;
104105
106+ remaining = (totalBytes - receivedBytes) / bytesPerSecond + 1 ;
107+ if (remaining >= 0 ) {
108+ QTime tm (0 , 0 , 0 );
109+ szRemaining = tm.addSecs (remaining).toString (QLocale::system ().timeFormat ());
110+ qDebug (log) << " Remaining:" << remaining << tm << szRemaining;
111+ }
112+
105113 auto state = m_pDownload->state ();
106114 switch (state) {
107115 case QWebEngineDownloadRequest::DownloadRequested:
@@ -113,9 +121,9 @@ void CFrmDownload::slotUpdateWidget()
113121 ui->progressBar ->setValue (qRound (100 * receivedBytes / totalBytes));
114122 ui->progressBar ->setDisabled (false );
115123 ui->progressBar ->setFormat (
116- tr (" %p% - %1 of %2 downloaded - %3/s" )
124+ tr (" %p% - %1 of %2 downloaded - %3/s - time left: %4 " )
117125 .arg (CStats::Convertbytes (receivedBytes), CStats::Convertbytes (totalBytes),
118- CStats::Convertbytes (bytesPerSecond)));
126+ CStats::Convertbytes (bytesPerSecond), szRemaining ));
119127 } else {
120128 ui->progressBar ->setValue (0 );
121129 ui->progressBar ->setDisabled (false );
0 commit comments