mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
commit
1fd456833c
|
@ -137,13 +137,14 @@ void FileTransferWidget::onFileTransferInfo(ToxFile file)
|
||||||
qreal bytesPerSec = static_cast<int>(static_cast<qreal>(deltaBytes) / deltaSecs);
|
qreal bytesPerSec = static_cast<int>(static_cast<qreal>(deltaBytes) / deltaSecs);
|
||||||
|
|
||||||
// calculate mean
|
// calculate mean
|
||||||
meanData[(meanIndex++) % FTW_MEAN_PERIODES] = bytesPerSec;
|
meanData[meanIndex] = bytesPerSec;
|
||||||
|
meanIndex = (meanIndex + 1) % TRANSFER_ROLLING_AVG_COUNT;
|
||||||
|
|
||||||
qreal meanBytesPerSec = 0.0;
|
qreal meanBytesPerSec = 0.0;
|
||||||
for(size_t i = 0; i < FTW_MEAN_PERIODES; ++i)
|
for(size_t i = 0; i < TRANSFER_ROLLING_AVG_COUNT; ++i)
|
||||||
meanBytesPerSec += meanData[i];
|
meanBytesPerSec += meanData[i];
|
||||||
|
|
||||||
meanBytesPerSec /= qMin(meanIndex, static_cast<size_t>(FTW_MEAN_PERIODES));
|
meanBytesPerSec /= qMin(static_cast<size_t>(meanIndex), static_cast<size_t>(TRANSFER_ROLLING_AVG_COUNT));
|
||||||
|
|
||||||
// update UI
|
// update UI
|
||||||
if(meanBytesPerSec > 0)
|
if(meanBytesPerSec > 0)
|
||||||
|
@ -209,7 +210,7 @@ void FileTransferWidget::onFileTransferPaused(ToxFile file)
|
||||||
|
|
||||||
// reset mean
|
// reset mean
|
||||||
meanIndex = 0;
|
meanIndex = 0;
|
||||||
for(size_t i=0; i<FTW_MEAN_PERIODES; ++i)
|
for(size_t i=0; i<TRANSFER_ROLLING_AVG_COUNT; ++i)
|
||||||
meanData[i] = 0.0;
|
meanData[i] = 0.0;
|
||||||
|
|
||||||
setStyleSheet(Style::getStylesheet(":/ui/fileTransferInstance/grey.css"));
|
setStyleSheet(Style::getStylesheet(":/ui/fileTransferInstance/grey.css"));
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#include "../chatlinecontent.h"
|
#include "../chatlinecontent.h"
|
||||||
#include "../../corestructs.h"
|
#include "../../corestructs.h"
|
||||||
|
|
||||||
#define FTW_MEAN_PERIODES 4
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class FileTransferWidget;
|
class FileTransferWidget;
|
||||||
|
@ -66,8 +65,9 @@ private:
|
||||||
QTime lastTick;
|
QTime lastTick;
|
||||||
qint64 lastBytesSent = 0;
|
qint64 lastBytesSent = 0;
|
||||||
|
|
||||||
qreal meanData[FTW_MEAN_PERIODES] = {0.0};
|
static const uint8_t TRANSFER_ROLLING_AVG_COUNT = 4;
|
||||||
size_t meanIndex = 0;
|
uint8_t meanIndex = 0;
|
||||||
|
qreal meanData[TRANSFER_ROLLING_AVG_COUNT] = {0.0};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FILETRANSFERWIDGET_H
|
#endif // FILETRANSFERWIDGET_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user