Skip to content

Commit d9a9b72

Browse files
committed
Plugins::WebBrowser: modify download prompt
1 parent 0d293a8 commit d9a9b72

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

Plugins/WebBrowser/FrmDownload.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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);

Plugins/WebBrowser/Resource/Translations/WebBrowser_zh_CN.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,8 @@
380380
</message>
381381
<message>
382382
<location filename="../../FrmDownload.cpp" line="116"/>
383-
<source>%p% - %1 of %2 downloaded - %3/s</source>
384-
<translation>%p% - 已下载: %1 / %2 - %3/秒</translation>
383+
<source>%p% - %1 of %2 downloaded - %3/s - time left: %4</source>
384+
<translation>%p% - 已下载: %1 / %2 - %3/秒 - 剩余时间: %4</translation>
385385
</message>
386386
<message>
387387
<location filename="../../FrmDownload.cpp" line="123"/>

0 commit comments

Comments
 (0)