mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-13 09:47:50 -06:00
WIP: Materials management page, make Activate work
This commit is contained in:
parent
4468f4d620
commit
a0b53dc1c9
3 changed files with 40 additions and 10 deletions
|
@ -3,6 +3,7 @@
|
|||
|
||||
import UM.Settings.Models.SettingVisibilityHandler
|
||||
|
||||
|
||||
class MaterialSettingsVisibilityHandler(UM.Settings.Models.SettingVisibilityHandler.SettingVisibilityHandler):
|
||||
def __init__(self, parent = None, *args, **kwargs):
|
||||
super().__init__(parent = parent, *args, **kwargs)
|
||||
|
|
|
@ -205,6 +205,7 @@ class NewMaterialsModel(ListModel):
|
|||
GuidRole = Qt.UserRole + 12
|
||||
DensityRole = Qt.UserRole + 13
|
||||
DiameterRole = Qt.UserRole + 14
|
||||
IsReadOnlyRole = Qt.UserRole + 15
|
||||
|
||||
def __init__(self, parent = None):
|
||||
super().__init__(parent)
|
||||
|
@ -224,8 +225,10 @@ class NewMaterialsModel(ListModel):
|
|||
self.addRoleName(self.GuidRole, "guid")
|
||||
self.addRoleName(self.DensityRole, "density")
|
||||
self.addRoleName(self.DiameterRole, "diameter")
|
||||
self.addRoleName(self.IsReadOnlyRole, "is_read_only")
|
||||
|
||||
from cura.CuraApplication import CuraApplication
|
||||
self._container_registry = CuraApplication.getInstance().getContainerRegistry()
|
||||
machine_manager = CuraApplication.getInstance().getMachineManager()
|
||||
extruder_manager = CuraApplication.getInstance().getExtruderManager()
|
||||
material_manager = CuraApplication.getInstance()._material_manager
|
||||
|
@ -259,6 +262,7 @@ class NewMaterialsModel(ListModel):
|
|||
"container_id": container_node.metadata["id"],
|
||||
"density": container_node.metadata.get("properties", {}).get("density", ""),
|
||||
"diameter": container_node.metadata.get("properties", {}).get("diameter", ""),
|
||||
"is_read_only": self._container_registry.isReadOnly(container_node.metadata["id"]),
|
||||
}
|
||||
|
||||
for key in keys_to_fetch:
|
||||
|
|
|
@ -34,6 +34,19 @@ Item
|
|||
text: catalog.i18nc("@title:tab", "Materials")
|
||||
}
|
||||
|
||||
property var currentItem:
|
||||
{
|
||||
var current_index = materialListView.currentIndex;
|
||||
return materialsModel.getItem(current_index);
|
||||
}
|
||||
|
||||
property var isCurrentItemActivated:
|
||||
{
|
||||
const extruder_position = Cura.ExtruderManager.activeExtruderIndex;
|
||||
const root_material_id = Cura.MachineManager.currentRootMaterialId[extruder_position];
|
||||
return base.currentItem.root_material_id == root_material_id;
|
||||
}
|
||||
|
||||
Row // Button Row
|
||||
{
|
||||
id: buttonRow
|
||||
|
@ -48,12 +61,15 @@ Item
|
|||
Button {
|
||||
text: catalog.i18nc("@action:button", "Activate")
|
||||
iconName: "list-activate"
|
||||
//enabled: base.currentItem != null && base.currentItem.id != Cura.MachineManager.activeMaterialId && Cura.MachineManager.hasMaterials
|
||||
enabled: true // TODO
|
||||
enabled: !isCurrentItemActivated
|
||||
onClicked: {
|
||||
forceActiveFocus()
|
||||
Cura.MachineManager.setActiveMaterial(base.currentItem.id)
|
||||
currentItem = base.model.getItem(base.objectList.currentIndex) // Refresh the current item.
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -147,7 +163,16 @@ Item
|
|||
top: parent.top
|
||||
left: parent.left
|
||||
}
|
||||
text: "TODO"
|
||||
visible: text != ""
|
||||
text: {
|
||||
// OLD STUFF
|
||||
var caption = catalog.i18nc("@action:label", "Printer") + ": " + Cura.MachineManager.activeMachineName;
|
||||
if (Cura.MachineManager.hasVariants)
|
||||
{
|
||||
caption += ", " + Cura.MachineManager.activeDefinitionVariantsName + ": " + Cura.MachineManager.activeVariantName;
|
||||
}
|
||||
return caption;
|
||||
}
|
||||
width: materialScrollView.width
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
@ -219,10 +244,10 @@ Item
|
|||
width: Math.floor((parent.width * 0.3))
|
||||
text: model.material
|
||||
elide: Text.ElideRight
|
||||
font.italic: {
|
||||
font.italic: { // TODO: make it easier
|
||||
const extruder_position = Cura.ExtruderManager.activeExtruderIndex;
|
||||
const root_material_id = Cura.MachineManager.currentRootMaterialId[extruder_position];
|
||||
return model.root_material_id == root_material_id; // TODO
|
||||
return model.root_material_id == root_material_id
|
||||
}
|
||||
color: parent.ListView.isCurrentItem ? palette.highlightedText : palette.text;
|
||||
}
|
||||
|
@ -230,10 +255,10 @@ Item
|
|||
{
|
||||
text: (model.name != model.material) ? model.name : ""
|
||||
elide: Text.ElideRight
|
||||
font.italic: {
|
||||
font.italic: { // TODO: make it easier
|
||||
const extruder_position = Cura.ExtruderManager.activeExtruderIndex;
|
||||
const root_material_id = Cura.MachineManager.currentRootMaterialId[extruder_position];
|
||||
return model.root_material_id == root_material_id; // TODO
|
||||
return model.root_material_id == root_material_id;
|
||||
}
|
||||
color: parent.ListView.isCurrentItem ? palette.highlightedText : palette.text;
|
||||
}
|
||||
|
@ -329,7 +354,7 @@ Item
|
|||
bottom: parent.bottom
|
||||
}
|
||||
|
||||
editingEnabled: base.currentItem != null && !base.currentItem.readOnly
|
||||
editingEnabled: base.currentItem != null && !base.currentItem.is_read_only
|
||||
|
||||
properties: materialProperties
|
||||
containerId: base.currentItem != null ? base.currentItem.id : ""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue