diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index 767021e2df..be30c83dda 100755 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -451,6 +451,12 @@ class MachineManager(QObject): def stacksHaveErrors(self) -> bool: return bool(self._stacks_have_errors) + @pyqtProperty(str, notify = globalContainerChanged) + def activeMachineDefinitionName(self) -> str: + if self._global_container_stack: + return self._global_container_stack.definition.getName() + return "" + @pyqtProperty(str, notify = globalContainerChanged) def activeMachineName(self) -> str: if self._global_container_stack: @@ -1024,6 +1030,17 @@ class MachineManager(QObject): self._setMaterial(position, new_material) continue + def switchPrinterType(self, machine_type): + container_registry = ContainerRegistry.getInstance() + machine_definition = container_registry.findDefinitionContainers(name = machine_type)[0] + self._global_container_stack.definition = machine_definition + self.globalContainerChanged.emit() + # machine_stack = CuraStackBuilder.createMachine("ultimaker_s5" + "_instance", "ultimaker_s5") + # # if not machine_stack: + # # raise Exception("No machine found for ID {}".format(machine_id)) + # Logger.log("d", "Setting active machine to %s", machine_stack.getId()) + # self.setActiveMachine(machine_stack.getId()) + @pyqtSlot(QObject) def applyRemoteConfiguration(self, configuration: ConfigurationModel): self.blurSettings.emit() diff --git a/resources/qml/Menus/ConfigurationMenu/ConfigurationListView.qml b/resources/qml/Menus/ConfigurationMenu/ConfigurationListView.qml index 037fadcb22..be11240831 100644 --- a/resources/qml/Menus/ConfigurationMenu/ConfigurationListView.qml +++ b/resources/qml/Menus/ConfigurationMenu/ConfigurationListView.qml @@ -57,7 +57,7 @@ Column section.criteria: ViewSection.FullString section.delegate: sectionHeading - model: outputDevice.uniqueConfigurations + model: (ouputDevice != null) ? outputDevice.uniqueConfigurations : [] delegate: ConfigurationItem { width: parent.width - UM.Theme.getSize("default_margin").width diff --git a/resources/qml/Menus/ConfigurationMenu/SyncButton.qml b/resources/qml/Menus/ConfigurationMenu/SyncButton.qml index 43cf4529cb..58b738323e 100644 --- a/resources/qml/Menus/ConfigurationMenu/SyncButton.qml +++ b/resources/qml/Menus/ConfigurationMenu/SyncButton.qml @@ -18,13 +18,16 @@ Button function updateOnSync() { - for (var index in outputDevice.uniqueConfigurations) + if (outputDevice != undefined) { - var configuration = outputDevice.uniqueConfigurations[index] - if (Cura.MachineManager.matchesConfiguration(configuration)) + for (var index in outputDevice.uniqueConfigurations) { - base.text = catalog.i18nc("@label:sync indicator", "Matched") - return + var configuration = outputDevice.uniqueConfigurations[index] + if (Cura.MachineManager.matchesConfiguration(configuration)) + { + base.text = catalog.i18nc("@label:sync indicator", "Matched") + return + } } } base.text = catalog.i18nc("@label:sync indicator", "No match") diff --git a/resources/qml/Menus/PrinterTypeMenu.qml b/resources/qml/Menus/PrinterTypeMenu.qml index b4fdb0a1d4..e84f53a4ba 100644 --- a/resources/qml/Menus/PrinterTypeMenu.qml +++ b/resources/qml/Menus/PrinterTypeMenu.qml @@ -1,8 +1,8 @@ // Copyright (c) 2018 Ultimaker B.V. // Cura is released under the terms of the LGPLv3 or higher. -import QtQuick 2.2 -import QtQuick.Controls 1.1 +import QtQuick 2.7 +import QtQuick.Controls 1.4 import UM 1.3 as UM import Cura 1.0 as Cura @@ -16,12 +16,12 @@ Menu Instantiator { id: printerTypeInstantiator - model: outputDevice != null ? outputDevice.connectedPrintersTypeCount : null + model: outputDevice != null ? outputDevice.connectedPrintersTypeCount : [] MenuItem { text: modelData.machine_type checkable: true - checked: false + checked: Cura.MachineManager.activeMachineDefinitionName == modelData.machine_type exclusiveGroup: group // onTriggered: // { diff --git a/resources/qml/SidebarHeader.qml b/resources/qml/SidebarHeader.qml index 7acc58c52a..8e12cd017b 100644 --- a/resources/qml/SidebarHeader.qml +++ b/resources/qml/SidebarHeader.qml @@ -17,6 +17,7 @@ Column property int currentExtruderIndex: Cura.ExtruderManager.activeExtruderIndex; property bool currentExtruderVisible: extrudersList.visible; property bool printerConnected: Cura.MachineManager.printerOutputDevices.length != 0 + property bool hasManyPrinterTypes: printerConnected ? Cura.MachineManager.printerOutputDevices[0].connectedPrintersTypeCount.length > 1 : false spacing: Math.round(UM.Theme.getSize("sidebar_margin").width * 0.9) @@ -35,45 +36,6 @@ Column width: height } - // Printer Type Row - Item - { - id: printerTypeSelectionRow - height: UM.Theme.getSize("sidebar_setup").height - visible: printerConnected && !sidebar.monitoringPrint && !sidebar.hideSettings - - anchors - { - left: parent.left - leftMargin: UM.Theme.getSize("sidebar_margin").width - right: parent.right - rightMargin: UM.Theme.getSize("sidebar_margin").width - } - - Label - { - id: configurationLabel - text: catalog.i18nc("@label", "Printer type"); - width: Math.round(parent.width * 0.4 - UM.Theme.getSize("default_margin").width) - height: parent.height - verticalAlignment: Text.AlignVCenter - font: UM.Theme.getFont("default"); - color: UM.Theme.getColor("text"); - } - - ToolButton - { - id: printerTypeSelection - text: catalog.i18nc("@label", "Printer type"); - height: UM.Theme.getSize("setting_control").height - width: Math.round(parent.width * 0.7) + UM.Theme.getSize("sidebar_margin").width - anchors.right: parent.right - style: UM.Theme.styles.sidebar_header_button - activeFocusOnPress: true; - menu: PrinterTypeMenu { } - } - } - // Extruder Row Item { @@ -264,6 +226,47 @@ Column visible: !extruderSelectionRow.visible } + // Printer Type Row + Item + { + id: printerTypeSelectionRow + height: UM.Theme.getSize("sidebar_setup").height + visible: printerConnected && hasManyPrinterTypes && !sidebar.monitoringPrint && !sidebar.hideSettings + + anchors + { + left: parent.left + leftMargin: UM.Theme.getSize("sidebar_margin").width + right: parent.right + rightMargin: UM.Theme.getSize("sidebar_margin").width + } + + Label + { + id: configurationLabel + text: catalog.i18nc("@label", "Printer type"); + width: Math.round(parent.width * 0.4 - UM.Theme.getSize("default_margin").width) + height: parent.height + verticalAlignment: Text.AlignVCenter + font: UM.Theme.getFont("default"); + color: UM.Theme.getColor("text"); + } + + ToolButton + { + id: printerTypeSelection + text: Cura.MachineManager.activeMachineDefinitionName + tooltip: Cura.MachineManager.activeMachineDefinitionName + height: UM.Theme.getSize("setting_control").height + width: Math.round(parent.width * 0.7) + UM.Theme.getSize("sidebar_margin").width + anchors.right: parent.right + style: UM.Theme.styles.sidebar_header_button + activeFocusOnPress: true; + + menu: PrinterTypeMenu { } + } + } + // Material Row Item {