Fix codestyle

CURA-5785
This commit is contained in:
Jaime van Kessel 2018-11-12 11:24:11 +01:00
parent b60977e435
commit 88b57518d9

View file

@ -13,16 +13,18 @@ Item
{ {
id: base id: base
signal showTooltip(Item item, point location, string text); signal showTooltip(Item item, point location, string text)
signal hideTooltip(); signal hideTooltip()
property Action configureSettings
property Action configureSettings;
property variant minimumPrintTime: PrintInformation.minimumPrintTime;
property variant maximumPrintTime: PrintInformation.maximumPrintTime;
property bool settingsEnabled: Cura.ExtruderManager.activeExtruderStackId || extrudersEnabledCount.properties.value == 1 property bool settingsEnabled: Cura.ExtruderManager.activeExtruderStackId || extrudersEnabledCount.properties.value == 1
Component.onCompleted: PrintInformation.enabled = true
Component.onDestruction: PrintInformation.enabled = false UM.I18nCatalog
UM.I18nCatalog { id: catalog; name: "cura" } {
id: catalog
name: "cura"
}
ScrollView ScrollView
{ {
@ -313,7 +315,7 @@ Item
} }
} }
Rectangle Item
{ {
id: rightArea id: rightArea
width: width:
@ -324,7 +326,6 @@ Item
return qualityModel.qualitySliderMarginRight - 10 return qualityModel.qualitySliderMarginRight - 10
} }
height: parent.height height: parent.height
color: "transparent"
x: x:
{ {
if (qualityModel.availableTotalTicks == 0) if (qualityModel.availableTotalTicks == 0)
@ -450,10 +451,7 @@ Item
var content = catalog.i18nc("@tooltip","A custom profile is currently active. To enable the quality slider, choose a default quality profile in Custom tab") var content = catalog.i18nc("@tooltip","A custom profile is currently active. To enable the quality slider, choose a default quality profile in Custom tab")
base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, customisedSettings.height), content) base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, customisedSettings.height), content)
} }
onExited: onExited: base.hideTooltip()
{
base.hideTooltip();
}
} }
} }
@ -575,7 +573,8 @@ Item
} }
// We use a binding to make sure that after manually setting infillSlider.value it is still bound to the property provider // We use a binding to make sure that after manually setting infillSlider.value it is still bound to the property provider
Binding { Binding
{
target: infillSlider target: infillSlider
property: "value" property: "value"
value: parseInt(infillDensity.properties.value) value: parseInt(infillDensity.properties.value)
@ -604,10 +603,12 @@ Item
// set initial value from stack // set initial value from stack
value: parseInt(infillDensity.properties.value) value: parseInt(infillDensity.properties.value)
onValueChanged: { onValueChanged:
{
// Don't round the value if it's already the same // Don't round the value if it's already the same
if (parseInt(infillDensity.properties.value) == infillSlider.value) { if (parseInt(infillDensity.properties.value) == infillSlider.value)
{
return return
} }
@ -631,7 +632,8 @@ Item
style: SliderStyle style: SliderStyle
{ {
groove: Rectangle { groove: Rectangle
{
id: groove id: groove
implicitWidth: 200 * screenScaleFactor implicitWidth: 200 * screenScaleFactor
implicitHeight: 2 * screenScaleFactor implicitHeight: 2 * screenScaleFactor
@ -639,8 +641,10 @@ Item
radius: 1 radius: 1
} }
handle: Item { handle: Item
Rectangle { {
Rectangle
{
id: handleButton id: handleButton
anchors.centerIn: parent anchors.centerIn: parent
color: control.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") color: control.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable")
@ -650,24 +654,27 @@ Item
} }
} }
tickmarks: Repeater { tickmarks: Repeater
{
id: repeater id: repeater
model: control.maximumValue / control.stepSize + 1 model: control.maximumValue / control.stepSize + 1
// check if a tick should be shown based on it's index and wether the infill density is a multiple of 10 (slider step size) // check if a tick should be shown based on it's index and wether the infill density is a multiple of 10 (slider step size)
function shouldShowTick (index) { function shouldShowTick (index)
if (index % 10 == 0) { {
if (index % 10 == 0)
{
return true return true
} }
return false return false
} }
Rectangle { Rectangle
{
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
color: control.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") color: control.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable")
width: 1 * screenScaleFactor width: 1 * screenScaleFactor
height: 6 * screenScaleFactor height: 6 * screenScaleFactor
y: 0
x: Math.round(styleData.handleWidth / 2 + index * ((repeater.width - styleData.handleWidth) / (repeater.count-1))) x: Math.round(styleData.handleWidth / 2 + index * ((repeater.width - styleData.handleWidth) / (repeater.count-1)))
visible: shouldShowTick(index) visible: shouldShowTick(index)
} }
@ -693,8 +700,10 @@ Item
model: infillModel model: infillModel
anchors.fill: parent anchors.fill: parent
function activeIndex () { function activeIndex ()
for (var i = 0; i < infillModel.count; i++) { {
for (var i = 0; i < infillModel.count; i++)
{
var density = Math.round(infillDensity.properties.value) var density = Math.round(infillDensity.properties.value)
var steps = Math.round(infillSteps.properties.value) var steps = Math.round(infillSteps.properties.value)
var infillModelItem = infillModel.get(i) var infillModelItem = infillModel.get(i)
@ -703,8 +712,8 @@ Item
&& density >= infillModelItem.percentageMin && density >= infillModelItem.percentageMin
&& density <= infillModelItem.percentageMax && density <= infillModelItem.percentageMax
&& steps >= infillModelItem.stepsMin && steps >= infillModelItem.stepsMin
&& steps <= infillModelItem.stepsMax && steps <= infillModelItem.stepsMax)
){ {
return i return i
} }
} }
@ -719,7 +728,8 @@ Item
border.width: UM.Theme.getSize("default_lining").width border.width: UM.Theme.getSize("default_lining").width
border.color: UM.Theme.getColor("quality_slider_unavailable") border.color: UM.Theme.getColor("quality_slider_unavailable")
UM.RecolorImage { UM.RecolorImage
{
anchors.fill: parent anchors.fill: parent
anchors.margins: 2 * screenScaleFactor anchors.margins: 2 * screenScaleFactor
sourceSize.width: width sourceSize.width: width
@ -732,7 +742,8 @@ Item
} }
// Gradual Support Infill Checkbox // Gradual Support Infill Checkbox
CheckBox { CheckBox
{
id: enableGradualInfillCheckBox id: enableGradualInfillCheckBox
property alias _hovered: enableGradualInfillMouseArea.containsMouse property alias _hovered: enableGradualInfillMouseArea.containsMouse
@ -745,7 +756,8 @@ Item
visible: infillSteps.properties.enabled == "True" visible: infillSteps.properties.enabled == "True"
checked: parseInt(infillSteps.properties.value) > 0 checked: parseInt(infillSteps.properties.value) > 0
MouseArea { MouseArea
{
id: enableGradualInfillMouseArea id: enableGradualInfillMouseArea
anchors.fill: parent anchors.fill: parent
@ -754,35 +766,37 @@ Item
property var previousInfillDensity: parseInt(infillDensity.properties.value) property var previousInfillDensity: parseInt(infillDensity.properties.value)
onClicked: { onClicked:
{
// Set to 90% only when enabling gradual infill // Set to 90% only when enabling gradual infill
var newInfillDensity; var newInfillDensity;
if (parseInt(infillSteps.properties.value) == 0) { if (parseInt(infillSteps.properties.value) == 0)
{
previousInfillDensity = parseInt(infillDensity.properties.value) previousInfillDensity = parseInt(infillDensity.properties.value)
newInfillDensity = 90; newInfillDensity = 90
} else { } else {
newInfillDensity = previousInfillDensity; newInfillDensity = previousInfillDensity
} }
Cura.MachineManager.setSettingForAllExtruders("infill_sparse_density", "value", String(newInfillDensity)) Cura.MachineManager.setSettingForAllExtruders("infill_sparse_density", "value", String(newInfillDensity))
var infill_steps_value = 0; var infill_steps_value = 0
if (parseInt(infillSteps.properties.value) == 0) if (parseInt(infillSteps.properties.value) == 0)
infill_steps_value = 5; {
infill_steps_value = 5
}
Cura.MachineManager.setSettingForAllExtruders("gradual_infill_steps", "value", infill_steps_value) Cura.MachineManager.setSettingForAllExtruders("gradual_infill_steps", "value", infill_steps_value)
} }
onEntered: { onEntered: base.showTooltip(enableGradualInfillCheckBox, Qt.point(-infillCellRight.x, 0),
base.showTooltip(enableGradualInfillCheckBox, Qt.point(-infillCellRight.x, 0),
catalog.i18nc("@label", "Gradual infill will gradually increase the amount of infill towards the top.")) catalog.i18nc("@label", "Gradual infill will gradually increase the amount of infill towards the top."))
}
onExited: { onExited: base.hideTooltip()
base.hideTooltip()
}
} }
Label { Label
{
id: gradualInfillLabel id: gradualInfillLabel
height: parent.height height: parent.height
anchors.left: enableGradualInfillCheckBox.right anchors.left: enableGradualInfillCheckBox.right
@ -855,9 +869,9 @@ Item
anchors.rightMargin: UM.Theme.getSize("thick_margin").width anchors.rightMargin: UM.Theme.getSize("thick_margin").width
anchors.verticalCenter: enableSupportCheckBox.verticalCenter anchors.verticalCenter: enableSupportCheckBox.verticalCenter
text: catalog.i18nc("@label", "Generate Support"); text: catalog.i18nc("@label", "Generate Support")
font: UM.Theme.getFont("default"); font: UM.Theme.getFont("default")
color: UM.Theme.getColor("text"); color: UM.Theme.getColor("text")
elide: Text.ElideRight elide: Text.ElideRight
} }
@ -869,32 +883,24 @@ Item
anchors.top: enableSupportLabel.top anchors.top: enableSupportLabel.top
anchors.left: infillCellRight.left anchors.left: infillCellRight.left
style: UM.Theme.styles.checkbox; style: UM.Theme.styles.checkbox
enabled: base.settingsEnabled enabled: base.settingsEnabled
visible: supportEnabled.properties.enabled == "True" visible: supportEnabled.properties.enabled == "True"
checked: supportEnabled.properties.value == "True"; checked: supportEnabled.properties.value == "True"
MouseArea MouseArea
{ {
id: enableSupportMouseArea id: enableSupportMouseArea
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
enabled: true onClicked: supportEnabled.setPropertyValue("value", supportEnabled.properties.value != "True")
onClicked:
{ onEntered: base.showTooltip(enableSupportCheckBox, Qt.point(-enableSupportCheckBox.x, 0),
// The value is a string "True" or "False" catalog.i18nc("@label", "Generate structures to support parts of the model which have overhangs. Without these structures, such parts would collapse during printing."))
supportEnabled.setPropertyValue("value", supportEnabled.properties.value != "True");
} onExited: base.hideTooltip()
onEntered:
{
base.showTooltip(enableSupportCheckBox, Qt.point(-enableSupportCheckBox.x, 0),
catalog.i18nc("@label", "Generate structures to support parts of the model which have overhangs. Without these structures, such parts would collapse during printing."));
}
onExited:
{
base.hideTooltip();
}
} }
} }
@ -916,7 +922,7 @@ Item
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.top anchors.top: enableSupportCheckBox.top
//anchors.topMargin: ((supportEnabled.properties.value === "True") && (machineExtruderCount.properties.value > 1)) ? UM.Theme.getSize("thick_margin").height : 0
anchors.left: enableSupportCheckBox.right anchors.left: enableSupportCheckBox.right
anchors.leftMargin: Math.round(UM.Theme.getSize("thick_margin").width / 2) anchors.leftMargin: Math.round(UM.Theme.getSize("thick_margin").width / 2)
@ -933,24 +939,21 @@ Item
{ {
if (supportExtruderNr.properties == null) if (supportExtruderNr.properties == null)
{ {
return Cura.MachineManager.defaultExtruderPosition; return Cura.MachineManager.defaultExtruderPosition
} }
else else
{ {
var extruder = parseInt(supportExtruderNr.properties.value); var extruder = parseInt(supportExtruderNr.properties.value)
if ( extruder === -1) if ( extruder === -1)
{ {
return Cura.MachineManager.defaultExtruderPosition; return Cura.MachineManager.defaultExtruderPosition
} }
return extruder; return extruder;
} }
} }
onActivated: onActivated: supportExtruderNr.setPropertyValue("value", String(index))
{
// Send the extruder nr as a string.
supportExtruderNr.setPropertyValue("value", String(index));
}
MouseArea MouseArea
{ {
id: supportExtruderMouseArea id: supportExtruderMouseArea
@ -963,17 +966,16 @@ Item
base.showTooltip(supportExtruderCombobox, Qt.point(-supportExtruderCombobox.x, 0), base.showTooltip(supportExtruderCombobox, Qt.point(-supportExtruderCombobox.x, 0),
catalog.i18nc("@label", "Select which extruder to use for support. This will build up supporting structures below the model to prevent the model from sagging or printing in mid air.")); catalog.i18nc("@label", "Select which extruder to use for support. This will build up supporting structures below the model to prevent the model from sagging or printing in mid air."));
} }
onExited: onExited: base.hideTooltip()
{
base.hideTooltip();
}
} }
function updateCurrentColor() function updateCurrentColor()
{ {
var current_extruder = extruderModel.get(currentIndex); var current_extruder = extruderModel.get(currentIndex)
if (current_extruder !== undefined) { if (current_extruder !== undefined)
supportExtruderCombobox.color_override = current_extruder.color; {
supportExtruderCombobox.color_override = current_extruder.color
} }
} }
@ -989,7 +991,8 @@ Item
color: UM.Theme.getColor("text") color: UM.Theme.getColor("text")
elide: Text.ElideRight elide: Text.ElideRight
anchors { anchors
{
left: parent.left left: parent.left
leftMargin: UM.Theme.getSize("thick_margin").width leftMargin: UM.Theme.getSize("thick_margin").width
right: infillCellLeft.right right: infillCellLeft.right
@ -1008,7 +1011,7 @@ Item
anchors.left: infillCellRight.left anchors.left: infillCellRight.left
//: Setting enable printing build-plate adhesion helper checkbox //: Setting enable printing build-plate adhesion helper checkbox
style: UM.Theme.styles.checkbox; style: UM.Theme.styles.checkbox
enabled: base.settingsEnabled enabled: base.settingsEnabled
visible: platformAdhesionType.properties.enabled == "True" visible: platformAdhesionType.properties.enabled == "True"
@ -1022,29 +1025,27 @@ Item
enabled: base.settingsEnabled enabled: base.settingsEnabled
onClicked: onClicked:
{ {
var adhesionType = "skirt"; var adhesionType = "skirt"
if(!parent.checked) if(!parent.checked)
{ {
// Remove the "user" setting to see if the rest of the stack prescribes a brim or a raft // Remove the "user" setting to see if the rest of the stack prescribes a brim or a raft
platformAdhesionType.removeFromContainer(0); platformAdhesionType.removeFromContainer(0)
adhesionType = platformAdhesionType.properties.value; adhesionType = platformAdhesionType.properties.value
if(adhesionType == "skirt" || adhesionType == "none") if(adhesionType == "skirt" || adhesionType == "none")
{ {
// If the rest of the stack doesn't prescribe an adhesion-type, default to a brim // If the rest of the stack doesn't prescribe an adhesion-type, default to a brim
adhesionType = "brim"; adhesionType = "brim"
} }
} }
platformAdhesionType.setPropertyValue("value", adhesionType); platformAdhesionType.setPropertyValue("value", adhesionType)
} }
onEntered: onEntered:
{ {
base.showTooltip(adhesionCheckBox, Qt.point(-adhesionCheckBox.x, 0), base.showTooltip(adhesionCheckBox, Qt.point(-adhesionCheckBox.x, 0),
catalog.i18nc("@label", "Enable printing a brim or raft. This will add a flat area around or under your object which is easy to cut off afterwards.")); catalog.i18nc("@label", "Enable printing a brim or raft. This will add a flat area around or under your object which is easy to cut off afterwards."));
} }
onExited: onExited: base.hideTooltip()
{
base.hideTooltip();
}
} }
} }
@ -1163,6 +1164,6 @@ Item
color: extruders.getItem(extruderNumber).color color: extruders.getItem(extruderNumber).color
}) })
} }
supportExtruderCombobox.updateCurrentColor(); supportExtruderCombobox.updateCurrentColor()
} }
} }