WIP: MachineSettings Printer tab

This commit is contained in:
Lipu Fei 2019-03-18 13:34:02 +01:00
parent 6c6ccb16b8
commit 449740a631
6 changed files with 524 additions and 364 deletions

View file

@ -64,6 +64,10 @@ class GlobalStack(CuraContainerStack):
machine_extruder_count = self.getProperty("machine_extruder_count", "value")
return result_list[:machine_extruder_count]
@pyqtProperty(int, constant = True)
def maxExtruderCount(self):
return len(self.getMetaDataEntry("machine_extruder_trains"))
@classmethod
def getLoadingPriority(cls) -> int:
return 2

View file

@ -34,6 +34,7 @@ UM.TooltipArea
property alias labelText: fieldLabel.text
property alias labelFont: fieldLabel.font
property alias labelWidth: fieldLabel.width
property alias optionModel: comboBox.model
property string tooltipText: propertyProvider.properties.description
@ -50,13 +51,10 @@ UM.TooltipArea
watchedProperties: [ "value", "options", "description" ]
}
Row
{
spacing: UM.Theme.getSize("default_margin").width
Label
{
id: fieldLabel
anchors.left: parent.left
anchors.verticalCenter: comboBox.verticalCenter
visible: text != ""
font: UM.Theme.getFont("medium")
@ -65,7 +63,7 @@ UM.TooltipArea
ListModel
{
id: optionsModel
id: defaultOptionsModel
Component.onCompleted:
{
// Options come in as a string-representation of an OrderedDict
@ -76,7 +74,7 @@ UM.TooltipArea
for (var i = 0; i < options.length; i++)
{
var option = options[i].substring(1, options[i].length - 1).split("', '")
optionsModel.append({text: option[1], value: option[0]})
defaultOptionsModel.append({text: option[1], value: option[0]})
}
}
}
@ -85,9 +83,11 @@ UM.TooltipArea
CuraComboBox
{
id: comboBox
anchors.left: fieldLabel.right
anchors.leftMargin: UM.Theme.getSize("default_margin").width
width: comboBoxWithOptions.controlWidth
height: comboBoxWithOptions.controlHeight
model: optionsModel
model: defaultOptionsModel
textRole: "text"
currentIndex:
@ -116,4 +116,3 @@ UM.TooltipArea
}
}
}
}

View file

