QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
ParameterDiffDialog.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Layouts
3import QtQuick.Controls
4import QtQuick.Dialogs
5
6import QGroundControl
7import QGroundControl.Controls
8import QGroundControl.FactControls
9
10QGCPopupDialog {
11 title: qsTr("Load Parameters")
12 buttons: Dialog.Cancel | (_sendableCount > 0 ? Dialog.Ok : 0)
13 acceptButtonEnabled: paramController.diffSelectedCount > 0
14
15 required property var paramController
16
17 property int _sendableCount: paramController.diffSendableCount
18
19 onAccepted: paramController.sendDiff()
20
21 Component.onDestruction: paramController.clearDiff();
22
23 ColumnLayout {
24 spacing: ScreenTools.defaultDialogControlSpacing
25
26 QGCLabel {
27 id: summaryLabel
28 objectName: "diffSummaryLabel"
29 Layout.preferredWidth: mainGrid.visible ? mainGrid.width : ScreenTools.defaultFontPixelWidth * 40
30 wrapMode: Text.WordWrap
31 text: {
32 var clauses = []
33 if (_sendableCount > 0) {
34 if (paramController.diffNoVehicleCount > 0) {
35 clauses.push(qsTr("%1 will be changed (including %2 not currently on the Vehicle)").arg(_sendableCount).arg(paramController.diffNoVehicleCount))
36 } else {
37 clauses.push(qsTr("%1 will be changed").arg(_sendableCount))
38 }
39 }
40 if (paramController.diffUnchangedCount === 1) {
41 clauses.push(qsTr("1 already matches the Vehicle"))
42 } else if (paramController.diffUnchangedCount > 1) {
43 clauses.push(qsTr("%1 already match the Vehicle").arg(paramController.diffUnchangedCount))
44 }
45 if (paramController.diffReadOnlyCount === 1) {
46 clauses.push(qsTr("1 read-only parameter will not be sent"))
47 } else if (paramController.diffReadOnlyCount > 1) {
48 clauses.push(qsTr("%1 read-only parameters will not be sent").arg(paramController.diffReadOnlyCount))
49 }
50 if (paramController.diffMissingParams.length > 0) {
51 clauses.push(qsTr("%1 not found on the Vehicle and cannot be sent").arg(paramController.diffMissingParams.length))
52 }
53 if (paramController.diffInvalidParams.length === 1) {
54 clauses.push(qsTr("1 has an invalid value and will not be sent"))
55 } else if (paramController.diffInvalidParams.length > 1) {
56 clauses.push(qsTr("%1 have invalid values and will not be sent").arg(paramController.diffInvalidParams.length))
57 }
58 if (paramController.diffParsedCount === 1) {
59 return clauses.length === 0 ? qsTr("Loaded 1 parameter from file.")
60 : qsTr("Loaded 1 parameter from file: %1.").arg(clauses.join(", "))
61 }
62 return clauses.length === 0 ? qsTr("Loaded %1 parameters from file.").arg(paramController.diffParsedCount)
63 : qsTr("Loaded %1 parameters from file: %2.").arg(paramController.diffParsedCount).arg(clauses.join(", "))
64 }
65 }
66
67 QGCLabel {
68 objectName: "diffOkHintLabel"
69 Layout.preferredWidth: summaryLabel.Layout.preferredWidth
70 wrapMode: Text.WordWrap
71 visible: _sendableCount > 0
72 text: qsTr("Click 'Ok' to update the parameters below on the Vehicle.")
73 }
74
75 GridLayout {
76 id: mainGrid
77 objectName: "diffGrid"
78 rows: paramController.diffList.count + 1
79 columns: paramController.diffMultipleComponents ? 5 : 4
80 flow: GridLayout.TopToBottom
81 rowSpacing: 0
82 columnSpacing: ScreenTools.defaultFontPixelWidth
83 visible: paramController.diffList.count
84
85 QGCCheckBox {
86 objectName: "diffCheckAllCheckbox"
87 checked: true
88 onClicked: {
89 for (var i=0; i<paramController.diffList.count; i++) {
90 var paramDiff = paramController.diffList.get(i)
91 if (!paramDiff.cannotSend) {
92 paramDiff.load = checked
93 }
94 }
95 }
96 }
97 Repeater {
98 model: paramController.diffList
99 QGCCheckBox {
100 objectName: "diffRowCheckbox_" + (paramController.diffMultipleComponents ? object.componentId + "_" : "") + object.name
101 enabled: !object.cannotSend
102 checked: object.load
103 onClicked: object.load = checked
104 }
105 }
106
107 Repeater {
108 model: paramController.diffMultipleComponents ? 1 : 0
109 QGCLabel { text: qsTr("Comp ID") }
110 }
111 Repeater {
112 model: paramController.diffMultipleComponents ? paramController.diffList : 0
113 QGCLabel { text: object.componentId }
114 }
115
116 QGCLabel { text: qsTr("Name") }
117 Repeater {
118 model: paramController.diffList
119 QGCLabel { text: object.name }
120 }
121
122 QGCLabel { text: qsTr("File") }
123 Repeater {
124 model: paramController.diffList
125 QGCLabel { text: object.invalidFileValue ? qsTr("%1 — invalid").arg(object.fileValue) : object.fileValue + " " + object.units }
126 }
127
128 QGCLabel { text: qsTr("Vehicle") }
129 Repeater {
130 model: paramController.diffList
131 QGCLabel {
132 text: object.noVehicleValue ? qsTr("N/A — new to Vehicle") :
133 (object.cannotSend && !object.invalidFileValue) ? qsTr("N/A — not on Vehicle") :
134 object.vehicleValue + " " + object.units
135 }
136 }
137 }
138
139 QGCLabel {
140 objectName: "diffNoVehicleHintLabel"
141 Layout.preferredWidth: summaryLabel.Layout.preferredWidth
142 wrapMode: Text.WordWrap
143 visible: paramController.diffNoVehicleCount > 0
144 text: qsTr("Parameters marked 'new to Vehicle' have not been reported by the Vehicle. They may only become visible after they are sent and the Vehicle is rebooted.")
145 }
146
147 QGCLabel {
148 objectName: "diffCannotSendHintLabel"
149 Layout.preferredWidth: summaryLabel.Layout.preferredWidth
150 wrapMode: Text.WordWrap
151 visible: paramController.diffMissingParams.length > 0
152 text: qsTr("Parameters marked 'not on Vehicle' cannot be sent since the file does not include type information. They may only exist after another parameter is changed and the Vehicle is rebooted, after which you can load this file again.")
153 }
154
155 QGCLabel {
156 objectName: "diffInvalidHintLabel"
157 Layout.preferredWidth: summaryLabel.Layout.preferredWidth
158 wrapMode: Text.WordWrap
159 visible: paramController.diffInvalidParams.length > 0
160 text: qsTr("Parameters marked 'invalid' have a value in the file that cannot be converted to the parameter's type on the Vehicle. They will not be sent.")
161 }
162 }
163}