mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 14:37:29 -06:00
Remove deprecated functions in MachineManager
CURA-6858
This commit is contained in:
parent
7544d049c5
commit
38ee4bf208
15 changed files with 27 additions and 170 deletions
|
@ -447,27 +447,6 @@ class MachineManager(QObject):
|
|||
def stacksHaveErrors(self) -> bool:
|
||||
return bool(self._stacks_have_errors)
|
||||
|
||||
@pyqtProperty(str, notify = globalContainerChanged)
|
||||
@deprecated("use Cura.MachineManager.activeMachine.definition.name instead", "4.1")
|
||||
def activeMachineDefinitionName(self) -> str:
|
||||
if self._global_container_stack:
|
||||
return self._global_container_stack.definition.getName()
|
||||
return ""
|
||||
|
||||
@pyqtProperty(str, notify = globalContainerChanged)
|
||||
@deprecated("use Cura.MachineManager.activeMachine.name instead", "4.1")
|
||||
def activeMachineName(self) -> str:
|
||||
if self._global_container_stack:
|
||||
return self._global_container_stack.getMetaDataEntry("group_name", self._global_container_stack.getName())
|
||||
return ""
|
||||
|
||||
@pyqtProperty(str, notify = globalContainerChanged)
|
||||
@deprecated("use Cura.MachineManager.activeMachine.id instead", "4.1")
|
||||
def activeMachineId(self) -> str:
|
||||
if self._global_container_stack:
|
||||
return self._global_container_stack.getId()
|
||||
return ""
|
||||
|
||||
@pyqtProperty(str, notify = globalContainerChanged)
|
||||
def activeMachineFirmwareVersion(self) -> str:
|
||||
if not self._printer_output_devices:
|
||||
|
@ -496,13 +475,6 @@ class MachineManager(QObject):
|
|||
return has_remote_connection
|
||||
return False
|
||||
|
||||
@pyqtProperty("QVariantList", notify=globalContainerChanged)
|
||||
@deprecated("use Cura.MachineManager.activeMachine.configuredConnectionTypes instead", "4.1")
|
||||
def activeMachineConfiguredConnectionTypes(self):
|
||||
if self._global_container_stack:
|
||||
return self._global_container_stack.configuredConnectionTypes
|
||||
return []
|
||||
|
||||
@pyqtProperty(bool, notify = printerConnectedStatusChanged)
|
||||
def activeMachineIsGroup(self) -> bool:
|
||||
return bool(self._printer_output_devices) and len(self._printer_output_devices[0].printers) > 1
|
||||
|
@ -554,24 +526,6 @@ class MachineManager(QObject):
|
|||
return material.getId()
|
||||
return ""
|
||||
|
||||
## Gets a dict with the active materials ids set in all extruder stacks and the global stack
|
||||
# (when there is one extruder, the material is set in the global stack)
|
||||
#
|
||||
# \return The material ids in all stacks
|
||||
@pyqtProperty("QVariantMap", notify = activeMaterialChanged)
|
||||
@deprecated("use Cura.MachineManager.activeStack.extruders instead.", "4.3")
|
||||
def allActiveMaterialIds(self) -> Dict[str, str]:
|
||||
result = {}
|
||||
|
||||
active_stacks = ExtruderManager.getInstance().getActiveExtruderStacks()
|
||||
for stack in active_stacks:
|
||||
material_container = stack.material
|
||||
if not material_container:
|
||||
continue
|
||||
result[stack.getId()] = material_container.getId()
|
||||
|
||||
return result
|
||||
|
||||
## Gets the layer height of the currently active quality profile.
|
||||
#
|
||||
# This is indicated together with the name of the active quality profile.
|
||||
|
@ -693,44 +647,6 @@ class MachineManager(QObject):
|
|||
# Check if the value has to be replaced
|
||||
extruder_stack.userChanges.setProperty(key, "value", new_value)
|
||||
|
||||
@pyqtProperty(str, notify = activeVariantChanged)
|
||||
@deprecated("use Cura.MachineManager.activeStack.variant.name instead", "4.1")
|
||||
def activeVariantName(self) -> str:
|
||||
if self._active_container_stack:
|
||||
variant = self._active_container_stack.variant
|
||||
if variant:
|
||||
return variant.getName()
|
||||
|
||||
return ""
|
||||
|
||||
@pyqtProperty(str, notify = activeVariantChanged)
|
||||
@deprecated("use Cura.MachineManager.activeStack.variant.id instead", "4.1")
|
||||
def activeVariantId(self) -> str:
|
||||
if self._active_container_stack:
|
||||
variant = self._active_container_stack.variant
|
||||
if variant:
|
||||
return variant.getId()
|
||||
|
||||
return ""
|
||||
|
||||
@pyqtProperty(str, notify = activeVariantChanged)
|
||||
@deprecated("use Cura.MachineManager.activeMachine.variant.name instead", "4.1")
|
||||
def activeVariantBuildplateName(self) -> str:
|
||||
if self._global_container_stack:
|
||||
variant = self._global_container_stack.variant
|
||||
if variant:
|
||||
return variant.getName()
|
||||
|
||||
return ""
|
||||
|
||||
@pyqtProperty(str, notify = globalContainerChanged)
|
||||
@deprecated("use Cura.MachineManager.activeMachine.definition.id instead", "4.1")
|
||||
def activeDefinitionId(self) -> str:
|
||||
if self._global_container_stack:
|
||||
return self._global_container_stack.definition.id
|
||||
|
||||
return ""
|
||||
|
||||
## Get the Definition ID to use to select quality profiles for the currently active machine
|
||||
# \returns DefinitionID (string) if found, empty string otherwise
|
||||
@pyqtProperty(str, notify = globalContainerChanged)
|
||||
|
@ -788,27 +704,6 @@ class MachineManager(QObject):
|
|||
# This reuses the method and remove all printers recursively
|
||||
self.removeMachine(hidden_containers[0].getId())
|
||||
|
||||
@pyqtProperty(bool, notify = globalContainerChanged)
|
||||
@deprecated("use Cura.MachineManager.activeMachine.hasMaterials instead", "4.2")
|
||||
def hasMaterials(self) -> bool:
|
||||
if self._global_container_stack:
|
||||
return self._global_container_stack.hasMaterials
|
||||
return False
|
||||
|
||||
@pyqtProperty(bool, notify = globalContainerChanged)
|
||||
@deprecated("use Cura.MachineManager.activeMachine.hasVariants instead", "4.2")
|
||||
def hasVariants(self) -> bool:
|
||||
if self._global_container_stack:
|
||||
return self._global_container_stack.hasVariants
|
||||
return False
|
||||
|
||||
@pyqtProperty(bool, notify = globalContainerChanged)
|
||||
@deprecated("use Cura.MachineManager.activeMachine.hasVariantBuildplates instead", "4.2")
|
||||
def hasVariantBuildplates(self) -> bool:
|
||||
if self._global_container_stack:
|
||||
return self._global_container_stack.hasVariantBuildplates
|
||||
return False
|
||||
|
||||
## The selected buildplate is compatible if it is compatible with all the materials in all the extruders
|
||||
@pyqtProperty(bool, notify = activeMaterialChanged)
|
||||
def variantBuildplateCompatible(self) -> bool:
|
||||
|
@ -823,7 +718,8 @@ class MachineManager(QObject):
|
|||
if material_container == empty_material_container:
|
||||
continue
|
||||
if material_container.getMetaDataEntry("buildplate_compatible"):
|
||||
buildplate_compatible = buildplate_compatible and material_container.getMetaDataEntry("buildplate_compatible")[self.activeVariantBuildplateName]
|
||||
active_buildplate_name = self.activeMachine.variant.name
|
||||
buildplate_compatible = buildplate_compatible and material_container.getMetaDataEntry("buildplate_compatible")[active_buildplate_name]
|
||||
|
||||
return buildplate_compatible
|
||||
|
||||
|
@ -946,7 +842,7 @@ class MachineManager(QObject):
|
|||
if settable_per_extruder:
|
||||
limit_to_extruder = int(self._global_container_stack.getProperty(setting_key, "limit_to_extruder"))
|
||||
extruder_position = max(0, limit_to_extruder)
|
||||
extruder_stack = self.getExtruder(extruder_position)
|
||||
extruder_stack = self._global_container_stack.extruderList[extruder_position]
|
||||
if extruder_stack:
|
||||
extruder_stack.userChanges.setProperty(setting_key, "value", global_user_container.getProperty(setting_key, "value"))
|
||||
else:
|
||||
|
@ -957,20 +853,6 @@ class MachineManager(QObject):
|
|||
self._application.globalContainerStackChanged.emit()
|
||||
self.forceUpdateAllSettings()
|
||||
|
||||
@pyqtSlot(int, result = QObject)
|
||||
def getExtruder(self, position: int) -> Optional[ExtruderStack]:
|
||||
return self._getExtruder(position)
|
||||
|
||||
# This is a workaround for the deprecated decorator and the pyqtSlot not playing well together.
|
||||
@deprecated("use Cura.MachineManager.activeMachine.extruders instead", "4.2")
|
||||
def _getExtruder(self, position) -> Optional[ExtruderStack]:
|
||||
if self._global_container_stack:
|
||||
try:
|
||||
return self._global_container_stack.extruderList[int(position)]
|
||||
except IndexError:
|
||||
return None
|
||||
return None
|
||||
|
||||
def updateDefaultExtruder(self) -> None:
|
||||
if self._global_container_stack is None:
|
||||
return
|
||||
|
@ -1021,10 +903,10 @@ class MachineManager(QObject):
|
|||
|
||||
@pyqtSlot(int, bool)
|
||||
def setExtruderEnabled(self, position: int, enabled: bool) -> None:
|
||||
extruder = self.getExtruder(position)
|
||||
if not extruder or self._global_container_stack is None:
|
||||
if self._global_container_stack is None:
|
||||
Logger.log("w", "Could not find extruder on position %s", position)
|
||||
return
|
||||
extruder = self._global_container_stack.extruderList[position]
|
||||
|
||||
extruder.setEnabled(enabled)
|
||||
self.updateDefaultExtruder()
|
||||
|
@ -1356,7 +1238,7 @@ class MachineManager(QObject):
|
|||
@pyqtSlot(str)
|
||||
def switchPrinterType(self, machine_name: str) -> None:
|
||||
# Don't switch if the user tries to change to the same type of printer
|
||||
if self._global_container_stack is None or self.activeMachineDefinitionName == machine_name:
|
||||
if self._global_container_stack is None or self._global_container_stack.definition.name == machine_name:
|
||||
return
|
||||
Logger.log("i", "Attempting to switch the printer type to [%s]", machine_name)
|
||||
# Get the definition id corresponding to this machine name
|
||||
|
|
|
@ -68,7 +68,7 @@ Item
|
|||
Cura.NumericTextFieldWithUnit // "Nozzle size"
|
||||
{
|
||||
id: extruderNozzleSizeField
|
||||
visible: !Cura.MachineManager.hasVariants
|
||||
visible: !Cura.MachineManager.activeMachine.hasVariants
|
||||
containerStackId: base.extruderStackId
|
||||
settingKey: "machine_nozzle_size"
|
||||
settingStoreIndex: propertyStoreIndex
|
||||
|
|
|
@ -25,7 +25,7 @@ Item
|
|||
property int controlWidth: (columnWidth / 3) | 0
|
||||
property var labelFont: UM.Theme.getFont("default")
|
||||
|
||||
property string machineStackId: Cura.MachineManager.activeMachineId
|
||||
property string machineStackId: Cura.MachineManager.activeMachine.id
|
||||
|
||||
property var forceUpdateFunction: manager.forceUpdate
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ Rectangle
|
|||
{
|
||||
// Readability:
|
||||
var connectedTypes = [2, 3];
|
||||
var types = Cura.MachineManager.activeMachineConfiguredConnectionTypes
|
||||
var types = Cura.MachineManager.activeMachine.configuredConnectionTypes
|
||||
|
||||
// Check if configured connection types includes either 2 or 3 (LAN or cloud)
|
||||
for (var i = 0; i < types.length; i++)
|
||||
|
|
|
@ -27,7 +27,7 @@ NumericTextFieldWithUnit
|
|||
id: printerHeadMinMaxField
|
||||
UM.I18nCatalog { id: catalog; name: "cura" }
|
||||
|
||||
containerStackId: Cura.MachineManager.activeMachineId
|
||||
containerStackId: Cura.MachineManager.activeMachine.id
|
||||
settingKey: "machine_head_with_fans_polygon"
|
||||
settingStoreIndex: 1
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ Cura.ExpandablePopup
|
|||
}
|
||||
|
||||
contentPadding: UM.Theme.getSize("default_lining").width
|
||||
enabled: Cura.MachineManager.hasMaterials || Cura.MachineManager.hasVariants || Cura.MachineManager.hasVariantBuildplates; //Only let it drop down if there is any configuration that you could change.
|
||||
enabled: Cura.MachineManager.activeMachine.hasMaterials || Cura.MachineManager.activeMachine.hasVariants || Cura.MachineManager.activeMachine.hasVariantBuildplates; //Only let it drop down if there is any configuration that you could change.
|
||||
|
||||
headerItem: Item
|
||||
{
|
||||
|
@ -44,7 +44,7 @@ Cura.ExpandablePopup
|
|||
orientation: ListView.Horizontal
|
||||
anchors.fill: parent
|
||||
model: extrudersModel
|
||||
visible: Cura.MachineManager.hasMaterials
|
||||
visible: Cura.MachineManager.activeMachine.hasMaterials
|
||||
|
||||
delegate: Item
|
||||
{
|
||||
|
@ -86,7 +86,7 @@ Cura.ExpandablePopup
|
|||
{
|
||||
id: variantLabel
|
||||
|
||||
visible: Cura.MachineManager.hasVariants
|
||||
visible: Cura.MachineManager.activeMachine.hasVariants
|
||||
|
||||
text: model.variant
|
||||
elide: Text.ElideRight
|
||||
|
@ -115,7 +115,7 @@ Cura.ExpandablePopup
|
|||
color: UM.Theme.getColor("text")
|
||||
renderType: Text.NativeRendering
|
||||
|
||||
visible: !Cura.MachineManager.hasMaterials && (Cura.MachineManager.hasVariants || Cura.MachineManager.hasVariantBuildplates)
|
||||
visible: !Cura.MachineManager.activeMachine.hasMaterials && (Cura.MachineManager.activeMachine.hasVariants || Cura.MachineManager.activeMachine.hasVariantBuildplates)
|
||||
|
||||
anchors
|
||||
{
|
||||
|
|
|
@ -244,7 +244,7 @@ Item
|
|||
Row
|
||||
{
|
||||
height: visible ? UM.Theme.getSize("print_setup_big_item").height : 0
|
||||
visible: Cura.MachineManager.hasMaterials
|
||||
visible: Cura.MachineManager.activeMachine.hasMaterials
|
||||
|
||||
Label
|
||||
{
|
||||
|
@ -305,7 +305,7 @@ Item
|
|||
Row
|
||||
{
|
||||
height: visible ? UM.Theme.getSize("print_setup_big_item").height : 0
|
||||
visible: Cura.MachineManager.hasVariants
|
||||
visible: Cura.MachineManager.activeMachine.hasVariants
|
||||
|
||||
Label
|
||||
{
|
||||
|
|
|
@ -22,13 +22,13 @@ Menu
|
|||
Menu
|
||||
{
|
||||
title: modelData.name
|
||||
property var extruder: Cura.MachineManager.getExtruder(model.index)
|
||||
NozzleMenu { title: Cura.MachineManager.activeDefinitionVariantsName; visible: Cura.MachineManager.hasVariants; extruderIndex: index }
|
||||
MaterialMenu { title: catalog.i18nc("@title:menu", "&Material"); visible: Cura.MachineManager.hasMaterials; extruderIndex: index }
|
||||
property var extruder: Cura.MachineManager.activeMachine.extruderList[model.index]
|
||||
NozzleMenu { title: Cura.MachineManager.activeDefinitionVariantsName; visible: Cura.MachineManager.activeMachine.hasVariants; extruderIndex: index }
|
||||
MaterialMenu { title: catalog.i18nc("@title:menu", "&Material"); visible: Cura.MachineManager.activeMachine.hasMaterials; extruderIndex: index }
|
||||
|
||||
MenuSeparator
|
||||
{
|
||||
visible: Cura.MachineManager.hasVariants || Cura.MachineManager.hasMaterials
|
||||
visible: Cura.MachineManager.activeMachine.hasVariants || Cura.MachineManager.activeMachine.hasMaterials
|
||||
}
|
||||
|
||||
MenuItem
|
||||
|
|
|
@ -84,7 +84,7 @@ UM.ManagementPage
|
|||
Flow
|
||||
{
|
||||
id: machineActions
|
||||
visible: currentItem && currentItem.id == Cura.MachineManager.activeMachineId
|
||||
visible: currentItem && currentItem.id == Cura.MachineManager.activeMachine.id
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: machineName.bottom
|
||||
|
|
|
@ -103,7 +103,7 @@ Item
|
|||
id: activateMenuButton
|
||||
text: catalog.i18nc("@action:button", "Activate")
|
||||
iconName: "list-activate"
|
||||
enabled: !isCurrentItemActivated && Cura.MachineManager.hasMaterials
|
||||
enabled: !isCurrentItemActivated && Cura.MachineManager.activeMachine.hasMaterials
|
||||
onClicked:
|
||||
{
|
||||
forceActiveFocus()
|
||||
|
@ -227,7 +227,7 @@ Item
|
|||
text:
|
||||
{
|
||||
var caption = catalog.i18nc("@action:label", "Printer") + ": " + Cura.MachineManager.activeMachine.name;
|
||||
if (Cura.MachineManager.hasVariants)
|
||||
if (Cura.MachineManager.activeMachine.hasVariants)
|
||||
{
|
||||
var activeVariantName = ""
|
||||
if(Cura.MachineManager.activeStack != null)
|
||||
|
|
|
@ -449,7 +449,7 @@ TabView
|
|||
UM.ContainerPropertyProvider
|
||||
{
|
||||
id: variantPropertyProvider
|
||||
containerId: Cura.MachineManager.activeVariantId
|
||||
containerId: Cura.MachineManager.activeStack.variant.id
|
||||
watchedProperties: [ "value" ]
|
||||
key: model.key
|
||||
}
|
||||
|
|
|
@ -393,7 +393,7 @@ Item
|
|||
left: parent.left
|
||||
}
|
||||
visible: text != ""
|
||||
text: catalog.i18nc("@label %1 is printer name", "Printer: %1").arg(Cura.MachineManager.activeMachineName)
|
||||
text: catalog.i18nc("@label %1 is printer name", "Printer: %1").arg(Cura.MachineManager.activeMachine.name)
|
||||
width: profileScrollView.width
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ ListView
|
|||
width: listView.width
|
||||
outputDevice: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null
|
||||
|
||||
checked: Cura.MachineManager.activeMachineId == model.id
|
||||
checked: Cura.MachineManager.activeMachine.id == model.id
|
||||
|
||||
onClicked:
|
||||
{
|
||||
|
|
|
@ -33,7 +33,7 @@ Item
|
|||
// Create properties to put property provider stuff in (bindings break in qt 5.5.1 otherwise)
|
||||
property var state: propertyProvider.properties.state
|
||||
// There is no resolve property if there is only one stack.
|
||||
property var resolve: Cura.MachineManager.activeStackId !== Cura.MachineManager.activeMachineId ? propertyProvider.properties.resolve : "None"
|
||||
property var resolve: Cura.MachineManager.activeStackId !== Cura.MachineManager.activeMachine.id ? propertyProvider.properties.resolve : "None"
|
||||
property var stackLevels: propertyProvider.stackLevels
|
||||
property var stackLevel: stackLevels[0]
|
||||
// A list of stack levels that will trigger to show the revert button
|
||||
|
|
|
@ -90,37 +90,12 @@ def createMockedInstanceContainer(instance_id, name = ""):
|
|||
return instance
|
||||
|
||||
|
||||
def test_allActiveMaterialIds(machine_manager, extruder_manager):
|
||||
extruder_1 = createMockedExtruder("extruder_1")
|
||||
extruder_2 = createMockedExtruder("extruder_2")
|
||||
extruder_1.material = createMockedInstanceContainer("material_1")
|
||||
extruder_2.material = createMockedInstanceContainer("material_2")
|
||||
extruder_manager.getActiveExtruderStacks = MagicMock(return_value = [extruder_1, extruder_2])
|
||||
assert machine_manager.allActiveMaterialIds == {"extruder_1": "material_1", "extruder_2": "material_2"}
|
||||
|
||||
|
||||
def test_globalVariantName(machine_manager, application):
|
||||
global_stack = application.getGlobalContainerStack()
|
||||
global_stack.variant = createMockedInstanceContainer("beep", "zomg")
|
||||
assert machine_manager.globalVariantName == "zomg"
|
||||
|
||||
|
||||
def test_activeMachineDefinitionName(machine_manager):
|
||||
global_stack = machine_manager.activeMachine
|
||||
global_stack.definition = createMockedInstanceContainer("beep", "zomg")
|
||||
assert machine_manager.activeMachineDefinitionName == "zomg"
|
||||
|
||||
|
||||
def test_activeMachineId(machine_manager):
|
||||
assert machine_manager.activeMachineId == "GlobalStack"
|
||||
|
||||
|
||||
def test_activeVariantBuildplateName(machine_manager):
|
||||
global_stack = machine_manager.activeMachine
|
||||
global_stack.variant = createMockedInstanceContainer("beep", "zomg")
|
||||
assert machine_manager.activeVariantBuildplateName == "zomg"
|
||||
|
||||
|
||||
def test_resetSettingForAllExtruders(machine_manager):
|
||||
global_stack = machine_manager.activeMachine
|
||||
extruder_1 = createMockedExtruder("extruder_1")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue