mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-25 23:53:56 -06:00
Make SettingTextField work
This commit is contained in:
parent
e4fe1c6e21
commit
5b31634d3c
1 changed files with 28 additions and 26 deletions
|
@ -31,19 +31,19 @@ SettingItem
|
||||||
{
|
{
|
||||||
return UM.Theme.getColor("setting_control_disabled")
|
return UM.Theme.getColor("setting_control_disabled")
|
||||||
}
|
}
|
||||||
switch(definition.validationState)
|
switch(propertyProvider.properties.validationState)
|
||||||
{
|
{
|
||||||
case 0:
|
case "ValidatorState.Exception":
|
||||||
return UM.Theme.getColor("setting_validation_error")
|
return UM.Theme.getColor("setting_validation_error")
|
||||||
case 1:
|
case "ValidatorState.MinimumError":
|
||||||
return UM.Theme.getColor("setting_validation_error")
|
return UM.Theme.getColor("setting_validation_error")
|
||||||
case 2:
|
case "ValidatorState.MaximumError":
|
||||||
return UM.Theme.getColor("setting_validation_error")
|
return UM.Theme.getColor("setting_validation_error")
|
||||||
case 3:
|
case "ValidatorState.MinimumWarning":
|
||||||
return UM.Theme.getColor("setting_validation_warning")
|
return UM.Theme.getColor("setting_validation_warning")
|
||||||
case 4:
|
case "ValidatorState.MaximumWarning":
|
||||||
return UM.Theme.getColor("setting_validation_warning")
|
return UM.Theme.getColor("setting_validation_warning")
|
||||||
case 5:
|
case "ValidatorState.Valid":
|
||||||
return UM.Theme.getColor("setting_validation_ok")
|
return UM.Theme.getColor("setting_validation_ok")
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -56,8 +56,7 @@ SettingItem
|
||||||
anchors.fill: parent;
|
anchors.fill: parent;
|
||||||
anchors.margins: UM.Theme.getSize("default_lining").width;
|
anchors.margins: UM.Theme.getSize("default_lining").width;
|
||||||
color: UM.Theme.getColor("setting_control_highlight")
|
color: UM.Theme.getColor("setting_control_highlight")
|
||||||
opacity: 0.35
|
opacity: !control.hovered ? 0 : propertyProvider.properties.validationState == "ValidatorState.Valid" ? 1.0 : 0.35;
|
||||||
// opacity: !control.hovered ? 0 : valid == 5 ? 1.0 : 0.35;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Label
|
Label
|
||||||
|
@ -93,19 +92,22 @@ SettingItem
|
||||||
|
|
||||||
Keys.onReleased:
|
Keys.onReleased:
|
||||||
{
|
{
|
||||||
text = text.replace(",", ".") // User convenience. We use dots for decimal values
|
// text = text.replace(",", ".") // User convenience. We use dots for decimal values
|
||||||
if(parseFloat(text) != base.parentValue)
|
// if(parseFloat(text) != base.parentValue)
|
||||||
{
|
// {
|
||||||
base.valueChanged(parseFloat(text));
|
// base.valueChanged(parseFloat(text));
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
propertyProvider.setPropertyValue("value", text)
|
||||||
}
|
}
|
||||||
|
|
||||||
onEditingFinished:
|
onEditingFinished:
|
||||||
{
|
{
|
||||||
if(parseFloat(text) != base.parentValue)
|
// if(parseFloat(text) != base.parentValue)
|
||||||
{
|
// {
|
||||||
base.valueChanged(parseFloat(text));
|
// base.valueChanged(parseFloat(text));
|
||||||
}
|
// }
|
||||||
|
propertyProvider.setPropertyValue("value", text)
|
||||||
}
|
}
|
||||||
|
|
||||||
color: !enabled ? UM.Theme.getColor("setting_control_disabled_text") : UM.Theme.getColor("setting_control_text")
|
color: !enabled ? UM.Theme.getColor("setting_control_disabled_text") : UM.Theme.getColor("setting_control_text")
|
||||||
|
@ -117,13 +119,13 @@ SettingItem
|
||||||
|
|
||||||
validator: RegExpValidator { regExp: /[0-9.,-]{0,10}/ }
|
validator: RegExpValidator { regExp: /[0-9.,-]{0,10}/ }
|
||||||
|
|
||||||
// Binding
|
Binding
|
||||||
// {
|
{
|
||||||
// target: input
|
target: input
|
||||||
// property: "text"
|
property: "text"
|
||||||
// value: format(base.parentValue)
|
value: control.format(propertyProvider.properties.value)
|
||||||
// when: !input.activeFocus
|
when: !input.activeFocus
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Rounds a floating point number to 4 decimals. This prevents floating
|
//Rounds a floating point number to 4 decimals. This prevents floating
|
||||||
|
@ -147,7 +149,7 @@ SettingItem
|
||||||
//input: The string value to format.
|
//input: The string value to format.
|
||||||
//return: The formatted string.
|
//return: The formatted string.
|
||||||
function format(inputValue) {
|
function format(inputValue) {
|
||||||
return parseFloat(inputValue) ? roundFloat(parseFloat(inputValue), 4) : inputValue //If it's a float, round to four decimals.
|
return parseFloat(inputValue) ? roundFloat(parseFloat(inputValue), 4) : inputValue //If it's a float, round to four decimals.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue