I'm replacing all CheckBox in Cura with this CheckBox except ones that use the old "style" tag (Not in scope). This should make the design consistent everywhere and easier to update.

Moved set width and height from top level into "indicator" since this was causing the label to be cut off.

Swapped out setting_control_radius for checkbox_radius since these are different now.

Updated the UM.RecolorImage to work with tri state checkboxes so this can replace the Checkbox in SettingVisiblityPage.qml.
This commit is contained in:
j.delarago 2022-01-21 18:06:31 +01:00
parent 670872f8d1
commit 171da643d5
2 changed files with 50 additions and 13 deletions

View file

@ -17,13 +17,12 @@ CheckBox
hoverEnabled: true
height: UM.Theme.getSize("checkbox").height
width: UM.Theme.getSize("checkbox").width
indicator: Rectangle
{
width: control.height
height: control.height
height: UM.Theme.getSize("checkbox").height
width: UM.Theme.getSize("checkbox").width
anchors.verticalCenter: parent.verticalCenter
color:
{
@ -38,7 +37,7 @@ CheckBox
return UM.Theme.getColor("setting_control")
}
radius: UM.Theme.getSize("setting_control_radius").width
radius: UM.Theme.getSize("checkbox_radius").width
border.width: UM.Theme.getSize("default_lining").width
border.color:
{
@ -57,12 +56,46 @@ CheckBox
{
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
height: UM.Theme.getSize("checkbox_mark").height
width: UM.Theme.getSize("checkbox_mark").width
sourceSize.height: width
color: !enabled ? UM.Theme.getColor("setting_control_disabled_text") : UM.Theme.getColor("setting_control_text")
source: UM.Theme.getIcon("EmptyCheck", "low")
opacity: control.checked ? 1 : 0
height:
{
switch(control.checkState)
{
case Qt.Checked: return UM.Theme.getSize("checkbox_mark").height
case Qt.PartiallyChecked: return UM.Theme.getSize("checkbox_square").height
default: UM.Theme.getSize("checkbox_mark").height
}
}
width: height
sourceSize.height: height
color:
{
switch(control.checkState)
{
case Qt.Checked: return !enabled ? UM.Theme.getColor("setting_control_disabled_text") : UM.Theme.getColor("checkbox_mark")
case Qt.PartiallyChecked: return !enabled ? UM.Theme.getColor("setting_control_disabled_text") : UM.Theme.getColor("checkbox_square")
default: return !enabled ? UM.Theme.getColor("setting_control_disabled_text") : UM.Theme.getColor("checkbox_mark")
}
}
source:
{
switch (control.checkState)
{
case Qt.Checked: return UM.Theme.getIcon("EmptyCheck", "low")
case Qt.PartiallyChecked: return UM.Theme.getIcon("CheckBoxFill", "low")
default: return UM.Theme.getIcon("EmptyCheck", "low")
}
}
opacity:
{
switch (control.checkState)
{
case Qt.Checked: return 1;
case Qt.PartiallyChecked: return 1;
default: 0;
}
}
Behavior on opacity { NumberAnimation { duration: 100; } }
}
}
@ -70,7 +103,8 @@ CheckBox
contentItem: Label
{
id: textLabel
leftPadding: control.indicator.width + control.spacing
anchors.left: control.indicator.right
leftPadding: UM.Theme.getSize("checkbox_label_padding").width
text: control.text
font: control.font
color: UM.Theme.getColor("text")