Warning, /plasma/plasma-systemmonitor/src/page/MissingSensorsDialog.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: 2022 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.15 0008 import QtQuick.Controls 2.15 0009 import QtQuick.Layouts 1.15 0010 0011 import org.kde.kirigami 2.15 as Kirigami 0012 0013 import org.kde.ksysguard.page 1.0 0014 import org.kde.ksysguard.faces 1.0 as Faces 0015 0016 Dialog { 0017 id: dialog 0018 0019 property var missingSensors: { } 0020 property var sensorReplacement: { } 0021 0022 modal: true 0023 parent: Overlay.overlay 0024 focus: true 0025 0026 x: parent ? Math.round(parent.width / 2 - width / 2) : 0 0027 y: ApplicationWindow.window ? ApplicationWindow.window.pageStack.globalToolBar.height - Kirigami.Units.smallSpacing : 0 0028 0029 leftPadding: 1 // Allow dialog background border to show 0030 rightPadding: 1 // Allow dialog background border to show 0031 bottomPadding: Kirigami.Units.smallSpacing 0032 topPadding: Kirigami.Units.smallSpacing 0033 bottomInset: -Kirigami.Units.smallSpacing 0034 0035 title: i18nc("@title", "Replace Missing Sensors") 0036 0037 onAccepted: { 0038 let result = [] 0039 0040 for (let i = 0; i < sensorsModel.count; ++i) { 0041 let entry = sensorsModel.get(i) 0042 if (!entry.replacement) { 0043 continue 0044 } 0045 0046 result.push({ 0047 "face": entry.face, 0048 "sensor": entry.sensor, 0049 "replacement": entry.replacement 0050 }) 0051 } 0052 0053 sensorReplacement = result 0054 } 0055 0056 onMissingSensorsChanged: { 0057 sensorsModel.clear(); 0058 missingSensors.sort((first, second) => first.title.localeCompare(second.title)) 0059 for (let entry of missingSensors) { 0060 entry.replacement = "" 0061 sensorsModel.append(entry) 0062 } 0063 } 0064 0065 contentItem: Rectangle { 0066 Kirigami.Theme.colorSet: Kirigami.Theme.View 0067 color: Kirigami.Theme.backgroundColor 0068 implicitWidth: Kirigami.Units.gridUnit * 30 0069 implicitHeight: Kirigami.Units.gridUnit * 30 0070 0071 Kirigami.Separator { anchors { left: parent.left; right: parent.right; top: parent.top } } 0072 0073 ScrollView { 0074 anchors.fill: parent 0075 anchors.topMargin: 1 0076 anchors.bottomMargin: 1 0077 clip: true 0078 0079 ScrollBar.horizontal.policy: ScrollBar.AlwaysOff 0080 0081 ListView { 0082 id: columnView 0083 0084 model: ListModel { id: sensorsModel } 0085 0086 section.property: "title" 0087 section.delegate: Kirigami.ListSectionHeader { 0088 required property string section 0089 label: section 0090 } 0091 0092 delegate: Kirigami.BasicListItem { 0093 id: delegate 0094 0095 implicitHeight: Kirigami.Units.gridUnit * 2 + Kirigami.Units.smallSpacing * 2 0096 labelItem.textFormat: Text.MarkdownText 0097 label: model.sensor 0098 0099 trailing: Faces.Choices { 0100 width: delegate.width * 0.5 0101 0102 supportsColors: false 0103 maxAllowedSensors: 1 0104 labelsEditable: false 0105 labels: { } 0106 0107 onSelectedChanged: { 0108 if (selected.length > 0) { 0109 sensorsModel.setProperty(index, "replacement", selected[0]) 0110 } 0111 } 0112 } 0113 } 0114 } 0115 } 0116 0117 Kirigami.Separator { anchors { left: parent.left; right: parent.right; bottom: parent.bottom } } 0118 } 0119 0120 footer: DialogButtonBox { 0121 Button { 0122 DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole 0123 text: i18nc("@action:button", "Save") 0124 icon.name: "document-save" 0125 } 0126 Button { 0127 DialogButtonBox.buttonRole: DialogButtonBox.RejectRole 0128 text: i18nc("@action:button", "Cancel") 0129 icon.name: "dialog-close" 0130 } 0131 } 0132 } 0133