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