summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Edmundson <[email protected]>2017-02-10 22:07:35 +0100
committerDavid Edmundson <[email protected]>2017-02-10 22:07:35 +0100
commit8da91cde831c75111c62f2bc7e2e9481f227d7a6 (patch)
tree1ecf3a6abc0ff7c624125dc86d88453a563fc668
parent1c513a0dcd9a26bcdd4129271014db300c6a60d7 (diff)
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
-rw-r--r--applets/systemmonitor/net/contents/ui/net.qml22
1 files changed, 20 insertions, 2 deletions
diff --git a/applets/systemmonitor/net/contents/ui/net.qml b/applets/systemmonitor/net/contents/ui/net.qml
index 025d604..bd23450 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));
+ }
+ }
+}