1/* 2 SPDX-FileCopyrightText: 2019 Marco Martin <mart@kde.org> 3 SPDX-FileCopyrightText: 2019 David Edmundson <davidedmundson@kde.org> 4 SPDX-FileCopyrightText: 2019 Arjen Hiemstra <ahiemstra@heimr.nl> 5 SPDX-FileCopyrightText: 2019 Kai Uwe Broulik <kde@broulik.de> 6 7 SPDX-License-Identifier: LGPL-2.0-or-later 8*/ 9 10import QtQuick 2.9 11import QtQuick.Layouts 1.4 12 13import org.kde.kirigami 2.8 as Kirigami 14 15import org.kde.ksysguard.sensors 1.0 as Sensors 16import org.kde.ksysguard.faces 1.0 as Faces 17 18import org.kde.quickcharts 1.0 as Charts 19import org.kde.quickcharts.controls 1.0 as ChartsControls 20 21Faces.SensorFace { 22 id: root 23 readonly property bool showLegend: controller.faceConfiguration.showLegend 24 25 Layout.minimumWidth: Kirigami.Units.gridUnit * 8 26 Layout.preferredWidth: titleMetrics.width 27 28 contentItem: ColumnLayout { 29 spacing: Kirigami.Units.largeSpacing 30 Kirigami.Heading { 31 id: heading 32 Layout.fillWidth: true 33 horizontalAlignment: Text.AlignHCenter 34 elide: Text.ElideRight 35 text: root.controller.title 36 visible: root.controller.showTitle && text.length > 0 37 level: 2 38 TextMetrics { 39 id: titleMetrics 40 font: heading.font 41 text: heading.text 42 } 43 } 44 45 PieChart { 46 id: compactRepresentation 47 Layout.fillWidth: true 48 Layout.fillHeight: true 49 Layout.minimumWidth: root.formFactor != Faces.SensorFace.Vertical ? Kirigami.Units.gridUnit * 4 : Kirigami.Units.gridUnit 50 Layout.minimumHeight: root.formFactor === Faces.SensorFace.Constrained 51 ? Kirigami.Units.gridUnit 52 : 5 * Kirigami.Units.gridUnit 53 Layout.preferredHeight: 8 * Kirigami.Units.gridUnit 54 Layout.maximumHeight: Math.max(root.width, Layout.minimumHeight) 55 updateRateLimit: root.controller.updateRateLimit 56 } 57 58 Faces.ExtendedLegend { 59 Layout.fillWidth: true 60 Layout.fillHeight: true 61 Layout.minimumHeight: root.formFactor === Faces.SensorFace.Horizontal 62 || root.formFactor === Faces.SensorFace.Vertical 63 ? implicitHeight 64 : Kirigami.Units.gridUnit 65 visible: root.showLegend 66 chart: compactRepresentation.chart 67 sourceModel: root.showLegend ? compactRepresentation.sensorsModel : null 68 sensorIds: root.showLegend ? root.controller.lowPrioritySensorIds : [] 69 updateRateLimit: root.controller.updateRateLimit 70 } 71 } 72} 73