diff options
author | Henning Gruendl <henning.gruendl@qt.io> | 2022-09-23 16:24:38 +0200 |
---|---|---|
committer | Henning Gründl <henning.gruendl@qt.io> | 2022-09-23 14:50:35 +0000 |
commit | d9201393027022f1851f9a36362984fb83eb897e (patch) | |
tree | e0c751ba528a361d70a60202c551d9dbcf470c36 | |
parent | 2f55183557dccd1265b39f3059c59037e1967be1 (diff) | |
download | qt-creator-d9201393027022f1851f9a36362984fb83eb897e.tar.gz |
QmlDesigner: Fix binding editor empty expression
If the user pressed "Accept" on the binding editor if the text was empty
a dialog with a warning popped up. This fix avoids sending empty strings
to backend when condition.
Task-number: QDS-7729
Change-Id: I77e5e9d34f8566dc4ed215c839b01186d839a2df
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
3 files changed, 16 insertions, 9 deletions
diff --git a/share/qtcreator/qmldesigner/newstateseditor/Main.qml b/share/qtcreator/qmldesigner/newstateseditor/Main.qml index ca2cf9e1eb..dd9e5772b4 100644 --- a/share/qtcreator/qmldesigner/newstateseditor/Main.qml +++ b/share/qtcreator/qmldesigner/newstateseditor/Main.qml @@ -807,10 +807,6 @@ Rectangle { onStateNameFinished: statesEditorModel.renameState( delegateRoot.internalNodeId, stateThumbnail.stateName) - - onWhenConditionFinished: statesEditorModel.setWhenCondition( - delegateRoot.internalNodeId, - stateThumbnail.whenCondition) } } } diff --git a/share/qtcreator/qmldesigner/newstateseditor/StateThumbnail.qml b/share/qtcreator/qmldesigner/newstateseditor/StateThumbnail.qml index 199ef9bd77..9cde5f2744 100644 --- a/share/qtcreator/qmldesigner/newstateseditor/StateThumbnail.qml +++ b/share/qtcreator/qmldesigner/newstateseditor/StateThumbnail.qml @@ -65,7 +65,6 @@ Item { signal extend signal remove signal stateNameFinished - signal whenConditionFinished signal grabbing signal letGo @@ -608,8 +607,16 @@ Item { running: false interval: 50 repeat: false - onTriggered: statesEditorModel.setWhenCondition(root.internalNodeId, - bindingEditor.newWhenCondition) + onTriggered: { + if (whenCondition.previousCondition === bindingEditor.newWhenCondition) + return + + if ( bindingEditor.newWhenCondition !== "") + statesEditorModel.setWhenCondition(root.internalNodeId, + bindingEditor.newWhenCondition) + else + statesEditorModel.resetWhenCondition(root.internalNodeId) + } } stateModelNodeProperty: statesEditorModel.stateModelNode(root.internalNodeId) @@ -635,6 +642,8 @@ Item { indicatorVisible: true indicator.icon.text: StudioTheme.Constants.edit indicator.onClicked: { + whenCondition.previousCondition = whenCondition.text + bindingEditor.showWidget() bindingEditor.text = whenCondition.text bindingEditor.prepareBindings() @@ -662,7 +671,7 @@ Item { whenCondition.previousCondition = whenCondition.text if (whenCondition.text !== "") - root.whenConditionFinished() + statesEditorModel.setWhenCondition(root.internalNodeId, root.whenCondition) else statesEditorModel.resetWhenCondition(root.internalNodeId) diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/TextField.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/TextField.qml index 531a5b0ff3..0a683fa6d1 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/TextField.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/TextField.qml @@ -99,7 +99,9 @@ T.TextField { } onActiveFocusChanged: { - if (root.activeFocus) + // OtherFocusReason in this case means, if the TextField gets focus after the context menu + // was closed due to an menu item click. + if (root.activeFocus && root.focusReason !== Qt.OtherFocusReason) root.preFocusText = root.text } |