mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
tweak speed shown back to recent speed, keep eta avg speed
This commit is contained in:
parent
6e15bcb8d8
commit
e2b4d7280d
|
@ -82,24 +82,28 @@ void FileTransferInstance::onFileTransferInfo(int FriendId, int FileNum, int64_t
|
||||||
|
|
||||||
// state = tsProcessing;
|
// state = tsProcessing;
|
||||||
QDateTime now = QDateTime::currentDateTime();
|
QDateTime now = QDateTime::currentDateTime();
|
||||||
if (lastUpdateTime.secsTo(now) < 1) //update every 1s
|
long recenttimediff = lastUpdateTime.msecsTo(now);
|
||||||
|
if (recenttimediff < 1000) //update every 1s
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int timediff = effStartTime.secsTo(now);
|
long timediff = effStartTime.msecsTo(now);
|
||||||
if (timediff <= 0)
|
if (timediff <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
long rawspeed = (BytesSent - previousBytesSent) / timediff;
|
long avgspeed = (BytesSent - previousBytesSent) / timediff * 1000;
|
||||||
|
long recentspeed = (BytesSent - lastBytesSent) / recenttimediff * 1000;
|
||||||
|
|
||||||
speed = getHumanReadableSize(rawspeed)+"/s";
|
speed = getHumanReadableSize(recentspeed)+"/s";
|
||||||
size = getHumanReadableSize(Filesize);
|
size = getHumanReadableSize(Filesize);
|
||||||
totalBytes = Filesize;
|
totalBytes = Filesize;
|
||||||
if (!rawspeed)
|
|
||||||
|
if (!avgspeed)
|
||||||
return;
|
return;
|
||||||
int etaSecs = (Filesize - BytesSent) / rawspeed;
|
int etaSecs = (Filesize - BytesSent) / avgspeed;
|
||||||
QTime etaTime(0,0);
|
QTime etaTime(0,0);
|
||||||
etaTime = etaTime.addSecs(etaSecs);
|
etaTime = etaTime.addSecs(etaSecs);
|
||||||
eta = etaTime.toString("mm:ss");
|
eta = etaTime.toString("mm:ss");
|
||||||
|
|
||||||
lastBytesSent = BytesSent;
|
lastBytesSent = BytesSent;
|
||||||
lastUpdateTime = now;
|
lastUpdateTime = now;
|
||||||
emit stateUpdated();
|
emit stateUpdated();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user