QmlDesigner: Allow plain expressions to be set with LineEdit control

Task-number: QDS-2603
Change-Id: I10a1b513bc21b8736683d4ddc2e290c29b39696d
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Miikka Heikkinen
2020-08-14 13:41:08 +03:00
parent a0067e9444
commit 7adc062cf9

View File

@@ -40,6 +40,7 @@ StudioControls.TextField {
translationIndicatorVisible: showTranslateCheckBox translationIndicatorVisible: showTranslateCheckBox
property bool writeValueManually: false property bool writeValueManually: false
property bool writeAsExpression: false
property bool __dirty: false property bool __dirty: false
@@ -93,6 +94,9 @@ StudioControls.TextField {
target: modelNodeBackend target: modelNodeBackend
onSelectionToBeChanged: { onSelectionToBeChanged: {
if (__dirty && !writeValueManually) { if (__dirty && !writeValueManually) {
if (writeAsExpression)
lineEdit.backendValue.expression = text
else
lineEdit.backendValue.value = text lineEdit.backendValue.value = text
} else if (__dirty) { } else if (__dirty) {
commitData() commitData()
@@ -112,8 +116,12 @@ StudioControls.TextField {
if (backendValue.isTranslated) { if (backendValue.isTranslated) {
setTranslateExpression() setTranslateExpression()
} else { } else {
if (lineEdit.backendValue.value !== text) if (writeAsExpression) {
lineEdit.backendValue.value = text; if (lineEdit.backendValue.expression !== text)
lineEdit.backendValue.expression = text
} else if (lineEdit.backendValue.value !== text) {
lineEdit.backendValue.value = text
}
} }
__dirty = false __dirty = false
} }