Skip to content

Commit 7cac2bf

Browse files
authored
Merge pull request #2911 from alicevision/fix/expressionTextFields
[qml] ExpressionTextFields: Fix unwanted value updates
2 parents e88f34a + c633ae0 commit 7cac2bf

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

meshroom/ui/qml/Utils/ExpressionTextField.qml

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ TextField {
66

77
// evaluated numeric value (NaN if invalid)
88
// It helps keeping the connection that text has so that we don't loose ability to undo/reset
9-
property bool textChanged: false
9+
property bool exprTextChanged: false
1010
property real evaluatedValue: 0
1111

1212
property bool hasExprError: false
1313
property bool isInt: false
14-
property int decimals: 2
1514

1615
// Overlay for error state (red border on top of default background)
1716
Rectangle {
@@ -36,8 +35,6 @@ TextField {
3635
if (_err == false) {
3736
if (isInt)
3837
_res = Math.round(_res)
39-
else
40-
_res = _res.toFixed(decimals)
4138
return _res
4239
} else {
4340
console.error("Error: Expression", _text, "is invalid")
@@ -63,7 +60,7 @@ TextField {
6360
evaluatedValue = previousEvaluatedValue
6461
raiseError()
6562
}
66-
textChanged = false
63+
exprTextChanged = false
6764
}
6865

6966
// onAccepted and onEditingFinished will break the bindings to text
@@ -72,42 +69,42 @@ TextField {
7269
// No need to restore the binding if the expression has an error because we don't break it
7370

7471
onAccepted: {
75-
if (textChanged)
72+
if (exprTextChanged)
7673
{
7774
updateExpression()
7875
if (!hasExprError && !isNaN(evaluatedValue)) {
7976
// Commit the result value to the text field
8077
if (isInt)
8178
root.text = Number(evaluatedValue).toFixed(0)
8279
else
83-
root.text = Number(evaluatedValue).toFixed(decimals)
80+
root.text = Number(evaluatedValue)
8481
}
8582
}
8683
}
8784

8885
onEditingFinished: {
89-
if (textChanged)
86+
if (exprTextChanged)
9087
{
9188
updateExpression()
9289
if (!hasExprError && !isNaN(evaluatedValue)) {
9390
if (isInt)
9491
root.text = Number(evaluatedValue).toFixed(0)
9592
else
96-
root.text = Number(evaluatedValue).toFixed(decimals)
93+
root.text = Number(evaluatedValue)
9794
}
9895
}
9996
}
10097

10198
onTextChanged: {
102-
if (!activeFocus) {
99+
if (!activeFocus && exprTextChanged) {
103100
refreshStatus()
104101
} else {
105-
textChanged = true
102+
exprTextChanged = true
106103
}
107104
}
108105

109106
Component.onDestruction: {
110-
if (textChanged) {
107+
if (exprTextChanged) {
111108
root.accepted()
112109
}
113110
}

meshroom/ui/qml/Viewer/HdrImageToolbar.qml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ FloatingPane {
124124
ToolTip.text: "Color Gain (in linear colorspace)"
125125

126126
text: gainValue
127-
decimals: 2
128127
Layout.preferredWidth: textMetrics_gainValue.width
129128
selectByMouse: true
130129
onAccepted: {
@@ -164,7 +163,7 @@ FloatingPane {
164163

165164
onClicked: {
166165
gammaLabel.text = gammaDefaultValue
167-
gammaCtrl.value = gammaLabel.text;
166+
gammaCtrl.value = gammaLabel.text
168167
}
169168
}
170169
ExpressionTextField {
@@ -175,7 +174,6 @@ FloatingPane {
175174
ToolTip.text: "Apply Gamma (after Gain and in linear colorspace)"
176175

177176
text: gammaValue
178-
decimals: 2
179177
Layout.preferredWidth: textMetrics_gainValue.width
180178
selectByMouse: true
181179
onAccepted: {

0 commit comments

Comments
 (0)