Debian Codegraph @

faces/facepackages/facegrid/contents/ui/FaceGrid.qml

raw
1 /*
2 SPDX-FileCopyrightText: 2021 Arjen Hiemstra <[email protected]>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7 import QtQuick
8 import QtQuick.Controls
9 import QtQuick.Layouts
10
11 import org.kde.kirigami as Kirigami
12
13 import org.kde.ksysguard.sensors as Sensors
14 import org.kde.ksysguard.faces as Faces
15 import org.kde.ksysguard.formatter as Formatter
16
17 GridLayout {
18 id: grid
19
20 property bool compact
21
22 readonly property real preferredWidth: titleMetrics.width
23
24 readonly property int rowCount: Math.ceil(gridRepeater.count / columns)
25
26 columnSpacing: compact ? 1 : Kirigami.Units.largeSpacing
27 rowSpacing: compact ? 1 : Kirigami.Units.largeSpacing
28
29 Kirigami.Heading {
30 id: heading
31 Layout.fillWidth: true
32 Layout.columnSpan: parent.columns > 0 ? parent.columns : 1
33
34 horizontalAlignment: Text.AlignHCenter
35 elide: Text.ElideRight
36 text: root.controller.title
37 visible: !grid.compact && root.controller.showTitle && text.length > 0
38 level: 2
39
40 TextMetrics {
41 id: titleMetrics
42 font: heading.font
43 text: heading.text
44 }
45 }
46
47 Repeater {
48 id: gridRepeater
49
50 model: root.controller.highPrioritySensorIds
51
52 FaceControl {
53 Layout.fillWidth: true
54 Layout.fillHeight: true
55 Layout.preferredWidth: 0
56 Layout.preferredHeight: 0
57 compact: grid.compact
58 controller: root.controller
59 sensors: [modelData]
60 faceId: root.controller.faceConfiguration.faceId
61 }
62 }
63 }