Commit e51d9c17 authored by David Redondo's avatar David Redondo 🏎
Browse files

Only calculate the upload and download rates once

parent 5963322d
......@@ -159,9 +159,8 @@ PlasmaExtras.ExpandableListItem {
left: parent.left
right: parent.right
}
rxBytes: RxBytes
txBytes: TxBytes
interval: 2000
downloadSpeed: txBytes
uploadSpeed: rxBytes
visible: detailsTabBar.currentTab == speedTabButton
}
}
......@@ -269,8 +268,8 @@ PlasmaExtras.ExpandableListItem {
} else if (ConnectionState == PlasmaNM.Enums.Activated) {
if (showSpeed) {
return i18n("Connected, ⬇ %1/s, ⬆ %2/s",
KCoreAddons.Format.formatByteSize(rxBytes),
KCoreAddons.Format.formatByteSize(txBytes))
KCoreAddons.Format.formatByteSize(rxBytes),
KCoreAddons.Format.formatByteSize(txBytes))
} else {
return i18n("Connected")
}
......
......@@ -26,9 +26,8 @@ import org.kde.plasma.components 3.0 as PlasmaComponents3
import org.kde.plasma.core 2.0 as PlasmaCore
Item {
property real rxBytes: 0
property real txBytes: 0
property alias interval: timer.interval
property alias downloadSpeed: download.value
property alias uploadSpeed: upload.value
height: visible ? plotter.height + plotter.anchors.topMargin + units.smallSpacing : 0
......@@ -102,23 +101,6 @@ Item {
itemCount: 2
}
Timer {
id: timer
repeat: true
running: parent.visible
property real prevRxBytes
property real prevTxBytes
Component.onCompleted: {
prevRxBytes = rxBytes
prevTxBytes = txBytes
}
onTriggered: {
rxSpeed.value = (rxBytes - prevRxBytes) * 1000 / interval
txSpeed.value = (txBytes - prevTxBytes) * 1000 / interval
prevRxBytes = rxBytes
prevTxBytes = txBytes
}
}
}
TextMetrics {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment