Add rounded corners to the settings

Contributes to CURA-5941
This commit is contained in:
Diego Prado Gesto 2018-12-03 15:56:21 +01:00
parent 4e9c595bdd
commit d3b5b2717d
6 changed files with 81 additions and 75 deletions

View File

@ -97,10 +97,10 @@ Item
property string color_override: "" // for manually setting values property string color_override: "" // for manually setting values
property string color: // is evaluated automatically, but the first time is before extruderModel being filled property string color: // is evaluated automatically, but the first time is before extruderModel being filled
{ {
var current_extruder = extruderModel.get(currentIndex); var current_extruder = extruderModel.get(currentIndex)
color_override = ""; color_override = ""
if (current_extruder === undefined) return "" if (current_extruder === undefined) return ""
return (current_extruder.color) ? current_extruder.color : ""; return (current_extruder.color) ? current_extruder.color : ""
} }
currentIndex: currentIndex:

View File

@ -28,37 +28,40 @@ SettingItem
// 3: material -> user changed material in materials page // 3: material -> user changed material in materials page
// 4: variant // 4: variant
// 5: machine // 5: machine
var value; var value
if ((base.resolve != "None") && (stackLevel != 0) && (stackLevel != 1)) { if ((base.resolve != "None") && (stackLevel != 0) && (stackLevel != 1))
{
// We have a resolve function. Indicates that the setting is not settable per extruder and that // We have a resolve function. Indicates that the setting is not settable per extruder and that
// we have to choose between the resolved value (default) and the global value // we have to choose between the resolved value (default) and the global value
// (if user has explicitly set this). // (if user has explicitly set this).
value = base.resolve; value = base.resolve
} else { }
value = propertyProvider.properties.value; else
{
value = propertyProvider.properties.value
} }
switch(value) switch(value)
{ {
case "True": case "True":
return true; return true
case "False": case "False":
return false; return false
default: default:
return value; return value
} }
} }
Keys.onSpacePressed: Keys.onSpacePressed:
{ {
forceActiveFocus(); forceActiveFocus()
propertyProvider.setPropertyValue("value", !checked); propertyProvider.setPropertyValue("value", !checked)
} }
onClicked: onClicked:
{ {
forceActiveFocus(); forceActiveFocus()
propertyProvider.setPropertyValue("value", !checked); propertyProvider.setPropertyValue("value", !checked)
} }
Keys.onTabPressed: Keys.onTabPressed:
@ -72,9 +75,9 @@ SettingItem
onActiveFocusChanged: onActiveFocusChanged:
{ {
if(activeFocus) if (activeFocus)
{ {
base.focusReceived(); base.focusReceived()
} }
} }
@ -90,32 +93,34 @@ SettingItem
color: color:
{ {
if(!enabled) if (!enabled)
{ {
return UM.Theme.getColor("setting_control_disabled") return UM.Theme.getColor("setting_control_disabled")
} }
if(control.containsMouse || control.activeFocus) if (control.containsMouse || control.activeFocus)
{ {
return UM.Theme.getColor("setting_control_highlight") return UM.Theme.getColor("setting_control_highlight")
} }
return UM.Theme.getColor("setting_control") return UM.Theme.getColor("setting_control")
} }
radius: UM.Theme.getSize("setting_control_radius").width
border.width: UM.Theme.getSize("default_lining").width border.width: UM.Theme.getSize("default_lining").width
border.color: border.color:
{ {
if(!enabled) if (!enabled)
{ {
return UM.Theme.getColor("setting_control_disabled_border") return UM.Theme.getColor("setting_control_disabled_border")
} }
if(control.containsMouse || control.activeFocus) if (control.containsMouse || control.activeFocus)
{ {
return UM.Theme.getColor("setting_control_border_highlight") return UM.Theme.getColor("setting_control_border_highlight")
} }
return UM.Theme.getColor("setting_control_border") return UM.Theme.getColor("setting_control_border")
} }
UM.RecolorImage { UM.RecolorImage
{
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
width: Math.round(parent.width / 2.5) width: Math.round(parent.width / 2.5)

View File

@ -35,6 +35,7 @@ SettingItem
return UM.Theme.getColor("setting_control") return UM.Theme.getColor("setting_control")
} }
radius: UM.Theme.getSize("setting_control_radius").width
border.width: UM.Theme.getSize("default_lining").width border.width: UM.Theme.getSize("default_lining").width
border.color: border.color:
{ {

View File

@ -19,8 +19,9 @@ SettingItem
model: Cura.ExtrudersModel model: Cura.ExtrudersModel
{ {
onModelChanged: { onModelChanged:
control.color = getItem(control.currentIndex).color; {
control.color = getItem(control.currentIndex).color
} }
} }
@ -113,14 +114,15 @@ SettingItem
{ {
if (!enabled) if (!enabled)
{ {
return UM.Theme.getColor("setting_control_disabled"); return UM.Theme.getColor("setting_control_disabled")
} }
if (control.hovered || base.activeFocus) if (control.hovered || base.activeFocus)
{ {
return UM.Theme.getColor("setting_control_highlight"); return UM.Theme.getColor("setting_control_highlight")
} }
return UM.Theme.getColor("setting_control"); return UM.Theme.getColor("setting_control")
} }
radius: UM.Theme.getSize("setting_control_radius").width
border.width: UM.Theme.getSize("default_lining").width border.width: UM.Theme.getSize("default_lining").width
border.color: border.color:
{ {
@ -153,20 +155,18 @@ SettingItem
elide: Text.ElideLeft elide: Text.ElideLeft
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
background: Rectangle background: UM.RecolorImage
{ {
id: swatch id: swatch
height: Math.round(UM.Theme.getSize("setting_control").height / 2) height: Math.round(parent.height / 2)
width: height width: height
anchors.right: parent.right anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.margins: Math.round(UM.Theme.getSize("default_margin").width / 4) anchors.rightMargin: UM.Theme.getSize("thin_margin").width
border.width: UM.Theme.getSize("default_lining").width
border.color: enabled ? UM.Theme.getColor("setting_control_border") : UM.Theme.getColor("setting_control_disabled_border")
radius: Math.round(width / 2)
sourceSize.width: width
sourceSize.height: height
source: UM.Theme.getIcon("extruder_button")
color: control.color color: control.color
} }
} }
@ -219,20 +219,18 @@ SettingItem
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
rightPadding: swatch.width + UM.Theme.getSize("setting_unit_margin").width rightPadding: swatch.width + UM.Theme.getSize("setting_unit_margin").width
background: Rectangle background: UM.RecolorImage
{ {
id: swatch id: swatch
height: Math.round(UM.Theme.getSize("setting_control").height / 2) height: Math.round(parent.height / 2)
width: height width: height
anchors.right: parent.right anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.margins: Math.round(UM.Theme.getSize("default_margin").width / 4) anchors.rightMargin: UM.Theme.getSize("thin_margin").width
border.width: UM.Theme.getSize("default_lining").width
border.color: enabled ? UM.Theme.getColor("setting_control_border") : UM.Theme.getColor("setting_control_disabled_border")
radius: Math.round(width / 2)
sourceSize.width: width
sourceSize.height: height
source: UM.Theme.getIcon("extruder_button")
color: control.model.getItem(index).color color: control.model.getItem(index).color
} }
} }

View File

@ -116,6 +116,7 @@ SettingItem
} }
return UM.Theme.getColor("setting_control"); return UM.Theme.getColor("setting_control");
} }
radius: UM.Theme.getSize("setting_control_radius").width
border.width: UM.Theme.getSize("default_lining").width border.width: UM.Theme.getSize("default_lining").width
border.color: border.color:
{ {
@ -148,20 +149,18 @@ SettingItem
elide: Text.ElideRight elide: Text.ElideRight
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
background: Rectangle background: UM.RecolorImage
{ {
id: swatch id: swatch
height: Math.round(UM.Theme.getSize("setting_control").height / 2) height: Math.round(parent.height / 2)
width: height width: height
anchors.right: parent.right anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.margins: Math.round(UM.Theme.getSize("default_margin").width / 4) anchors.rightMargin: UM.Theme.getSize("thin_margin").width
border.width: UM.Theme.getSize("default_lining").width
border.color: enabled ? UM.Theme.getColor("setting_control_border") : UM.Theme.getColor("setting_control_disabled_border")
radius: Math.round(width / 2)
sourceSize.width: width
sourceSize.height: height
source: UM.Theme.getIcon("extruder_button")
color: control.color color: control.color
} }
} }
@ -215,20 +214,18 @@ SettingItem
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
rightPadding: swatch.width + UM.Theme.getSize("setting_unit_margin").width rightPadding: swatch.width + UM.Theme.getSize("setting_unit_margin").width
background: Rectangle background: UM.RecolorImage
{ {
id: swatch id: swatch
height: Math.round(UM.Theme.getSize("setting_control").height / 2) height: Math.round(parent.height / 2)
width: height width: height
anchors.right: parent.right anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.margins: Math.round(UM.Theme.getSize("default_margin").width / 4) anchors.rightMargin: UM.Theme.getSize("thin_margin").width
border.width: UM.Theme.getSize("default_lining").width
border.color: enabled ? UM.Theme.getColor("setting_control_border") : UM.Theme.getColor("setting_control_disabled_border")
radius: Math.round(width / 2)
sourceSize.width: width
sourceSize.height: height
source: UM.Theme.getIcon("extruder_button")
color: control.model.getItem(index).color color: control.model.getItem(index).color
} }
} }

