Changeset View
Changeset View
Standalone View
Standalone View
applet/contents/ui/TrafficMonitor.qml
Show All 21 Lines | |||||
22 | import org.kde.kcoreaddons 1.0 as KCoreAddons | 22 | import org.kde.kcoreaddons 1.0 as KCoreAddons | ||
23 | import org.kde.kquickcontrolsaddons 2.0 as KQuickControlsAddons | 23 | import org.kde.kquickcontrolsaddons 2.0 as KQuickControlsAddons | ||
24 | import org.kde.plasma.components 2.0 as PlasmaComponents | 24 | import org.kde.plasma.components 2.0 as PlasmaComponents | ||
25 | 25 | | |||
26 | Item { | 26 | Item { | ||
27 | property QtObject dataEngine: null | 27 | property QtObject dataEngine: null | ||
28 | property string deviceName | 28 | property string deviceName | ||
29 | 29 | | |||
30 | height: visible ? plotter.height + Math.round(units.gridUnit / 3) : 0 | 30 | height: visible ? plotter.height + units.gridUnit : 0 | ||
31 | 31 | | |||
32 | Repeater { | 32 | Repeater { | ||
33 | model: 5 | 33 | model: 5 | ||
34 | 34 | | |||
35 | PlasmaComponents.Label { | 35 | PlasmaComponents.Label { | ||
36 | anchors { | 36 | anchors { | ||
37 | left: parent.left | 37 | left: parent.left | ||
38 | top: parent.top | 38 | top: parent.top | ||
39 | topMargin: Math.round(units.gridUnit / 3) + (index * plotter.height / 5) | 39 | topMargin: Math.round(units.gridUnit / 3) + (index * plotter.height / 5) | ||
40 | } | 40 | } | ||
41 | height: paintedHeight | 41 | height: paintedHeight | ||
42 | font.pointSize: theme.smallestFont.pointSize | 42 | font.pointSize: theme.smallestFont.pointSize | ||
43 | lineHeight: 1.75 | ||||
43 | text: KCoreAddons.Format.formatByteSize((plotter.maxValue * 1024) * (1 - index / 5)) | 44 | text: KCoreAddons.Format.formatByteSize((plotter.maxValue * 1024) * (1 - index / 5)) | ||
44 | } | 45 | } | ||
45 | } | 46 | } | ||
46 | 47 | | |||
47 | KQuickControlsAddons.Plotter { | 48 | KQuickControlsAddons.Plotter { | ||
48 | id: plotter | 49 | id: plotter | ||
49 | 50 | | |||
50 | // Joining two QList<foo> in QML/javascript doesn't seem to work so I'm getting maximum from both list separately | 51 | // Joining two QList<foo> in QML/javascript doesn't seem to work so I'm getting maximum from both list separately | ||
51 | readonly property int maxValue: Math.max(Math.max.apply(null, downloadPlotData.values), Math.max.apply(null, uploadPlotData.values)) | 52 | readonly property int maxValue: Math.max(Math.max.apply(null, downloadPlotData.values), Math.max.apply(null, uploadPlotData.values)) | ||
52 | anchors { | 53 | anchors { | ||
53 | left: parent.left | 54 | left: parent.left | ||
54 | leftMargin: units.iconSizes.medium | 55 | leftMargin: units.gridUnit * 3 | ||
davidedmundson: Semantically it's weird to use the size of an icon for a margin, unless you're trying to line… | |||||
Thank you very much for the pointer. I tried adding the medium size with large spacing, but for some reason it returns empty value and the lines got overlapped So I suggest a different method of using "units.gridUnit * 3" since everything else is also calculated with this property, it is suitable here I think. Also this returns to 54 while earlier the iconSizes.larger returned 48 , this is not harmful because we anyways wanted some more space to accommodate longer text. So changing this to "units.gridUnit * 3" gave a reasonable space and it is independent of the icons size now. which gives the below result kamathraghavendra: Thank you very much for the pointer.
I tried adding the medium size with large spacing, but… | |||||
55 | right: parent.right | 56 | right: parent.right | ||
56 | top: parent.top | 57 | top: parent.top | ||
57 | topMargin: Math.round(units.gridUnit / 2) | 58 | topMargin: units.gridUnit | ||
58 | } | 59 | } | ||
59 | width: units.gridUnit * 20 | 60 | width: units.gridUnit * 20 | ||
60 | height: units.gridUnit * 8 | 61 | height: units.gridUnit * 8 | ||
61 | horizontalGridLineCount: 5 | 62 | horizontalGridLineCount: 5 | ||
62 | 63 | | |||
63 | dataSets: [ | 64 | dataSets: [ | ||
64 | KQuickControlsAddons.PlotData { | 65 | KQuickControlsAddons.PlotData { | ||
65 | id: downloadPlotData | 66 | id: downloadPlotData | ||
Show All 28 Lines |
Semantically it's weird to use the size of an icon for a margin, unless you're trying to line up with an icon. There's a medium sized icon in the toolbar, which I assume is the intent here.
Can you rewrite this as "units.iconSizes.medium + largeSpacing"
Should equate to the same value, but self-documents what it's actually doing and handles a user changing icon sizes in the config file.