QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
FactTextField.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Dialogs
4
5import QGroundControl
6import QGroundControl.Controls
7
8QGCTextField {
9 id: control
10 text: fact ? fact.valueString : ""
11 unitsLabel: fact ? fact.units : ""
12 showUnits: true
13 showHelp: false
14 numericValuesOnly: fact && !fact.typeIsString
15 maximumLength: fact && fact.maxStringLength > 0 ? fact.maxStringLength : 32767 // 32767 is the TextInput default (no limit)
16
17 signal updated()
18
19 property Fact fact: null
20
21 onEditingFinished: _onEditingFinished()
22
23 function _onEditingFinished() {
24 // Focus loss also lands here; writing back the unedited, rounded display text would change the value
25 if (text === fact.valueString) {
26 clearValidationError()
27 return
28 }
29 var errorString = fact.validate(text, false /* convertOnly */)
30 if (errorString === "") {
31 clearValidationError()
32 fact.value = text
33 control.updated()
34 } else {
35 showValidationError(errorString, fact.valueString)
36 }
37 }
38
39 onHelpClicked: helpDialogFactory.open()
40
41 QGCPopupDialogFactory {
42 id: helpDialogFactory
43
44 dialogComponent: helpDialogComponent
45 }
46
47 Component {
48 id: helpDialogComponent
49
50 ParameterEditorDialog {
51 title: qsTr("Value Details")
52 fact: control.fact
53 }
54 }
55}