View File

@ -32,6 +32,7 @@ SettingItem
anchors.fill: parent anchors.fill: parent
radius: UM.Theme.getSize("setting_control_radius").width
border.width: Math.round(UM.Theme.getSize("default_lining").width) border.width: Math.round(UM.Theme.getSize("default_lining").width)
border.color: border.color:
{ {
@ -81,10 +82,10 @@ SettingItem
Rectangle Rectangle
{ {
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)
color: UM.Theme.getColor("setting_control_highlight") color: UM.Theme.getColor("setting_control_highlight")
opacity: !control.hovered ? 0 : propertyProvider.properties.validationState == "ValidatorState.Valid" ? 1.0 : 0.35; opacity: !control.hovered ? 0 : propertyProvider.properties.validationState == "ValidatorState.Valid" ? 1.0 : 0.35
} }
Label Label
@ -145,11 +146,11 @@ SettingItem
} }
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")
font: UM.Theme.getFont("default"); font: UM.Theme.getFont("default")
selectByMouse: true; selectByMouse: true
maximumLength: (definition.type == "str" || definition.type == "[int]") ? -1 : 10; maximumLength: (definition.type == "str" || definition.type == "[int]") ? -1 : 10
clip: true; //Hide any text that exceeds the width of the text box. clip: true; //Hide any text that exceeds the width of the text box.
validator: RegExpValidator { regExp: (definition.type == "[int]") ? /^\[?(\s*-?[0-9]{0,9}\s*,)*(\s*-?[0-9]{0,9})\s*\]?$/ : (definition.type == "int") ? /^-?[0-9]{0,10}$/ : (definition.type == "float") ? /^-?[0-9]{0,9}[.,]?[0-9]{0,3}$/ : /^.*$/ } // definition.type property from parent loader used to disallow fractional number entry validator: RegExpValidator { regExp: (definition.type == "[int]") ? /^\[?(\s*-?[0-9]{0,9}\s*,)*(\s*-?[0-9]{0,9})\s*\]?$/ : (definition.type == "int") ? /^-?[0-9]{0,10}$/ : (definition.type == "float") ? /^-?[0-9]{0,9}[.,]?[0-9]{0,3}$/ : /^.*$/ } // definition.type property from parent loader used to disallow fractional number entry
@ -158,7 +159,8 @@ SettingItem
{ {
target: input target: input
property: "text" property: "text"
value: { value:
{
// Stacklevels // Stacklevels
// 0: user -> unsaved change // 0: user -> unsaved change
// 1: quality changes -> saved change // 1: quality changes -> saved change
@ -167,13 +169,15 @@ SettingItem
// 4: variant // 4: variant
// 5: machine_changes // 5: machine_changes
// 6: machine // 6: machine
if ((base.resolve != "None" && base.resolve) && (stackLevel != 0) && (stackLevel != 1)) { if ((base.resolve != "None" && base.resolve) && (stackLevel != 0) && (stackLevel != 1))
{
// We have a resolve function. Indicates that the setting is not settable per extruder and that // We have a resolve function. Indicates that the setting is not settable per extruder and that
// we have to choose between the resolved value (default) and the global value // we have to choose between the resolved value (default) and the global value
// (if user has explicitly set this). // (if user has explicitly set this).
return base.resolve; return base.resolve
} else { }
return propertyProvider.properties.value; else {
return propertyProvider.properties.value
} }
} }
when: !input.activeFocus when: !input.activeFocus
@ -182,16 +186,17 @@ SettingItem
MouseArea MouseArea
{ {
id: mouseArea id: mouseArea
anchors.fill: parent; anchors.fill: parent
cursorShape: Qt.IBeamCursor cursorShape: Qt.IBeamCursor
onPressed: { onPressed: {
if(!input.activeFocus) { if (!input.activeFocus)
base.focusGainedByClick = true; {
input.forceActiveFocus(); base.focusGainedByClick = true
input.forceActiveFocus()
} }
mouse.accepted = false; mouse.accepted = false
} }
} }
} }