diff --git a/applet/contents/ui/ConnectionItem.qml b/applet/contents/ui/ConnectionItem.qml --- a/applet/contents/ui/ConnectionItem.qml +++ b/applet/contents/ui/ConnectionItem.qml @@ -43,6 +43,9 @@ property bool visibleDetails: false property bool visiblePasswordDialog: false + property real rxBytes: 0 + property real txBytes: 0 + checked: connectionItem.containsMouse enabled: true height: expanded ? baseHeight + separator.height + expandableComponentLoader.height + (2 * Math.round(units.gridUnit / 3)) : baseHeight @@ -232,6 +235,25 @@ } } + Timer { + id: timer + repeat: true + interval: 2000 + running: showSpeed + property real prevRxBytes + property real prevTxBytes + Component.onCompleted: { + prevRxBytes = RxBytes + prevTxBytes = TxBytes + } + onTriggered: { + rxBytes = (RxBytes - prevRxBytes) * 1000 / interval + txBytes = (TxBytes - prevTxBytes) * 1000 / interval + prevRxBytes = RxBytes + prevTxBytes = TxBytes + } + } + states: [ State { name: "collapsed" @@ -311,9 +333,9 @@ return i18n("Connected, %2, %4", downloadColor, - KCoreAddons.Format.formatByteSize(RxBytes), + KCoreAddons.Format.formatByteSize(rxBytes), uploadColor, - KCoreAddons.Format.formatByteSize(TxBytes)) + KCoreAddons.Format.formatByteSize(txBytes)) } else { return i18n("Connected") } diff --git a/libs/models/networkmodel.cpp b/libs/models/networkmodel.cpp --- a/libs/models/networkmodel.cpp +++ b/libs/models/networkmodel.cpp @@ -300,6 +300,12 @@ } item->invalidateDetails(); qCDebug(PLASMA_NM) << "Item " << item->name() << ": active connection state changed to " << item->connectionState(); + + if (device && device->uni() == item->devicePath()) { + auto deviceStatistics = device->deviceStatistics(); + item->setRxBytes(deviceStatistics->rxBytes()); + item->setTxBytes(deviceStatistics->txBytes()); + } } } endResetModel();