diff options
author | Henning Gruendl <henning.gruendl@qt.io> | 2022-05-19 10:59:53 +0200 |
---|---|---|
committer | Henning Gründl <henning.gruendl@qt.io> | 2022-05-20 08:32:28 +0000 |
commit | 5294c3a23bdc60d9952662f045479893fb4518d4 (patch) | |
tree | 641854f98cdad05e53146d93adc0cb12a7753d51 | |
parent | e10b3bc98b8928e28e6d9dd9cddf9b9338a4f8a2 (diff) |
QmlDesigner: Fix FilterComboBox same value submit
* Fix issue when same URL gets submitted twice in a row
* Fix selection of model item when submitting a custom URL that aligns
with an item in the model
Change-Id: Ica8819f72a1f2dc0c239eb2ced25a11a1355d81f
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
-rw-r--r-- | share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/UrlChooser.qml | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/UrlChooser.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/UrlChooser.qml index ce2584c4be..f6766234d0 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/UrlChooser.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/UrlChooser.qml @@ -185,24 +185,34 @@ Row { onEditTextChanged: comboBox.dirty = true function setCurrentText(text) { - var index = comboBox.find(text) - if (index === -1) - comboBox.currentIndex = -1 - + comboBox.currentIndex = comboBox.find(text) + comboBox.setHighlightedIndexItems(comboBox.currentIndex) + comboBox.autocompleteString = "" comboBox.editText = text comboBox.dirty = false } // Takes into account applied bindings - property string textValue: { - if (root.backendValue.isBound) - return root.backendValue.expression + function updateTextValue() { + if (root.backendValue.isBound) { + comboBox.textValue = root.backendValue.expression + } else { + var fullPath = root.backendValue.valueToString + comboBox.textValue = fullPath.substr(fullPath.lastIndexOf('/') + 1) + } + + comboBox.setCurrentText(comboBox.textValue) + } + + Connections { + target: root.backendValue - var fullPath = root.backendValue.valueToString - return fullPath.substr(fullPath.lastIndexOf('/') + 1) + function onIsBoundChanged() { comboBox.updateTextValue() } + function onExpressionChanged() { comboBox.updateTextValue() } + function onValueChangedQml() { comboBox.updateTextValue() } } - onTextValueChanged: comboBox.setCurrentText(comboBox.textValue) + property string textValue: "" onModelChanged: { if (!comboBox.isComplete) @@ -223,7 +233,6 @@ Row { inputValue = comboBox.items.get(index).model.fullPath root.backendValue.value = inputValue - comboBox.dirty = false } @@ -303,7 +312,10 @@ Row { onDefaultItemsChanged: root.createModel() - Component.onCompleted: root.createModel() + Component.onCompleted: { + root.createModel() + comboBox.updateTextValue() + } function indexOf(model, criteria) { for (var i = 0; i < model.count; ++i) { |