mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-22 14:13:55 -06:00
CURA-4400 first version that disables extruder and updates available quality profiles
This commit is contained in:
parent
7507ba10a9
commit
86c13e86c7
8 changed files with 54 additions and 15 deletions
|
@ -35,6 +35,7 @@ class QualityProfilesModel(ListModel):
|
||||||
# connect signals
|
# connect signals
|
||||||
Application.getInstance().globalContainerStackChanged.connect(self._update)
|
Application.getInstance().globalContainerStackChanged.connect(self._update)
|
||||||
Application.getInstance().getMachineManager().activeQualityGroupChanged.connect(self._update)
|
Application.getInstance().getMachineManager().activeQualityGroupChanged.connect(self._update)
|
||||||
|
Application.getInstance().getMachineManager().extruderChanged.connect(self._update)
|
||||||
|
|
||||||
self._quality_manager = Application.getInstance()._quality_manager
|
self._quality_manager = Application.getInstance()._quality_manager
|
||||||
self._quality_manager.qualitiesUpdated.connect(self._update)
|
self._quality_manager.qualitiesUpdated.connect(self._update)
|
||||||
|
|
|
@ -237,9 +237,9 @@ class QualityManager(QObject):
|
||||||
# Updates the given quality groups' availabilities according to which extruders are being used/ enabled.
|
# Updates the given quality groups' availabilities according to which extruders are being used/ enabled.
|
||||||
def _updateQualityGroupsAvailability(self, machine: "GlobalStack", quality_group_list):
|
def _updateQualityGroupsAvailability(self, machine: "GlobalStack", quality_group_list):
|
||||||
used_extruders = set()
|
used_extruders = set()
|
||||||
# TODO: This will change after the Machine refactoring
|
|
||||||
for i in range(machine.getProperty("machine_extruder_count", "value")):
|
for i in range(machine.getProperty("machine_extruder_count", "value")):
|
||||||
used_extruders.add(str(i))
|
if machine.extruders[str(i)].isEnabled:
|
||||||
|
used_extruders.add(str(i))
|
||||||
|
|
||||||
# Update the "is_available" flag for each quality group.
|
# Update the "is_available" flag for each quality group.
|
||||||
for quality_group in quality_group_list:
|
for quality_group in quality_group_list:
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
from typing import Any, TYPE_CHECKING, Optional
|
from typing import Any, TYPE_CHECKING, Optional
|
||||||
|
|
||||||
from PyQt5.QtCore import pyqtProperty
|
from PyQt5.QtCore import pyqtProperty, pyqtSignal
|
||||||
|
|
||||||
from UM.Decorators import override
|
from UM.Decorators import override
|
||||||
from UM.MimeTypeDatabase import MimeType, MimeTypeDatabase
|
from UM.MimeTypeDatabase import MimeType, MimeTypeDatabase
|
||||||
|
@ -28,9 +28,12 @@ class ExtruderStack(CuraContainerStack):
|
||||||
super().__init__(container_id, *args, **kwargs)
|
super().__init__(container_id, *args, **kwargs)
|
||||||
|
|
||||||
self.addMetaDataEntry("type", "extruder_train") # For backward compatibility
|
self.addMetaDataEntry("type", "extruder_train") # For backward compatibility
|
||||||
|
self._enabled = True
|
||||||
|
|
||||||
self.propertiesChanged.connect(self._onPropertiesChanged)
|
self.propertiesChanged.connect(self._onPropertiesChanged)
|
||||||
|
|
||||||
|
enabledChanged = pyqtSignal()
|
||||||
|
|
||||||
## Overridden from ContainerStack
|
## Overridden from ContainerStack
|
||||||
#
|
#
|
||||||
# This will set the next stack and ensure that we register this stack as an extruder.
|
# This will set the next stack and ensure that we register this stack as an extruder.
|
||||||
|
@ -47,6 +50,14 @@ class ExtruderStack(CuraContainerStack):
|
||||||
def getNextStack(self) -> Optional["GlobalStack"]:
|
def getNextStack(self) -> Optional["GlobalStack"]:
|
||||||
return super().getNextStack()
|
return super().getNextStack()
|
||||||
|
|
||||||
|
def setEnabled(self, enabled):
|
||||||
|
self._enabled = enabled
|
||||||
|
self.enabledChanged.emit()
|
||||||
|
|
||||||
|
@pyqtProperty(bool, notify = enabledChanged)
|
||||||
|
def isEnabled(self):
|
||||||
|
return self._enabled
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def getLoadingPriority(cls) -> int:
|
def getLoadingPriority(cls) -> int:
|
||||||
return 3
|
return 3
|
||||||
|
|
|
@ -135,6 +135,7 @@ class MachineManager(QObject):
|
||||||
activeVariantChanged = pyqtSignal()
|
activeVariantChanged = pyqtSignal()
|
||||||
activeQualityChanged = pyqtSignal()
|
activeQualityChanged = pyqtSignal()
|
||||||
activeStackChanged = pyqtSignal() # Emitted whenever the active stack is changed (ie: when changing between extruders, changing a profile, but not when changing a value)
|
activeStackChanged = pyqtSignal() # Emitted whenever the active stack is changed (ie: when changing between extruders, changing a profile, but not when changing a value)
|
||||||
|
extruderChanged = pyqtSignal()
|
||||||
|
|
||||||
globalValueChanged = pyqtSignal() # Emitted whenever a value inside global container is changed.
|
globalValueChanged = pyqtSignal() # Emitted whenever a value inside global container is changed.
|
||||||
activeStackValueChanged = pyqtSignal() # Emitted whenever a value inside the active stack is changed.
|
activeStackValueChanged = pyqtSignal() # Emitted whenever a value inside the active stack is changed.
|
||||||
|
@ -764,6 +765,13 @@ class MachineManager(QObject):
|
||||||
extruder = self._global_container_stack.extruders.get(str(position))
|
extruder = self._global_container_stack.extruders.get(str(position))
|
||||||
return extruder
|
return extruder
|
||||||
|
|
||||||
|
@pyqtSlot(int, bool)
|
||||||
|
def setExtruderEnabled(self, position: int, enabled) -> None:
|
||||||
|
extruder = self.getExtruder(position)
|
||||||
|
extruder.setEnabled(enabled)
|
||||||
|
|
||||||
|
self.extruderChanged.emit()
|
||||||
|
|
||||||
def _onMachineNameChanged(self):
|
def _onMachineNameChanged(self):
|
||||||
self.globalContainerChanged.emit()
|
self.globalContainerChanged.emit()
|
||||||
|
|
||||||
|
|
|
@ -200,8 +200,21 @@ UM.MainWindow
|
||||||
|
|
||||||
MenuItem {
|
MenuItem {
|
||||||
text: catalog.i18nc("@action:inmenu", "Set as Active Extruder")
|
text: catalog.i18nc("@action:inmenu", "Set as Active Extruder")
|
||||||
onTriggered: Cura.ExtruderManager.setActiveExtruderIndex(model.index)
|
onTriggered: Cura.MachineManager.setExtruderIndex(model.index)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MenuItem {
|
||||||
|
text: catalog.i18nc("@action:inmenu", "Enable Extruder")
|
||||||
|
onTriggered: Cura.MachineManager.setExtruderEnabled(model.index, true)
|
||||||
|
visible: !Cura.MachineManager.getExtruder(model.index).isEnabled
|
||||||
|
}
|
||||||
|
|
||||||
|
MenuItem {
|
||||||
|
text: catalog.i18nc("@action:inmenu", "Disable Extruder")
|
||||||
|
onTriggered: Cura.MachineManager.setExtruderEnabled(model.index, false)
|
||||||
|
visible: Cura.MachineManager.getExtruder(model.index).isEnabled
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
onObjectAdded: settingsMenu.insertItem(index, object)
|
onObjectAdded: settingsMenu.insertItem(index, object)
|
||||||
onObjectRemoved: settingsMenu.removeItem(object)
|
onObjectRemoved: settingsMenu.removeItem(object)
|
||||||
|
|
|
@ -19,7 +19,7 @@ Button
|
||||||
iconSource: UM.Theme.getIcon("extruder_button")
|
iconSource: UM.Theme.getIcon("extruder_button")
|
||||||
|
|
||||||
checked: Cura.ExtruderManager.selectedObjectExtruders.indexOf(extruder.id) != -1
|
checked: Cura.ExtruderManager.selectedObjectExtruders.indexOf(extruder.id) != -1
|
||||||
enabled: UM.Selection.hasSelection
|
enabled: UM.Selection.hasSelection && extruder.stack.isEnabled
|
||||||
|
|
||||||
property color customColor: base.hovered ? UM.Theme.getColor("button_hover") : UM.Theme.getColor("button");
|
property color customColor: base.hovered ? UM.Theme.getColor("button_hover") : UM.Theme.getColor("button");
|
||||||
|
|
||||||
|
|
|
@ -114,6 +114,18 @@ Column
|
||||||
Behavior on color { ColorAnimation { duration: 50; } }
|
Behavior on color { ColorAnimation { duration: 50; } }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function buttonColor(index) {
|
||||||
|
var extruder = Cura.MachineManager.getExtruder(index);
|
||||||
|
if (extruder.isEnabled) {
|
||||||
|
return (
|
||||||
|
control.checked || control.pressed) ? UM.Theme.getColor("action_button_active_text") :
|
||||||
|
control.hovered ? UM.Theme.getColor("action_button_hovered_text") :
|
||||||
|
UM.Theme.getColor("action_button_text");
|
||||||
|
} else {
|
||||||
|
return UM.Theme.getColor("action_button_disabled");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Item
|
Item
|
||||||
{
|
{
|
||||||
id: extruderButtonFace
|
id: extruderButtonFace
|
||||||
|
@ -131,9 +143,7 @@ Column
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
|
|
||||||
color: (control.checked || control.pressed) ? UM.Theme.getColor("action_button_active_text") :
|
color: buttonColor(index)
|
||||||
control.hovered ? UM.Theme.getColor("action_button_hovered_text") :
|
|
||||||
UM.Theme.getColor("action_button_text")
|
|
||||||
|
|
||||||
font: UM.Theme.getFont("large_nonbold")
|
font: UM.Theme.getFont("large_nonbold")
|
||||||
text: catalog.i18nc("@label", "Extruder")
|
text: catalog.i18nc("@label", "Extruder")
|
||||||
|
@ -176,9 +186,7 @@ Column
|
||||||
id: extruderNumberText
|
id: extruderNumberText
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
text: index + 1;
|
text: index + 1;
|
||||||
color: (control.checked || control.pressed) ? UM.Theme.getColor("action_button_active_text") :
|
color: buttonColor(index)
|
||||||
control.hovered ? UM.Theme.getColor("action_button_hovered_text") :
|
|
||||||
UM.Theme.getColor("action_button_text")
|
|
||||||
font: UM.Theme.getFont("default_bold")
|
font: UM.Theme.getFont("default_bold")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,10 +67,8 @@ Item
|
||||||
|
|
||||||
Connections
|
Connections
|
||||||
{
|
{
|
||||||
target: Cura.MachineManager
|
target: Cura.QualityProfilesModel
|
||||||
onActiveQualityChanged: qualityModel.update()
|
onItemsChanged: qualityModel.update()
|
||||||
onActiveMaterialChanged: qualityModel.update()
|
|
||||||
onActiveVariantChanged: qualityModel.update()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue