Changeset View
Changeset View
Standalone View
Standalone View
applets/systemmonitor/common/contents/ui/DoublePlotter.qml
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | 35 | function cycle(color, degrees) { | |||
---|---|---|---|---|---|
49 | } | 49 | } | ||
50 | var hue = (1/6) * h + (degrees/360); | 50 | var hue = (1/6) * h + (degrees/360); | ||
51 | var saturation = c / (1 - Math.abs(2 * ((max+min)/2) - 1)); | 51 | var saturation = c / (1 - Math.abs(2 * ((max+min)/2) - 1)); | ||
52 | var lightness = (max + min)/2; | 52 | var lightness = (max + min)/2; | ||
53 | 53 | | |||
54 | return Qt.hsla(hue, saturation, lightness, 1.0); | 54 | return Qt.hsla(hue, saturation, lightness, 1.0); | ||
55 | } | 55 | } | ||
56 | 56 | | |||
57 | property string downloadColor: theme.highlightColor | ||||
58 | property string uploadColor: cycle(theme.highlightColor, -90) | ||||
59 | | ||||
57 | dataSets: [ | 60 | dataSets: [ | ||
58 | KQuickAddons.PlotData { | 61 | KQuickAddons.PlotData { | ||
59 | color: theme.highlightColor | 62 | color: downloadColor | ||
60 | }, | 63 | }, | ||
61 | KQuickAddons.PlotData { | 64 | KQuickAddons.PlotData { | ||
62 | color: cycle(theme.highlightColor, -90) | 65 | color: uploadColor | ||
63 | } | 66 | } | ||
64 | ] | 67 | ] | ||
65 | 68 | | |||
66 | PlasmaComponents.Label { | 69 | PlasmaComponents.Label { | ||
67 | id: nameLabel | 70 | id: nameLabel | ||
68 | anchors { | 71 | anchors { | ||
69 | left: parent.left | 72 | left: parent.left | ||
70 | top: parent.top | 73 | top: parent.top | ||
Show All 23 Lines | 96 | if (data1 === undefined || data1.value === undefined || | |||
94 | data2 === undefined || data2.value === undefined) { | 97 | data2 === undefined || data2.value === undefined) { | ||
95 | return; | 98 | return; | ||
96 | } | 99 | } | ||
97 | 100 | | |||
98 | plotter.addSample([data1.value, data2.value]); | 101 | plotter.addSample([data1.value, data2.value]); | ||
99 | 102 | | |||
100 | if (plasmoid.formFactor != PlasmaCore.Types.Vertical) { | 103 | if (plasmoid.formFactor != PlasmaCore.Types.Vertical) { | ||
101 | nameLabel.text = plotter.sensorName | 104 | nameLabel.text = plotter.sensorName | ||
102 | speedLabel.text = formatData(data1) + " | " + formatData(data2) | 105 | speedLabel.text = i18n("<font color='%1'>⬇</font> %2 | <font color='%3'>⬆</font> %4", | ||
davidedmundson: Can we assume a font has ⬆ characters? | |||||
I grabbed this code from plasma-nm, which does the same thing. I haven't heard any complaints about that so I'm going to assume yes? ngraham: I grabbed this code from `plasma-nm`, which does the same thing. I haven't heard any complaints… | |||||
106 | downloadColor, | ||||
107 | formatData(data1), | ||||
108 | uploadColor, | ||||
109 | formatData(data2)) | ||||
103 | } else { | 110 | } else { | ||
104 | nameLabel.text = plotter.sensorName+ "\n" + formatData(data1) + "\n" + formatData(data2) | 111 | nameLabel.text = plotter.sensorName+ "\n" + formatData(data1) + "\n" + formatData(data2) | ||
105 | speedLabel.text = "" | 112 | speedLabel.text = "" | ||
106 | } | 113 | } | ||
107 | } | 114 | } | ||
108 | } | 115 | } | ||
109 | } | 116 | } |
Can we assume a font has ⬆ characters?