1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.4
import QtQuick.Dialogs 1.2
import QGroundControl.FactSystem 1.0
import QGroundControl.Palette 1.0
import QGroundControl.Controls 1.0
import QGroundControl.ScreenTools 1.0
QGCTextField {
id: _textField
text: fact ? fact.valueString : ""
unitsLabel: fact ? fact.units : ""
showUnits: true
showHelp: true
signal updated()
property Fact fact: null
property string _validateString
inputMethodHints: ((fact && fact.typeIsString) || ScreenTools.isiOS) ?
Qt.ImhNone : // iOS numeric keyboard has no done button, we can't use it
Qt.ImhFormattedNumbersOnly // Forces use of virtual numeric keyboard
onEditingFinished: {
var errorString = fact.validate(text, false /* convertOnly */)
if (errorString === "") {
fact.value = text
_textField.updated()
} else {
_validateString = text
mainWindow.showComponentDialog(validationErrorDialogComponent, qsTr("Invalid Value"), mainWindow.showDialogDefaultWidth, StandardButton.Save | StandardButton.Cancel)
}
}
onHelpClicked: mainWindow.showComponentDialog(helpDialogComponent, qsTr("Value Details"), mainWindow.showDialogDefaultWidth, StandardButton.Save | StandardButton.Cancel)
Component {
id: validationErrorDialogComponent
ParameterEditorDialog {
validate: true
validateValue: _validateString
fact: _textField.fact
}
}
Component {
id: helpDialogComponent
ParameterEditorDialog {
fact: _textField.fact
}
}
}