Do not overload kuiserver

This commit is contained in:
Erik Duisters 2019-01-26 14:04:38 +01:00 committed by Nicolas Fella
parent fab782d91c
commit 205eb8f497
2 changed files with 10 additions and 5 deletions

View file

@ -39,6 +39,7 @@ CompositeUploadJob::CompositeUploadJob(const QString& deviceId, bool displayNoti
, m_totalSendPayloadSize(0)
, m_totalPayloadSize(0)
, m_currentJob(nullptr)
, m_prevElapsedTime(0)
{
setCapabilities(Killable);
@ -226,13 +227,16 @@ void CompositeUploadJob::slotProcessedAmount(KJob *job, KJob::Unit unit, qulongl
Q_UNUSED(job);
m_currentJobSendPayloadSize = amount;
quint64 uploaded = m_totalSendPayloadSize + m_currentJobSendPayloadSize;
setProcessedAmount(unit, uploaded);
const auto elapsed = m_timer.elapsed();
if (elapsed > 0) {
emitSpeed((1000 * uploaded) / elapsed);
if (uploaded == m_totalPayloadSize || m_prevElapsedTime == 0 || m_timer.elapsed() - m_prevElapsedTime >= 100) {
m_prevElapsedTime = m_timer.elapsed();
setProcessedAmount(unit, uploaded);
const auto elapsed = m_timer.elapsed();
if (elapsed > 0) {
emitSpeed((1000 * uploaded) / elapsed);
}
}
}

View file

@ -66,6 +66,7 @@ private:
quint64 m_totalPayloadSize;
UploadJob *m_currentJob;
QElapsedTimer m_timer;
quint64 m_prevElapsedTime;
const static quint16 MIN_PORT = 1739;
const static quint16 MAX_PORT = 1764;