mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-16 03:07:53 -06:00
WIP: Rework Material management page
This commit is contained in:
parent
7fa218e9cd
commit
f024f45cfe
5 changed files with 104 additions and 114 deletions
|
@ -12,7 +12,8 @@ TabView
|
|||
{
|
||||
id: base
|
||||
|
||||
property QtObject properties;
|
||||
property QtObject properties
|
||||
property var currentMaterialNode: null
|
||||
|
||||
property bool editingEnabled: false;
|
||||
property string currency: UM.Preferences.getValue("cura/currency") ? UM.Preferences.getValue("cura/currency") : "€"
|
||||
|
@ -27,15 +28,16 @@ TabView
|
|||
property bool reevaluateLinkedMaterials: false
|
||||
property string linkedMaterialNames:
|
||||
{
|
||||
if (reevaluateLinkedMaterials)
|
||||
{
|
||||
if (reevaluateLinkedMaterials) {
|
||||
reevaluateLinkedMaterials = false;
|
||||
}
|
||||
if(!base.containerId || !base.editingEnabled)
|
||||
{
|
||||
if (!base.containerId || !base.editingEnabled) {
|
||||
return ""
|
||||
}
|
||||
var linkedMaterials = Cura.ContainerManager.getLinkedMaterials(base.currentMaterialNode);
|
||||
if (linkedMaterials.length <= 1) {
|
||||
return ""
|
||||
}
|
||||
var linkedMaterials = Cura.ContainerManager.getLinkedMaterials(base.containerId);
|
||||
return linkedMaterials.join(", ");
|
||||
}
|
||||
|
||||
|
@ -80,18 +82,18 @@ TabView
|
|||
{
|
||||
id: textField;
|
||||
width: scrollView.columnWidth;
|
||||
text: properties.supplier;
|
||||
text: properties.brand;
|
||||
readOnly: !base.editingEnabled;
|
||||
onEditingFinished: base.updateMaterialSupplier(properties.supplier, text)
|
||||
onEditingFinished: base.updateMaterialBrand(properties.brand, text)
|
||||
}
|
||||
|
||||
Label { width: scrollView.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Material Type") }
|
||||
ReadOnlyTextField
|
||||
{
|
||||
width: scrollView.columnWidth;
|
||||
text: properties.material_type;
|
||||
text: properties.material;
|
||||
readOnly: !base.editingEnabled;
|
||||
onEditingFinished: base.updateMaterialType(properties.material_type, text)
|
||||
onEditingFinished: base.updateMaterialType(properties.material, text)
|
||||
}
|
||||
|
||||
Label { width: scrollView.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Color") }
|
||||
|
@ -251,7 +253,7 @@ TabView
|
|||
visible: base.linkedMaterialNames != ""
|
||||
onClicked:
|
||||
{
|
||||
Cura.ContainerManager.unlinkMaterial(base.containerId)
|
||||
Cura.ContainerManager.unlinkMaterial(base.currentMaterialNode)
|
||||
base.reevaluateLinkedMaterials = true
|
||||
}
|
||||
}
|
||||
|
@ -466,12 +468,12 @@ TabView
|
|||
// update the type of the material
|
||||
function updateMaterialType (old_type, new_type) {
|
||||
base.setMetaDataEntry("material", old_type, new_type)
|
||||
materialProperties.material_type = new_type
|
||||
materialProperties.material= new_type
|
||||
}
|
||||
|
||||
// update the supplier of the material
|
||||
function updateMaterialSupplier (old_supplier, new_supplier) {
|
||||
base.setMetaDataEntry("brand", old_supplier, new_supplier)
|
||||
materialProperties.supplier = new_supplier
|
||||
// update the brand of the material
|
||||
function updateMaterialBrand (old_brand, new_brand) {
|
||||
base.setMetaDataEntry("brand", old_brand, new_brand)
|
||||
materialProperties.brand = new_brand
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,8 @@ Item
|
|||
text: catalog.i18nc("@title:tab", "Materials")
|
||||
}
|
||||
|
||||
property var hasCurrentItem: materialListView.currentItem != null;
|
||||
|
||||
property var currentItem:
|
||||
{
|
||||
var current_index = materialListView.currentIndex;
|
||||
|
@ -65,9 +67,6 @@ Item
|
|||
onClicked: {
|
||||
forceActiveFocus()
|
||||
|
||||
var current_index = materialListView.currentIndex;
|
||||
var item = materialsModel.getItem(current_index);
|
||||
|
||||
const extruder_position = Cura.ExtruderManager.activeExtruderIndex;
|
||||
Cura.MachineManager.setMaterial(extruder_position, base.currentItem.container_node);
|
||||
}
|
||||
|
@ -87,10 +86,11 @@ Item
|
|||
Button {
|
||||
text: catalog.i18nc("@action:button", "Duplicate");
|
||||
iconName: "list-add"
|
||||
enabled: true //TODO
|
||||
enabled: base.hasCurrentItem
|
||||
onClicked: {
|
||||
forceActiveFocus()
|
||||
// TODO
|
||||
|
||||
Cura.ContainerManager.duplicateMaterial(base.currentItem.container_node);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -277,6 +277,7 @@ Item
|
|||
{
|
||||
var model = materialsModel.getItem(currentIndex);
|
||||
materialDetailsView.containerId = model.container_id;
|
||||
materialDetailsView.currentMaterialNode = model.container_node;
|
||||
|
||||
detailsPanel.updateMaterialPropertiesObject();
|
||||
}
|
||||
|
@ -303,8 +304,8 @@ Item
|
|||
materialProperties.name = currentItem.name;
|
||||
materialProperties.guid = currentItem.guid;
|
||||
|
||||
materialProperties.supplier = currentItem.brand ? currentItem.brand : "Unknown";
|
||||
materialProperties.material_type = currentItem.material ? currentItem.material : "Unknown";
|
||||
materialProperties.brand = currentItem.brand ? currentItem.brand : "Unknown";
|
||||
materialProperties.material = currentItem.material ? currentItem.material : "Unknown";
|
||||
materialProperties.color_name = currentItem.color_name ? currentItem.color_name : "Yellow";
|
||||
materialProperties.color_code = currentItem.color_code ? currentItem.color_code : "yellow";
|
||||
|
||||
|
@ -358,6 +359,7 @@ Item
|
|||
|
||||
properties: materialProperties
|
||||
containerId: base.currentItem != null ? base.currentItem.id : ""
|
||||
currentMaterialNode: base.currentItem
|
||||
|
||||
property alias pane: base
|
||||
}
|
||||
|
@ -369,8 +371,9 @@ Item
|
|||
property string guid: "00000000-0000-0000-0000-000000000000"
|
||||
property string name: "Unknown";
|
||||
property string profile_type: "Unknown";
|
||||
property string supplier: "Unknown";
|
||||
property string material_type: "Unknown";
|
||||
property string brand: "Unknown";
|
||||
property string material: "Unknown"; // This needs to be named as "material" to be consistent with
|
||||
// the material container's metadata entry
|
||||
|
||||
property string color_name: "Yellow";
|
||||
property color color_code: "yellow";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue