| 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 |
Control { |
| 18 |
id: control |
| 19 |
|
| 20 |
property var controller |
| 21 |
property var sensors: [] |
| 22 |
property var sensorNames: [] |
| 23 |
property string faceId |
| 24 |
property bool compact |
| 25 |
|
| 26 |
topPadding: 0 |
| 27 |
bottomPadding: 0 |
| 28 |
leftPadding: 0 |
| 29 |
rightPadding: 0 |
| 30 |
|
| 31 |
Layout.minimumWidth: contentItem?.Layout.minimumWidth ?? -1 |
| 32 |
Layout.minimumHeight: contentItem?.Layout.minimumHeight ?? -1 |
| 33 |
Layout.preferredWidth: contentItem?.Layout.preferredWidth ?? -1 |
| 34 |
Layout.preferredHeight: contentItem?.Layout.preferredHeight ?? -1 |
| 35 |
Layout.maximumWidth: contentItem?.Layout.maximumWidth ?? -1 |
| 36 |
Layout.maximumHeight: contentItem?.Layout.maximumHeight ?? -1 |
| 37 |
|
| 38 |
implicitWidth: contentItem?.implicitWidth ?? 0 |
| 39 |
implicitHeight: contentItem?.implicitHeight ?? 0 |
| 40 |
|
| 41 |
Faces.FaceLoader { |
| 42 |
id: loader |
| 43 |
parentController: control.controller |
| 44 |
groupName: "FaceGrid" |
| 45 |
sensors: control.sensors |
| 46 |
faceId: control.faceId |
| 47 |
colors: control.controller.sensorColors |
| 48 |
labels: control.controller.sensorLabels |
| 49 |
updateRateLimit: control.controller.updateRateLimit |
| 50 |
} |
| 51 |
|
| 52 |
Component.onCompleted: updateContentItem() |
| 53 |
|
| 54 |
Connections { |
| 55 |
target: loader.controller |
| 56 |
function onFaceIdChanged() { |
| 57 |
control.updateContentItem() |
| 58 |
} |
| 59 |
} |
| 60 |
|
| 61 |
function updateContentItem() { |
| 62 |
if (control.compact) { |
| 63 |
loader.controller.compactRepresentation.formFactor = Faces.SensorFace.Constrained; |
| 64 |
control.contentItem = loader.controller.compactRepresentation; |
| 65 |
} else { |
| 66 |
loader.controller.fullRepresentation.formFactor = Faces.SensorFace.Constrained; |
| 67 |
control.contentItem = loader.controller.fullRepresentation; |
| 68 |
} |
| 69 |
} |
| 70 |
|
| 71 |
Connections { |
| 72 |
target: root.controller.faceConfigUi |
| 73 |
function onConfigurationChanged() { |
| 74 |
loader.controller.reloadFaceConfiguration() |
| 75 |
} |
| 76 |
} |
| 77 |
} |