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