Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
77e2276e99 | ||
|
|
beb13fc33d |
@@ -534,10 +534,12 @@ void NetworkMonitorApplet::calculateSpeed()
|
|||||||
const qint64 txDeltaClamped = txDelta > 0 ? txDelta : 0;
|
const qint64 txDeltaClamped = txDelta > 0 ? txDelta : 0;
|
||||||
m_downloadSpeed = rxDeltaClamped / elapsedSec;
|
m_downloadSpeed = rxDeltaClamped / elapsedSec;
|
||||||
m_uploadSpeed = txDeltaClamped / elapsedSec;
|
m_uploadSpeed = txDeltaClamped / elapsedSec;
|
||||||
// 累加会话总量:总量 = 本次会话期间所有活动接口的流量总和
|
// 会话总量:直接读取活动接口累计字节数(开机至今),而非累加差值
|
||||||
m_totalDownload += rxDeltaClamped;
|
// 设计原因:用户期望"本次会话"显示当前网卡从开机起的累计流量,
|
||||||
m_totalUpload += txDeltaClamped;
|
// 切换网卡后立即显示新网卡的累计值,无流量网卡显示 0
|
||||||
// 累加日/月流量日志(仅活动接口,与总量口径一致,避免多接口重复计数)
|
m_totalDownload = currentRxBytes;
|
||||||
|
m_totalUpload = currentTxBytes;
|
||||||
|
// 累加日/月流量日志(仅活动接口增量,与速度计算口径一致)
|
||||||
appendToTrafficLog(rxDeltaClamped, txDeltaClamped);
|
appendToTrafficLog(rxDeltaClamped, txDeltaClamped);
|
||||||
m_lastRxBytes = currentRxBytes;
|
m_lastRxBytes = currentRxBytes;
|
||||||
m_lastTxBytes = currentTxBytes;
|
m_lastTxBytes = currentTxBytes;
|
||||||
@@ -559,7 +561,16 @@ void NetworkMonitorApplet::calculateSpeed()
|
|||||||
m_txErrors = static_cast<quint64>(iface.txErrors);
|
m_txErrors = static_cast<quint64>(iface.txErrors);
|
||||||
m_rxDropped = static_cast<quint64>(iface.rxDropped);
|
m_rxDropped = static_cast<quint64>(iface.rxDropped);
|
||||||
m_txDropped = static_cast<quint64>(iface.txDropped);
|
m_txDropped = static_cast<quint64>(iface.txDropped);
|
||||||
emit packetStatsChanged();
|
emit packetStatsChanged();
|
||||||
|
|
||||||
|
// 接口切换后立即更新会话总量为新网卡的累计字节数(开机至今)
|
||||||
|
// 设计原因:会话总量改为读取活动接口累计值,切换后应立即显示新网卡数据,
|
||||||
|
// 无需等下一次 calculateSpeed(1 秒后)才更新
|
||||||
|
if (m_interfaces.contains(m_activeInterface)) {
|
||||||
|
m_totalDownload = m_interfaces[m_activeInterface].rxBytes;
|
||||||
|
m_totalUpload = m_interfaces[m_activeInterface].txBytes;
|
||||||
|
emit totalChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user