Changeset View
Changeset View
Standalone View
Standalone View
applets/systemmonitor/common/contents/ui/SinglePlotter.qml
Show All 29 Lines | 28 | KQuickAddons.Plotter { | |||
---|---|---|---|---|---|
30 | property string sensorName: model.friendlyName1 | 30 | property string sensorName: model.friendlyName1 | ||
31 | 31 | | |||
32 | Layout.fillWidth: true | 32 | Layout.fillWidth: true | ||
33 | Layout.fillHeight: true | 33 | Layout.fillHeight: true | ||
34 | //FIXME: doesn't seem to properly fill otherwise | 34 | //FIXME: doesn't seem to properly fill otherwise | ||
35 | Layout.preferredHeight: parent.height | 35 | Layout.preferredHeight: parent.height | ||
36 | horizontalGridLineCount: 0 | 36 | horizontalGridLineCount: 0 | ||
37 | 37 | | |||
38 | function formatLabel(data) { | | |||
39 | return i18nc("%1 is data value, %2 is unit datatype", "%1 %2", data.value, data.units); | | |||
40 | } | | |||
41 | | ||||
42 | dataSets: [ | 38 | dataSets: [ | ||
43 | KQuickAddons.PlotData { | 39 | KQuickAddons.PlotData { | ||
44 | color: theme.highlightColor | 40 | color: theme.highlightColor | ||
45 | } | 41 | } | ||
46 | ] | 42 | ] | ||
47 | 43 | | |||
48 | PlasmaComponents.Label { | 44 | PlasmaComponents.Label { | ||
45 | id: nameLabel | ||||
49 | anchors { | 46 | anchors { | ||
50 | left: parent.left | 47 | left: parent.left | ||
51 | top: parent.top | 48 | top: parent.top | ||
52 | } | 49 | } | ||
53 | text: plotter.sensorName | | |||
54 | } | 50 | } | ||
55 | 51 | | |||
56 | PlasmaComponents.Label { | 52 | PlasmaComponents.Label { | ||
57 | id: speedLabel | 53 | id: speedLabel | ||
58 | wrapMode: Text.WordWrap | 54 | wrapMode: Text.WordWrap | ||
55 | visible: plasmoid.formFactor != PlasmaCore.Types.Vertical | ||||
59 | anchors { | 56 | anchors { | ||
60 | right: parent.right | 57 | right: parent.right | ||
61 | } | 58 | } | ||
62 | } | 59 | } | ||
63 | 60 | | |||
64 | Connections { | 61 | Connections { | ||
65 | target: model.dataSource | 62 | target: model.dataSource | ||
66 | onNewData: { | 63 | onNewData: { | ||
67 | if (sourceName.indexOf(decodeURIComponent(model.source1)) != 0) { | 64 | if (sourceName.indexOf(decodeURIComponent(model.source1)) != 0) { | ||
68 | return; | 65 | return; | ||
69 | } | 66 | } | ||
70 | 67 | | |||
71 | var data1 = model.dataSource.data[decodeURIComponent(model.source1)]; | 68 | var data1 = model.dataSource.data[decodeURIComponent(model.source1)]; | ||
72 | 69 | | |||
73 | if (data1 === undefined || data1.value === undefined) { | 70 | if (data1 === undefined || data1.value === undefined) { | ||
74 | return; | 71 | return; | ||
75 | } | 72 | } | ||
76 | 73 | | |||
77 | plotter.addSample([data1.value]); | 74 | plotter.addSample([data1.value]); | ||
78 | 75 | | |||
79 | speedLabel.text = formatLabel(data1); | 76 | if (plasmoid.formFactor != PlasmaCore.Types.Vertical) { | ||
77 | nameLabel.text = plotter.sensorName | ||||
78 | speedLabel.text = formatData(data1) | ||||
79 | } else { | ||||
80 | nameLabel.text = plotter.sensorName+ "\n" + formatData(data1) | ||||
81 | speedLabel.text = "" | ||||
82 | } | ||||
80 | } | 83 | } | ||
81 | } | 84 | } | ||
82 | } | 85 | } | ||
83 | 86 | |