mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 15:37:27 -06:00
Make textfield use states
CURA-6435
This commit is contained in:
parent
dfa35bd589
commit
f5ef6aed8d
2 changed files with 27 additions and 32 deletions
|
@ -141,7 +141,7 @@ Item
|
||||||
anchors.leftMargin: UM.Theme.getSize("default_margin").width
|
anchors.leftMargin: UM.Theme.getSize("default_margin").width
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
text: button.text
|
text: button.text
|
||||||
font.bold: true
|
font: UM.Theme.getFont("default_bold")
|
||||||
renderType: Text.NativeRendering
|
renderType: Text.NativeRendering
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,48 +17,43 @@ TextField
|
||||||
|
|
||||||
UM.I18nCatalog { id: catalog; name: "cura" }
|
UM.I18nCatalog { id: catalog; name: "cura" }
|
||||||
|
|
||||||
property int controlWidth: UM.Theme.getSize("setting_control").width
|
|
||||||
property int controlHeight: UM.Theme.getSize("setting_control").height
|
|
||||||
|
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
selectByMouse: true
|
selectByMouse: true
|
||||||
font: UM.Theme.getFont("default")
|
font: UM.Theme.getFont("default")
|
||||||
renderType: Text.NativeRendering
|
renderType: Text.NativeRendering
|
||||||
|
|
||||||
|
states: [
|
||||||
|
State
|
||||||
|
{
|
||||||
|
name: "disabled"
|
||||||
|
when: !textField.enabled
|
||||||
|
PropertyChanges { target: backgroundRectangle.border; color: UM.Theme.getColor("setting_control_disabled_border")}
|
||||||
|
PropertyChanges { target: backgroundRectangle; color: UM.Theme.getColor("setting_control_disabled")}
|
||||||
|
},
|
||||||
|
State
|
||||||
|
{
|
||||||
|
name: "invalid"
|
||||||
|
when: !textField.acceptableInput
|
||||||
|
PropertyChanges { target: backgroundRectangle.border; color: UM.Theme.getColor("setting_validation_error")}
|
||||||
|
PropertyChanges { target: backgroundRectangle; color: UM.Theme.getColor("setting_validation_error_background")}
|
||||||
|
},
|
||||||
|
State
|
||||||
|
{
|
||||||
|
name: "hovered"
|
||||||
|
when: textField.hovered || textField.activeFocus
|
||||||
|
PropertyChanges { target: backgroundRectangle.border; color: UM.Theme.getColor("setting_control_border_highlight") }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
background: Rectangle
|
background: Rectangle
|
||||||
{
|
{
|
||||||
|
id: backgroundRectangle
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: Math.round(UM.Theme.getSize("default_lining").width)
|
anchors.margins: Math.round(UM.Theme.getSize("default_lining").width)
|
||||||
radius: UM.Theme.getSize("setting_control_radius").width
|
radius: UM.Theme.getSize("setting_control_radius").width
|
||||||
|
|
||||||
border.color:
|
border.color: UM.Theme.getColor("setting_control_border")
|
||||||
{
|
|
||||||
if (!textField.enabled)
|
|
||||||
{
|
|
||||||
return UM.Theme.getColor("setting_control_disabled_border")
|
|
||||||
}
|
|
||||||
if (!textField.acceptableInput)
|
|
||||||
{
|
|
||||||
return UM.Theme.getColor("setting_validation_error")
|
|
||||||
}
|
|
||||||
if (textField.hovered || textField.activeFocus)
|
|
||||||
{
|
|
||||||
return UM.Theme.getColor("setting_control_border_highlight")
|
|
||||||
}
|
|
||||||
return UM.Theme.getColor("setting_control_border")
|
|
||||||
}
|
|
||||||
|
|
||||||
color:
|
color: UM.Theme.getColor("setting_control")
|
||||||
{
|
|
||||||
if (!textField.enabled)
|
|
||||||
{
|
|
||||||
return UM.Theme.getColor("setting_control_disabled")
|
|
||||||
}
|
|
||||||
if (!textField.acceptableInput)
|
|
||||||
{
|
|
||||||
return UM.Theme.getColor("setting_validation_error_background")
|
|
||||||
}
|
|
||||||
return UM.Theme.getColor("setting_control")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue