QmlDesigner: Fix ComboBox for raw strings

Change-Id: Ie35bda95290042f2faaf938ee67b6ee02e8c55b1
Reviewed-by: Henning Gründl <henning.gruendl@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Thomas Hartmann
2020-04-22 20:30:05 +02:00
parent ae080facf5
commit d5ac552314

View File

@@ -38,6 +38,10 @@ StudioControls.ComboBox {
enum ValueType { String, Integer, Enum } enum ValueType { String, Integer, Enum }
property int valueType: ComboBox.ValueType.Enum property int valueType: ComboBox.ValueType.Enum
onModelChanged: colorLogic.invalidate()
// This is available in all editors.
onValueTypeChanged: { onValueTypeChanged: {
if (comboBox.valueType === ComboBox.ValueType.Integer) if (comboBox.valueType === ComboBox.ValueType.Integer)
comboBox.useInteger = true comboBox.useInteger = true
@@ -98,8 +102,14 @@ StudioControls.ComboBox {
} else { } else {
switch (comboBox.valueType) { switch (comboBox.valueType) {
case ComboBox.ValueType.String: case ComboBox.ValueType.String:
if (comboBox.currentText !== comboBox.backendValue.value) if (comboBox.currentText !== comboBox.backendValue.value) {
comboBox.currentText = comboBox.backendValue.value var index = comboBox.find(comboBox.backendValue.value)
if (index < 0)
index = 0
if (index !== comboBox.currentIndex)
comboBox.currentIndex = index
}
break break
case ComboBox.ValueType.Integer: case ComboBox.ValueType.Integer:
if (comboBox.currentIndex !== comboBox.backendValue.value) if (comboBox.currentIndex !== comboBox.backendValue.value)
@@ -112,7 +122,7 @@ StudioControls.ComboBox {
if (enumString === "") if (enumString === "")
enumString = comboBox.backendValue.value enumString = comboBox.backendValue.value
var index = comboBox.find(enumString) index = comboBox.find(enumString)
if (index < 0) if (index < 0)
index = 0 index = 0