diff --git a/applets/systemmonitor/common/contents/ui/Applet.qml b/applets/systemmonitor/common/contents/ui/Applet.qml --- a/applets/systemmonitor/common/contents/ui/Applet.qml +++ b/applets/systemmonitor/common/contents/ui/Applet.qml @@ -24,7 +24,6 @@ import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.extras 2.0 as PlasmaExtras -import org.kde.kquickcontrolsaddons 2.0 as KQuickAddons Item { id: rootItem @@ -83,7 +82,7 @@ engine: "systemmonitor" interval: plasmoid.configuration.updateInterval onSourceAdded: { - if (plasmoid.configuration.sources.length > 0 && + if (plasmoid.configuration.sources && plasmoid.configuration.sources.length > 0 && plasmoid.configuration.sources.indexOf(encodeURIComponent(source)) === -1) { return; } diff --git a/applets/systemmonitor/common/contents/ui/ConfigGeneral.qml b/applets/systemmonitor/common/contents/ui/ConfigGeneral.qml --- a/applets/systemmonitor/common/contents/ui/ConfigGeneral.qml +++ b/applets/systemmonitor/common/contents/ui/ConfigGeneral.qml @@ -32,6 +32,7 @@ property var cfg_sources: [] onCfg_sourcesChanged: { + if (! cfg_sources) { cfg_sources = [] } if (cfg_sources.length == 0) { for (var i in mainColumn.children) { var child = mainColumn.children[i]; diff --git a/applets/systemmonitor/common/contents/ui/DoublePlotter.qml b/applets/systemmonitor/common/contents/ui/DoublePlotter.qml --- a/applets/systemmonitor/common/contents/ui/DoublePlotter.qml +++ b/applets/systemmonitor/common/contents/ui/DoublePlotter.qml @@ -32,11 +32,6 @@ Layout.fillHeight: true horizontalGridLineCount: 0 - function formatLabel(data1, data2) { - return i18nc("%1 and %3 are data values, %2 and %4 are unit datatypes", "%1 %2 | %3 %4", data1.value, data1.units, - data2.value, data2.units); - } - function cycle(color, degrees) { var min = Math.min(color.r, Math.min(color.g, color.b)); var max = Math.max(color.r, Math.max(color.g, color.b)); @@ -69,16 +64,17 @@ ] PlasmaComponents.Label { + id: nameLabel anchors { left: parent.left top: parent.top } - text: plotter.sensorName } PlasmaComponents.Label { id: speedLabel wrapMode: Text.WordWrap + visible: plasmoid.formFactor != PlasmaCore.Types.Vertical anchors { right: parent.right } @@ -101,7 +97,13 @@ plotter.addSample([data1.value, data2.value]); - speedLabel.text = formatLabel(data1, data2); + if (plasmoid.formFactor != PlasmaCore.Types.Vertical) { + nameLabel.text = plotter.sensorName + speedLabel.text = formatData(data1) + " | " + formatData(data2) + } else { + nameLabel.text = plotter.sensorName+ "\n" + formatData(data1) + "\n" + formatData(data2) + speedLabel.text = "" + } } } } diff --git a/applets/systemmonitor/common/contents/ui/SinglePlotter.qml b/applets/systemmonitor/common/contents/ui/SinglePlotter.qml --- a/applets/systemmonitor/common/contents/ui/SinglePlotter.qml +++ b/applets/systemmonitor/common/contents/ui/SinglePlotter.qml @@ -35,27 +35,24 @@ Layout.preferredHeight: parent.height horizontalGridLineCount: 0 - function formatLabel(data) { - return i18nc("%1 is data value, %2 is unit datatype", "%1 %2", data.value, data.units); - } - dataSets: [ KQuickAddons.PlotData { color: theme.highlightColor } ] PlasmaComponents.Label { + id: nameLabel anchors { left: parent.left top: parent.top } - text: plotter.sensorName } PlasmaComponents.Label { id: speedLabel wrapMode: Text.WordWrap + visible: plasmoid.formFactor != PlasmaCore.Types.Vertical anchors { right: parent.right } @@ -76,7 +73,13 @@ plotter.addSample([data1.value]); - speedLabel.text = formatLabel(data1); + if (plasmoid.formFactor != PlasmaCore.Types.Vertical) { + nameLabel.text = plotter.sensorName + speedLabel.text = formatData(data1) + } else { + nameLabel.text = plotter.sensorName+ "\n" + formatData(data1) + speedLabel.text = "" + } } } } diff --git a/applets/systemmonitor/cpu/contents/ui/cpu.qml b/applets/systemmonitor/cpu/contents/ui/cpu.qml --- a/applets/systemmonitor/cpu/contents/ui/cpu.qml +++ b/applets/systemmonitor/cpu/contents/ui/cpu.qml @@ -39,7 +39,7 @@ autoRange: false rangeMin: 0 rangeMax: 100 - function formatLabel(data) { + function formatData(data) { //i18nc("CPU usage: %1 is the value, %2 the unit datatype", "%1 %2") //return i18n("%1 %2", Math.round(data.value), data.units); return i18nc("CPU usage: %1 is the value, %2 the unit datatype", "%1 %2", Math.round(data.value), data.units); diff --git a/applets/systemmonitor/diskactivity/contents/ui/diskactivity.qml b/applets/systemmonitor/diskactivity/contents/ui/diskactivity.qml --- a/applets/systemmonitor/diskactivity/contents/ui/diskactivity.qml +++ b/applets/systemmonitor/diskactivity/contents/ui/diskactivity.qml @@ -37,9 +37,8 @@ } delegate: DoublePlotter { - function formatLabel(data1, data2) { - return i18nc("%1 and %2 are values of the same datatype", "%1/s | %2/s", KCoreAddons.Format.formatByteSize(data1.value * 1024), - KCoreAddons.Format.formatByteSize(data2.value * 1024)); + function formatData(data) { + return i18nc("%1 is value of data per seconds", "%1/s", KCoreAddons.Format.formatByteSize(data.value * 1024)) } } } diff --git a/applets/systemmonitor/memory/contents/ui/memory.qml b/applets/systemmonitor/memory/contents/ui/memory.qml --- a/applets/systemmonitor/memory/contents/ui/memory.qml +++ b/applets/systemmonitor/memory/contents/ui/memory.qml @@ -40,9 +40,9 @@ autoRange: false rangeMin: 0 rangeMax: 0 - function formatLabel(data) { + function formatData(data) { rangeMax = data.max; return KCoreAddons.Format.formatByteSize(data.value * 1024) } } -} \ No newline at end of file +} 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 @@ -39,23 +39,19 @@ } } - 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)); + 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 (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; } } }