Changeset View
Changeset View
Standalone View
Standalone View
faces/facepackages/piechart/contents/ui/PieChart.qml
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright 2019 Marco Martin <mart@kde.org> | ||||
3 | * Copyright 2019 David Edmundson <davidedmundson@kde.org> | ||||
4 | * Copyright 2019 Arjen Hiemstra <ahiemstra@heimr.nl> | ||||
5 | * Copyright 2019 Kai Uwe Broulik <kde@broulik.de> | ||||
6 | * | ||||
7 | * 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 | ||||
9 | * published by the Free Software Foundation; either version 2, or | ||||
10 | * (at your option) any later version. | ||||
11 | * | ||||
12 | * This program is distributed in the hope that it will be useful, | ||||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
15 | * GNU General Public License for more details | ||||
16 | * | ||||
17 | * You should have received a copy of the GNU Library General Public | ||||
18 | * License along with this program; if not, write to the | ||||
19 | * Free Software Foundation, Inc., | ||||
20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
21 | */ | ||||
22 | | ||||
23 | import QtQuick 2.9 | ||||
24 | import QtQuick.Layouts 1.1 | ||||
25 | import org.kde.kirigami 2.8 as Kirigami | ||||
26 | | ||||
27 | import org.kde.ksysguard.sensors 1.0 as Sensors | ||||
28 | import org.kde.ksysguard.faces 1.0 as Faces | ||||
29 | | ||||
30 | import org.kde.quickcharts 1.0 as Charts | ||||
31 | import org.kde.quickcharts.controls 1.0 as ChartControls | ||||
32 | | ||||
33 | | ||||
34 | ChartControls.PieChartControl { | ||||
35 | id: chart | ||||
36 | | ||||
37 | property alias headingSensor: sensor.sensorId | ||||
38 | property alias sensors: sensorsModel.sensors | ||||
39 | property alias sensorsModel: sensorsModel | ||||
40 | | ||||
41 | Layout.minimumWidth: root.formFactor != Faces.SensorFace.Vertical ? Kirigami.Units.gridUnit * 4 : Kirigami.Units.gridUnit | ||||
42 | Layout.minimumHeight: root.formFactor == Faces.SensorFace.Vertical ? width : Kirigami.Units.gridUnit | ||||
43 | | ||||
44 | leftPadding: 0 | ||||
45 | rightPadding: 0 | ||||
46 | topPadding: 0 | ||||
47 | bottomPadding: 0 | ||||
48 | | ||||
49 | chart.smoothEnds: root.controller.faceConfiguration.smoothEnds | ||||
50 | chart.fromAngle: root.controller.faceConfiguration.fromAngle | ||||
51 | chart.toAngle: root.controller.faceConfiguration.toAngle | ||||
52 | | ||||
53 | range { | ||||
54 | from: root.controller.faceConfiguration.rangeFrom | ||||
55 | to: root.controller.faceConfiguration.rangeTo | ||||
56 | automatic: root.controller.faceConfiguration.rangeAuto | ||||
57 | } | ||||
58 | | ||||
59 | chart.backgroundColor: Qt.rgba(0.0, 0.0, 0.0, 0.2) | ||||
60 | | ||||
61 | text: sensor.formattedValue | ||||
62 | valueSources: Charts.ModelSource { | ||||
63 | model: Sensors.SensorDataModel { | ||||
64 | id: sensorsModel | ||||
65 | sensors: root.controller.highPrioritySensorIds | ||||
66 | } | ||||
67 | roleName: "Value" | ||||
68 | indexColumns: true | ||||
69 | } | ||||
70 | chart.nameSource: Charts.ModelSource { | ||||
71 | roleName: "ShortName"; | ||||
72 | model: valueSources[0].model; | ||||
73 | indexColumns: true | ||||
74 | } | ||||
75 | chart.colorSource: root.colorSource | ||||
76 | | ||||
77 | Sensors.Sensor { | ||||
78 | id: sensor | ||||
79 | sensorId: root.controller.totalSensors.length > 0 ? root.controller.totalSensors[0] : "" | ||||
80 | } | ||||
81 | } | ||||
82 | |