mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-14 05:55:53 +08:00
style and code improvements for combobox with color swatch
This commit is contained in:
parent
3f60bc9287
commit
073c2d3335
@ -331,41 +331,19 @@ Item
|
||||
{
|
||||
var current_extruder = extruderModel.get(currentIndex);
|
||||
color_override = "";
|
||||
if (current_extruder === undefined) {
|
||||
return "";
|
||||
}
|
||||
var model_color = current_extruder.color;
|
||||
return (model_color) ? model_color : "";
|
||||
if (current_extruder === undefined) return ""
|
||||
return (current_extruder.color) ? current_extruder.color : "";
|
||||
}
|
||||
|
||||
textRole: 'text' // this solves that the combobox isn't populated in the first time Cura is started
|
||||
textRole: "text" // this solves that the combobox isn't populated in the first time Cura is started
|
||||
|
||||
anchors.top: enableSupportCheckBox.bottom
|
||||
anchors.topMargin:
|
||||
{
|
||||
if ((supportEnabled.properties.value == "True") && (machineExtruderCount.properties.value > 1))
|
||||
{
|
||||
return UM.Theme.getSize("sidebar_margin").height;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
anchors.topMargin: ((supportEnabled.properties.value === "True") && (machineExtruderCount.properties.value > 1)) ? UM.Theme.getSize("sidebar_margin").height : 0
|
||||
anchors.left: infillCellRight.left
|
||||
|
||||
width: UM.Theme.getSize("sidebar").width * .55
|
||||
height:
|
||||
{
|
||||
if ((supportEnabled.properties.value == "True") && (machineExtruderCount.properties.value > 1))
|
||||
{
|
||||
// default height when control is enabled
|
||||
return UM.Theme.getSize("setting_control").height;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
height: ((supportEnabled.properties.value == "True") && (machineExtruderCount.properties.value > 1)) ? UM.Theme.getSize("setting_control").height : 0
|
||||
|
||||
Behavior on height { NumberAnimation { duration: 100 } }
|
||||
|
||||
style: UM.Theme.styles.combobox_color
|
||||
|
@ -610,6 +610,7 @@ QtObject {
|
||||
|
||||
property Component combobox: Component {
|
||||
ComboBoxStyle {
|
||||
|
||||
background: Rectangle {
|
||||
implicitHeight: Theme.getSize("setting_control").height;
|
||||
implicitWidth: Theme.getSize("setting_control").width;
|
||||
@ -620,6 +621,7 @@ QtObject {
|
||||
border.width: Theme.getSize("default_lining").width;
|
||||
border.color: (control.hovered || control._hovered) ? Theme.getColor("setting_control_border_highlight") : Theme.getColor("setting_control_border");
|
||||
}
|
||||
|
||||
label: Item {
|
||||
Label {
|
||||
anchors.left: parent.left;
|
||||
@ -656,19 +658,17 @@ QtObject {
|
||||
|
||||
// Combobox with items with colored rectangles
|
||||
property Component combobox_color: Component {
|
||||
ComboBoxStyle
|
||||
{
|
||||
background: Rectangle
|
||||
{
|
||||
ComboBoxStyle {
|
||||
|
||||
background: Rectangle {
|
||||
color: !enabled ? UM.Theme.getColor("setting_control_disabled") : (control.hovered || controler._hovered) ? UM.Theme.getColor("setting_control_highlight") : UM.Theme.getColor("setting_control")
|
||||
border.width: UM.Theme.getSize("default_lining").width
|
||||
border.color: !enabled ? UM.Theme.getColor("setting_control_disabled_border") : (control.hovered || control._hovered) ? UM.Theme.getColor("setting_control_border_highlight") : UM.Theme.getColor("setting_control_border")
|
||||
}
|
||||
|
||||
label: Item
|
||||
{
|
||||
Label
|
||||
{
|
||||
label: Item {
|
||||
|
||||
Label {
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: UM.Theme.getSize("default_lining").width
|
||||
anchors.right: swatch.left
|
||||
@ -683,28 +683,25 @@ QtObject {
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
|
||||
Rectangle
|
||||
{
|
||||
Rectangle {
|
||||
id: swatch
|
||||
height: UM.Theme.getSize("setting_control").height / 2
|
||||
width: height
|
||||
|
||||
anchors
|
||||
{
|
||||
anchors {
|
||||
right: downArrow.left;
|
||||
verticalCenter: parent.verticalCenter
|
||||
margins: UM.Theme.getSize("default_margin").width / 4
|
||||
}
|
||||
|
||||
border.width: UM.Theme.getSize("default_lining").width * 2
|
||||
border.color: enabled ? UM.Theme.getColor("setting_control_border") : UM.Theme.getColor("setting_control_disabled_border")
|
||||
// border.width: UM.Theme.getSize("default_lining").width * 2
|
||||
// border.color: enabled ? UM.Theme.getColor("setting_control_border") : UM.Theme.getColor("setting_control_disabled_border")
|
||||
radius: width / 2
|
||||
|
||||
color: if (control.color_override != "") {return control.color_override} else {return control.color;}
|
||||
}
|
||||
|
||||
UM.RecolorImage
|
||||
{
|
||||
UM.RecolorImage {
|
||||
id: downArrow
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: UM.Theme.getSize("default_lining").width * 2
|
||||
|
Loading…
x
Reference in New Issue
Block a user