From 8da91cde831c75111c62f2bc7e2e9481f227d7a6 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Fri, 10 Feb 2017 22:07:35 +0100 Subject: [PATCH] Display speeds in bits per second instead of KiB/s Summary: This is a patch to make the Network Monitor desktop plasmoid widget display the upload and download speeds in bits per second (Mbps, Kbps or bps as the case may be) rather than the fixed "KiB/s" unit. It appears the input data is always in KiB units so the bps part may never be called but left it in there anyway. Reviewers: davidedmundson Reviewed By: davidedmundson Subscribers: broulik, sebas, Zren, davidedmundson, plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D4551 --- applets/systemmonitor/net/contents/ui/net.qml | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/applets/systemmonitor/net/contents/ui/net.qml b/applets/systemmonitor/net/contents/ui/net.qml index 025d6048b..bd23450b4 100644 --- a/applets/systemmonitor/net/contents/ui/net.qml +++ b/applets/systemmonitor/net/contents/ui/net.qml @@ -39,5 +39,23 @@ Applet { } } - delegate: DoublePlotter {} -} \ No newline at end of file + function formatBitSpeed(value) { + if (value > (1024 * 1024)) { + return i18nc("%1 is the displayed data transfer speed in megabits per second", "%1 Mbps", (value / (1024 * 1024)).toFixed(1)); + } + if (value > 1024) { + return i18nc("%1 is the displayed data transfer speed in kilobits per second", "%1 Kbps", (value / 1024)); + } + if (value > 0) { + return i18nc("%1 is the displayed data transfer speed in bits per second", "%1 bps", value); + } + return value; + } + + delegate: DoublePlotter { + function formatLabel(data1, data2) { + return i18nc("%1 and %2 are values of the same datatype", "%1 | %2", formatBitSpeed(data1.value * 1024 * 8), + formatBitSpeed(data2.value * 1024 * 8)); + } + } +}