7import QGroundControl.Controls
8import QGroundControl.FactControls
12 title: qsTr("Telemetry Display")
15 property var instrumentValueData
17 QGCPalette { id: qgcPal; colorGroupEnabled: parent.enabled }
18 QGCPalette { id: qgcPalDisable; colorGroupEnabled: false }
21 sourceComponent: instrumentValueData.fact ? editorComponent : noFactComponent
28 text: qsTr("Valuec requires a connected vehicle for setup.")
36 spacing: ScreenTools.defaultFontPixelWidth
39 spacing: ScreenTools.defaultFontPixelHeight / 2
42 heading: qsTr("Telemetry")
47 model: instrumentValueData.factGroupNames
48 currentIndex: instrumentValueData.factGroupNames.indexOf(instrumentValueData.factGroupName)
49 onActivated: (index) => {
50 instrumentValueData.setFact(currentText, "")
51 instrumentValueData.icon = ""
52 instrumentValueData.text = instrumentValueData.fact.shortDescription
55 target: instrumentValueData
56 onFactGroupNameChanged: factGroupCombo.currentIndex = factGroupCombo.comboBox.find(instrumentValueData.factGroupName)
63 model: instrumentValueData.factValueNames
64 currentIndex: instrumentValueData.factValueNames.indexOf(instrumentValueData.factName)
65 onActivated: (index) => {
66 instrumentValueData.setFact(instrumentValueData.factGroupName, currentText)
67 instrumentValueData.icon = ""
68 instrumentValueData.text = instrumentValueData.fact.shortDescription
71 target: instrumentValueData
72 onFactNameChanged: factNamesCombo.currentIndex = factNamesCombo.comboBox.find(instrumentValueData.factName)
78 heading: qsTr("Label")
81 Layout.fillWidth: true
82 spacing: ScreenTools.defaultFontPixelHeight / 2
85 Layout.fillWidth: true
90 Layout.fillWidth: true
91 Component.onCompleted: checked = instrumentValueData.icon != ""
93 instrumentValueData.text = ""
94 instrumentValueData.icon = instrumentValueData.factValueGrid.iconNames[0]
96 ButtonGroup.group: labelTypeGroup
97 ButtonGroup { id: labelTypeGroup }
104 height: changeIconBtn.height
105 color: qgcPal.windowShade
106 opacity: iconRadio.checked ? 1 : .3
110 anchors.centerIn: parent
111 height: ScreenTools.defaultFontPixelHeight
113 source: "/InstrumentValueIcons/" + (instrumentValueData.icon ? instrumentValueData.icon : instrumentValueData.factValueGrid.iconNames[0])
114 sourceSize.height: height
115 fillMode: Image.PreserveAspectFit
118 color: valueIcon.status === Image.Error ? "red" : qgcPal.text
124 enabled: iconRadio.checked
126 var updateFunction = function(icon){ instrumentValueData.icon = icon }
127 iconPickerDialogFactory.open({ iconNames: instrumentValueData.factValueGrid.iconNames, icon: instrumentValueData.icon, updateIconFunction: updateFunction })
134 Layout.fillWidth: true
139 Layout.fillWidth: true
140 ButtonGroup.group: labelTypeGroup
141 Component.onCompleted: checked = instrumentValueData.icon == ""
143 instrumentValueData.icon = ""
144 instrumentValueData.text = instrumentValueData.fact ? instrumentValueData.fact.shortDescription : qsTr("Label")
149 enabled: textRadio.checked
150 Layout.minimumWidth: iconOptionInputs.width
151 text: textRadio.checked
152 ? instrumentValueData.text
153 : instrumentValueData.fact ? instrumentValueData.fact.shortDescription : qsTr("Label")
154 onEditingFinished: instrumentValueData.text = text
161 model: instrumentValueData.factValueGrid.fontSizeNames
162 currentIndex: instrumentValueData.factValueGrid.fontSize
163 onActivated: (index) => { instrumentValueData.factValueGrid.fontSize = index }
167 Layout.fillWidth: true
168 text: qsTr("Show Units")
169 checked: instrumentValueData.showUnits
170 onClicked: instrumentValueData.showUnits = checked
175 SettingsGroupLayout {
176 Layout.alignment: Qt.AlignTop
177 heading: qsTr("Value range")
180 Layout.fillWidth: true
183 Layout.fillWidth: true
184 spacing: ScreenTools.defaultFontPixelWidth * 2
187 Layout.fillWidth: true
193 model: instrumentValueData.rangeTypeNames
194 currentIndex: instrumentValueData.rangeType
196 onActivated: (index) => { instrumentValueData.rangeType = index }
202 visible: sourceComponent
204 Layout.alignment: Qt.AlignHCenter
205 Layout.margins: ScreenTools.defaultFontPixelWidth
206 Layout.preferredWidth: item ? item.width : 0
207 Layout.preferredHeight: item ? item.height : 0
209 property var instrumentValueData: root.instrumentValueData
211 function updateSourceComponent() {
212 switch (instrumentValueData.rangeType) {
213 case InstrumentValueData.NoRangeInfo:
214 sourceComponent = undefined
216 case InstrumentValueData.ColorRange:
217 sourceComponent = colorRangeDialog
219 case InstrumentValueData.OpacityRange:
220 sourceComponent = opacityRangeDialog
222 case InstrumentValueData.IconSelectRange:
223 sourceComponent = iconRangeDialog
228 Component.onCompleted: {
229 updateSourceComponent()
230 if (sourceComponent) {
231 height = item.childrenRect.height
232 width = item.childrenRect.width
237 target: instrumentValueData
238 onRangeTypeChanged: rangeLoader.updateSourceComponent()
250 width: childrenRect.width
251 height: childrenRect.height
253 function updateRangeValue(index, text) {
254 var newValues = instrumentValueData.rangeValues
255 newValues[index] = parseFloat(text)
256 instrumentValueData.rangeValues = newValues
259 function updateColorValue(index, color) {
260 var newColors = instrumentValueData.rangeColors
261 newColors[index] = color
262 instrumentValueData.rangeColors = newColors
266 id: colorPickerDialog
267 modality: Qt.ApplicationModal
268 selectedColor: instrumentValueData.rangeColors.length ? instrumentValueData.rangeColors[colorIndex] : "white"
269 onAccepted: updateColorValue(colorIndex, selectedColor)
271 property int colorIndex: 0
276 spacing: ScreenTools.defaultFontPixelHeight / 2
279 width: rowLayout.width
280 text: qsTr("Specify the color you want to apply based on value ranges. The color will be applied to the icon if available, otherwise to the value itself.")
281 wrapMode: Text.WordWrap
289 anchors.verticalCenter: parent.verticalCenter
293 model: instrumentValueData.rangeValues.length
296 width: ScreenTools.implicitTextFieldHeight
298 fillMode: Image.PreserveAspectFit
299 color: QGroundControl.globalPalette.text
300 source: "/res/TrashDelete.svg"
304 onClicked: instrumentValueData.removeRangeValue(index)
311 anchors.verticalCenter: parent.verticalCenter
315 model: instrumentValueData.rangeValues.length
318 text: instrumentValueData.rangeValues[index]
319 onEditingFinished: updateRangeValue(index, text)
327 model: instrumentValueData.rangeColors
330 height: ScreenTools.implicitTextFieldHeight
331 checked: instrumentValueData.isValidColor(instrumentValueData.rangeColors[index])
332 onClicked: updateColorValue(index, checked ? "green" : instrumentValueData.invalidColor())
340 model: instrumentValueData.rangeColors
343 width: ScreenTools.implicitTextFieldHeight
345 border.color: qgcPal.text
346 color: instrumentValueData.isValidColor(modelData) ? modelData : qgcPal.text
351 colorPickerDialog.colorIndex = index
352 colorPickerDialog.open()
361 text: qsTr("Add Row")
362 onClicked: instrumentValueData.addRangeValue()
372 width: childrenRect.width
373 height: childrenRect.height
375 function updateRangeValue(index, text) {
376 var newValues = instrumentValueData.rangeValues
377 newValues[index] = parseFloat(text)
378 instrumentValueData.rangeValues = newValues
381 function updateIconValue(index, icon) {
382 var newIcons = instrumentValueData.rangeIcons
383 newIcons[index] = icon
384 instrumentValueData.rangeIcons = newIcons
389 spacing: ScreenTools.defaultFontPixelHeight / 2
392 width: rowLayout.width
393 text: qsTr("Specify the icon you want to display based on value ranges.")
394 wrapMode: Text.WordWrap
402 anchors.verticalCenter: parent.verticalCenter
406 model: instrumentValueData.rangeValues.length
409 width: ScreenTools.implicitTextFieldHeight
411 fillMode: Image.PreserveAspectFit
412 color: QGroundControl.globalPalette.text
413 source: "/res/TrashDelete.svg"
417 onClicked: instrumentValueData.removeRangeValue(index)
424 anchors.verticalCenter: parent.verticalCenter
428 model: instrumentValueData.rangeValues.length
431 text: instrumentValueData.rangeValues[index]
432 onEditingFinished: updateRangeValue(index, text)
441 model: instrumentValueData.rangeIcons
444 height: ScreenTools.implicitTextFieldHeight
446 source: "/InstrumentValueIcons/" + modelData
447 sourceSize.height: height
448 fillMode: Image.PreserveAspectFit
456 var updateFunction = function(icon){ updateIconValue(index, icon) }
457 iconPickerDialogFactory.open({ iconNames: instrumentValueData.factValueGrid.iconNames, icon: modelData, updateIconFunction: updateFunction })
466 text: qsTr("Add Row")
467 onClicked: instrumentValueData.addRangeValue()
474 id: opacityRangeDialog
477 width: childrenRect.width
478 height: childrenRect.height
480 function updateRangeValue(index, text) {
481 var newValues = instrumentValueData.rangeValues
482 newValues[index] = parseFloat(text)
483 instrumentValueData.rangeValues = newValues
486 function updateOpacityValue(index, opacity) {
487 var newOpacities = instrumentValueData.rangeOpacities
488 newOpacities[index] = opacity
489 instrumentValueData.rangeOpacities = newOpacities
494 spacing: ScreenTools.defaultFontPixelHeight / 2
497 width: rowLayout.width
498 text: qsTr("Specify the icon opacity you want based on value ranges.")
499 wrapMode: Text.WordWrap
507 anchors.verticalCenter: parent.verticalCenter
511 model: instrumentValueData.rangeValues.length
514 width: ScreenTools.implicitTextFieldHeight
516 fillMode: Image.PreserveAspectFit
517 color: QGroundControl.globalPalette.text
518 source: "/res/TrashDelete.svg"
522 onClicked: instrumentValueData.removeRangeValue(index)
529 anchors.verticalCenter: parent.verticalCenter
533 model: instrumentValueData.rangeValues
537 onEditingFinished: updateRangeValue(index, text)
546 model: instrumentValueData.rangeOpacities
550 onEditingFinished: updateOpacityValue(index, text)
557 text: qsTr("Add Row")
558 onClicked: instrumentValueData.addRangeValue()
564 QGCPopupDialogFactory {
565 id: iconPickerDialogFactory
567 dialogComponent: iconPickerDialog
574 title: qsTr("Select Icon")
575 buttons: Dialog.Close
577 property var iconNames
579 property var updateIconFunction
590 height: ScreenTools.minTouchPixels
592 color: currentSelection ? qgcPal.text : qgcPal.window
594 property bool currentSelection: icon == modelData
597 anchors.centerIn: parent
598 height: parent.height * 0.75
600 source: "/InstrumentValueIcons/" + modelData
601 sourceSize.height: height
602 fillMode: Image.PreserveAspectFit
605 color: currentSelection ? qgcPal.window : qgcPal.text
611 updateIconFunction(modelData)