mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-15 02:35:57 +08:00
Use TabRow for material page selection
The contents of the page is done with a simple page that becomes visible or not. The easiest solution I could think of. No StackLayout necessary here. Contributes to issue CURA-8686.
This commit is contained in:
parent
cfafdf878a
commit
2758957d5c
@ -11,7 +11,7 @@ import Cura 1.0 as Cura
|
|||||||
|
|
||||||
import ".." // Access to ReadOnlyTextArea.qml
|
import ".." // Access to ReadOnlyTextArea.qml
|
||||||
|
|
||||||
OldControls.TabView
|
Item
|
||||||
{
|
{
|
||||||
id: base
|
id: base
|
||||||
|
|
||||||
@ -68,410 +68,420 @@ OldControls.TabView
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OldControls.Tab
|
UM.TabRow
|
||||||
{
|
{
|
||||||
title: catalog.i18nc("@title", "Information")
|
id: pageSelectorTabRow
|
||||||
|
UM.TabRowButton
|
||||||
anchors.margins: UM.Theme.getSize("default_margin").width
|
|
||||||
|
|
||||||
ScrollView
|
|
||||||
{
|
{
|
||||||
id: scrollView
|
text: catalog.i18nc("@title", "Information")
|
||||||
anchors.fill: parent
|
property string activeView: "information" //To determine which page gets displayed.
|
||||||
|
}
|
||||||
ScrollBar.vertical: UM.ScrollBar
|
UM.TabRowButton
|
||||||
{
|
{
|
||||||
parent: scrollView
|
text: catalog.i18nc("@label", "Print settings")
|
||||||
anchors
|
property string activeView: "settings"
|
||||||
{
|
|
||||||
top: parent.top
|
|
||||||
right: parent.right
|
|
||||||
bottom: parent.bottom
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
|
||||||
clip: true
|
|
||||||
|
|
||||||
property real columnWidth: (scrollView.width * 0.5 - UM.Theme.getSize("default_margin").width) | 0
|
|
||||||
|
|
||||||
Flow
|
|
||||||
{
|
|
||||||
id: containerGrid
|
|
||||||
|
|
||||||
x: UM.Theme.getSize("default_margin").width
|
|
||||||
y: UM.Theme.getSize("default_lining").height
|
|
||||||
|
|
||||||
width: base.width
|
|
||||||
property real rowHeight: brandTextField.height + UM.Theme.getSize("default_lining").height
|
|
||||||
|
|
||||||
MessageDialog
|
|
||||||
{
|
|
||||||
id: confirmDiameterChangeDialog
|
|
||||||
|
|
||||||
icon: StandardIcon.Question;
|
|
||||||
title: catalog.i18nc("@title:window", "Confirm Diameter Change")
|
|
||||||
text: catalog.i18nc("@label (%1 is a number)", "The new filament diameter is set to %1 mm, which is not compatible with the current extruder. Do you wish to continue?".arg(new_diameter_value))
|
|
||||||
standardButtons: StandardButton.Yes | StandardButton.No
|
|
||||||
modality: Qt.ApplicationModal
|
|
||||||
|
|
||||||
property var new_diameter_value: null;
|
|
||||||
property var old_diameter_value: null;
|
|
||||||
property var old_approximate_diameter_value: null;
|
|
||||||
|
|
||||||
onYes:
|
|
||||||
{
|
|
||||||
base.setMetaDataEntry("approximate_diameter", old_approximate_diameter_value, getApproximateDiameter(new_diameter_value).toString());
|
|
||||||
base.setMetaDataEntry("properties/diameter", properties.diameter, new_diameter_value);
|
|
||||||
// CURA-6868 Make sure to update the extruder to user a diameter-compatible material.
|
|
||||||
Cura.MachineManager.updateMaterialWithVariant()
|
|
||||||
base.resetSelectedMaterial()
|
|
||||||
}
|
|
||||||
|
|
||||||
onNo:
|
|
||||||
{
|
|
||||||
base.properties.diameter = old_diameter_value;
|
|
||||||
diameterSpinBox.value = Qt.binding(function() { return base.properties.diameter })
|
|
||||||
}
|
|
||||||
|
|
||||||
onRejected: no()
|
|
||||||
}
|
|
||||||
|
|
||||||
Label { width: scrollView.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Display Name") }
|
|
||||||
ReadOnlyTextField
|
|
||||||
{
|
|
||||||
id: displayNameTextField;
|
|
||||||
width: scrollView.columnWidth;
|
|
||||||
text: properties.name;
|
|
||||||
readOnly: !base.editingEnabled;
|
|
||||||
onEditingFinished: base.updateMaterialDisplayName(properties.name, text)
|
|
||||||
}
|
|
||||||
|
|
||||||
Label { width: scrollView.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Brand") }
|
|
||||||
ReadOnlyTextField
|
|
||||||
{
|
|
||||||
id: brandTextField;
|
|
||||||
width: scrollView.columnWidth;
|
|
||||||
text: properties.brand;
|
|
||||||
readOnly: !base.editingEnabled;
|
|
||||||
onEditingFinished: base.updateMaterialBrand(properties.brand, text)
|
|
||||||
}
|
|
||||||
|
|
||||||
Label { width: scrollView.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Material Type") }
|
|
||||||
ReadOnlyTextField
|
|
||||||
{
|
|
||||||
id: materialTypeField;
|
|
||||||
width: scrollView.columnWidth;
|
|
||||||
text: properties.material;
|
|
||||||
readOnly: !base.editingEnabled;
|
|
||||||
onEditingFinished: base.updateMaterialType(properties.material, text)
|
|
||||||
}
|
|
||||||
|
|
||||||
Label { width: scrollView.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Color") }
|
|
||||||
Row
|
|
||||||
{
|
|
||||||
width: scrollView.columnWidth
|
|
||||||
height: parent.rowHeight
|
|
||||||
spacing: Math.round(UM.Theme.getSize("default_margin").width / 2)
|
|
||||||
|
|
||||||
// color indicator square
|
|
||||||
Rectangle
|
|
||||||
{
|
|
||||||
id: colorSelector
|
|
||||||
color: properties.color_code
|
|
||||||
|
|
||||||
width: Math.round(colorLabel.height * 0.75)
|
|
||||||
height: Math.round(colorLabel.height * 0.75)
|
|
||||||
border.width: UM.Theme.getSize("default_lining").height
|
|
||||||
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
|
|
||||||
// open the color selection dialog on click
|
|
||||||
MouseArea
|
|
||||||
{
|
|
||||||
anchors.fill: parent
|
|
||||||
onClicked: colorDialog.open()
|
|
||||||
enabled: base.editingEnabled
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// pretty color name text field
|
|
||||||
ReadOnlyTextField
|
|
||||||
{
|
|
||||||
id: colorLabel;
|
|
||||||
width: parent.width - colorSelector.width - parent.spacing
|
|
||||||
text: properties.color_name;
|
|
||||||
readOnly: !base.editingEnabled
|
|
||||||
onEditingFinished: base.setMetaDataEntry("color_name", properties.color_name, text)
|
|
||||||
}
|
|
||||||
|
|
||||||
// popup dialog to select a new color
|
|
||||||
// if successful it sets the properties.color_code value to the new color
|
|
||||||
ColorDialog
|
|
||||||
{
|
|
||||||
id: colorDialog
|
|
||||||
color: properties.color_code
|
|
||||||
onAccepted: base.setMetaDataEntry("color_code", properties.color_code, color)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Item { width: parent.width; height: UM.Theme.getSize("default_margin").height }
|
|
||||||
|
|
||||||
Label { width: parent.width; height: parent.rowHeight; font.bold: true; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Properties") }
|
|
||||||
|
|
||||||
Label { width: scrollView.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Density") }
|
|
||||||
ReadOnlySpinBox
|
|
||||||
{
|
|
||||||
id: densitySpinBox
|
|
||||||
width: scrollView.columnWidth
|
|
||||||
value: properties.density
|
|
||||||
decimals: 2
|
|
||||||
suffix: " g/cm³"
|
|
||||||
stepSize: 0.01
|
|
||||||
readOnly: !base.editingEnabled
|
|
||||||
|
|
||||||
onEditingFinished: base.setMetaDataEntry("properties/density", properties.density, value)
|
|
||||||
onValueChanged: updateCostPerMeter()
|
|
||||||
}
|
|
||||||
|
|
||||||
Label { width: scrollView.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Diameter") }
|
|
||||||
ReadOnlySpinBox
|
|
||||||
{
|
|
||||||
id: diameterSpinBox
|
|
||||||
width: scrollView.columnWidth
|
|
||||||
value: properties.diameter
|
|
||||||
decimals: 2
|
|
||||||
suffix: " mm"
|
|
||||||
stepSize: 0.01
|
|
||||||
readOnly: !base.editingEnabled
|
|
||||||
|
|
||||||
onEditingFinished:
|
|
||||||
{
|
|
||||||
// This does not use a SettingPropertyProvider, because we need to make the change to all containers
|
|
||||||
// which derive from the same base_file
|
|
||||||
var old_diameter = Cura.ContainerManager.getContainerMetaDataEntry(base.containerId, "properties/diameter");
|
|
||||||
var old_approximate_diameter = Cura.ContainerManager.getContainerMetaDataEntry(base.containerId, "approximate_diameter");
|
|
||||||
var new_approximate_diameter = getApproximateDiameter(value);
|
|
||||||
if (new_approximate_diameter != Cura.ExtruderManager.getActiveExtruderStack().approximateMaterialDiameter)
|
|
||||||
{
|
|
||||||
confirmDiameterChangeDialog.old_diameter_value = old_diameter;
|
|
||||||
confirmDiameterChangeDialog.new_diameter_value = value;
|
|
||||||
confirmDiameterChangeDialog.old_approximate_diameter_value = old_approximate_diameter;
|
|
||||||
|
|
||||||
confirmDiameterChangeDialog.open()
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
base.setMetaDataEntry("approximate_diameter", old_approximate_diameter, getApproximateDiameter(value).toString());
|
|
||||||
base.setMetaDataEntry("properties/diameter", properties.diameter, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onValueChanged: updateCostPerMeter()
|
|
||||||
}
|
|
||||||
|
|
||||||
Label { width: scrollView.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Filament Cost") }
|
|
||||||
OldControls.SpinBox
|
|
||||||
{
|
|
||||||
id: spoolCostSpinBox
|
|
||||||
width: scrollView.columnWidth
|
|
||||||
value: base.getMaterialPreferenceValue(properties.guid, "spool_cost")
|
|
||||||
prefix: base.currency + " "
|
|
||||||
decimals: 2
|
|
||||||
maximumValue: 100000000
|
|
||||||
|
|
||||||
onValueChanged:
|
|
||||||
{
|
|
||||||
base.setMaterialPreferenceValue(properties.guid, "spool_cost", parseFloat(value))
|
|
||||||
updateCostPerMeter()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Label { width: scrollView.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Filament weight") }
|
|
||||||
OldControls.SpinBox
|
|
||||||
{
|
|
||||||
id: spoolWeightSpinBox
|
|
||||||
width: scrollView.columnWidth
|
|
||||||
value: base.getMaterialPreferenceValue(properties.guid, "spool_weight", Cura.ContainerManager.getContainerMetaDataEntry(properties.container_id, "properties/weight"))
|
|
||||||
suffix: " g"
|
|
||||||
stepSize: 100
|
|
||||||
decimals: 0
|
|
||||||
maximumValue: 10000
|
|
||||||
|
|
||||||
onValueChanged:
|
|
||||||
{
|
|
||||||
base.setMaterialPreferenceValue(properties.guid, "spool_weight", parseFloat(value))
|
|
||||||
updateCostPerMeter()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Label { width: scrollView.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Filament length") }
|
|
||||||
Label
|
|
||||||
{
|
|
||||||
width: scrollView.columnWidth
|
|
||||||
text: "~ %1 m".arg(Math.round(base.spoolLength))
|
|
||||||
verticalAlignment: Qt.AlignVCenter
|
|
||||||
height: parent.rowHeight
|
|
||||||
}
|
|
||||||
|
|
||||||
Label { width: scrollView.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Cost per Meter") }
|
|
||||||
Label
|
|
||||||
{
|
|
||||||
width: scrollView.columnWidth
|
|
||||||
text: "~ %1 %2/m".arg(base.costPerMeter.toFixed(2)).arg(base.currency)
|
|
||||||
verticalAlignment: Qt.AlignVCenter
|
|
||||||
height: parent.rowHeight
|
|
||||||
}
|
|
||||||
|
|
||||||
Item { width: parent.width; height: UM.Theme.getSize("default_margin").height; visible: unlinkMaterialButton.visible }
|
|
||||||
Label
|
|
||||||
{
|
|
||||||
width: 2 * scrollView.columnWidth
|
|
||||||
verticalAlignment: Qt.AlignVCenter
|
|
||||||
text: catalog.i18nc("@label", "This material is linked to %1 and shares some of its properties.").arg(base.linkedMaterialNames)
|
|
||||||
wrapMode: Text.WordWrap
|
|
||||||
visible: unlinkMaterialButton.visible
|
|
||||||
}
|
|
||||||
OldControls.Button
|
|
||||||
{
|
|
||||||
id: unlinkMaterialButton
|
|
||||||
text: catalog.i18nc("@label", "Unlink Material")
|
|
||||||
visible: base.linkedMaterialNames != ""
|
|
||||||
onClicked:
|
|
||||||
{
|
|
||||||
Cura.ContainerManager.unlinkMaterial(base.currentMaterialNode)
|
|
||||||
base.reevaluateLinkedMaterials = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Item { width: parent.width; height: UM.Theme.getSize("default_margin").height }
|
|
||||||
|
|
||||||
Label { width: parent.width; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Description") }
|
|
||||||
|
|
||||||
ReadOnlyTextArea
|
|
||||||
{
|
|
||||||
text: properties.description;
|
|
||||||
width: 2 * scrollView.columnWidth
|
|
||||||
wrapMode: Text.WordWrap
|
|
||||||
|
|
||||||
readOnly: !base.editingEnabled;
|
|
||||||
|
|
||||||
onEditingFinished: base.setMetaDataEntry("description", properties.description, text)
|
|
||||||
}
|
|
||||||
|
|
||||||
Label { width: parent.width; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Adhesion Information") }
|
|
||||||
|
|
||||||
ReadOnlyTextArea
|
|
||||||
{
|
|
||||||
text: properties.adhesion_info;
|
|
||||||
width: 2 * scrollView.columnWidth
|
|
||||||
wrapMode: Text.WordWrap
|
|
||||||
|
|
||||||
readOnly: !base.editingEnabled;
|
|
||||||
|
|
||||||
onEditingFinished: base.setMetaDataEntry("adhesion_info", properties.adhesion_info, text)
|
|
||||||
}
|
|
||||||
|
|
||||||
Item { width: parent.width; height: UM.Theme.getSize("default_margin").height }
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateCostPerMeter()
|
|
||||||
{
|
|
||||||
base.spoolLength = calculateSpoolLength(diameterSpinBox.value, densitySpinBox.value, spoolWeightSpinBox.value);
|
|
||||||
base.costPerMeter = calculateCostPerMeter(spoolCostSpinBox.value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OldControls.Tab
|
ScrollView
|
||||||
{
|
{
|
||||||
title: catalog.i18nc("@label", "Print settings")
|
id: informationPage
|
||||||
anchors
|
anchors
|
||||||
{
|
{
|
||||||
leftMargin: UM.Theme.getSize("default_margin").width
|
top: pageSelectorTabRow.bottom
|
||||||
topMargin: UM.Theme.getSize("default_margin").height
|
left: parent.left
|
||||||
bottomMargin: UM.Theme.getSize("default_margin").height
|
right: parent.right
|
||||||
rightMargin: 0
|
bottom: parent.bottom
|
||||||
}
|
}
|
||||||
|
|
||||||
ListView
|
ScrollBar.vertical: UM.ScrollBar
|
||||||
{
|
{
|
||||||
anchors.fill: parent
|
parent: informationPage
|
||||||
model: UM.SettingDefinitionsModel
|
anchors
|
||||||
{
|
{
|
||||||
containerId: Cura.MachineManager.activeMachine != null ? Cura.MachineManager.activeMachine.definition.id: ""
|
top: parent.top
|
||||||
visibilityHandler: Cura.MaterialSettingsVisibilityHandler { }
|
right: parent.right
|
||||||
expanded: ["*"]
|
bottom: parent.bottom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
||||||
|
clip: true
|
||||||
|
visible: pageSelectorTabRow.currentItem.activeView === "information"
|
||||||
|
|
||||||
|
property real columnWidth: (width * 0.5 - UM.Theme.getSize("default_margin").width) | 0
|
||||||
|
|
||||||
|
Flow
|
||||||
|
{
|
||||||
|
id: containerGrid
|
||||||
|
|
||||||
|
x: UM.Theme.getSize("default_margin").width
|
||||||
|
y: UM.Theme.getSize("default_lining").height
|
||||||
|
|
||||||
|
width: base.width
|
||||||
|
property real rowHeight: brandTextField.height + UM.Theme.getSize("default_lining").height
|
||||||
|
|
||||||
|
MessageDialog
|
||||||
|
{
|
||||||
|
id: confirmDiameterChangeDialog
|
||||||
|
|
||||||
|
icon: StandardIcon.Question;
|
||||||
|
title: catalog.i18nc("@title:window", "Confirm Diameter Change")
|
||||||
|
text: catalog.i18nc("@label (%1 is a number)", "The new filament diameter is set to %1 mm, which is not compatible with the current extruder. Do you wish to continue?".arg(new_diameter_value))
|
||||||
|
standardButtons: StandardButton.Yes | StandardButton.No
|
||||||
|
modality: Qt.ApplicationModal
|
||||||
|
|
||||||
|
property var new_diameter_value: null;
|
||||||
|
property var old_diameter_value: null;
|
||||||
|
property var old_approximate_diameter_value: null;
|
||||||
|
|
||||||
|
onYes:
|
||||||
|
{
|
||||||
|
base.setMetaDataEntry("approximate_diameter", old_approximate_diameter_value, getApproximateDiameter(new_diameter_value).toString());
|
||||||
|
base.setMetaDataEntry("properties/diameter", properties.diameter, new_diameter_value);
|
||||||
|
// CURA-6868 Make sure to update the extruder to user a diameter-compatible material.
|
||||||
|
Cura.MachineManager.updateMaterialWithVariant()
|
||||||
|
base.resetSelectedMaterial()
|
||||||
|
}
|
||||||
|
|
||||||
|
onNo:
|
||||||
|
{
|
||||||
|
base.properties.diameter = old_diameter_value;
|
||||||
|
diameterSpinBox.value = Qt.binding(function() { return base.properties.diameter })
|
||||||
|
}
|
||||||
|
|
||||||
|
onRejected: no()
|
||||||
}
|
}
|
||||||
|
|
||||||
ScrollBar.vertical: UM.ScrollBar {}
|
Label { width: informationPage.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Display Name") }
|
||||||
clip: true
|
ReadOnlyTextField
|
||||||
|
|
||||||
delegate: UM.TooltipArea
|
|
||||||
{
|
{
|
||||||
width: childrenRect.width
|
id: displayNameTextField;
|
||||||
height: childrenRect.height
|
width: informationPage.columnWidth;
|
||||||
text: model.description
|
text: properties.name;
|
||||||
Label
|
readOnly: !base.editingEnabled;
|
||||||
|
onEditingFinished: base.updateMaterialDisplayName(properties.name, text)
|
||||||
|
}
|
||||||
|
|
||||||
|
Label { width: informationPage.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Brand") }
|
||||||
|
ReadOnlyTextField
|
||||||
|
{
|
||||||
|
id: brandTextField;
|
||||||
|
width: informationPage.columnWidth;
|
||||||
|
text: properties.brand;
|
||||||
|
readOnly: !base.editingEnabled;
|
||||||
|
onEditingFinished: base.updateMaterialBrand(properties.brand, text)
|
||||||
|
}
|
||||||
|
|
||||||
|
Label { width: informationPage.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Material Type") }
|
||||||
|
ReadOnlyTextField
|
||||||
|
{
|
||||||
|
id: materialTypeField;
|
||||||
|
width: informationPage.columnWidth;
|
||||||
|
text: properties.material;
|
||||||
|
readOnly: !base.editingEnabled;
|
||||||
|
onEditingFinished: base.updateMaterialType(properties.material, text)
|
||||||
|
}
|
||||||
|
|
||||||
|
Label { width: informationPage.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Color") }
|
||||||
|
Row
|
||||||
|
{
|
||||||
|
width: informationPage.columnWidth
|
||||||
|
height: parent.rowHeight
|
||||||
|
spacing: Math.round(UM.Theme.getSize("default_margin").width / 2)
|
||||||
|
|
||||||
|
// color indicator square
|
||||||
|
Rectangle
|
||||||
{
|
{
|
||||||
id: label
|
id: colorSelector
|
||||||
width: base.firstColumnWidth;
|
color: properties.color_code
|
||||||
height: spinBox.height + UM.Theme.getSize("default_lining").height
|
|
||||||
text: model.label
|
width: Math.round(colorLabel.height * 0.75)
|
||||||
elide: Text.ElideRight
|
height: Math.round(colorLabel.height * 0.75)
|
||||||
verticalAlignment: Qt.AlignVCenter
|
border.width: UM.Theme.getSize("default_lining").height
|
||||||
}
|
|
||||||
ReadOnlySpinBox
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
{
|
|
||||||
id: spinBox
|
// open the color selection dialog on click
|
||||||
anchors.left: label.right
|
MouseArea
|
||||||
value:
|
|
||||||
{
|
{
|
||||||
// In case the setting is not in the material...
|
anchors.fill: parent
|
||||||
if (!isNaN(parseFloat(materialPropertyProvider.properties.value)))
|
onClicked: colorDialog.open()
|
||||||
{
|
enabled: base.editingEnabled
|
||||||
return parseFloat(materialPropertyProvider.properties.value);
|
|
||||||
}
|
|
||||||
// ... we search in the variant, and if it is not there...
|
|
||||||
if (!isNaN(parseFloat(variantPropertyProvider.properties.value)))
|
|
||||||
{
|
|
||||||
return parseFloat(variantPropertyProvider.properties.value);
|
|
||||||
}
|
|
||||||
// ... then look in the definition container.
|
|
||||||
if (!isNaN(parseFloat(machinePropertyProvider.properties.value)))
|
|
||||||
{
|
|
||||||
return parseFloat(machinePropertyProvider.properties.value);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
width: base.secondColumnWidth
|
}
|
||||||
|
|
||||||
|
// pretty color name text field
|
||||||
|
ReadOnlyTextField
|
||||||
|
{
|
||||||
|
id: colorLabel;
|
||||||
|
width: parent.width - colorSelector.width - parent.spacing
|
||||||
|
text: properties.color_name;
|
||||||
readOnly: !base.editingEnabled
|
readOnly: !base.editingEnabled
|
||||||
suffix: " " + model.unit
|
onEditingFinished: base.setMetaDataEntry("color_name", properties.color_name, text)
|
||||||
maximumValue: 99999
|
|
||||||
decimals: model.unit == "mm" ? 2 : 0
|
|
||||||
|
|
||||||
onEditingFinished: materialPropertyProvider.setPropertyValue("value", value)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UM.ContainerPropertyProvider
|
// popup dialog to select a new color
|
||||||
|
// if successful it sets the properties.color_code value to the new color
|
||||||
|
ColorDialog
|
||||||
{
|
{
|
||||||
id: materialPropertyProvider
|
id: colorDialog
|
||||||
containerId: base.containerId
|
color: properties.color_code
|
||||||
watchedProperties: [ "value" ]
|
onAccepted: base.setMetaDataEntry("color_code", properties.color_code, color)
|
||||||
key: model.key
|
|
||||||
}
|
}
|
||||||
UM.ContainerPropertyProvider
|
}
|
||||||
|
|
||||||
|
Item { width: parent.width; height: UM.Theme.getSize("default_margin").height }
|
||||||
|
|
||||||
|
Label { width: parent.width; height: parent.rowHeight; font.bold: true; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Properties") }
|
||||||
|
|
||||||
|
Label { width: informationPage.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Density") }
|
||||||
|
ReadOnlySpinBox
|
||||||
|
{
|
||||||
|
id: densitySpinBox
|
||||||
|
width: informationPage.columnWidth
|
||||||
|
value: properties.density
|
||||||
|
decimals: 2
|
||||||
|
suffix: " g/cm³"
|
||||||
|
stepSize: 0.01
|
||||||
|
readOnly: !base.editingEnabled
|
||||||
|
|
||||||
|
onEditingFinished: base.setMetaDataEntry("properties/density", properties.density, value)
|
||||||
|
onValueChanged: updateCostPerMeter()
|
||||||
|
}
|
||||||
|
|
||||||
|
Label { width: informationPage.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Diameter") }
|
||||||
|
ReadOnlySpinBox
|
||||||
|
{
|
||||||
|
id: diameterSpinBox
|
||||||
|
width: informationPage.columnWidth
|
||||||
|
value: properties.diameter
|
||||||
|
decimals: 2
|
||||||
|
suffix: " mm"
|
||||||
|
stepSize: 0.01
|
||||||
|
readOnly: !base.editingEnabled
|
||||||
|
|
||||||
|
onEditingFinished:
|
||||||
{
|
{
|
||||||
id: variantPropertyProvider
|
// This does not use a SettingPropertyProvider, because we need to make the change to all containers
|
||||||
containerId: Cura.MachineManager.activeStack.variant.id
|
// which derive from the same base_file
|
||||||
watchedProperties: [ "value" ]
|
var old_diameter = Cura.ContainerManager.getContainerMetaDataEntry(base.containerId, "properties/diameter");
|
||||||
key: model.key
|
var old_approximate_diameter = Cura.ContainerManager.getContainerMetaDataEntry(base.containerId, "approximate_diameter");
|
||||||
|
var new_approximate_diameter = getApproximateDiameter(value);
|
||||||
|
if (new_approximate_diameter != Cura.ExtruderManager.getActiveExtruderStack().approximateMaterialDiameter)
|
||||||
|
{
|
||||||
|
confirmDiameterChangeDialog.old_diameter_value = old_diameter;
|
||||||
|
confirmDiameterChangeDialog.new_diameter_value = value;
|
||||||
|
confirmDiameterChangeDialog.old_approximate_diameter_value = old_approximate_diameter;
|
||||||
|
|
||||||
|
confirmDiameterChangeDialog.open()
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
base.setMetaDataEntry("approximate_diameter", old_approximate_diameter, getApproximateDiameter(value).toString());
|
||||||
|
base.setMetaDataEntry("properties/diameter", properties.diameter, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
UM.ContainerPropertyProvider
|
onValueChanged: updateCostPerMeter()
|
||||||
|
}
|
||||||
|
|
||||||
|
Label { width: informationPage.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Filament Cost") }
|
||||||
|
OldControls.SpinBox
|
||||||
|
{
|
||||||
|
id: spoolCostSpinBox
|
||||||
|
width: informationPage.columnWidth
|
||||||
|
value: base.getMaterialPreferenceValue(properties.guid, "spool_cost")
|
||||||
|
prefix: base.currency + " "
|
||||||
|
decimals: 2
|
||||||
|
maximumValue: 100000000
|
||||||
|
|
||||||
|
onValueChanged:
|
||||||
{
|
{
|
||||||
id: machinePropertyProvider
|
base.setMaterialPreferenceValue(properties.guid, "spool_cost", parseFloat(value))
|
||||||
containerId: Cura.MachineManager.activeMachine != null ? Cura.MachineManager.activeMachine.definition.id: ""
|
updateCostPerMeter()
|
||||||
watchedProperties: [ "value" ]
|
|
||||||
key: model.key
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Label { width: informationPage.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Filament weight") }
|
||||||
|
OldControls.SpinBox
|
||||||
|
{
|
||||||
|
id: spoolWeightSpinBox
|
||||||
|
width: informationPage.columnWidth
|
||||||
|
value: base.getMaterialPreferenceValue(properties.guid, "spool_weight", Cura.ContainerManager.getContainerMetaDataEntry(properties.container_id, "properties/weight"))
|
||||||
|
suffix: " g"
|
||||||
|
stepSize: 100
|
||||||
|
decimals: 0
|
||||||
|
maximumValue: 10000
|
||||||
|
|
||||||
|
onValueChanged:
|
||||||
|
{
|
||||||
|
base.setMaterialPreferenceValue(properties.guid, "spool_weight", parseFloat(value))
|
||||||
|
updateCostPerMeter()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Label { width: informationPage.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Filament length") }
|
||||||
|
Label
|
||||||
|
{
|
||||||
|
width: informationPage.columnWidth
|
||||||
|
text: "~ %1 m".arg(Math.round(base.spoolLength))
|
||||||
|
verticalAlignment: Qt.AlignVCenter
|
||||||
|
height: parent.rowHeight
|
||||||
|
}
|
||||||
|
|
||||||
|
Label { width: informationPage.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Cost per Meter") }
|
||||||
|
Label
|
||||||
|
{
|
||||||
|
width: informationPage.columnWidth
|
||||||
|
text: "~ %1 %2/m".arg(base.costPerMeter.toFixed(2)).arg(base.currency)
|
||||||
|
verticalAlignment: Qt.AlignVCenter
|
||||||
|
height: parent.rowHeight
|
||||||
|
}
|
||||||
|
|
||||||
|
Item { width: parent.width; height: UM.Theme.getSize("default_margin").height; visible: unlinkMaterialButton.visible }
|
||||||
|
Label
|
||||||
|
{
|
||||||
|
width: 2 * informationPage.columnWidth
|
||||||
|
verticalAlignment: Qt.AlignVCenter
|
||||||
|
text: catalog.i18nc("@label", "This material is linked to %1 and shares some of its properties.").arg(base.linkedMaterialNames)
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
visible: unlinkMaterialButton.visible
|
||||||
|
}
|
||||||
|
OldControls.Button
|
||||||
|
{
|
||||||
|
id: unlinkMaterialButton
|
||||||
|
text: catalog.i18nc("@label", "Unlink Material")
|
||||||
|
visible: base.linkedMaterialNames != ""
|
||||||
|
onClicked:
|
||||||
|
{
|
||||||
|
Cura.ContainerManager.unlinkMaterial(base.currentMaterialNode)
|
||||||
|
base.reevaluateLinkedMaterials = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Item { width: parent.width; height: UM.Theme.getSize("default_margin").height }
|
||||||
|
|
||||||
|
Label { width: parent.width; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Description") }
|
||||||
|
|
||||||
|
ReadOnlyTextArea
|
||||||
|
{
|
||||||
|
text: properties.description;
|
||||||
|
width: 2 * informationPage.columnWidth
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
|
||||||
|
readOnly: !base.editingEnabled;
|
||||||
|
|
||||||
|
onEditingFinished: base.setMetaDataEntry("description", properties.description, text)
|
||||||
|
}
|
||||||
|
|
||||||
|
Label { width: parent.width; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Adhesion Information") }
|
||||||
|
|
||||||
|
ReadOnlyTextArea
|
||||||
|
{
|
||||||
|
text: properties.adhesion_info;
|
||||||
|
width: 2 * informationPage.columnWidth
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
|
||||||
|
readOnly: !base.editingEnabled;
|
||||||
|
|
||||||
|
onEditingFinished: base.setMetaDataEntry("adhesion_info", properties.adhesion_info, text)
|
||||||
|
}
|
||||||
|
|
||||||
|
Item { width: parent.width; height: UM.Theme.getSize("default_margin").height }
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateCostPerMeter()
|
||||||
|
{
|
||||||
|
base.spoolLength = calculateSpoolLength(diameterSpinBox.value, densitySpinBox.value, spoolWeightSpinBox.value);
|
||||||
|
base.costPerMeter = calculateCostPerMeter(spoolCostSpinBox.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ListView
|
||||||
|
{
|
||||||
|
anchors
|
||||||
|
{
|
||||||
|
top: pageSelectorTabRow.bottom
|
||||||
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
bottom: parent.bottom
|
||||||
|
}
|
||||||
|
|
||||||
|
model: UM.SettingDefinitionsModel
|
||||||
|
{
|
||||||
|
containerId: Cura.MachineManager.activeMachine != null ? Cura.MachineManager.activeMachine.definition.id: ""
|
||||||
|
visibilityHandler: Cura.MaterialSettingsVisibilityHandler { }
|
||||||
|
expanded: ["*"]
|
||||||
|
}
|
||||||
|
ScrollBar.vertical: UM.ScrollBar {}
|
||||||
|
clip: true
|
||||||
|
visible: pageSelectorTabRow.currentItem.activeView === "settings"
|
||||||
|
|
||||||
|
delegate: UM.TooltipArea
|
||||||
|
{
|
||||||
|
width: childrenRect.width
|
||||||
|
height: childrenRect.height
|
||||||
|
text: model.description
|
||||||
|
Label
|
||||||
|
{
|
||||||
|
id: label
|
||||||
|
width: base.firstColumnWidth;
|
||||||
|
height: spinBox.height + UM.Theme.getSize("default_lining").height
|
||||||
|
text: model.label
|
||||||
|
elide: Text.ElideRight
|
||||||
|
verticalAlignment: Qt.AlignVCenter
|
||||||
|
}
|
||||||
|
ReadOnlySpinBox
|
||||||
|
{
|
||||||
|
id: spinBox
|
||||||
|
anchors.left: label.right
|
||||||
|
value:
|
||||||
|
{
|
||||||
|
// In case the setting is not in the material...
|
||||||
|
if (!isNaN(parseFloat(materialPropertyProvider.properties.value)))
|
||||||
|
{
|
||||||
|
return parseFloat(materialPropertyProvider.properties.value);
|
||||||
|
}
|
||||||
|
// ... we search in the variant, and if it is not there...
|
||||||
|
if (!isNaN(parseFloat(variantPropertyProvider.properties.value)))
|
||||||
|
{
|
||||||
|
return parseFloat(variantPropertyProvider.properties.value);
|
||||||
|
}
|
||||||
|
// ... then look in the definition container.
|
||||||
|
if (!isNaN(parseFloat(machinePropertyProvider.properties.value)))
|
||||||
|
{
|
||||||
|
return parseFloat(machinePropertyProvider.properties.value);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
width: base.secondColumnWidth
|
||||||
|
readOnly: !base.editingEnabled
|
||||||
|
suffix: " " + model.unit
|
||||||
|
maximumValue: 99999
|
||||||
|
decimals: model.unit == "mm" ? 2 : 0
|
||||||
|
|
||||||
|
onEditingFinished: materialPropertyProvider.setPropertyValue("value", value)
|
||||||
|
}
|
||||||
|
|
||||||
|
UM.ContainerPropertyProvider
|
||||||
|
{
|
||||||
|
id: materialPropertyProvider
|
||||||
|
containerId: base.containerId
|
||||||
|
watchedProperties: [ "value" ]
|
||||||
|
key: model.key
|
||||||
|
}
|
||||||
|
UM.ContainerPropertyProvider
|
||||||
|
{
|
||||||
|
id: variantPropertyProvider
|
||||||
|
containerId: Cura.MachineManager.activeStack.variant.id
|
||||||
|
watchedProperties: [ "value" ]
|
||||||
|
key: model.key
|
||||||
|
}
|
||||||
|
UM.ContainerPropertyProvider
|
||||||
|
{
|
||||||
|
id: machinePropertyProvider
|
||||||
|
containerId: Cura.MachineManager.activeMachine != null ? Cura.MachineManager.activeMachine.definition.id: ""
|
||||||
|
watchedProperties: [ "value" ]
|
||||||
|
key: model.key
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user