From 7cfb29e337ae47884c0faf80be7394ea19ddb604 Mon Sep 17 00:00:00 2001 From: Aleksei S Date: Thu, 20 Dec 2018 18:12:40 +0100 Subject: [PATCH 01/15] If a connected printer has a selected material which is unknown for Cura then show a message for downloading it from Marketplace CURA-6033 --- .../ConfigurationMenu/ConfigurationItem.qml | 104 +++++++++++++++++- 1 file changed, 102 insertions(+), 2 deletions(-) diff --git a/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml b/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml index 862e1475a9..16d683adca 100644 --- a/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml +++ b/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml @@ -14,6 +14,23 @@ Button property var configuration: null hoverEnabled: true + property bool isValidMaterial: + { + var extruderConfigurations = configuration.extruderConfigurations + + for (var index = 0; index < extruderConfigurations.length; index++) + { + var name = extruderConfigurations[index].material.brand ? extruderConfigurations[index].material.name : "" + + if (name == "" || name == "Unknown") + { + hoverEnabled = false + return false + } + } + return true + } + background: Rectangle { color: parent.hovered ? UM.Theme.getColor("action_button_hovered") : UM.Theme.getColor("action_button") @@ -40,19 +57,102 @@ Button right: parent.right rightMargin: UM.Theme.getSize("wide_margin").width } - + height: childrenRect.height spacing: UM.Theme.getSize("default_margin").width Repeater { id: repeater - model: configuration.extruderConfigurations + model: + { + if (configurationItem.isValidMaterial) + { + return configuration.extruderConfigurations + } + return [] + } + delegate: PrintCoreConfiguration { width: Math.round(parent.width / 2) printCoreConfiguration: modelData } } + + // Unknown material + Rectangle + { + id: unknownMaterial + height: unknownMaterialMessage.height + UM.Theme.getSize("thin_margin").width / 2 + width: parent.width + + anchors.top: parent.top + anchors.topMargin: + { + return UM.Theme.getSize("thin_margin").width / 2 + } + + visible: !configurationItem.isValidMaterial + + UM.RecolorImage + { + id: icon + anchors.verticalCenter: unknownMaterialMessage.verticalCenter + + source: UM.Theme.getIcon("warning") + color: UM.Theme.getColor("warning") + width: UM.Theme.getSize("section_icon").width + height: width + } + + Label + { + id: unknownMaterialMessage + text: + { + var extruderConfigurations = configuration.extruderConfigurations + var unknownMaterials = [] + for (var index = 0; index < extruderConfigurations.length; index++) + { + var name = extruderConfigurations[index].material.brand ? extruderConfigurations[index].material.name : "" + + if (name == "" || name == "Unknown") + { + unknownMaterials.push(extruderConfigurations[index].material.brand ? extruderConfigurations[index].material.brand : "Unknown Brand") + } + } + + unknownMaterials = "" + unknownMaterials + "" + var draftResult = catalog.i18nc("@label", "This configuration is not available because %1 is not recognized. Please visit %2 to download the correct material profile."); + var result = draftResult.arg(unknownMaterials).arg("" + catalog.i18nc("@label","Marketplace") + " ") + + return result + } + width: extruderRow.width + + anchors.left: icon.right + anchors.right: unknownMaterial.right + anchors.leftMargin: UM.Theme.getSize("wide_margin").height + anchors.top: unknownMaterial.top + + wrapMode: Text.WordWrap + font: UM.Theme.getFont("default") + color: UM.Theme.getColor("text") + verticalAlignment: Text.AlignVCenter + linkColor: UM.Theme.getColor("text_link") + + onLinkActivated: + { + Cura.Actions.browsePackages.trigger() + } + } + + MouseArea { + anchors.fill: parent + cursorShape: unknownMaterialMessage.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor + acceptedButtons: Qt.NoButton + } + } } //Buildplate row separator From 9430c421ebcf202caca4c6dda40af920678e396d Mon Sep 17 00:00:00 2001 From: Aleksei S Date: Thu, 20 Dec 2018 18:19:59 +0100 Subject: [PATCH 02/15] Code refactor CURA-6033 --- resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml b/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml index 16d683adca..4cf0437098 100644 --- a/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml +++ b/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml @@ -87,10 +87,7 @@ Button width: parent.width anchors.top: parent.top - anchors.topMargin: - { - return UM.Theme.getSize("thin_margin").width / 2 - } + anchors.topMargin: UM.Theme.getSize("thin_margin").width / 2 visible: !configurationItem.isValidMaterial From 81a6531f47f3b7356146827f27a8bf430b93a94e Mon Sep 17 00:00:00 2001 From: Aleksei S Date: Thu, 20 Dec 2018 20:37:48 +0100 Subject: [PATCH 03/15] Fix range slider label position in LayerSlider.qml. --- plugins/SimulationView/LayerSlider.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/SimulationView/LayerSlider.qml b/plugins/SimulationView/LayerSlider.qml index 42b8cf0ba0..88f298d1f5 100644 --- a/plugins/SimulationView/LayerSlider.qml +++ b/plugins/SimulationView/LayerSlider.qml @@ -163,9 +163,9 @@ Item id: rangleHandleLabel height: sliderRoot.handleSize + UM.Theme.getSize("default_margin").height - x: parent.x + parent.width + UM.Theme.getSize("default_margin").width + x: parent.x - width - UM.Theme.getSize("default_margin").width anchors.verticalCenter: parent.verticalCenter - target: Qt.point(sliderRoot.width + width, y + height / 2) + target: Qt.point(sliderRoot.width, y + height / 2) visible: sliderRoot.activeHandle == parent // custom properties From 01783e7f685cda2a24ce6a0de846ab7cca79d17d Mon Sep 17 00:00:00 2001 From: Aleksei S Date: Fri, 21 Dec 2018 13:54:01 +0100 Subject: [PATCH 04/15] Check material name instead of material brand CURA-6033 --- resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml b/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml index 4cf0437098..9e2fed0767 100644 --- a/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml +++ b/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml @@ -20,7 +20,7 @@ Button for (var index = 0; index < extruderConfigurations.length; index++) { - var name = extruderConfigurations[index].material.brand ? extruderConfigurations[index].material.name : "" + var name = extruderConfigurations[index].material ? extruderConfigurations[index].material.name : "" if (name == "" || name == "Unknown") { @@ -111,7 +111,7 @@ Button var unknownMaterials = [] for (var index = 0; index < extruderConfigurations.length; index++) { - var name = extruderConfigurations[index].material.brand ? extruderConfigurations[index].material.name : "" + var name = extruderConfigurations[index].material ? extruderConfigurations[index].material.name : "" if (name == "" || name == "Unknown") { From c8994102da49ac08f3fcd041df12c7ffaa12eb88 Mon Sep 17 00:00:00 2001 From: Aleksei S Date: Fri, 21 Dec 2018 14:44:25 +0100 Subject: [PATCH 05/15] Use short for each javascript function CURA-6033 --- .../qml/Menus/ConfigurationMenu/ConfigurationItem.qml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml b/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml index 9e2fed0767..b23bcc4b8c 100644 --- a/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml +++ b/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml @@ -18,7 +18,7 @@ Button { var extruderConfigurations = configuration.extruderConfigurations - for (var index = 0; index < extruderConfigurations.length; index++) + for (var index in extruderConfigurations) { var name = extruderConfigurations[index].material ? extruderConfigurations[index].material.name : "" @@ -109,7 +109,7 @@ Button { var extruderConfigurations = configuration.extruderConfigurations var unknownMaterials = [] - for (var index = 0; index < extruderConfigurations.length; index++) + for (var index in extruderConfigurations) { var name = extruderConfigurations[index].material ? extruderConfigurations[index].material.name : "" @@ -144,7 +144,8 @@ Button } } - MouseArea { + MouseArea + { anchors.fill: parent cursorShape: unknownMaterialMessage.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor acceptedButtons: Qt.NoButton From e8ea742cf6c9cb533604fd7741a94381a33b27d7 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 21 Dec 2018 16:27:38 +0100 Subject: [PATCH 06/15] Retain binding with isValidMaterial on hover So that if a material becomes valid, it updates this property. Contributes to issue CURA-6033. --- resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml b/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml index b23bcc4b8c..31569c58d2 100644 --- a/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml +++ b/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml @@ -12,7 +12,7 @@ Button id: configurationItem property var configuration: null - hoverEnabled: true + hoverEnabled: isValidMaterial property bool isValidMaterial: { @@ -24,7 +24,6 @@ Button if (name == "" || name == "Unknown") { - hoverEnabled = false return false } } From 5e9854454185fee9490b0d9aa996d36f65b7e2fd Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 21 Dec 2018 16:33:16 +0100 Subject: [PATCH 07/15] Don't change the model depending on isValidMaterial That would cause a circular dependency in a way. Contributes to issue CURA-6033. --- .../qml/Menus/ConfigurationMenu/ConfigurationItem.qml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml b/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml index 31569c58d2..6a17353459 100644 --- a/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml +++ b/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml @@ -62,19 +62,13 @@ Button Repeater { id: repeater - model: - { - if (configurationItem.isValidMaterial) - { - return configuration.extruderConfigurations - } - return [] - } + model: configuration.extruderConfigurations delegate: PrintCoreConfiguration { width: Math.round(parent.width / 2) printCoreConfiguration: modelData + visible: configurationItem.isValidMaterial } } From a720cca5b6f279696e398e96abe919491c12775e Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 21 Dec 2018 16:40:24 +0100 Subject: [PATCH 08/15] Fix background colour for dark theme The default colour for Rectangle is white. So this Rectangle, not defining a colour, became white. Instead we should use an Item, which cannot have a background colour and thus becomes transparent, making the background colour the same as the button below, which was intended. It's also slightly faster to render. Contributes to issue CURA-6033. --- resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml b/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml index 6a17353459..81f2183488 100644 --- a/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml +++ b/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml @@ -73,7 +73,7 @@ Button } // Unknown material - Rectangle + Item { id: unknownMaterial height: unknownMaterialMessage.height + UM.Theme.getSize("thin_margin").width / 2 From 2277a3d316ae2ded6c8f6df18e43de9277181e38 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 21 Dec 2018 16:43:45 +0100 Subject: [PATCH 09/15] Prevent syncing with invalid configurations Contributes to issue CURA-6033. --- resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml b/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml index 81f2183488..75a1b21186 100644 --- a/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml +++ b/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml @@ -216,6 +216,9 @@ Button onClicked: { - Cura.MachineManager.applyRemoteConfiguration(configuration) + if(isValidMaterial) + { + Cura.MachineManager.applyRemoteConfiguration(configuration); + } } } From a16e40650754f45f178cdc33f0ef9076863cd55b Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 31 Dec 2018 11:01:30 +0100 Subject: [PATCH 10/15] Properly display the full type + brand of unknown material CURA-6033 --- .../src/ClusterUM3OutputDevice.py | 3 ++- .../ConfigurationMenu/ConfigurationItem.qml | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/plugins/UM3NetworkPrinting/src/ClusterUM3OutputDevice.py b/plugins/UM3NetworkPrinting/src/ClusterUM3OutputDevice.py index bebccc54e3..5e8aaa9fa9 100644 --- a/plugins/UM3NetworkPrinting/src/ClusterUM3OutputDevice.py +++ b/plugins/UM3NetworkPrinting/src/ClusterUM3OutputDevice.py @@ -620,8 +620,9 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): if material_group_list is None: material_name = i18n_catalog.i18nc("@label:material", "Empty") if len(material_data.get("guid", "")) == 0 \ else i18n_catalog.i18nc("@label:material", "Unknown") + return MaterialOutputModel(guid = material_data.get("guid", ""), - type = material_data.get("type", ""), + type = material_data.get("material", ""), color = material_data.get("color", ""), brand = material_data.get("brand", ""), name = material_data.get("name", material_name) diff --git a/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml b/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml index 75a1b21186..51ba77d012 100644 --- a/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml +++ b/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml @@ -105,10 +105,22 @@ Button for (var index in extruderConfigurations) { var name = extruderConfigurations[index].material ? extruderConfigurations[index].material.name : "" - if (name == "" || name == "Unknown") { - unknownMaterials.push(extruderConfigurations[index].material.brand ? extruderConfigurations[index].material.brand : "Unknown Brand") + var materialType = extruderConfigurations[index].material.type + if (extruderConfigurations[index].material.type == "") + { + materialType = "Unknown" + } + + var brand = extruderConfigurations[index].material.brand + if (brand == "") + { + brand = "Unknown" + } + + name = materialType + " (" + brand + ")" + unknownMaterials.push(name) } } From fd9b29fee2558e9e387d2cdb9f74fed5c69bbf53 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 31 Dec 2018 11:09:39 +0100 Subject: [PATCH 11/15] Rename printersModel to GlobalStacksModel This is a better description for the model anyway. CURA-6011 --- cura/CuraApplication.py | 4 ++-- cura/{PrintersModel.py => GlobalStacksModel.py} | 3 ++- resources/qml/Menus/LocalPrinterMenu.qml | 2 +- resources/qml/Menus/NetworkPrinterMenu.qml | 2 +- resources/qml/PrinterSelector/MachineSelectorList.qml | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) rename cura/{PrintersModel.py => GlobalStacksModel.py} (97%) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 905c367cd1..0edf6c1899 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -51,7 +51,7 @@ from cura.Arranging.ArrangeObjectsJob import ArrangeObjectsJob from cura.Arranging.ArrangeObjectsAllBuildPlatesJob import ArrangeObjectsAllBuildPlatesJob from cura.Arranging.ShapeArray import ShapeArray from cura.MultiplyObjectsJob import MultiplyObjectsJob -from cura.PrintersModel import PrintersModel +from cura.GlobalStacksModel import GlobalStacksModel from cura.Scene.ConvexHullDecorator import ConvexHullDecorator from cura.Operations.SetParentOperation import SetParentOperation from cura.Scene.SliceableObjectDecorator import SliceableObjectDecorator @@ -971,7 +971,7 @@ class CuraApplication(QtApplication): qmlRegisterType(MultiBuildPlateModel, "Cura", 1, 0, "MultiBuildPlateModel") qmlRegisterType(InstanceContainer, "Cura", 1, 0, "InstanceContainer") qmlRegisterType(ExtrudersModel, "Cura", 1, 0, "ExtrudersModel") - qmlRegisterType(PrintersModel, "Cura", 1, 0, "PrintersModel") + qmlRegisterType(GlobalStacksModel, "Cura", 1, 0, "GlobalStacksModel") qmlRegisterType(FavoriteMaterialsModel, "Cura", 1, 0, "FavoriteMaterialsModel") qmlRegisterType(GenericMaterialsModel, "Cura", 1, 0, "GenericMaterialsModel") diff --git a/cura/PrintersModel.py b/cura/GlobalStacksModel.py similarity index 97% rename from cura/PrintersModel.py rename to cura/GlobalStacksModel.py index 8b5d2f6cc9..8ae6b05291 100644 --- a/cura/PrintersModel.py +++ b/cura/GlobalStacksModel.py @@ -12,7 +12,8 @@ from cura.PrinterOutputDevice import ConnectionType from cura.Settings.GlobalStack import GlobalStack -class PrintersModel(ListModel): + +class GlobalStacksModel(ListModel): NameRole = Qt.UserRole + 1 IdRole = Qt.UserRole + 2 HasRemoteConnectionRole = Qt.UserRole + 3 diff --git a/resources/qml/Menus/LocalPrinterMenu.qml b/resources/qml/Menus/LocalPrinterMenu.qml index e7c5037814..4da1de2abf 100644 --- a/resources/qml/Menus/LocalPrinterMenu.qml +++ b/resources/qml/Menus/LocalPrinterMenu.qml @@ -9,7 +9,7 @@ import Cura 1.0 as Cura Instantiator { - model: Cura.PrintersModel {} + model: Cura.GlobalStacksModel {} MenuItem { diff --git a/resources/qml/Menus/NetworkPrinterMenu.qml b/resources/qml/Menus/NetworkPrinterMenu.qml index 8c607bc5ae..3cb0aae016 100644 --- a/resources/qml/Menus/NetworkPrinterMenu.qml +++ b/resources/qml/Menus/NetworkPrinterMenu.qml @@ -9,7 +9,7 @@ import Cura 1.0 as Cura Instantiator { - model: Cura.PrintersModel {} + model: Cura.GlobalStacksModel {} MenuItem { text: model.metadata["connect_group_name"] diff --git a/resources/qml/PrinterSelector/MachineSelectorList.qml b/resources/qml/PrinterSelector/MachineSelectorList.qml index ea8068fa95..62ecf48cc5 100644 --- a/resources/qml/PrinterSelector/MachineSelectorList.qml +++ b/resources/qml/PrinterSelector/MachineSelectorList.qml @@ -11,7 +11,7 @@ ListView { id: listView height: childrenRect.height - model: Cura.PrintersModel {} + model: Cura.GlobalStacksModel {} section.property: "hasRemoteConnection" section.delegate: Label From 1277fbabc588634a78b6544f10abdcbc16f9c8ad Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 31 Dec 2018 11:15:03 +0100 Subject: [PATCH 12/15] Fix connection type not always being seen correctly CURA-6011 --- cura/GlobalStacksModel.py | 3 +-- cura/Settings/MachineManager.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/cura/GlobalStacksModel.py b/cura/GlobalStacksModel.py index 8ae6b05291..b0052900cd 100644 --- a/cura/GlobalStacksModel.py +++ b/cura/GlobalStacksModel.py @@ -54,9 +54,8 @@ class GlobalStacksModel(ListModel): container_stacks = ContainerRegistry.getInstance().findContainerStacks(type = "machine") for container_stack in container_stacks: - connection_type = container_stack.getMetaDataEntry("connection_type") + connection_type = int(container_stack.getMetaDataEntry("connection_type", "-1")) has_remote_connection = connection_type in [ConnectionType.NetworkConnection.value, ConnectionType.CloudConnection.value] - if container_stack.getMetaDataEntry("hidden", False) in ["True", True]: continue diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index 2185bbce9d..5b99b73b3c 100755 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -527,7 +527,7 @@ class MachineManager(QObject): @pyqtProperty(bool, notify = printerConnectedStatusChanged) def activeMachineHasRemoteConnection(self) -> bool: if self._global_container_stack: - connection_type = self._global_container_stack.getMetaDataEntry("connection_type") + connection_type = int(self._global_container_stack.getMetaDataEntry("connection_type", "-1")) return connection_type in [ConnectionType.NetworkConnection.value, ConnectionType.CloudConnection.value] return False From 89040b6d8f9957d41b92c7b88bc78f6fb25fca2e Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 31 Dec 2018 11:18:17 +0100 Subject: [PATCH 13/15] Remove unneeded nameChanged signal connection CURA-6011 --- cura/GlobalStacksModel.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/cura/GlobalStacksModel.py b/cura/GlobalStacksModel.py index b0052900cd..3ad110b7d0 100644 --- a/cura/GlobalStacksModel.py +++ b/cura/GlobalStacksModel.py @@ -42,14 +42,8 @@ class GlobalStacksModel(ListModel): if isinstance(container, GlobalStack): self._update() - ## Handler for container name change events. - def _onContainerNameChanged(self): - self._update() - def _update(self) -> None: items = [] - for container in self._container_stacks: - container.nameChanged.disconnect(self._onContainerNameChanged) container_stacks = ContainerRegistry.getInstance().findContainerStacks(type = "machine") From d9d1c93bd08d262a52aafe61024498ea4421f9a3 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 31 Dec 2018 11:25:23 +0100 Subject: [PATCH 14/15] Use "NotConnected" as default for the connection state CURA-6011 --- cura/GlobalStacksModel.py | 2 +- cura/PrinterOutputDevice.py | 4 ++-- cura/Settings/MachineManager.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cura/GlobalStacksModel.py b/cura/GlobalStacksModel.py index 3ad110b7d0..939809151d 100644 --- a/cura/GlobalStacksModel.py +++ b/cura/GlobalStacksModel.py @@ -48,7 +48,7 @@ class GlobalStacksModel(ListModel): container_stacks = ContainerRegistry.getInstance().findContainerStacks(type = "machine") for container_stack in container_stacks: - connection_type = int(container_stack.getMetaDataEntry("connection_type", "-1")) + connection_type = int(container_stack.getMetaDataEntry("connection_type", ConnectionType.NotConnected.value)) has_remote_connection = connection_type in [ConnectionType.NetworkConnection.value, ConnectionType.CloudConnection.value] if container_stack.getMetaDataEntry("hidden", False) in ["True", True]: continue diff --git a/cura/PrinterOutputDevice.py b/cura/PrinterOutputDevice.py index aeeb0381b2..99e8835c2f 100644 --- a/cura/PrinterOutputDevice.py +++ b/cura/PrinterOutputDevice.py @@ -36,7 +36,7 @@ class ConnectionState(IntEnum): class ConnectionType(IntEnum): - Unknown = 0 + NotConnected = 0 UsbConnection = 1 NetworkConnection = 2 CloudConnection = 3 @@ -74,7 +74,7 @@ class PrinterOutputDevice(QObject, OutputDevice): # Signal to indicate that the configuration of one of the printers has changed. uniqueConfigurationsChanged = pyqtSignal() - def __init__(self, device_id: str, connection_type: "ConnectionType" = ConnectionType.Unknown, parent: QObject = None) -> None: + def __init__(self, device_id: str, connection_type: "ConnectionType" = ConnectionType.NotConnected, parent: QObject = None) -> None: super().__init__(device_id = device_id, parent = parent) # type: ignore # MyPy complains with the multiple inheritance self._printers = [] # type: List[PrinterOutputModel] diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index 5b99b73b3c..32b83ead28 100755 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -527,7 +527,7 @@ class MachineManager(QObject): @pyqtProperty(bool, notify = printerConnectedStatusChanged) def activeMachineHasRemoteConnection(self) -> bool: if self._global_container_stack: - connection_type = int(self._global_container_stack.getMetaDataEntry("connection_type", "-1")) + connection_type = int(self._global_container_stack.getMetaDataEntry("connection_type", ConnectionType.NotConnected.value)) return connection_type in [ConnectionType.NetworkConnection.value, ConnectionType.CloudConnection.value] return False From 8dbebaa23c0ba8132e0245a62221cababb6bf3b4 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 31 Dec 2018 13:14:08 +0100 Subject: [PATCH 15/15] Ensure that the machine selector list scales properly The old implementation directly listend to the height (instead of childrenRect). This caused issues, since other things apart from adding / removing machines could influence the height. CURA-6060 --- resources/qml/PrinterSelector/MachineSelector.qml | 8 +++++--- resources/qml/PrinterSelector/MachineSelectorList.qml | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/resources/qml/PrinterSelector/MachineSelector.qml b/resources/qml/PrinterSelector/MachineSelector.qml index 28e01c7ae9..9f0d3b4ac6 100644 --- a/resources/qml/PrinterSelector/MachineSelector.qml +++ b/resources/qml/PrinterSelector/MachineSelector.qml @@ -93,14 +93,16 @@ Cura.ExpandablePopup width: scroll.width - scroll.leftPadding - scroll.rightPadding property real maximumHeight: UM.Theme.getSize("machine_selector_widget_content").height - buttonRow.height - onHeightChanged: + // We use an extra property here, since we only want to to be informed about the content size changes. + onContentHeightChanged: { - scroll.height = Math.min(height, maximumHeight) + scroll.height = Math.min(contentHeight, maximumHeight) popup.height = scroll.height + buttonRow.height } + Component.onCompleted: { - scroll.height = Math.min(height, maximumHeight) + scroll.height = Math.min(contentHeight, maximumHeight) popup.height = scroll.height + buttonRow.height } diff --git a/resources/qml/PrinterSelector/MachineSelectorList.qml b/resources/qml/PrinterSelector/MachineSelectorList.qml index 62ecf48cc5..604e0f668d 100644 --- a/resources/qml/PrinterSelector/MachineSelectorList.qml +++ b/resources/qml/PrinterSelector/MachineSelectorList.qml @@ -10,9 +10,9 @@ import Cura 1.0 as Cura ListView { id: listView - height: childrenRect.height model: Cura.GlobalStacksModel {} section.property: "hasRemoteConnection" + property real contentHeight: childrenRect.height section.delegate: Label {