aboutsummaryrefslogtreecommitdiffstats
path: root/share/qtcreator
diff options
context:
space:
mode:
authorHenning Gruendl <henning.gruendl@qt.io>2019-08-13 18:13:00 +0200
committerThomas Hartmann <thomas.hartmann@qt.io>2019-08-13 16:17:10 +0000
commitfc86de5e5ad07dbcd7693445e0dea7b9b0e26bed (patch)
tree5b2fa417b6aa37680cee7b9d302c5183ae7b3f00 /share/qtcreator
parentd877a391240c9e54791804189b28ecb6a4fc9f52 (diff)
QmlDesigner: Fix editable ComboBox
Change-Id: Ibf449a3dc34ffeedd70e46bffcb0670049bfb4fc Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Diffstat (limited to 'share/qtcreator')
-rw-r--r--share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/UrlChooser.qml48
1 files changed, 33 insertions, 15 deletions
diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/UrlChooser.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/UrlChooser.qml
index d4b59a32d9..327bfb2335 100644
--- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/UrlChooser.qml
+++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/UrlChooser.qml
@@ -37,7 +37,6 @@ RowLayout {
property string filter: "*.png *.gif *.jpg *.bmp *.jpeg *.svg"
-
FileResourcesModel {
modelNodeBackendProperty: modelNodeBackend
filter: urlChooser.filter
@@ -63,15 +62,20 @@ RowLayout {
property bool isComplete: false
+ property bool dirty: false
+
+ onEditTextChanged: comboBox.dirty = true
+
function setCurrentText(text) {
if (text === "")
return
-
- var index = comboBox.find(textValue)
+ var index = comboBox.find(text)
if (index === -1)
currentIndex = -1
- editText = textValue
+
+ editText = text
+ comboBox.dirty = false
}
property string textValue: {
@@ -81,9 +85,7 @@ RowLayout {
return backendValue.valueToString
}
- onTextValueChanged: {
- setCurrentText(textValue)
- }
+ onTextValueChanged: setCurrentText(textValue)
Layout.fillWidth: true
@@ -97,25 +99,41 @@ RowLayout {
setCurrentText(textValue)
}
+
onAccepted: {
if (!comboBox.isComplete)
return;
- if (backendValue.value !== currentText)
- backendValue.value = currentText;
+ if (backendValue.value !== editText)
+ backendValue.value = editText;
+
+ comboBox.dirty = false
+ }
+
+ onFocusChanged: {
+ if (comboBox.dirty)
+ handleActivate(comboBox.currentIndex)
}
- onActivated: {
- var cText = textAt(index)
- print(cText)
- if (backendValue === undefined)
+ onActivated: handleActivate(index)
+
+ function handleActivate(index)
+ {
+ var cText = comboBox.textAt(index)
+
+ if (index === -1)
+ cText = comboBox.editText
+
+ if (urlChooser.backendValue === undefined)
return;
if (!comboBox.isComplete)
return;
- if (backendValue.value !== cText)
- backendValue.value = cText;
+ if (urlChooser.backendValue.value !== cText)
+ urlChooser.backendValue.value = cText;
+
+ comboBox.dirty = false
}
Component.onCompleted: {