diff options
Diffstat (limited to 'share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ComboBox.qml')
-rw-r--r-- | share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ComboBox.qml | 74 |
1 files changed, 54 insertions, 20 deletions
diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ComboBox.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ComboBox.qml index cdd4fc4a67..b3e8fda368 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ComboBox.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ComboBox.qml @@ -35,8 +35,28 @@ StudioControls.ComboBox { labelColor: edit && !colorLogic.errorState ? StudioTheme.Values.themeTextColor : colorLogic.textColor property string scope: "Qt" + enum ValueType { String, Integer, Enum } + property int valueType: ComboBox.ValueType.Enum + + onValueTypeChanged: { + if (comboBox.valueType === ComboBox.ValueType.Integer) + comboBox.useInteger = true + else + comboBox.useInteger = false + } + + // This property shouldn't be used anymore, valueType has come to replace it. property bool useInteger: false + onUseIntegerChanged: { + if (comboBox.useInteger) { + comboBox.valueType = ComboBox.ValueType.Integer + } else { + if (comboBox.valueType === ComboBox.ValueType.Integer) + comboBox.valueType = ComboBox.ValueType.Enum // set to default + } + } + property bool __isCompleted: false property bool manualMapping: false @@ -75,23 +95,31 @@ StudioControls.ComboBox { if (comboBox.manualMapping) { comboBox.valueFromBackendChanged() - } else if (!comboBox.useInteger) { - var enumString = comboBox.backendValue.enumeration - - if (enumString === "") - enumString = comboBox.backendValue.value - - var index = comboBox.find(enumString) - - if (index < 0) - index = 0 - - if (index !== comboBox.currentIndex) - comboBox.currentIndex = index - } else { - if (comboBox.currentIndex !== comboBox.backendValue.value) - comboBox.currentIndex = comboBox.backendValue.value + switch (comboBox.valueType) { + case ComboBox.ValueType.String: + if (comboBox.currentText !== comboBox.backendValue.value) + comboBox.currentText = comboBox.backendValue.value + break + case ComboBox.ValueType.Integer: + if (comboBox.currentIndex !== comboBox.backendValue.value) + comboBox.currentIndex = comboBox.backendValue.value + break + case ComboBox.ValueType.Enum: + default: + var enumString = comboBox.backendValue.enumeration + + if (enumString === "") + enumString = comboBox.backendValue.value + + var index = comboBox.find(enumString) + + if (index < 0) + index = 0 + + if (index !== comboBox.currentIndex) + comboBox.currentIndex = index + } } comboBox.block = false @@ -108,10 +136,16 @@ StudioControls.ComboBox { if (comboBox.manualMapping) return - if (!comboBox.useInteger) { - comboBox.backendValue.setEnumeration(comboBox.scope, comboBox.currentText) - } else { - comboBox.backendValue.value = comboBox.currentIndex + switch (comboBox.valueType) { + case ComboBox.ValueType.String: + comboBox.backendValue.value = comboBox.currentText + break + case ComboBox.ValueType.Integer: + comboBox.backendValue.value = comboBox.currentIndex + break + case ComboBox.ValueType.Enum: + default: + comboBox.backendValue.setEnumeration(comboBox.scope, comboBox.currentText) } } |