mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-04-29 23:34:32 +08:00
Merge pull request #14885 from Ultimaker/CURA-10374_fix_combobobobobox
Cura 10374 fix combobobobobox
This commit is contained in:
commit
dc22a4980c
@ -65,32 +65,30 @@ UM.TooltipArea
|
|||||||
{
|
{
|
||||||
id: defaultOptionsModel
|
id: defaultOptionsModel
|
||||||
|
|
||||||
function updateModel()
|
function updateModel() {
|
||||||
{
|
clear();
|
||||||
clear()
|
|
||||||
|
|
||||||
if(!propertyProvider.properties.options)
|
if (!propertyProvider.properties.options) {
|
||||||
{
|
return;
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof propertyProvider.properties["options"] === "string")
|
if (typeof propertyProvider.properties["options"] === "string") {
|
||||||
{
|
return;
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let currentIndex = -1;
|
||||||
|
const keys = propertyProvider.properties["options"].keys();
|
||||||
|
for (let index = 0; index < propertyProvider.properties["options"].keys().length; index ++) {
|
||||||
|
const key = propertyProvider.properties["options"].keys()[index];
|
||||||
|
const value = propertyProvider.properties["options"][key];
|
||||||
|
|
||||||
for (var i = 0; i < propertyProvider.properties["options"].keys().length; i++)
|
if (propertyProvider.properties.value === key) {
|
||||||
{
|
currentIndex = index;
|
||||||
var key = propertyProvider.properties["options"].keys()[i]
|
}
|
||||||
var value = propertyProvider.properties["options"][key]
|
defaultOptionsModel.append({ text: value, value: key });
|
||||||
append({ text: value, code: key })
|
}
|
||||||
|
|
||||||
if (propertyProvider.properties.value === key)
|
comboBox.currentIndex = currentIndex;
|
||||||
{
|
|
||||||
comboBox.currentIndex = i
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: updateModel()
|
Component.onCompleted: updateModel()
|
||||||
@ -114,36 +112,28 @@ UM.TooltipArea
|
|||||||
model: defaultOptionsModel
|
model: defaultOptionsModel
|
||||||
textRole: "text"
|
textRole: "text"
|
||||||
|
|
||||||
currentIndex:
|
currentIndex: function () {
|
||||||
{
|
const currentValue = propertyProvider.properties.value
|
||||||
var currentValue = propertyProvider.properties.value
|
for (let i = 0; i < model.count; i ++) {
|
||||||
var index = 0
|
if (model.get(i).value === currentValue) {
|
||||||
for (var i = 0; i < model.count; i++)
|
return i;
|
||||||
{
|
|
||||||
if (model.get(i).value == currentValue)
|
|
||||||
{
|
|
||||||
index = i
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return index
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
onActivated:
|
onActivated: function (index) {
|
||||||
{
|
const key = propertyProvider.properties["options"].keys()[index];
|
||||||
var newValue = model.get(index).value
|
const newValue = model.get(index).value;
|
||||||
if (propertyProvider.properties.value !== newValue && newValue !== undefined)
|
|
||||||
{
|
if (propertyProvider.properties.value !== newValue && newValue !== undefined) {
|
||||||
if (setValueFunction !== null)
|
if (setValueFunction !== null) {
|
||||||
{
|
setValueFunction(newValue);
|
||||||
setValueFunction(newValue)
|
} else {
|
||||||
|
propertyProvider.setPropertyValue("value", newValue);
|
||||||
}
|
}
|
||||||
else
|
forceUpdateOnChangeFunction();
|
||||||
{
|
afterOnEditingFinishedFunction();
|
||||||
propertyProvider.setPropertyValue("value", newValue)
|
|
||||||
}
|
|
||||||
forceUpdateOnChangeFunction()
|
|
||||||
afterOnEditingFinishedFunction()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user