Warning, /plasma/plasma-systemmonitor/src/page/FaceControl.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  * SPDX-FileCopyrightText: 2020 Arjen Hiemstra <ahiemstra@heimr.nl>
0003  *
0004  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005  */
0006 
0007 import QtQuick
0008 import QtQuick.Controls
0009 import QtQuick.Layouts
0010 
0011 import org.kde.ksysguard.sensors as Sensors
0012 import org.kde.ksysguard.faces as Faces
0013 import org.kde.ksysguard.page
0014 
0015 Container {
0016     id: control
0017 
0018     property alias dataObject: loader.dataObject
0019 
0020     function replaceSensors(replacement) {
0021         let changed = false
0022 
0023         for (let entry of replacement) {
0024             if (entry.face != dataObject.face) {
0025                 continue
0026             }
0027 
0028             loader.controller.replaceSensors(entry.sensor, entry.replacement)
0029             changed = true
0030         }
0031 
0032         if (changed) {
0033             loader.controller.reloadConfig()
0034         }
0035     }
0036 
0037     topPadding: 0
0038     bottomPadding: 0
0039     leftPadding: 0
0040     rightPadding: 0
0041 
0042     minimumContentHeight: contentItem ? contentItem.Layout.minimumHeight : 0
0043     minimumHeight: minimumContentHeight + topPadding + bottomPadding
0044 
0045     toolbar.visible: false
0046 
0047     onActiveChanged: {
0048         if (active) {
0049             applicationWindow().pageStack.push(Qt.resolvedUrl("FaceConfigurationPage.qml"), {"loader": loader})
0050         } else {
0051             if (activeItem instanceof FaceControl) {
0052                 return
0053             } else {
0054                 if (applicationWindow().pageStack.depth > 1) {
0055                     applicationWindow().pageStack.pop()
0056                 }
0057             }
0058         }
0059     }
0060 
0061     FaceLoader {
0062         id: loader
0063     }
0064 
0065     MouseArea {
0066         anchors.fill: parent
0067         z: 99
0068         onClicked: control.select(control)
0069     }
0070 
0071     Component.onCompleted: updateContentItem()
0072 
0073     Connections {
0074         target: loader.controller
0075         function onFaceIdChanged() {
0076             control.updateContentItem()
0077         }
0078 
0079         function onMissingSensorsChanged() {
0080             control.missingSensorsChanged(dataObject.face, controller.title, loader.controller.missingSensors)
0081         }
0082     }
0083 
0084     function updateContentItem() {
0085         loader.controller.fullRepresentation.formFactor = Faces.SensorFace.Constrained;
0086         control.contentItem = loader.controller.fullRepresentation;
0087 
0088         if (loader.controller.missingSensors.length > 0) {
0089             control.missingSensorsChanged(dataObject.face, loader.controller.title, loader.controller.missingSensors)
0090         }
0091     }
0092 }