Changeset View
Changeset View
Standalone View
Standalone View
faces/facepackages/textonly/contents/ui/CompactRepresentation.qml
- This file was copied from sensors/declarative/ExtendedLegend.qml.
1 | /* | 1 | /* | ||
---|---|---|---|---|---|
2 | * Copyright 2019 Marco Martin <mart@kde.org> | 2 | * Copyright 2019 Marco Martin <mart@kde.org> | ||
3 | * Copyright 2019 David Edmundson <davidedmundson@kde.org> | 3 | * Copyright 2019 David Edmundson <davidedmundson@kde.org> | ||
4 | * Copyright 2019 Arjen Hiemstra <ahiemstra@heimr.nl> | 4 | * Copyright 2019 Arjen Hiemstra <ahiemstra@heimr.nl> | ||
5 | * Copyright 2019 Kai Uwe Broulik <kde@broulik.de> | | |||
6 | * | 5 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU Library General Public License as | 7 | * it under the terms of the GNU Library General Public License as | ||
9 | * published by the Free Software Foundation; either version 2, or | 8 | * published by the Free Software Foundation; either version 2, or | ||
10 | * (at your option) any later version. | 9 | * (at your option) any later version. | ||
11 | * | 10 | * | ||
12 | * This program is distributed in the hope that it will be useful, | 11 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details | 14 | * GNU General Public License for more details | ||
16 | * | 15 | * | ||
17 | * You should have received a copy of the GNU Library General Public | 16 | * You should have received a copy of the GNU Library General Public | ||
18 | * License along with this program; if not, write to the | 17 | * License along with this program; if not, write to the | ||
19 | * Free Software Foundation, Inc., | 18 | * Free Software Foundation, Inc., | ||
20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
21 | */ | 20 | */ | ||
22 | 21 | | |||
23 | import QtQuick 2.9 | 22 | import QtQuick 2.9 | ||
24 | import QtQuick.Layouts 1.1 | 23 | import QtQuick.Layouts 1.1 | ||
25 | 24 | | |||
26 | import org.kde.kirigami 2.8 as Kirigami | 25 | import org.kde.kirigami 2.8 as Kirigami | ||
27 | 26 | | |||
28 | import org.kde.ksysguard.formatter 1.0 | 27 | import org.kde.ksysguard.sensors 1.0 as Sensors | ||
29 | import org.kde.ksysguard.sensors 1.0 | 28 | import org.kde.ksysguard.faces 1.0 as Faces | ||
30 | 29 | | |||
31 | import org.kde.quickcharts 1.0 as Charts | 30 | import org.kde.quickcharts 1.0 as Charts | ||
32 | import org.kde.quickcharts.controls 1.0 as ChartsControls | 31 | import org.kde.quickcharts.controls 1.0 as ChartsControls | ||
33 | 32 | | |||
34 | ChartsControls.Legend { | | |||
35 | id: legend | | |||
36 | 33 | | |||
37 | property alias textOnlySensorIds: textOnlySensorsRepeater.model | 34 | Faces.SensorFace { | ||
38 | property var sourceModel | 35 | id: root | ||
39 | property var colorSource | | |||
40 | 36 | | |||
41 | flow: GridLayout.TopToBottom | 37 | Layout.minimumWidth: root.formFactor == Faces.SensorFace.Vertical ? Kirigami.Units.gridUnit : Kirigami.Units.gridUnit * 2 | ||
42 | 38 | | |||
43 | Layout.maximumHeight: implicitHeight | 39 | contentItem: ColumnLayout { | ||
44 | Layout.maximumWidth: parent.width | | |||
45 | 40 | | |||
46 | spacing: Kirigami.Units.smallSpacing | 41 | Repeater { | ||
42 | model: root.controller.highPrioritySensorIds | ||||
47 | 43 | | |||
48 | valueVisible: true | 44 | ChartsControls.LegendDelegate { | ||
49 | valueWidth: units.gridUnit * 2 | 45 | Layout.fillWidth: true | ||
50 | formatValue: function(input, index) { | | |||
51 | return Formatter.formatValueShowNull(input, sourceModel.data(sourceModel.index(0, index), SensorDataModel.Unit)) | | |||
52 | } | | |||
53 | 46 | | |||
54 | Repeater { | | |||
55 | id: textOnlySensorsRepeater | | |||
56 | delegate: ChartsControls.LegendDelegate { | | |||
57 | name: sensor.shortName | 47 | name: sensor.shortName | ||
58 | value: sensor.formattedValue || "" | 48 | value: sensor.formattedValue | ||
59 | colorVisible: false | 49 | colorVisible: false | ||
50 | colorWidth: 0 | ||||
60 | 51 | | |||
61 | layoutWidth: legend.width | 52 | layoutWidth: root.width | ||
62 | valueWidth: units.gridUnit * 2 | 53 | valueWidth: Kirigami.Units.gridUnit * 2 | ||
63 | 54 | | |||
64 | Sensor { | 55 | Sensors.Sensor { | ||
65 | id: sensor | 56 | id: sensor | ||
66 | sensorId: modelData | 57 | sensorId: modelData | ||
67 | } | 58 | } | ||
68 | } | 59 | } | ||
69 | } | 60 | } | ||
61 | | ||||
62 | Item { Layout.fillWidth: true; Layout.fillHeight: true } | ||||
63 | } | ||||
70 | } | 64 | } |