diff --git a/applets/systemmonitor/common/contents/config/main.xml b/applets/systemmonitor/common/contents/config/main.xml --- a/applets/systemmonitor/common/contents/config/main.xml +++ b/applets/systemmonitor/common/contents/config/main.xml @@ -13,6 +13,14 @@ 2000 + + + + + + + 1 + diff --git a/applets/systemmonitor/net/contents/config/config.qml b/applets/systemmonitor/net/contents/config/config.qml --- a/applets/systemmonitor/net/contents/config/config.qml +++ b/applets/systemmonitor/net/contents/config/config.qml @@ -26,4 +26,9 @@ icon: "network-workgroup" source: "netConfig.qml" } + ConfigCategory { + name: i18n("Display") + icon: "network-workgroup" + source: "displayConfig.qml" + } } diff --git a/applets/systemmonitor/net/contents/ui/displayConfig.qml b/applets/systemmonitor/net/contents/ui/displayConfig.qml new file mode 100644 --- /dev/null +++ b/applets/systemmonitor/net/contents/ui/displayConfig.qml @@ -0,0 +1,54 @@ +/* + * Copyright 2019 George Vogiatzis + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2 or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import QtQuick 2.0 +import QtQuick.Layouts 1.1 +import org.kde.plasma.plasmoid 2.0 +import QtQuick.Controls 2.5 as QQC2 +import org.kde.kirigami 2.5 as Kirigami + +Kirigami.FormLayout { + property int cfg_displayUnit: plasmoid.configuration.displayUnit + + QQC2.ButtonGroup { + id: displayUnitGroup + } + + QQC2.RadioButton { + id: byteDisplayUnit + QQC2.ButtonGroup.group: displayUnitGroup + + Kirigami.FormData.label: i18nc("@label", "Display unit:") + + text: i18nc("@option:radio", "Byte") + checked: cfg_displayUnit == 0 + onClicked: if (checked) {cfg_displayUnit = 0;} + } + + QQC2.RadioButton { + id: bitDisplayUnit + QQC2.ButtonGroup.group: displayUnitGroup + + text: i18nc("@option:radio", "bit") + + checked: cfg_displayUnit == 1 + onClicked: if (checked) {cfg_displayUnit = 1;} + } +} diff --git a/applets/systemmonitor/net/contents/ui/net.qml b/applets/systemmonitor/net/contents/ui/net.qml --- a/applets/systemmonitor/net/contents/ui/net.qml +++ b/applets/systemmonitor/net/contents/ui/net.qml @@ -24,6 +24,7 @@ import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.kquickcontrolsaddons 2.0 as KQuickAddons +import org.kde.kcoreaddons 1.0 as KCoreAddons Applet { id: root @@ -41,14 +42,19 @@ delegate: DoublePlotter { function formatData(data) { - var value = data.value * 1024 * 8 - 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 (plasmoid.configuration.displayUnit === 0) { + var value = data.value * 1024 + return i18nc("%1 is the displayed data transfer speed in bytes per second", "%1/s", KCoreAddons.Format.formatByteSize(value)); + } else { + var value = data.value * 1024 * 8 + 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)); + } + return i18nc("%1 is the displayed data transfer speed in bits per second", "%1 bps", value); } - if (value > 1024) { - return i18nc("%1 is the displayed data transfer speed in kilobits per second", "%1 Kbps", (value / 1024)); - } - return i18nc("%1 is the displayed data transfer speed in bits per second", "%1 bps", value); } } }