@ -14,12 +14,10 @@ import Cura 1.1 as Cura
//
UM.TooltipArea
{
id: gcodeTextArea
id: control
UM.I18nCatalog { id: catalog; name: "cura"; }
height: childrenRect.height
width: childrenRect.width
text: tooltip
property alias containerStackId: propertyProvider.containerStackId
@ -28,22 +26,57 @@ UM.TooltipArea
property string tooltip: propertyProvider.properties.description
property alias labelText: titleLabel.text
property alias labelFont: titleLabel.font
UM.SettingPropertyProvider
{
id: propertyProvider
watchedProperties: [ "value", "description" ]
}
// TODO: put label here
Label // Title Label
{
id: titleLabel
anchors.top: parent.top
anchors.left: parent.left
font: UM.Theme.getFont("medium_bold")
renderType: Text.NativeRendering
}
TextArea
{
id: gcodeArea
width: areaWidth
height: areaHeight
id: gcodeTextArea
anchors.top: titleLabel.bottom
anchors.topMargin: UM.Theme.getSize("default_margin").height
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
hoverEnabled: true
selectByMouse: true
font: UM.Theme.getFont("fixed")
renderType: Text.NativeRendering
text: (propertyProvider.properties.value) ? propertyProvider.properties.value : ""
wrapMode: TextEdit.NoWrap
background: Rectangle
{
border.color:
{
if (!gcodeTextArea.enabled)
{
return UM.Theme.getColor("setting_control_disabled_border")
}
if (gcodeTextArea.hovered || gcodeTextArea.activeFocus)
{
return UM.Theme.getColor("setting_control_border_highlight")
}
return UM.Theme.getColor("setting_control_border")
}
}
onActiveFocusChanged:
{
if (!activeFocus)

View file

@ -59,14 +59,10 @@ UM.TooltipArea
watchedProperties: [ "value", "description" ]
}
Row
{
id: itemRow
spacing: UM.Theme.getSize("default_margin").width
Label
{
id: fieldLabel
anchors.left: parent.left
anchors.verticalCenter: textFieldWithUnit.verticalCenter
visible: text != ""
font: UM.Theme.getFont("medium")
@ -76,6 +72,8 @@ UM.TooltipArea
TextField
{
id: textFieldWithUnit
anchors.left: fieldLabel.right
anchors.leftMargin: UM.Theme.getSize("default_margin").width
width: numericTextFieldWithUnit.controlWidth
height: numericTextFieldWithUnit.controlHeight
@ -202,4 +200,3 @@ UM.TooltipArea
}
}
}
}

View file

@ -30,8 +30,9 @@ UM.TooltipArea
property alias settingKey: propertyProvider.key
property alias settingStoreIndex: propertyProvider.storeIndex
property alias labelText: checkBox.text
property alias labelFont: checkBox.font
property alias labelText: fieldLabel.text
property alias labelFont: fieldLabel.font
property alias labelWidth: fieldLabel.width
property string tooltip: propertyProvider.properties.description
@ -47,12 +48,24 @@ UM.TooltipArea
watchedProperties: [ "value", "description" ]
}
Label
{
id: fieldLabel
anchors.left: parent.left
anchors.verticalCenter: checkBox.verticalCenter
visible: text != ""
font: UM.Theme.getFont("medium")
renderType: Text.NativeRendering
}
CuraCheckBox
{
id: checkBox
anchors.left: fieldLabel.right
anchors.leftMargin: UM.Theme.getSize("default_margin").width
checked: String(propertyProvider.properties.value).toLowerCase() != 'false'
height: simpleCheckBox.controlHeight
font: UM.Theme.getFont("medium")
text: ""
onClicked:
{
propertyProvider.setPropertyValue("value", checked)

View file

@ -14,7 +14,7 @@ import "../MachineSettings"
// This component contains the content for the "Welcome" page of the welcome on-boarding process.
//
Row
Item
{
id: base
UM.I18nCatalog { id: catalog; name: "cura" }
@ -22,24 +22,41 @@ Row
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
anchors.margins: UM.Theme.getSize("default_margin").width
property int labelWidth: 110
property int labelWidth: 130
property int controlWidth: UM.Theme.getSize("setting_control").width * 3 / 4
property var labelFont: UM.Theme.getFont("medium")
spacing: 10
property int columnWidth: (parent.width - 2 * UM.Theme.getSize("default_margin").width) / 2
property int columnSpacing: 10
property int propertyStoreIndex: 5 // definition_changes
Item
{
id: upperBlock
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.margins: UM.Theme.getSize("default_margin").width
height: childrenRect.height
// =======================================
// Left-side column for "Printer Settings"
// =======================================
Column
{
spacing: 10
anchors.top: parent.top
anchors.left: parent.left
width: base.columnWidth
spacing: base.columnSpacing
Label // Title Label
{
text: catalog.i18nc("@title:label", "Printer Settings")
font: UM.Theme.getFont("medium_bold")
renderType: Text.NativeRendering
}
NumericTextFieldWithUnit // "X (Width)"
@ -47,10 +64,11 @@ Row
id: machineXWidthField
containerStackId: Cura.MachineManager.activeMachineId
settingKey: "machine_width"
settingStoreIndex: 1 // TODO
settingStoreIndex: propertyStoreIndex
labelText: catalog.i18nc("@label", "X (Width)")
labelFont: base.labelFont
labelWidth: base.labelWidth
controlWidth: base.controlWidth
unitText: catalog.i18nc("@label", "mm")
// TODO: add forceUpdateOnChangeFunction:
}
@ -60,10 +78,11 @@ Row
id: machineYDepthField
containerStackId: Cura.MachineManager.activeMachineId
settingKey: "machine_depth"
settingStoreIndex: 1 // TODO
settingStoreIndex: propertyStoreIndex
labelText: catalog.i18nc("@label", "Y (Depth)")
labelFont: base.labelFont
labelWidth: base.labelWidth
controlWidth: base.controlWidth
unitText: catalog.i18nc("@label", "mm")
// TODO: add forceUpdateOnChangeFunction:
}
@ -73,10 +92,11 @@ Row
id: machineZHeightField
containerStackId: Cura.MachineManager.activeMachineId
settingKey: "machine_height"
settingStoreIndex: 1 // TODO
settingStoreIndex: propertyStoreIndex
labelText: catalog.i18nc("@label", "Z (Height)")
labelFont: base.labelFont
labelWidth: base.labelWidth
controlWidth: base.controlWidth
unitText: catalog.i18nc("@label", "mm")
// TODO: add forceUpdateOnChangeFunction:
}
@ -86,9 +106,11 @@ Row
id: buildPlateShapeComboBox
containerStackId: Cura.MachineManager.activeMachineId
settingKey: "machine_shape"
settingStoreIndex: 1 // TODO
settingStoreIndex: propertyStoreIndex
labelText: catalog.i18nc("@label", "Build plate shape")
labelFont: base.labelFont
labelWidth: base.labelWidth
controlWidth: base.controlWidth
// TODO: add forceUpdateOnChangeFunction:
}
@ -97,9 +119,10 @@ Row
id: originAtCenterCheckBox
containerStackId: Cura.MachineManager.activeMachineId
settingKey: "machine_center_is_zero"
settingStoreIndex: 1 // TODO
settingStoreIndex: propertyStoreIndex
labelText: catalog.i18nc("@label", "Origin at center")
labelFont: base.labelFont
labelWidth: base.labelWidth
// TODO: add forceUpdateOnChangeFunction:
}
@ -108,9 +131,10 @@ Row
id: heatedBedCheckBox
containerStackId: Cura.MachineManager.activeMachineId
settingKey: "machine_heated_bed"
settingStoreIndex: 1 // TODO
settingStoreIndex: propertyStoreIndex
labelText: catalog.i18nc("@label", "Heated bed")
labelFont: base.labelFont
labelWidth: base.labelWidth
// TODO: add forceUpdateOnChangeFunction:
}
@ -119,10 +143,11 @@ Row
id: gcodeFlavorComboBox
containerStackId: Cura.MachineManager.activeMachineId
settingKey: "machine_gcode_flavor"
settingStoreIndex: 1 // TODO
settingStoreIndex: propertyStoreIndex
labelText: catalog.i18nc("@label", "G-code flavor")
labelFont: base.labelFont
labelWidth: base.labelWidth
controlWidth: base.controlWidth
// TODO: add forceUpdateOnChangeFunction:
// TODO: add afterOnActivate: manager.updateHasMaterialsMetadata
}
@ -133,23 +158,29 @@ Row
// =======================================
Column
{
spacing: 10
anchors.top: parent.top
anchors.right: parent.right
width: base.columnWidth
spacing: base.columnSpacing
Label // Title Label
{
text: catalog.i18nc("@title:label", "Printhead Settings")
font: UM.Theme.getFont("medium_bold")
renderType: Text.NativeRendering
}
PrintHeadMinMaxTextField // "X min"
{
id: machineXMinField
settingStoreIndex: 1 // TODO
settingStoreIndex: propertyStoreIndex
labelText: catalog.i18nc("@label", "X min")
labelFont: base.labelFont
labelWidth: base.labelWidth
controlWidth: base.controlWidth
unitText: catalog.i18nc("@label", "mm")
axisName: "x"
@ -162,11 +193,12 @@ Row
{
id: machineYMinField
settingStoreIndex: 1 // TODO
settingStoreIndex: propertyStoreIndex
labelText: catalog.i18nc("@label", "Y min")
labelFont: base.labelFont
labelWidth: base.labelWidth
controlWidth: base.controlWidth
unitText: catalog.i18nc("@label", "mm")
axisName: "y"
@ -179,11 +211,12 @@ Row
{
id: machineXMaxField
settingStoreIndex: 1 // TODO
settingStoreIndex: propertyStoreIndex
labelText: catalog.i18nc("@label", "X max")
labelFont: base.labelFont
labelWidth: base.labelWidth
controlWidth: base.controlWidth
unitText: catalog.i18nc("@label", "mm")
axisName: "x"
@ -198,11 +231,12 @@ Row
containerStackId: Cura.MachineManager.activeMachineId
settingKey: "machine_head_with_fans_polygon"
settingStoreIndex: 1 // TODO
settingStoreIndex: propertyStoreIndex
labelText: catalog.i18nc("@label", "Y max")
labelFont: base.labelFont
labelWidth: base.labelWidth
controlWidth: base.controlWidth
unitText: catalog.i18nc("@label", "mm")
axisName: "y"
@ -210,5 +244,85 @@ Row
// TODO: add forceUpdateOnChangeFunction:
}
NumericTextFieldWithUnit // "Gantry Height"
{
id: machineGantryHeightField
containerStackId: Cura.MachineManager.activeMachineId
settingKey: "gantry_height"
settingStoreIndex: propertyStoreIndex
labelText: catalog.i18nc("@label", "Gantry Height")
labelFont: base.labelFont
labelWidth: base.labelWidth
controlWidth: base.controlWidth
unitText: catalog.i18nc("@label", "mm")
// TODO: add forceUpdateOnChangeFunction:
}
ComboBoxWithOptions // "Number of Extruders"
{
id: numberOfExtrudersComboBox
containerStackId: Cura.MachineManager.activeMachineId
settingKey: "machine_extruder_count"
settingStoreIndex: propertyStoreIndex
labelText: catalog.i18nc("@label", "Number of Extruders")
labelFont: base.labelFont
labelWidth: base.labelWidth
controlWidth: base.controlWidth
// TODO: add forceUpdateOnChangeFunction:
// TODO: add afterOnActivate: manager.updateHasMaterialsMetadata
optionModel: ListModel
{
id: extruderCountModel
Component.onCompleted:
{
extruderCountModel.clear()
for (var i = 1; i <= Cura.MachineManager.activeMachine.maxExtruderCount; i++)
{
extruderCountModel.append({text: String(i), value: i})
}
}
}
}
}
}
Item // Start and End G-code
{
id: lowerBlock
anchors.top: upperBlock.bottom
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.margins: UM.Theme.getSize("default_margin").width
GcodeTextArea // "Start G-code"
{
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.bottomMargin: UM.Theme.getSize("default_margin").height
anchors.left: parent.left
width: base.columnWidth - UM.Theme.getSize("default_margin").width
labelText: catalog.i18nc("@title:label", "Start G-code")
containerStackId: Cura.MachineManager.activeMachineId
settingKey: "machine_start_gcode"
settingStoreIndex: propertyStoreIndex
}
GcodeTextArea // "End G-code"
{
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.bottomMargin: UM.Theme.getSize("default_margin").height
anchors.right: parent.right
width: base.columnWidth - UM.Theme.getSize("default_margin").width
labelText: catalog.i18nc("@title:label", "End G-code")
containerStackId: Cura.MachineManager.activeMachineId
settingKey: "machine_end_gcode"
settingStoreIndex: propertyStoreIndex
}
}
}