From da23eff2a657377575c15c375ebffa0c0e6d6415 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 9 Aug 2018 13:28:08 +0200 Subject: [PATCH 01/67] Codestyle changes --- .../UM3NetworkPrinting/ClusterControlItem.qml | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index 5cf550955c..3d7b25d59c 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -41,14 +41,18 @@ Component Rectangle { id: printJobArea + border.width: UM.Theme.getSize("default_lining").width border.color: lineColor - anchors.top: activePrintersLabel.bottom - anchors.topMargin: UM.Theme.getSize("default_margin").height - anchors.left: parent.left - anchors.leftMargin: UM.Theme.getSize("default_margin").width - anchors.right: parent.right - anchors.rightMargin:UM.Theme.getSize("default_margin").width + + anchors + { + top: activePrintersLabel.bottom + margins: UM.Theme.getSize("default_margin").width + left: parent.left + right: parent.right + } + radius: cornerRadius height: childrenRect.height @@ -81,12 +85,14 @@ Component Column { id: printJobColumn - anchors.top: printJobTitleBar.bottom - anchors.topMargin: UM.Theme.getSize("default_margin").height - anchors.left: parent.left - anchors.leftMargin: UM.Theme.getSize("default_margin").width - anchors.right: parent.right - anchors.rightMargin: UM.Theme.getSize("default_margin").width + + anchors + { + top: printJobTitleBar.bottom + margins: UM.Theme.getSize("default_margin").height + right: parent.right + left: parent.left + } Item { @@ -99,6 +105,7 @@ Component font: UM.Theme.getFont("very_small") } + Label { text: manager.activePrintJobs.length @@ -106,6 +113,7 @@ Component anchors.right: parent.right } } + Item { width: parent.width @@ -116,6 +124,7 @@ Component text: catalog.i18nc("@label", "Queued") font: UM.Theme.getFont("very_small") } + Label { text: manager.queuedPrintJobs.length @@ -124,6 +133,7 @@ Component } } } + OpenPanelButton { anchors.top: printJobColumn.bottom From 86be07b095929bfd70c1870db96df063e7384c9c Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 9 Aug 2018 16:22:35 +0200 Subject: [PATCH 02/67] Refactored the config models so they they function are more stand alone units. The seperation of concern got a bit mixed up, as the printer output model was connecting the signals that the config model needed to function together. With these changes it's now also possible to use the config model as a part of a printjob, since printjobs can also have a configuration --- cura/PrinterOutput/ConfigurationModel.py | 8 ++- .../ExtruderConfigurationModel.py | 35 ++++++---- cura/PrinterOutput/ExtruderOutputModel.py | 65 +++++++++---------- cura/PrinterOutput/PrinterOutputModel.py | 16 +++-- 4 files changed, 67 insertions(+), 57 deletions(-) diff --git a/cura/PrinterOutput/ConfigurationModel.py b/cura/PrinterOutput/ConfigurationModel.py index c03d968b9e..a3d6afd01d 100644 --- a/cura/PrinterOutput/ConfigurationModel.py +++ b/cura/PrinterOutput/ConfigurationModel.py @@ -27,7 +27,13 @@ class ConfigurationModel(QObject): return self._printer_type def setExtruderConfigurations(self, extruder_configurations): - self._extruder_configurations = extruder_configurations + if self._extruder_configurations != extruder_configurations: + self._extruder_configurations = extruder_configurations + + for extruder_configuration in self._extruder_configurations: + extruder_configuration.extruderConfigurationChanged.connect(self.configurationChanged) + + self.configurationChanged.emit() @pyqtProperty("QVariantList", fset = setExtruderConfigurations, notify = configurationChanged) def extruderConfigurations(self): diff --git a/cura/PrinterOutput/ExtruderConfigurationModel.py b/cura/PrinterOutput/ExtruderConfigurationModel.py index bc7f1a7c07..250237403f 100644 --- a/cura/PrinterOutput/ExtruderConfigurationModel.py +++ b/cura/PrinterOutput/ExtruderConfigurationModel.py @@ -1,8 +1,11 @@ # Copyright (c) 2018 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. +from typing import Optional from PyQt5.QtCore import pyqtProperty, QObject, pyqtSignal +from cura.PrinterOutput.MaterialOutputModel import MaterialOutputModel + class ExtruderConfigurationModel(QObject): @@ -10,38 +13,42 @@ class ExtruderConfigurationModel(QObject): def __init__(self): super().__init__() - self._position = -1 - self._material = None - self._hotend_id = None + self._position = -1 # type: int + self._material = None # type: Optional[MaterialOutputModel] + self._hotend_id = None # type: Optional[str] - def setPosition(self, position): + def setPosition(self, position: int) -> None: self._position = position @pyqtProperty(int, fset = setPosition, notify = extruderConfigurationChanged) - def position(self): + def position(self) -> int: return self._position - def setMaterial(self, material): - self._material = material + def setMaterial(self, material: Optional[MaterialOutputModel]): + if self._hotend_id != material: + self._material = material + self.extruderConfigurationChanged.emit() @pyqtProperty(QObject, fset = setMaterial, notify = extruderConfigurationChanged) - def material(self): + def material(self) -> MaterialOutputModel: return self._material - def setHotendID(self, hotend_id): - self._hotend_id = hotend_id + def setHotendID(self, hotend_id: Optional[str]) -> None: + if self._hotend_id != hotend_id: + self._hotend_id = hotend_id + self.extruderConfigurationChanged.emit() @pyqtProperty(str, fset = setHotendID, notify = extruderConfigurationChanged) - def hotendID(self): + def hotendID(self) -> Optional[str]: return self._hotend_id ## This method is intended to indicate whether the configuration is valid or not. # The method checks if the mandatory fields are or not set # At this moment is always valid since we allow to have empty material and variants. - def isValid(self): + def isValid(self) -> bool: return True - def __str__(self): + def __str__(self) -> str: message_chunks = [] message_chunks.append("Position: " + str(self._position)) message_chunks.append("-") @@ -50,7 +57,7 @@ class ExtruderConfigurationModel(QObject): message_chunks.append("HotendID: " + self.hotendID if self.hotendID else "empty") return " ".join(message_chunks) - def __eq__(self, other): + def __eq__(self, other) -> bool: return hash(self) == hash(other) # Calculating a hash function using the position of the extruder, the material GUID and the hotend id to check if is diff --git a/cura/PrinterOutput/ExtruderOutputModel.py b/cura/PrinterOutput/ExtruderOutputModel.py index 0726662c6c..546227123e 100644 --- a/cura/PrinterOutput/ExtruderOutputModel.py +++ b/cura/PrinterOutput/ExtruderOutputModel.py @@ -12,64 +12,61 @@ if TYPE_CHECKING: class ExtruderOutputModel(QObject): - hotendIDChanged = pyqtSignal() targetHotendTemperatureChanged = pyqtSignal() hotendTemperatureChanged = pyqtSignal() - activeMaterialChanged = pyqtSignal() + extruderConfigurationChanged = pyqtSignal() isPreheatingChanged = pyqtSignal() - def __init__(self, printer: "PrinterOutputModel", position, parent=None) -> None: + def __init__(self, printer: "PrinterOutputModel", position: int, parent=None) -> None: super().__init__(parent) - self._printer = printer + self._printer = printer # type: PrinterOutputModel self._position = position - self._target_hotend_temperature = 0 # type: float - self._hotend_temperature = 0 # type: float - self._hotend_id = "" - self._active_material = None # type: Optional[MaterialOutputModel] - self._extruder_configuration = ExtruderConfigurationModel() - self._extruder_configuration.position = self._position + self._target_hotend_temperature = 0 # type: float + self._hotend_temperature = 0 # type: float self._is_preheating = False - def getPrinter(self): + # The extruder output model wraps the configuration model. This way we can use the same config model for jobs + # and extruders alike. + self._extruder_configuration = ExtruderConfigurationModel() + self._extruder_configuration.position = self._position + self._extruder_configuration.extruderConfigurationChanged.connect(self.extruderConfigurationChanged) + + def getPrinter(self) -> "PrinterOutputModel": return self._printer - def getPosition(self): + def getPosition(self) -> int: return self._position # Does the printer support pre-heating the bed at all @pyqtProperty(bool, constant=True) - def canPreHeatHotends(self): + def canPreHeatHotends(self) -> bool: if self._printer: return self._printer.canPreHeatHotends return False - @pyqtProperty(QObject, notify = activeMaterialChanged) + @pyqtProperty(QObject, notify = extruderConfigurationChanged) def activeMaterial(self) -> Optional["MaterialOutputModel"]: - return self._active_material + return self._extruder_configuration.material def updateActiveMaterial(self, material: Optional["MaterialOutputModel"]): - if self._active_material != material: - self._active_material = material - self._extruder_configuration.material = self._active_material - self.activeMaterialChanged.emit() - self.extruderConfigurationChanged.emit() + self._extruder_configuration.setMaterial(material) ## Update the hotend temperature. This only changes it locally. - def updateHotendTemperature(self, temperature: float): + def updateHotendTemperature(self, temperature: float) -> None: if self._hotend_temperature != temperature: self._hotend_temperature = temperature self.hotendTemperatureChanged.emit() - def updateTargetHotendTemperature(self, temperature: float): + def updateTargetHotendTemperature(self, temperature: float) -> None: if self._target_hotend_temperature != temperature: self._target_hotend_temperature = temperature self.targetHotendTemperatureChanged.emit() ## Set the target hotend temperature. This ensures that it's actually sent to the remote. @pyqtSlot(float) - def setTargetHotendTemperature(self, temperature: float): + def setTargetHotendTemperature(self, temperature: float) -> None: self._printer.getController().setTargetHotendTemperature(self._printer, self, temperature) self.updateTargetHotendTemperature(temperature) @@ -81,30 +78,26 @@ class ExtruderOutputModel(QObject): def hotendTemperature(self) -> float: return self._hotend_temperature - @pyqtProperty(str, notify = hotendIDChanged) + @pyqtProperty(str, notify = extruderConfigurationChanged) def hotendID(self) -> str: - return self._hotend_id + return self._extruder_configuration.hotendID - def updateHotendID(self, id: str): - if self._hotend_id != id: - self._hotend_id = id - self._extruder_configuration.hotendID = self._hotend_id - self.hotendIDChanged.emit() - self.extruderConfigurationChanged.emit() + def updateHotendID(self, hotend_id: str) -> None: + self._extruder_configuration.setHotendID(hotend_id) @pyqtProperty(QObject, notify = extruderConfigurationChanged) - def extruderConfiguration(self): + def extruderConfiguration(self) -> Optional[ExtruderConfigurationModel]: if self._extruder_configuration.isValid(): return self._extruder_configuration return None - def updateIsPreheating(self, pre_heating): + def updateIsPreheating(self, pre_heating: bool) -> None: if self._is_preheating != pre_heating: self._is_preheating = pre_heating self.isPreheatingChanged.emit() @pyqtProperty(bool, notify=isPreheatingChanged) - def isPreheating(self): + def isPreheating(self) -> bool: return self._is_preheating ## Pre-heats the extruder before printer. @@ -113,9 +106,9 @@ class ExtruderOutputModel(QObject): # Celsius. # \param duration How long the bed should stay warm, in seconds. @pyqtSlot(float, float) - def preheatHotend(self, temperature, duration): + def preheatHotend(self, temperature: float, duration: float) -> None: self._printer._controller.preheatHotend(self, temperature, duration) @pyqtSlot() - def cancelPreheatHotend(self): + def cancelPreheatHotend(self) -> None: self._printer._controller.cancelPreheatHotend(self) \ No newline at end of file diff --git a/cura/PrinterOutput/PrinterOutputModel.py b/cura/PrinterOutput/PrinterOutputModel.py index f10d6bd75b..a849cb76f2 100644 --- a/cura/PrinterOutput/PrinterOutputModel.py +++ b/cura/PrinterOutput/PrinterOutputModel.py @@ -43,9 +43,13 @@ class PrinterOutputModel(QObject): self._is_preheating = False self._printer_type = "" self._buildplate_name = None - # Update the printer configuration every time any of the extruders changes its configuration - for extruder in self._extruders: - extruder.extruderConfigurationChanged.connect(self._updateExtruderConfiguration) + + + self._printer_configuration.extruderConfigurations = [extruder.extruderConfiguration for extruder in + self._extruders] + + #for extruder_configuration in self._printer_configuration.extruderConfigurations: + # extruder_configuration.extruderConfigurationChanged.connect(self.configurationChanged) self._camera = None @@ -284,6 +288,6 @@ class PrinterOutputModel(QObject): return self._printer_configuration return None - def _updateExtruderConfiguration(self): - self._printer_configuration.extruderConfigurations = [extruder.extruderConfiguration for extruder in self._extruders] - self.configurationChanged.emit() + #def _updateExtruderConfiguration(self): + + #self.configurationChanged.emit() From 74f8c82c5e32f147b6e47eb95a6f68b43a7e79f2 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 9 Aug 2018 16:38:30 +0200 Subject: [PATCH 03/67] Removed commented out code --- cura/PrinterOutput/PrinterOutputModel.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/cura/PrinterOutput/PrinterOutputModel.py b/cura/PrinterOutput/PrinterOutputModel.py index a849cb76f2..ba567b7bac 100644 --- a/cura/PrinterOutput/PrinterOutputModel.py +++ b/cura/PrinterOutput/PrinterOutputModel.py @@ -44,13 +44,9 @@ class PrinterOutputModel(QObject): self._printer_type = "" self._buildplate_name = None - self._printer_configuration.extruderConfigurations = [extruder.extruderConfiguration for extruder in self._extruders] - #for extruder_configuration in self._printer_configuration.extruderConfigurations: - # extruder_configuration.extruderConfigurationChanged.connect(self.configurationChanged) - self._camera = None @pyqtProperty(str, constant = True) @@ -286,8 +282,4 @@ class PrinterOutputModel(QObject): def printerConfiguration(self): if self._printer_configuration.isValid(): return self._printer_configuration - return None - - #def _updateExtruderConfiguration(self): - - #self.configurationChanged.emit() + return None \ No newline at end of file From 78ebdb13f4bf3ae6521eea0f3518090a2a77da3d Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 14 Aug 2018 13:34:05 +0200 Subject: [PATCH 04/67] Cluster monitor page now shows queue instead of added printers CL-894 --- cura/CuraApplication.py | 2 +- .../ExtruderConfigurationModel.py | 4 +- cura/PrinterOutput/ExtruderOutputModel.py | 4 +- cura/PrinterOutput/PrintJobOutputModel.py | 13 ++ .../UM3NetworkPrinting/ClusterControlItem.qml | 15 +- .../UM3NetworkPrinting/ClusterMonitorItem.qml | 30 ++-- .../ClusterUM3OutputDevice.py | 56 ++++--- .../PrintCoreConfiguration.qml | 4 +- .../UM3NetworkPrinting/PrintJobInfoBlock.qml | 140 ++++++++++++++++++ 9 files changed, 224 insertions(+), 44 deletions(-) create mode 100644 plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 78986d82ee..df25522be3 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -123,7 +123,7 @@ except ImportError: CuraVersion = "master" # [CodeStyle: Reflecting imported value] CuraBuildType = "" CuraDebugMode = False - CuraSDKVerion = "" + CuraSDKVersion = "" class CuraApplication(QtApplication): diff --git a/cura/PrinterOutput/ExtruderConfigurationModel.py b/cura/PrinterOutput/ExtruderConfigurationModel.py index 250237403f..2a7844b629 100644 --- a/cura/PrinterOutput/ExtruderConfigurationModel.py +++ b/cura/PrinterOutput/ExtruderConfigurationModel.py @@ -30,7 +30,7 @@ class ExtruderConfigurationModel(QObject): self.extruderConfigurationChanged.emit() @pyqtProperty(QObject, fset = setMaterial, notify = extruderConfigurationChanged) - def material(self) -> MaterialOutputModel: + def activeMaterial(self) -> MaterialOutputModel: return self._material def setHotendID(self, hotend_id: Optional[str]) -> None: @@ -52,7 +52,7 @@ class ExtruderConfigurationModel(QObject): message_chunks = [] message_chunks.append("Position: " + str(self._position)) message_chunks.append("-") - message_chunks.append("Material: " + self.material.type if self.material else "empty") + message_chunks.append("Material: " + self.activeMaterial.type if self.activeMaterial else "empty") message_chunks.append("-") message_chunks.append("HotendID: " + self.hotendID if self.hotendID else "empty") return " ".join(message_chunks) diff --git a/cura/PrinterOutput/ExtruderOutputModel.py b/cura/PrinterOutput/ExtruderOutputModel.py index 546227123e..c7fd58c098 100644 --- a/cura/PrinterOutput/ExtruderOutputModel.py +++ b/cura/PrinterOutput/ExtruderOutputModel.py @@ -48,7 +48,7 @@ class ExtruderOutputModel(QObject): @pyqtProperty(QObject, notify = extruderConfigurationChanged) def activeMaterial(self) -> Optional["MaterialOutputModel"]: - return self._extruder_configuration.material + return self._extruder_configuration.activeMaterial def updateActiveMaterial(self, material: Optional["MaterialOutputModel"]): self._extruder_configuration.setMaterial(material) @@ -111,4 +111,4 @@ class ExtruderOutputModel(QObject): @pyqtSlot() def cancelPreheatHotend(self) -> None: - self._printer._controller.cancelPreheatHotend(self) \ No newline at end of file + self._printer._controller.cancelPreheatHotend(self) diff --git a/cura/PrinterOutput/PrintJobOutputModel.py b/cura/PrinterOutput/PrintJobOutputModel.py index b77600f85c..8057965013 100644 --- a/cura/PrinterOutput/PrintJobOutputModel.py +++ b/cura/PrinterOutput/PrintJobOutputModel.py @@ -7,6 +7,7 @@ from typing import Optional, TYPE_CHECKING if TYPE_CHECKING: from cura.PrinterOutput.PrinterOutputController import PrinterOutputController from cura.PrinterOutput.PrinterOutputModel import PrinterOutputModel + from cura.PrinterOutput.ConfigurationModel import ConfigurationModel class PrintJobOutputModel(QObject): @@ -17,6 +18,7 @@ class PrintJobOutputModel(QObject): keyChanged = pyqtSignal() assignedPrinterChanged = pyqtSignal() ownerChanged = pyqtSignal() + configurationChanged =pyqtSignal() def __init__(self, output_controller: "PrinterOutputController", key: str = "", name: str = "", parent=None) -> None: super().__init__(parent) @@ -29,6 +31,17 @@ class PrintJobOutputModel(QObject): self._assigned_printer = None # type: Optional[PrinterOutputModel] self._owner = "" # Who started/owns the print job? + self._configuration = None # type: Optional[ConfigurationModel] + + @pyqtProperty(QObject, notify=configurationChanged) + def configuration(self) -> Optional["ConfigurationModel"]: + return self._configuration + + def updateConfiguration(self, configuration: Optional["ConfigurationModel"]) -> None: + if self._configuration != configuration: + self._configuration = configuration + self.configurationChanged.emit() + @pyqtProperty(str, notify=ownerChanged) def owner(self): return self._owner diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index 3d7b25d59c..5531e99d57 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -27,13 +27,14 @@ Component { id: activePrintersLabel font: UM.Theme.getFont("large") - anchors.horizontalCenter: parent.horizontalCenter - anchors.topMargin: UM.Theme.getSize("default_margin").height - anchors.top: parent.top - anchors.left: parent.left - anchors.leftMargin: UM.Theme.getSize("default_margin").width - anchors.right:parent.right - anchors.rightMargin: UM.Theme.getSize("default_margin").width + anchors + { + margins: UM.Theme.getSize("default_margin").width + top: parent.top + left: parent.left + right: parent.right + } + text: Cura.MachineManager.printerOutputDevices[0].name elide: Text.ElideRight } diff --git a/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml b/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml index 0e86d55de8..51301b7e8d 100644 --- a/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml @@ -28,7 +28,8 @@ Component id: activePrintersLabel font: UM.Theme.getFont("large") - anchors { + anchors + { top: parent.top topMargin: UM.Theme.getSize("default_margin").height * 2 // a bit more spacing to give it some breathing room horizontalCenter: parent.horizontalCenter @@ -71,25 +72,28 @@ Component ScrollView { - id: printerScrollView - anchors.margins: UM.Theme.getSize("default_margin").width - anchors.top: activePrintersLabel.bottom - anchors.bottom: parent.bottom - anchors.left: parent.left - anchors.leftMargin: UM.Theme.getSize("default_lining").width // To ensure border can be drawn. - anchors.rightMargin: UM.Theme.getSize("default_lining").width - anchors.right: parent.right + id: queuedPrintJobs + + anchors + { + margins: UM.Theme.getSize("default_margin").width + top: activePrintersLabel.bottom + left: parent.left + leftMargin: UM.Theme.getSize("default_lining").width // To ensure border can be drawn. + rightMargin: UM.Theme.getSize("default_lining").width + right: parent.right + } ListView { anchors.fill: parent spacing: -UM.Theme.getSize("default_lining").height - model: OutputDevice.printers + model: OutputDevice.queuedPrintJobs - delegate: PrinterInfoBlock + delegate: PrintJobInfoBlock { - printer: modelData + printJob: modelData width: Math.min(800 * screenScaleFactor, maximumWidth) height: 125 * screenScaleFactor @@ -102,7 +106,7 @@ Component PrinterVideoStream { visible: OutputDevice.activePrinter != null - anchors.fill:parent + anchors.fill: parent } onVisibleChanged: diff --git a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py index 84e0a66170..d91e7e1d93 100644 --- a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py +++ b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py @@ -17,6 +17,8 @@ from UM.Scene.SceneNode import SceneNode #For typing. from UM.Version import Version #To check against firmware versions for support. from cura.CuraApplication import CuraApplication +from cura.PrinterOutput.ConfigurationModel import ConfigurationModel +from cura.PrinterOutput.ExtruderConfigurationModel import ExtruderConfigurationModel from cura.PrinterOutput.NetworkedPrinterOutputDevice import NetworkedPrinterOutputDevice, AuthState from cura.PrinterOutput.PrinterOutputModel import PrinterOutputModel from cura.PrinterOutput.PrintJobOutputModel import PrintJobOutputModel @@ -478,6 +480,23 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): def _createPrintJobModel(self, data: Dict[str, Any]) -> PrintJobOutputModel: print_job = PrintJobOutputModel(output_controller=ClusterUM3PrinterOutputController(self), key=data["uuid"], name= data["name"]) + + configuration = ConfigurationModel() + extruders = [] + for index in range(0, self._number_of_extruders): + extruder = ExtruderConfigurationModel() + extruder.setPosition(index) + try: + extruder_data = data["configuration"][index] + except IndexError: + break + + extruder.setHotendID(extruder_data.get("print_core_id", "")) + extruder.setMaterial(self._createMaterialOutputModel(extruder_data.get("material", {}))) + extruders.append(extruder) + configuration.setExtruderConfigurations(extruders) + print_job.updateConfiguration(configuration) + print_job.stateChanged.connect(self._printJobStateChanged) self._print_jobs.append(print_job) return print_job @@ -488,6 +507,24 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): print_job.updateState(data["status"]) print_job.updateOwner(data["owner"]) + def _createMaterialOutputModel(self, material_data) -> MaterialOutputModel: + containers = ContainerRegistry.getInstance().findInstanceContainers(type="material", GUID=material_data["guid"]) + if containers: + color = containers[0].getMetaDataEntry("color_code") + brand = containers[0].getMetaDataEntry("brand") + material_type = containers[0].getMetaDataEntry("material") + name = containers[0].getName() + else: + Logger.log("w", + "Unable to find material with guid {guid}. Using data as provided by cluster".format( + guid=material_data["guid"])) + color = material_data["color"] + brand = material_data["brand"] + material_type = material_data["material"] + name = "Empty" if material_data["material"] == "empty" else "Unknown" + return MaterialOutputModel(guid=material_data["guid"], type=material_type, + brand=brand, color=color, name=name) + def _updatePrinter(self, printer: PrinterOutputModel, data: Dict[str, Any]) -> None: # For some unknown reason the cluster wants UUID for everything, except for sending a job directly to a printer. # Then we suddenly need the unique name. So in order to not have to mess up all the other code, we save a mapping. @@ -523,24 +560,7 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): material_data = extruder_data["material"] if extruder.activeMaterial is None or extruder.activeMaterial.guid != material_data["guid"]: - containers = ContainerRegistry.getInstance().findInstanceContainers(type="material", - GUID=material_data["guid"]) - if containers: - color = containers[0].getMetaDataEntry("color_code") - brand = containers[0].getMetaDataEntry("brand") - material_type = containers[0].getMetaDataEntry("material") - name = containers[0].getName() - else: - Logger.log("w", - "Unable to find material with guid {guid}. Using data as provided by cluster".format( - guid=material_data["guid"])) - color = material_data["color"] - brand = material_data["brand"] - material_type = material_data["material"] - name = "Empty" if material_data["material"] == "empty" else "Unknown" - - material = MaterialOutputModel(guid=material_data["guid"], type=material_type, - brand=brand, color=color, name=name) + material = self._createMaterialOutputModel(material_data) extruder.updateActiveMaterial(material) def _removeJob(self, job: PrintJobOutputModel) -> bool: diff --git a/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml b/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml index 267516091b..6ff5c6327f 100644 --- a/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml +++ b/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml @@ -12,14 +12,16 @@ Item width: Math.round(parent.width / 2) height: childrenRect.height + Label { id: materialLabel - text: printCoreConfiguration.activeMaterial != null ? printCoreConfiguration.activeMaterial.name : "" + text: printCoreConfiguration.activeMaterial != null ? printCoreConfiguration.activeMaterial.name : ":(" elide: Text.ElideRight width: parent.width font: UM.Theme.getFont("very_small") } + Label { id: printCoreLabel diff --git a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml new file mode 100644 index 0000000000..f88b917954 --- /dev/null +++ b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml @@ -0,0 +1,140 @@ +import QtQuick 2.2 +import QtQuick.Controls 1.4 +import QtQuick.Controls.Styles 1.4 + +import UM 1.3 as UM + + +Item +{ + property var printJob: null + + function getPrettyTime(time) + { + return OutputDevice.formatDuration(time) + } + + Rectangle + { + id: background + anchors.fill: parent + + Item + { + // Content on the left of the infobox + anchors + { + top: parent.top + bottom: parent.bottom + left: parent.left + right: parent.horizontalCenter + margins: UM.Theme.getSize("default_margin").width + } + + Label + { + id: printJobName + text: "printJobName" + } + + Label + { + id: ownerName + anchors.top: printJobName.bottom + text: "OwnerName" + } + + Label + { + id: totalTimeLabel + + anchors.bottom: parent.bottom + anchors.right: parent.right + + text: printJob != null ? getPrettyTime(printJob.timeTotal) : "3h 12m" + elide: Text.ElideRight + } + } + + Item + { + // Content on the right side of the infobox. + anchors + { + top: parent.top + bottom: parent.bottom + left: parent.horizontalCenter + right: parent.right + margins: UM.Theme.getSize("default_margin").width + } + + Label + { + id: targetPrinterLabel + text: "Waiting for: first available" + } + + Button + { + text: "..." + anchors + { + right: parent.right + top: parent.top + } + } + + // PrintCore && Material config + Row + { + id: extruderInfo + anchors.bottom: parent.bottom + + anchors + { + left: parent.left + right: parent.right + } + height: childrenRect.height + + spacing: UM.Theme.getSize("default_margin").width + + PrintCoreConfiguration + { + id: leftExtruderInfo + width: Math.round((parent.width - extruderSeperator.width) / 2) + printCoreConfiguration: printJob.configuration.extruderConfigurations[0] + } + + Rectangle + { + id: extruderSeperator + width: UM.Theme.getSize("default_lining").width + height: parent.height + color: lineColor + } + + PrintCoreConfiguration + { + id: rightExtruderInfo + width: Math.round((parent.width - extruderSeperator.width) / 2) + printCoreConfiguration: printJob.configuration.extruderConfigurations[1] + } + } + + } + + Rectangle + { + color: "grey" + width: 1 + + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.margins: UM.Theme.getSize("default_margin").height + anchors.horizontalCenter: parent.horizontalCenter + + } + + } +} \ No newline at end of file From 94b978211065c17a5b9ab020f1278f9a7b0c00ee Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 14 Aug 2018 14:54:27 +0200 Subject: [PATCH 05/67] Added preview image to print cluster monitor CL-894 --- cura/CuraApplication.py | 2 ++ cura/PrintJobPreviewImageProvider.py | 27 +++++++++++++++++++ cura/PrinterOutput/PrintJobOutputModel.py | 27 ++++++++++++++++++- .../UM3NetworkPrinting/ClusterMonitorItem.qml | 3 ++- .../ClusterUM3OutputDevice.py | 19 ++++++++++++- .../UM3NetworkPrinting/PrintJobInfoBlock.qml | 9 +++++++ 6 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 cura/PrintJobPreviewImageProvider.py diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index df25522be3..c29ddf10fd 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -94,6 +94,7 @@ from . import CuraActions from cura.Scene import ZOffsetDecorator from . import CuraSplashScreen from . import CameraImageProvider +from . import PrintJobPreviewImageProvider from . import MachineActionManager from cura.TaskManagement.OnExitCallbackManager import OnExitCallbackManager @@ -523,6 +524,7 @@ class CuraApplication(QtApplication): def _onEngineCreated(self): self._qml_engine.addImageProvider("camera", CameraImageProvider.CameraImageProvider()) + self._qml_engine.addImageProvider("print_job_preview", PrintJobPreviewImageProvider.PrintJobPreviewImageProvider()) @pyqtProperty(bool) def needToShowUserAgreement(self): diff --git a/cura/PrintJobPreviewImageProvider.py b/cura/PrintJobPreviewImageProvider.py new file mode 100644 index 0000000000..d3521bf0af --- /dev/null +++ b/cura/PrintJobPreviewImageProvider.py @@ -0,0 +1,27 @@ +from PyQt5.QtGui import QImage +from PyQt5.QtQuick import QQuickImageProvider +from PyQt5.QtCore import QSize + +from UM.Application import Application + + +class PrintJobPreviewImageProvider(QQuickImageProvider): + def __init__(self): + super().__init__(QQuickImageProvider.Image) + + ## Request a new image. + def requestImage(self, id, size): + # The id will have an uuid and an increment separated by a slash. As we don't care about the value of the + # increment, we need to strip that first. + uuid = id[id.find("/") + 1:] + for output_device in Application.getInstance().getOutputDeviceManager().getOutputDevices(): + if not hasattr(output_device, "printJobs"): + continue + + for print_job in output_device.printJobs: + if print_job.key == uuid: + if print_job.getPreviewImage(): + return print_job.getPreviewImage(), QSize(15, 15) + else: + return QImage(), QSize(15, 15) + return QImage(), QSize(15,15) \ No newline at end of file diff --git a/cura/PrinterOutput/PrintJobOutputModel.py b/cura/PrinterOutput/PrintJobOutputModel.py index 8057965013..373f816373 100644 --- a/cura/PrinterOutput/PrintJobOutputModel.py +++ b/cura/PrinterOutput/PrintJobOutputModel.py @@ -4,6 +4,9 @@ from PyQt5.QtCore import pyqtSignal, pyqtProperty, QObject, pyqtSlot from typing import Optional, TYPE_CHECKING +from PyQt5.QtCore import QUrl +from PyQt5.QtGui import QImage + if TYPE_CHECKING: from cura.PrinterOutput.PrinterOutputController import PrinterOutputController from cura.PrinterOutput.PrinterOutputModel import PrinterOutputModel @@ -18,7 +21,8 @@ class PrintJobOutputModel(QObject): keyChanged = pyqtSignal() assignedPrinterChanged = pyqtSignal() ownerChanged = pyqtSignal() - configurationChanged =pyqtSignal() + configurationChanged = pyqtSignal() + previewImageChanged = pyqtSignal() def __init__(self, output_controller: "PrinterOutputController", key: str = "", name: str = "", parent=None) -> None: super().__init__(parent) @@ -33,6 +37,27 @@ class PrintJobOutputModel(QObject): self._configuration = None # type: Optional[ConfigurationModel] + self._preview_image_id = 0 + + self._preview_image = None + + @pyqtProperty(QUrl, notify=previewImageChanged) + def preview_image_url(self): + self._preview_image_id += 1 + # There is an image provider that is called "camera". In order to ensure that the image qml object, that + # requires a QUrl to function, updates correctly we add an increasing number. This causes to see the QUrl + # as new (instead of relying on cached version and thus forces an update. + temp = "image://print_job_preview/" + str(self._preview_image_id) + "/" + self._key + return QUrl(temp, QUrl.TolerantMode) + + def getPreviewImage(self): + return self._preview_image + + def updatePreviewImage(self, preview_image: Optional[QImage]): + if self._preview_image != preview_image: + self._preview_image = preview_image + self.previewImageChanged.emit() + @pyqtProperty(QObject, notify=configurationChanged) def configuration(self) -> Optional["ConfigurationModel"]: return self._configuration diff --git a/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml b/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml index 51301b7e8d..3bc9fedc9c 100644 --- a/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml @@ -82,12 +82,13 @@ Component leftMargin: UM.Theme.getSize("default_lining").width // To ensure border can be drawn. rightMargin: UM.Theme.getSize("default_lining").width right: parent.right + bottom: parent.bottom } ListView { anchors.fill: parent - spacing: -UM.Theme.getSize("default_lining").height + spacing: UM.Theme.getSize("default_margin").height model: OutputDevice.queuedPrintJobs diff --git a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py index d91e7e1d93..b79ad6b5ce 100644 --- a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py +++ b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py @@ -29,7 +29,7 @@ from .ClusterUM3PrinterOutputController import ClusterUM3PrinterOutputController from .SendMaterialJob import SendMaterialJob from PyQt5.QtNetwork import QNetworkRequest, QNetworkReply -from PyQt5.QtGui import QDesktopServices +from PyQt5.QtGui import QDesktopServices, QImage from PyQt5.QtCore import pyqtSlot, QUrl, pyqtSignal, pyqtProperty, QObject from time import time @@ -394,11 +394,28 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): super().connect() self.sendMaterialProfiles() + def _onGetPreviewImageFinished(self, reply: QNetworkReply) -> None: + reply_url = reply.url().toString() + print(reply_url) + + uuid = reply_url[reply_url.find("print_jobs/")+len("print_jobs/"):reply_url.rfind("/preview_image")] + + print_job = findByKey(self._print_jobs, uuid) + if print_job: + image = QImage() + image.loadFromData(reply.readAll()) + print_job.updatePreviewImage(image) + + def _update(self) -> None: super()._update() self.get("printers/", on_finished = self._onGetPrintersDataFinished) self.get("print_jobs/", on_finished = self._onGetPrintJobsFinished) + for print_job in self._print_jobs: + if print_job.getPreviewImage() is None: + self.get("print_jobs/{uuid}/preview_image".format(uuid=print_job.key), on_finished=self._onGetPreviewImageFinished) + def _onGetPrintJobsFinished(self, reply: QNetworkReply) -> None: if not checkValidGetReply(reply): return diff --git a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml index f88b917954..7ae65dfb9b 100644 --- a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml +++ b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml @@ -44,6 +44,15 @@ Item text: "OwnerName" } + Image + { + source: printJob.preview_image_url + anchors.top: ownerName.bottom + anchors.horizontalCenter: parent.horizontalCenter + anchors.bottom: totalTimeLabel.top + width: height + } + Label { id: totalTimeLabel From ef00550df6df4c84413c8f2fe71f67a5dbca811e Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 16 Aug 2018 15:04:00 +0200 Subject: [PATCH 06/67] Added send to top context item CL-894 --- .../ClusterUM3OutputDevice.py | 7 +++ .../UM3NetworkPrinting/PrintJobInfoBlock.qml | 60 ++++++++++++++++++- 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py index 3a9bf20789..c4e78403b1 100644 --- a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py +++ b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py @@ -366,6 +366,13 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): datetime_completed = datetime.fromtimestamp(current_time + time_remaining) return (datetime_completed.strftime("%a %b ") + "{day}".format(day=datetime_completed.day)).upper() + @pyqtSlot(str) + def sendJobToTop(self, print_job_uuid: str) -> None: + # This function is part of the output device (and not of the printjob output model) as this type of operation + # is a modification of the cluster queue and not of the actual job. + data = "{\"to_position\": 0}" + self.put("print_jobs/{uuid}/move_to_position".format(uuid = print_job_uuid), data, on_finished=None) + def _printJobStateChanged(self) -> None: username = self._getUserName() diff --git a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml index 7ae65dfb9b..086740416d 100644 --- a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml +++ b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml @@ -1,7 +1,8 @@ import QtQuick 2.2 -import QtQuick.Controls 1.4 +import QtQuick.Controls 2.0 import QtQuick.Controls.Styles 1.4 + import UM 1.3 as UM @@ -83,16 +84,73 @@ Item text: "Waiting for: first available" } + + function switchPopupState() + { + popup.visible ? popup.close() : popup.open() + } Button { + id: contextButton text: "..." anchors { right: parent.right top: parent.top } + onClicked: parent.switchPopupState() } + + Popup + { + // TODO Change once updating to Qt5.10 - The 'opened' property is in 5.10 but the behavior is now implemented with the visible property + id: popup + clip: true + closePolicy: Popup.CloseOnPressOutsideParent + x: parent.width - width + y: contextButton.height + //y: configurationSelector.height - UM.Theme.getSize("default_lining").height + //x: configurationSelector.width - width + width: 200 + height: childrenRect.height + visible: false + padding: UM.Theme.getSize("default_lining").width + transformOrigin: Popup.Top + contentItem: Item + { + width: panelWidth - 2 * popup.padding + height: cildrenRect.height + Button + { + text: "Send to top" + onClicked: OutputDevice.sendJobToTop(printJob.key) + width: parent.width + } + } + + background: Rectangle + { + color: UM.Theme.getColor("setting_control") + border.color: UM.Theme.getColor("setting_control_border") + } + + exit: Transition + { + // This applies a default NumberAnimation to any changes a state change makes to x or y properties + NumberAnimation { property: "visible"; duration: 75; } + } + enter: Transition + { + // This applies a default NumberAnimation to any changes a state change makes to x or y properties + NumberAnimation { property: "visible"; duration: 75; } + } + + onClosed: visible = false + onOpened: visible = true + } + + // PrintCore && Material config Row { From af4b7c38c7720184825be2896854e41ac8c3f1c3 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 16 Aug 2018 15:04:52 +0200 Subject: [PATCH 07/67] Removed stray debug print CL-894 --- plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py index c4e78403b1..e01021d6c8 100644 --- a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py +++ b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py @@ -403,7 +403,6 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): def _onGetPreviewImageFinished(self, reply: QNetworkReply) -> None: reply_url = reply.url().toString() - print(reply_url) uuid = reply_url[reply_url.find("print_jobs/")+len("print_jobs/"):reply_url.rfind("/preview_image")] From 0fe0e4ac5415e4d3640bfcfcc8dafaec3e4800c7 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 16 Aug 2018 15:23:16 +0200 Subject: [PATCH 08/67] Ensure that the order of the cluster queue is correctly show in monitor tab CL-894 --- plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py index e01021d6c8..befed8d4cf 100644 --- a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py +++ b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py @@ -432,12 +432,15 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): print_jobs_seen = [] job_list_changed = False - for print_job_data in result: + for idx, print_job_data in enumerate(result): print_job = findByKey(self._print_jobs, print_job_data["uuid"]) - if print_job is None: print_job = self._createPrintJobModel(print_job_data) job_list_changed = True + elif not job_list_changed: + # Check if the order of the jobs has changed since the last check + if self._print_jobs.index(print_job) != idx: + job_list_changed = True self._updatePrintJob(print_job, print_job_data) @@ -462,6 +465,8 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): job_list_changed = job_list_changed or self._removeJob(removed_job) if job_list_changed: + # Override the old list with the new list (either because jobs were removed / added or order changed) + self._print_jobs = print_jobs_seen self.printJobsChanged.emit() # Do a single emit for all print job changes. def _onGetPrintersDataFinished(self, reply: QNetworkReply) -> None: @@ -521,7 +526,6 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): print_job.updateConfiguration(configuration) print_job.stateChanged.connect(self._printJobStateChanged) - self._print_jobs.append(print_job) return print_job def _updatePrintJob(self, print_job: PrintJobOutputModel, data: Dict[str, Any]) -> None: From 5bee561c9ce73996b2ed689562d1570ba741705c Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 16 Aug 2018 15:54:35 +0200 Subject: [PATCH 09/67] Removed the static placeholders for monitor info CL-894 --- .../PrintCoreConfiguration.qml | 4 +-- .../UM3NetworkPrinting/PrintJobInfoBlock.qml | 34 +++++++++++++++---- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml b/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml index 6ff5c6327f..d2c88e148b 100644 --- a/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml +++ b/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml @@ -19,7 +19,7 @@ Item text: printCoreConfiguration.activeMaterial != null ? printCoreConfiguration.activeMaterial.name : ":(" elide: Text.ElideRight width: parent.width - font: UM.Theme.getFont("very_small") + font: UM.Theme.getFont("default_bold") } Label @@ -29,7 +29,5 @@ Item anchors.top: materialLabel.bottom elide: Text.ElideRight width: parent.width - font: UM.Theme.getFont("very_small") - opacity: 0.5 } } diff --git a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml index 086740416d..a1123d29fc 100644 --- a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml +++ b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml @@ -35,14 +35,15 @@ Item Label { id: printJobName - text: "printJobName" + text: printJob.name + font: UM.Theme.getFont("default_bold") } Label { id: ownerName anchors.top: printJobName.bottom - text: "OwnerName" + text: printJob.owner } Image @@ -61,7 +62,7 @@ Item anchors.bottom: parent.bottom anchors.right: parent.right - text: printJob != null ? getPrettyTime(printJob.timeTotal) : "3h 12m" + text: printJob != null ? getPrettyTime(printJob.timeTotal) : "" elide: Text.ElideRight } } @@ -81,7 +82,27 @@ Item Label { id: targetPrinterLabel - text: "Waiting for: first available" + elide: Text.ElideRight + font: UM.Theme.getFont("default_bold") + text: + { + if(printJob.assignedPrinter == null) + { + return "Waiting for: first available" + } + else + { + return "Waiting for: " + printJob.assignedPrinter.name + } + + } + + anchors + { + left: parent.left + right: contextButton.left + rightMargin: UM.Theme.getSize("default_margin").width + } } @@ -89,6 +110,7 @@ Item { popup.visible ? popup.close() : popup.open() } + Button { id: contextButton @@ -119,8 +141,8 @@ Item transformOrigin: Popup.Top contentItem: Item { - width: panelWidth - 2 * popup.padding - height: cildrenRect.height + width: popup.width - 2 * popup.padding + height: childrenRect.height Button { text: "Send to top" From 01b9ba03d46fd742e8b274afc2f1da9f24dd116b Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 16 Aug 2018 16:24:14 +0200 Subject: [PATCH 10/67] Added extruder icon CL-894 --- .../PrintCoreConfiguration.qml | 25 +++++++++++++++++++ .../UM3NetworkPrinting/PrintJobInfoBlock.qml | 14 +++-------- resources/qml/SidebarHeader.qml | 2 +- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml b/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml index d2c88e148b..c71d0d1f79 100644 --- a/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml +++ b/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml @@ -13,6 +13,27 @@ Item width: Math.round(parent.width / 2) height: childrenRect.height + Item + { + id: extruderCircle + width: 30 + height: 30 + Rectangle + { + anchors.fill: parent + radius: Math.round(width / 2) + border.width: 1 + border.color: "black" + } + + Label + { + anchors.centerIn: parent + font: UM.Theme.getFont("default_bold") + text: printCoreConfiguration.position + 1 + } + } + Label { id: materialLabel @@ -20,6 +41,8 @@ Item elide: Text.ElideRight width: parent.width font: UM.Theme.getFont("default_bold") + anchors.left: extruderCircle.right + anchors.leftMargin: UM.Theme.getSize("default_margin").height } Label @@ -29,5 +52,7 @@ Item anchors.top: materialLabel.bottom elide: Text.ElideRight width: parent.width + anchors.left: extruderCircle.right + anchors.leftMargin: UM.Theme.getSize("default_margin").height } } diff --git a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml index a1123d29fc..d581d774b7 100644 --- a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml +++ b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml @@ -110,7 +110,7 @@ Item { popup.visible ? popup.close() : popup.open() } - + Button { id: contextButton @@ -191,22 +191,14 @@ Item PrintCoreConfiguration { id: leftExtruderInfo - width: Math.round((parent.width - extruderSeperator.width) / 2) + width: Math.round(parent.width / 2) printCoreConfiguration: printJob.configuration.extruderConfigurations[0] } - Rectangle - { - id: extruderSeperator - width: UM.Theme.getSize("default_lining").width - height: parent.height - color: lineColor - } - PrintCoreConfiguration { id: rightExtruderInfo - width: Math.round((parent.width - extruderSeperator.width) / 2) + width: Math.round(parent.width / 2) printCoreConfiguration: printJob.configuration.extruderConfigurations[1] } } diff --git a/resources/qml/SidebarHeader.qml b/resources/qml/SidebarHeader.qml index 6ee33dd2f2..3a041ae499 100644 --- a/resources/qml/SidebarHeader.qml +++ b/resources/qml/SidebarHeader.qml @@ -274,7 +274,7 @@ Column elide: Text.ElideRight } - // Everthing for the extruder icon + // Everything for the extruder icon Item { id: extruderIconItem From d4aaa739282ba9b3505c02530b4b473793f4169d Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 17 Aug 2018 10:34:14 +0200 Subject: [PATCH 11/67] Codestyle fixes CL-894 --- .../ExtruderConfigurationModel.py | 4 ++ .../ClusterUM3OutputDevice.py | 69 ++++++++++--------- .../UM3NetworkPrinting/PrintJobInfoBlock.qml | 1 + 3 files changed, 40 insertions(+), 34 deletions(-) diff --git a/cura/PrinterOutput/ExtruderConfigurationModel.py b/cura/PrinterOutput/ExtruderConfigurationModel.py index 2a7844b629..19d53d1271 100644 --- a/cura/PrinterOutput/ExtruderConfigurationModel.py +++ b/cura/PrinterOutput/ExtruderConfigurationModel.py @@ -33,6 +33,10 @@ class ExtruderConfigurationModel(QObject): def activeMaterial(self) -> MaterialOutputModel: return self._material + @pyqtProperty(QObject, fset=setMaterial, notify=extruderConfigurationChanged) + def material(self) -> MaterialOutputModel: + return self._material + def setHotendID(self, hotend_id: Optional[str]) -> None: if self._hotend_id != hotend_id: self._hotend_id = hotend_id diff --git a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py index befed8d4cf..fffab6caec 100644 --- a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py +++ b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py @@ -4,17 +4,17 @@ from typing import Any, cast, Optional, Set, Tuple, Union from UM.FileHandler.FileHandler import FileHandler -from UM.FileHandler.FileWriter import FileWriter #To choose based on the output file mode (text vs. binary). -from UM.FileHandler.WriteFileJob import WriteFileJob #To call the file writer asynchronously. +from UM.FileHandler.FileWriter import FileWriter # To choose based on the output file mode (text vs. binary). +from UM.FileHandler.WriteFileJob import WriteFileJob # To call the file writer asynchronously. from UM.Logger import Logger from UM.Settings.ContainerRegistry import ContainerRegistry from UM.i18n import i18nCatalog -from UM.Mesh.MeshWriter import MeshWriter # For typing + from UM.Message import Message from UM.Qt.Duration import Duration, DurationFormat -from UM.OutputDevice import OutputDeviceError #To show that something went wrong when writing. -from UM.Scene.SceneNode import SceneNode #For typing. -from UM.Version import Version #To check against firmware versions for support. +from UM.OutputDevice import OutputDeviceError # To show that something went wrong when writing. +from UM.Scene.SceneNode import SceneNode # For typing. +from UM.Version import Version # To check against firmware versions for support. from cura.CuraApplication import CuraApplication from cura.PrinterOutput.ConfigurationModel import ConfigurationModel @@ -34,9 +34,9 @@ from PyQt5.QtCore import pyqtSlot, QUrl, pyqtSignal, pyqtProperty, QObject from time import time from datetime import datetime -from typing import Optional, Dict, List, Set +from typing import Optional, Dict, List -import io #To create the correct buffers for sending data to the printer. +import io # To create the correct buffers for sending data to the printer. import json import os @@ -67,18 +67,18 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): # See comments about this hack with the clusterPrintersChanged signal self.printersChanged.connect(self.clusterPrintersChanged) - self._accepts_commands = True #type: bool + self._accepts_commands = True # type: bool # Cluster does not have authentication, so default to authenticated self._authentication_state = AuthState.Authenticated - self._error_message = None #type: Optional[Message] - self._write_job_progress_message = None #type: Optional[Message] - self._progress_message = None #type: Optional[Message] + self._error_message = None # type: Optional[Message] + self._write_job_progress_message = None # type: Optional[Message] + self._progress_message = None # type: Optional[Message] self._active_printer = None # type: Optional[PrinterOutputModel] - self._printer_selection_dialog = None #type: QObject + self._printer_selection_dialog = None # type: QObject self.setPriority(3) # Make sure the output device gets selected above local file output self.setName(self._id) @@ -89,32 +89,33 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): self._printer_uuid_to_unique_name_mapping = {} # type: Dict[str, str] - self._finished_jobs = [] # type: List[PrintJobOutputModel] + self._finished_jobs = [] # type: List[PrintJobOutputModel] - self._cluster_size = int(properties.get(b"cluster_size", 0)) + self._cluster_size = int(properties.get(b"cluster_size", 0)) # type: int - self._latest_reply_handler = None #type: Optional[QNetworkReply] + self._latest_reply_handler = None # type: Optional[QNetworkReply] + self._sending_job = None def requestWrite(self, nodes: List[SceneNode], file_name: Optional[str] = None, limit_mimetypes: bool = False, file_handler: Optional[FileHandler] = None, **kwargs: str) -> None: self.writeStarted.emit(self) self.sendMaterialProfiles() - #Formats supported by this application (file types that we can actually write). + # Formats supported by this application (file types that we can actually write). if file_handler: file_formats = file_handler.getSupportedFileTypesWrite() else: file_formats = CuraApplication.getInstance().getMeshFileHandler().getSupportedFileTypesWrite() global_stack = CuraApplication.getInstance().getGlobalContainerStack() - #Create a list from the supported file formats string. + # Create a list from the supported file formats string. if not global_stack: Logger.log("e", "Missing global stack!") return machine_file_formats = global_stack.getMetaDataEntry("file_formats").split(";") machine_file_formats = [file_type.strip() for file_type in machine_file_formats] - #Exception for UM3 firmware version >=4.4: UFP is now supported and should be the preferred file format. + # Exception for UM3 firmware version >=4.4: UFP is now supported and should be the preferred file format. if "application/x-ufp" not in machine_file_formats and Version(self.firmwareVersion) >= Version("4.4"): machine_file_formats = ["application/x-ufp"] + machine_file_formats @@ -127,7 +128,7 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): raise OutputDeviceError.WriteRequestFailedError(i18n_catalog.i18nc("@info:status", "There are no file formats available to write with!")) preferred_format = file_formats[0] - #Just take the first file format available. + #J ust take the first file format available. if file_handler is not None: writer = file_handler.getWriterByMimeType(cast(str, preferred_format["mime_type"])) else: @@ -137,18 +138,18 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): Logger.log("e", "Unexpected error when trying to get the FileWriter") return - #This function pauses with the yield, waiting on instructions on which printer it needs to print with. + # This function pauses with the yield, waiting on instructions on which printer it needs to print with. if not writer: Logger.log("e", "Missing file or mesh writer!") return self._sending_job = self._sendPrintJob(writer, preferred_format, nodes) - self._sending_job.send(None) #Start the generator. + self._sending_job.send(None) # Start the generator. - if len(self._printers) > 1: #We need to ask the user. + if len(self._printers) > 1: # We need to ask the user. self._spawnPrinterSelectionDialog() is_job_sent = True - else: #Just immediately continue. - self._sending_job.send("") #No specifically selected printer. + else: # Just immediately continue. + self._sending_job.send("") # No specifically selected printer. is_job_sent = self._sending_job.send(None) def _spawnPrinterSelectionDialog(self): @@ -159,7 +160,7 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): self._printer_selection_dialog.show() @pyqtProperty(int, constant=True) - def clusterSize(self): + def clusterSize(self) -> int: return self._cluster_size ## Allows the user to choose a printer to print with from the printer @@ -216,8 +217,8 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): job.start() - yield True #Return that we had success! - yield #To prevent having to catch the StopIteration exception. + yield True # Return that we had success! + yield # To prevent having to catch the StopIteration exception. def _sendPrintJobWaitOnWriteJobFinished(self, job: WriteFileJob) -> None: if self._write_job_progress_message: @@ -242,7 +243,7 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): file_name = CuraApplication.getInstance().getPrintInformation().jobName + "." + preferred_format["extension"] - output = stream.getvalue() #Either str or bytes depending on the output mode. + output = stream.getvalue() # Either str or bytes depending on the output mode. if isinstance(stream, io.StringIO): output = cast(str, output).encode("utf-8") output = cast(bytes, output) @@ -281,8 +282,8 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): # If successfully sent: if bytes_sent == bytes_total: - # Show a confirmation to the user so they know the job was sucessful and provide the option to switch to the - # monitor tab. + # Show a confirmation to the user so they know the job was sucessful and provide the option to switch to + # the monitor tab. self._success_message = Message( i18n_catalog.i18nc("@info:status", "Print job was successfully sent to the printer."), lifetime=5, dismissable=True, @@ -412,7 +413,6 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): image.loadFromData(reply.readAll()) print_job.updatePreviewImage(image) - def _update(self) -> None: super()._update() self.get("printers/", on_finished = self._onGetPrintersDataFinished) @@ -615,6 +615,7 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): job = SendMaterialJob(device = self) job.run() + def loadJsonFromReply(reply: QNetworkReply) -> Optional[List[Dict[str, Any]]]: try: result = json.loads(bytes(reply.readAll()).decode("utf-8")) @@ -633,8 +634,8 @@ def checkValidGetReply(reply: QNetworkReply) -> bool: return True -def findByKey(list: List[Union[PrintJobOutputModel, PrinterOutputModel]], key: str) -> Optional[PrintJobOutputModel]: - for item in list: +def findByKey(lst: List[Union[PrintJobOutputModel, PrinterOutputModel]], key: str) -> Optional[PrintJobOutputModel]: + for item in lst: if item.key == key: return item return None diff --git a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml index d581d774b7..72b46339e5 100644 --- a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml +++ b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml @@ -148,6 +148,7 @@ Item text: "Send to top" onClicked: OutputDevice.sendJobToTop(printJob.key) width: parent.width + enabled: OutputDevice.printJobs[0].key != printJob.key } } From c968e54750136769ceb80f1f0925e77f1fb8ef4b Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 17 Aug 2018 10:38:23 +0200 Subject: [PATCH 12/67] Moved duplicated code to own function CL-894 --- .../NetworkedPrinterOutputDevice.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/cura/PrinterOutput/NetworkedPrinterOutputDevice.py b/cura/PrinterOutput/NetworkedPrinterOutputDevice.py index b7862251c9..5a9e12ae06 100644 --- a/cura/PrinterOutput/NetworkedPrinterOutputDevice.py +++ b/cura/PrinterOutput/NetworkedPrinterOutputDevice.py @@ -188,28 +188,27 @@ class NetworkedPrinterOutputDevice(PrinterOutputDevice): if reply in self._kept_alive_multiparts: del self._kept_alive_multiparts[reply] - def put(self, target: str, data: str, on_finished: Optional[Callable[[QNetworkReply], None]]) -> None: + def _validateManager(self) -> None: if self._manager is None: self._createNetworkManager() assert (self._manager is not None) + + def put(self, target: str, data: str, on_finished: Optional[Callable[[QNetworkReply], None]]) -> None: + self._validateManager() request = self._createEmptyRequest(target) self._last_request_time = time() reply = self._manager.put(request, data.encode()) self._registerOnFinishedCallback(reply, on_finished) def get(self, target: str, on_finished: Optional[Callable[[QNetworkReply], None]]) -> None: - if self._manager is None: - self._createNetworkManager() - assert (self._manager is not None) + self._validateManager() request = self._createEmptyRequest(target) self._last_request_time = time() reply = self._manager.get(request) self._registerOnFinishedCallback(reply, on_finished) def post(self, target: str, data: str, on_finished: Optional[Callable[[QNetworkReply], None]], on_progress: Callable = None) -> None: - if self._manager is None: - self._createNetworkManager() - assert (self._manager is not None) + self._validateManager() request = self._createEmptyRequest(target) self._last_request_time = time() reply = self._manager.post(request, data) @@ -218,10 +217,7 @@ class NetworkedPrinterOutputDevice(PrinterOutputDevice): self._registerOnFinishedCallback(reply, on_finished) def postFormWithParts(self, target: str, parts: List[QHttpPart], on_finished: Optional[Callable[[QNetworkReply], None]], on_progress: Callable = None) -> QNetworkReply: - - if self._manager is None: - self._createNetworkManager() - assert (self._manager is not None) + self._validateManager() request = self._createEmptyRequest(target, content_type=None) multi_post_part = QHttpMultiPart(QHttpMultiPart.FormDataType) for part in parts: From db1d90ed9b9940cb57634cc77dd1f47bdd0ebbdd Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 17 Aug 2018 10:38:46 +0200 Subject: [PATCH 13/67] Added delete function This is needed at a later stage to delete print jobs from queue by the cluster CL-894 --- cura/PrinterOutput/NetworkedPrinterOutputDevice.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cura/PrinterOutput/NetworkedPrinterOutputDevice.py b/cura/PrinterOutput/NetworkedPrinterOutputDevice.py index 5a9e12ae06..b7c0818c72 100644 --- a/cura/PrinterOutput/NetworkedPrinterOutputDevice.py +++ b/cura/PrinterOutput/NetworkedPrinterOutputDevice.py @@ -200,6 +200,13 @@ class NetworkedPrinterOutputDevice(PrinterOutputDevice): reply = self._manager.put(request, data.encode()) self._registerOnFinishedCallback(reply, on_finished) + def delete(self, target: str, on_finished: Optional[Callable[[QNetworkReply], None]]) -> None: + self._validateManager() + request = self._createEmptyRequest(target) + self._last_request_time = time() + reply = self._manager.delete(request) + self._registerOnFinishedCallback(reply, on_finished) + def get(self, target: str, on_finished: Optional[Callable[[QNetworkReply], None]]) -> None: self._validateManager() request = self._createEmptyRequest(target) From eb7d42a7f8307c68e85021bf264b1bed0bfd47d1 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 17 Aug 2018 10:49:44 +0200 Subject: [PATCH 14/67] Added delete button to cluster queue CL-894 --- cura/PrinterOutput/NetworkedPrinterOutputDevice.py | 2 +- plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py | 6 ++++++ plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml | 12 +++++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/cura/PrinterOutput/NetworkedPrinterOutputDevice.py b/cura/PrinterOutput/NetworkedPrinterOutputDevice.py index b7c0818c72..36369feabb 100644 --- a/cura/PrinterOutput/NetworkedPrinterOutputDevice.py +++ b/cura/PrinterOutput/NetworkedPrinterOutputDevice.py @@ -204,7 +204,7 @@ class NetworkedPrinterOutputDevice(PrinterOutputDevice): self._validateManager() request = self._createEmptyRequest(target) self._last_request_time = time() - reply = self._manager.delete(request) + reply = self._manager.deleteResource(request) self._registerOnFinishedCallback(reply, on_finished) def get(self, target: str, on_finished: Optional[Callable[[QNetworkReply], None]]) -> None: diff --git a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py index fffab6caec..cbb5f25ee8 100644 --- a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py +++ b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py @@ -374,6 +374,12 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): data = "{\"to_position\": 0}" self.put("print_jobs/{uuid}/move_to_position".format(uuid = print_job_uuid), data, on_finished=None) + @pyqtSlot(str) + def deleteJobFromQueue(self, print_job_uuid: str) -> None: + # This function is part of the output device (and not of the printjob output model) as this type of operation + # is a modification of the cluster queue and not of the actual job. + self.delete("print_jobs/{uuid}".format(uuid = print_job_uuid), on_finished=None) + def _printJobStateChanged(self) -> None: username = self._getUserName() diff --git a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml index 72b46339e5..0c30255b08 100644 --- a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml +++ b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml @@ -135,7 +135,7 @@ Item //y: configurationSelector.height - UM.Theme.getSize("default_lining").height //x: configurationSelector.width - width width: 200 - height: childrenRect.height + height: contentItem.height + 2 * padding visible: false padding: UM.Theme.getSize("default_lining").width transformOrigin: Popup.Top @@ -145,17 +145,27 @@ Item height: childrenRect.height Button { + id: sendToTopButton text: "Send to top" onClicked: OutputDevice.sendJobToTop(printJob.key) width: parent.width enabled: OutputDevice.printJobs[0].key != printJob.key } + Button + { + id: deleteButton + text: "Delete" + onClicked: OutputDevice.deleteJobFromQueue(printJob.key) + width: parent.width + anchors.top: sendToTopButton.bottom + } } background: Rectangle { color: UM.Theme.getColor("setting_control") border.color: UM.Theme.getColor("setting_control_border") + height: popup.height } exit: Transition From b074d2bdf38071406df0be2151ba38c777923b0b Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 17 Aug 2018 13:41:23 +0200 Subject: [PATCH 15/67] Added translations for the strings CL-894 --- plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml index 0c30255b08..daa2aa80bb 100644 --- a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml +++ b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml @@ -15,6 +15,12 @@ Item return OutputDevice.formatDuration(time) } + UM.I18nCatalog + { + id: catalog + name: "cura" + } + Rectangle { id: background @@ -88,11 +94,11 @@ Item { if(printJob.assignedPrinter == null) { - return "Waiting for: first available" + return catalog.i18nc("@label", "Waiting for: first available") } else { - return "Waiting for: " + printJob.assignedPrinter.name + return catalog.i18nc("@label", "Waiting for: ") + printJob.assignedPrinter.name } } @@ -146,7 +152,7 @@ Item Button { id: sendToTopButton - text: "Send to top" + text: catalog.i18nc("@label", "Move to top") onClicked: OutputDevice.sendJobToTop(printJob.key) width: parent.width enabled: OutputDevice.printJobs[0].key != printJob.key @@ -154,7 +160,7 @@ Item Button { id: deleteButton - text: "Delete" + text: catalog.i18nc("@label", "Delete") onClicked: OutputDevice.deleteJobFromQueue(printJob.key) width: parent.width anchors.top: sendToTopButton.bottom From 1fa3b60f942610ed0b3e4f066e066dc30be163c7 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 17 Aug 2018 16:10:23 +0200 Subject: [PATCH 16/67] Added rough outline of the redesigned cluster controlItem CL-893 --- .../UM3NetworkPrinting/ClusterControlItem.qml | 357 +++++++++--------- .../ClusterUM3OutputDevice.py | 4 + .../UM3NetworkPrinting/PrintJobInfoBlock.qml | 2 +- 3 files changed, 175 insertions(+), 188 deletions(-) diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index 5531e99d57..2fb0b36471 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -1,5 +1,6 @@ import QtQuick 2.2 import QtQuick.Controls 1.4 +import QtQuick.Controls.Styles 1.3 import UM 1.3 as UM import Cura 1.0 as Cura @@ -9,11 +10,9 @@ Component Rectangle { id: base - property var manager: Cura.MachineManager.printerOutputDevices[0] property var lineColor: "#DCDCDC" // TODO: Should be linked to theme. property var cornerRadius: 4 * screenScaleFactor // TODO: Should be linked to theme. - - visible: manager != null + visible: OutputDevice != null anchors.fill: parent color: UM.Theme.getColor("viewport_background") @@ -35,218 +34,202 @@ Component right: parent.right } - text: Cura.MachineManager.printerOutputDevices[0].name + text: OutputDevice.name elide: Text.ElideRight } - Rectangle - { - id: printJobArea - border.width: UM.Theme.getSize("default_lining").width - border.color: lineColor + ScrollView + { + id: queuedPrintJobs anchors { top: activePrintersLabel.bottom - margins: UM.Theme.getSize("default_margin").width left: parent.left right: parent.right + margins: UM.Theme.getSize("default_margin").width + bottom: parent.bottom } - - radius: cornerRadius - height: childrenRect.height - - Item + ListView { - id: printJobTitleBar - width: parent.width - height: printJobTitleLabel.height + 2 * UM.Theme.getSize("default_margin").height + anchors.fill: parent + spacing: UM.Theme.getSize("default_margin").height - Label - { - id: printJobTitleLabel - anchors.left: parent.left - anchors.leftMargin: UM.Theme.getSize("default_margin").width - anchors.top: parent.top - anchors.topMargin: UM.Theme.getSize("default_margin").height - text: catalog.i18nc("@title", "Print jobs") - font: UM.Theme.getFont("default") - opacity: 0.75 - } - Rectangle - { - anchors.bottom: parent.bottom - height: UM.Theme.getSize("default_lining").width - color: lineColor - width: parent.width - } - } - - Column - { - id: printJobColumn - - anchors - { - top: printJobTitleBar.bottom - margins: UM.Theme.getSize("default_margin").height - right: parent.right - left: parent.left - } - - Item + model: OutputDevice.printers + delegate: Rectangle { width: parent.width - height: childrenRect.height - opacity: 0.65 - Label - { - text: catalog.i18nc("@label", "Printing") - font: UM.Theme.getFont("very_small") + height: childrenRect.height + 2 * UM.Theme.getSize("default_margin").height - } - - Label - { - text: manager.activePrintJobs.length - font: UM.Theme.getFont("small") - anchors.right: parent.right - } - } - - Item - { - width: parent.width - height: childrenRect.height - opacity: 0.65 - Label - { - text: catalog.i18nc("@label", "Queued") - font: UM.Theme.getFont("very_small") - } - - Label - { - text: manager.queuedPrintJobs.length - font: UM.Theme.getFont("small") - anchors.right: parent.right - } - } - } - - OpenPanelButton - { - anchors.top: printJobColumn.bottom - anchors.left: parent.left - anchors.right: parent.right - anchors.margins: UM.Theme.getSize("default_margin").height - id: configButton - onClicked: base.manager.openPrintJobControlPanel() - text: catalog.i18nc("@action:button", "View print jobs") - } - - Item - { - // spacer - anchors.top: configButton.bottom - width: UM.Theme.getSize("default_margin").width - height: UM.Theme.getSize("default_margin").height - } - } - - - Rectangle - { - id: printersArea - border.width: UM.Theme.getSize("default_lining").width - border.color: lineColor - anchors.top: printJobArea.bottom - anchors.topMargin: UM.Theme.getSize("default_margin").height - anchors.left: parent.left - anchors.leftMargin: UM.Theme.getSize("default_margin").width - anchors.right: parent.right - anchors.rightMargin:UM.Theme.getSize("default_margin").width - radius: cornerRadius - height: childrenRect.height - - Item - { - id: printersTitleBar - width: parent.width - height: printJobTitleLabel.height + 2 * UM.Theme.getSize("default_margin").height - - Label - { - id: printersTitleLabel - anchors.left: parent.left - anchors.leftMargin: UM.Theme.getSize("default_margin").width - anchors.top: parent.top - anchors.topMargin: UM.Theme.getSize("default_margin").height - text: catalog.i18nc("@label:title", "Printers") - font: UM.Theme.getFont("default") - opacity: 0.75 - } - Rectangle - { - anchors.bottom: parent.bottom - height: UM.Theme.getSize("default_lining").width - color: lineColor - width: parent.width - } - } - Column - { - id: printersColumn - anchors.top: printersTitleBar.bottom - anchors.topMargin: UM.Theme.getSize("default_margin").height - anchors.left: parent.left - anchors.leftMargin: UM.Theme.getSize("default_margin").width - anchors.right: parent.right - anchors.rightMargin: UM.Theme.getSize("default_margin").width - - Repeater - { - model: manager.connectedPrintersTypeCount + id: base + property var collapsed: true Item { - width: parent.width - height: childrenRect.height - opacity: 0.65 - Label + id: printerInfo + height: machineIcon.height + anchors { - text: modelData.machine_type - font: UM.Theme.getFont("very_small") + top: parent.top + left: parent.left + right: parent.right + + margins: UM.Theme.getSize("default_margin").width + } + + MouseArea + { + anchors.fill: parent + onClicked: base.collapsed = !base.collapsed + enabled: modelData.activePrintJob != null + } + + Rectangle + { + id: machineIcon + anchors.top: parent.top + width: 50 + height: 50 + color: "blue" } Label { - text: modelData.count - font: UM.Theme.getFont("small") + id: machineNameLabel + text: modelData.name + anchors.top: machineIcon.top + anchors.left: machineIcon.right + anchors.leftMargin: UM.Theme.getSize("default_margin").width + anchors.right: collapseIcon.left + anchors.rightMargin: UM.Theme.getSize("default_margin").width + elide: Text.ElideRight + } + + UM.RecolorImage + { + id: collapseIcon + width: 15 + height: 15 + visible: modelData.activePrintJob != null + sourceSize.width: width + sourceSize.height: height + source: base.collapsed ? UM.Theme.getIcon("arrow_left") : UM.Theme.getIcon("arrow_bottom") + anchors.verticalCenter: parent.verticalCenter anchors.right: parent.right + anchors.rightMargin: UM.Theme.getSize("default_margin").width + color: "black" + } + + Label + { + id: activeJobLabel + text: modelData.activePrintJob != null ? modelData.activePrintJob.name : "waiting" + anchors.top: machineNameLabel.bottom + anchors.left: machineNameLabel.left + anchors.right: collapseIcon.left + anchors.rightMargin: UM.Theme.getSize("default_margin").width + elide: Text.ElideRight + } + } + + Item + { + id: detailedInfo + property var printJob: modelData.activePrintJob + visible: !base.collapsed + anchors.top: printerInfo.bottom + width: parent.width + height: visible ? childrenRect.height : 0 + + Rectangle + { + id: topSpacer + color: "grey" + height: 1 + anchors + { + left: parent.left + right: parent.right + margins: UM.Theme.getSize("default_margin").width + top: parent.top + } + } + + Row + { + id: extrudersInfo + anchors.top: topSpacer.bottom + anchors.topMargin : UM.Theme.getSize("default_margin").height + anchors.left: parent.left + anchors.leftMargin: UM.Theme.getSize("default_margin").width + anchors.right: parent.right + anchors.rightMargin: UM.Theme.getSize("default_margin").width + height: childrenRect.height + spacing: UM.Theme.getSize("default_margin").width + + PrintCoreConfiguration + { + id: leftExtruderInfo + width: Math.round(parent.width / 2) + printCoreConfiguration: modelData.printerConfiguration.extruderConfigurations[0] + } + + PrintCoreConfiguration + { + id: rightExtruderInfo + width: Math.round(parent.width / 2) + printCoreConfiguration: modelData.printerConfiguration.extruderConfigurations[1] + } + } + + Rectangle + { + id: jobSpacer + color: "grey" + height: 1 + anchors + { + left: parent.left + right: parent.right + margins: UM.Theme.getSize("default_margin").width + top: extrudersInfo.bottom + } + } + + Item + { + id: jobInfo + anchors.top: jobSpacer.bottom + anchors.left: parent.left + anchors.right: parent.right + anchors.margins: UM.Theme.getSize("default_margin").width + height: childrenRect.height + Label + { + id: printJobName + text: modelData.activePrintJob.name + font: UM.Theme.getFont("default_bold") + } + Label + { + id: ownerName + anchors.top: printJobName.bottom + text: modelData.activePrintJob.owner + } + + Image + { + source: modelData.activePrintJob.preview_image_url + anchors.top: ownerName.bottom + anchors.horizontalCenter: parent.horizontalCenter + anchors.bottom: totalTimeLabel.top + width: height + } + } } } } - OpenPanelButton - { - anchors.top: printersColumn.bottom - anchors.left: parent.left - anchors.right: parent.right - anchors.margins: UM.Theme.getSize("default_margin").height - id: printerConfigButton - onClicked: base.manager.openPrinterControlPanel() - - text: catalog.i18nc("@action:button", "View printers") - } - - Item - { - // spacer - anchors.top: printerConfigButton.bottom - width: UM.Theme.getSize("default_margin").width - height: UM.Theme.getSize("default_margin").height - } } } } diff --git a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py index cbb5f25ee8..6f292d4f4b 100644 --- a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py +++ b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py @@ -351,6 +351,10 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): result.append({"machine_type": machine_type, "count": str(printer_count[machine_type])}) return result + @pyqtProperty("QVariantList", notify=clusterPrintersChanged) + def printers(self): + return self._printers + @pyqtSlot(int, result = str) def formatDuration(self, seconds: int) -> str: return Duration(seconds).getDisplayString(DurationFormat.Format.Short) diff --git a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml index daa2aa80bb..290e3d7605 100644 --- a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml +++ b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml @@ -193,7 +193,7 @@ Item // PrintCore && Material config Row { - id: extruderInfo + id: extrudersInfo anchors.bottom: parent.bottom anchors From 03a78331806cc5822e11b780822a9cee42abc2c9 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 21 Aug 2018 10:14:12 +0200 Subject: [PATCH 17/67] Fixed qml warnings (reading from undefined properties) CL-893 && CL-894 --- plugins/Toolbox/src/Toolbox.py | 1 + .../UM3NetworkPrinting/ClusterControlItem.qml | 33 +++++++++++++++---- .../PrintCoreConfiguration.qml | 21 ++++++++++-- 3 files changed, 46 insertions(+), 9 deletions(-) diff --git a/plugins/Toolbox/src/Toolbox.py b/plugins/Toolbox/src/Toolbox.py index c4205b8ed5..4d04da5de0 100644 --- a/plugins/Toolbox/src/Toolbox.py +++ b/plugins/Toolbox/src/Toolbox.py @@ -183,6 +183,7 @@ class Toolbox(QObject, Extension): "materials_available": QUrl("{base_url}/packages?package_type=material".format(base_url=self._api_url)), "materials_generic": QUrl("{base_url}/packages?package_type=material&tags=generic".format(base_url=self._api_url)) } + print("*******", self._request_urls ) # Get the API root for the packages API depending on Cura version settings. def _getCloudAPIRoot(self) -> str: diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index 2fb0b36471..6b5bb90479 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -203,29 +203,50 @@ Component anchors.left: parent.left anchors.right: parent.right anchors.margins: UM.Theme.getSize("default_margin").width - height: childrenRect.height + height: childrenRect.height + UM.Theme.getSize("default_margin").height Label { id: printJobName - text: modelData.activePrintJob.name + text: modelData.activePrintJob != null ? modelData.activePrintJob.name : "" font: UM.Theme.getFont("default_bold") } Label { id: ownerName anchors.top: printJobName.bottom - text: modelData.activePrintJob.owner + text: modelData.activePrintJob != null ? modelData.activePrintJob.owner : "" } Image { - source: modelData.activePrintJob.preview_image_url + id: printJobPreview + source: modelData.activePrintJob != null ? modelData.activePrintJob.preview_image_url : "" anchors.top: ownerName.bottom anchors.horizontalCenter: parent.horizontalCenter - anchors.bottom: totalTimeLabel.top - width: height + //anchors.bottom: totalTimeLabel.top + width: parent.width / 3 + height: width } + Rectangle + { + id: showCameraIcon + width: 30 * screenScaleFactor + height: width + radius: width + anchors.left: parent.left + anchors.rightMargin: UM.Theme.getSize("default_margin").width + anchors.bottom: printJobPreview.bottom + color: UM.Theme.getColor("setting_control_border_highlight") + Image + { + width: parent.width + height: width + anchors.right: parent.right + anchors.rightMargin: parent.rightMargin + source: "camera-icon.svg" + } + } } } } diff --git a/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml b/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml index c71d0d1f79..893f6f7177 100644 --- a/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml +++ b/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml @@ -30,14 +30,22 @@ Item { anchors.centerIn: parent font: UM.Theme.getFont("default_bold") - text: printCoreConfiguration.position + 1 + text: printCoreConfiguration != undefined ? printCoreConfiguration.position + 1 : "" } } Label { id: materialLabel - text: printCoreConfiguration.activeMaterial != null ? printCoreConfiguration.activeMaterial.name : ":(" + text: + + { + if(printCoreConfiguration != undefined && printCoreConfiguration.activeMaterial != undefined) + { + return printCoreConfiguration.activeMaterial.name + } + return "" + } elide: Text.ElideRight width: parent.width font: UM.Theme.getFont("default_bold") @@ -48,7 +56,14 @@ Item Label { id: printCoreLabel - text: printCoreConfiguration.hotendID + text: + { + if(printCoreConfiguration != undefined && printCoreConfiguration.hotendID != undefined) + { + return printCoreConfiguration.hotendID + } + return "" + } anchors.top: materialLabel.bottom elide: Text.ElideRight width: parent.width From 6a08b63f21c4b50eae56e883d8f02c4d57968b4d Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 21 Aug 2018 13:32:22 +0200 Subject: [PATCH 18/67] Ensure that extruder configurations are correctly sorted CL-894 --- cura/PrinterOutput/ExtruderConfigurationModel.py | 4 ++-- plugins/Toolbox/src/Toolbox.py | 1 - .../UM3NetworkPrinting/ClusterUM3OutputDevice.py | 10 ++++------ .../UM3NetworkPrinting/PrintCoreConfiguration.qml | 15 ++++++++++++--- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/cura/PrinterOutput/ExtruderConfigurationModel.py b/cura/PrinterOutput/ExtruderConfigurationModel.py index 19d53d1271..75ee4b6ab3 100644 --- a/cura/PrinterOutput/ExtruderConfigurationModel.py +++ b/cura/PrinterOutput/ExtruderConfigurationModel.py @@ -11,9 +11,9 @@ class ExtruderConfigurationModel(QObject): extruderConfigurationChanged = pyqtSignal() - def __init__(self): + def __init__(self, position: int = -1): super().__init__() - self._position = -1 # type: int + self._position = position # type: int self._material = None # type: Optional[MaterialOutputModel] self._hotend_id = None # type: Optional[str] diff --git a/plugins/Toolbox/src/Toolbox.py b/plugins/Toolbox/src/Toolbox.py index 4d04da5de0..c4205b8ed5 100644 --- a/plugins/Toolbox/src/Toolbox.py +++ b/plugins/Toolbox/src/Toolbox.py @@ -183,7 +183,6 @@ class Toolbox(QObject, Extension): "materials_available": QUrl("{base_url}/packages?package_type=material".format(base_url=self._api_url)), "materials_generic": QUrl("{base_url}/packages?package_type=material&tags=generic".format(base_url=self._api_url)) } - print("*******", self._request_urls ) # Get the API root for the packages API depending on Cura version settings. def _getCloudAPIRoot(self) -> str: diff --git a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py index 6f292d4f4b..6fffe2e3bf 100644 --- a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py +++ b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py @@ -520,18 +520,16 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): key=data["uuid"], name= data["name"]) configuration = ConfigurationModel() - extruders = [] + extruders = [ExtruderConfigurationModel(position = idx) for idx in range(0, self._number_of_extruders)] for index in range(0, self._number_of_extruders): - extruder = ExtruderConfigurationModel() - extruder.setPosition(index) try: extruder_data = data["configuration"][index] except IndexError: - break - + continue + extruder = extruders[int(data["configuration"][index]["extruder_index"])] extruder.setHotendID(extruder_data.get("print_core_id", "")) extruder.setMaterial(self._createMaterialOutputModel(extruder_data.get("material", {}))) - extruders.append(extruder) + configuration.setExtruderConfigurations(extruders) print_job.updateConfiguration(configuration) diff --git a/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml b/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml index 893f6f7177..46e45feac9 100644 --- a/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml +++ b/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml @@ -18,6 +18,15 @@ Item id: extruderCircle width: 30 height: 30 + opacity: + { + if(printCoreConfiguration == undefined || printCoreConfiguration.activeMaterial == undefined || printCoreConfiguration.hotendID == undefined) + { + return 0.5 + } + return 1 + } + Rectangle { anchors.fill: parent @@ -30,7 +39,7 @@ Item { anchors.centerIn: parent font: UM.Theme.getFont("default_bold") - text: printCoreConfiguration != undefined ? printCoreConfiguration.position + 1 : "" + text: printCoreConfiguration.position + 1 } } @@ -40,7 +49,7 @@ Item text: { - if(printCoreConfiguration != undefined && printCoreConfiguration.activeMaterial != undefined) + if(printCoreConfiguration != undefined && printCoreConfiguration.activeMaterial != undefined) { return printCoreConfiguration.activeMaterial.name } @@ -58,7 +67,7 @@ Item id: printCoreLabel text: { - if(printCoreConfiguration != undefined && printCoreConfiguration.hotendID != undefined) + if(printCoreConfiguration != undefined && printCoreConfiguration.hotendID != undefined) { return printCoreConfiguration.hotendID } From dc855689734b70109d670a9f7f19e2741b3e4433 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 21 Aug 2018 13:52:09 +0200 Subject: [PATCH 19/67] Printer tiles in sidepanel can now be collapsed even if no job is active CL-893 --- plugins/UM3NetworkPrinting/ClusterControlItem.qml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index 6b5bb90479..2d37142935 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -81,7 +81,6 @@ Component { anchors.fill: parent onClicked: base.collapsed = !base.collapsed - enabled: modelData.activePrintJob != null } Rectangle @@ -110,7 +109,6 @@ Component id: collapseIcon width: 15 height: 15 - visible: modelData.activePrintJob != null sourceSize.width: width sourceSize.height: height source: base.collapsed ? UM.Theme.getIcon("arrow_left") : UM.Theme.getIcon("arrow_bottom") @@ -199,11 +197,14 @@ Component Item { id: jobInfo + property var showJobInfo: modelData.activePrintJob != null && modelData.activePrintJob.state != "queued" + anchors.top: jobSpacer.bottom anchors.left: parent.left anchors.right: parent.right anchors.margins: UM.Theme.getSize("default_margin").width - height: childrenRect.height + UM.Theme.getSize("default_margin").height + height: showJobInfo ? childrenRect.height + UM.Theme.getSize("default_margin").height: 0 + visible: showJobInfo Label { id: printJobName From 5a13b86a3ff6922f55dd81341617e7df56b92fa5 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 21 Aug 2018 14:55:18 +0200 Subject: [PATCH 20/67] Changed style for context button CL-894 --- .../UM3NetworkPrinting/ClusterControlItem.qml | 1 - .../UM3NetworkPrinting/PrintJobInfoBlock.qml | 17 ++++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index 2d37142935..261685feda 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -224,7 +224,6 @@ Component source: modelData.activePrintJob != null ? modelData.activePrintJob.preview_image_url : "" anchors.top: ownerName.bottom anchors.horizontalCenter: parent.horizontalCenter - //anchors.bottom: totalTimeLabel.top width: parent.width / 3 height: width } diff --git a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml index 290e3d7605..d1d3b176bd 100644 --- a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml +++ b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml @@ -120,12 +120,25 @@ Item Button { id: contextButton - text: "..." + text: "\u22EE" //Unicode; Three stacked points. + + width: 30 + height: width anchors { right: parent.right top: parent.top } + hoverEnabled: true + + background: Rectangle + { + opacity: contextButton.down || contextButton.hovered ? 1 : 0 + width: contextButton.width + height: contextButton.height + radius: 0.5 * width + color: "grey" + } onClicked: parent.switchPopupState() } @@ -138,8 +151,6 @@ Item closePolicy: Popup.CloseOnPressOutsideParent x: parent.width - width y: contextButton.height - //y: configurationSelector.height - UM.Theme.getSize("default_lining").height - //x: configurationSelector.width - width width: 200 height: contentItem.height + 2 * padding visible: false From 5176ead0e2bb038348f679ed745e18c4fac8a890 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 23 Aug 2018 15:07:31 +0200 Subject: [PATCH 21/67] Added print progress to sidebar CL-893 --- .../UM3NetworkPrinting/ClusterControlItem.qml | 90 ++++++++++++++++++- 1 file changed, 86 insertions(+), 4 deletions(-) diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index 261685feda..da9bf1d457 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -5,12 +5,16 @@ import QtQuick.Controls.Styles 1.3 import UM 1.3 as UM import Cura 1.0 as Cura + + Component { Rectangle { id: base property var lineColor: "#DCDCDC" // TODO: Should be linked to theme. + + property var cornerRadius: 4 * screenScaleFactor // TODO: Should be linked to theme. visible: OutputDevice != null anchors.fill: parent @@ -41,8 +45,6 @@ Component ScrollView { - id: queuedPrintJobs - anchors { top: activePrintersLabel.bottom @@ -60,7 +62,7 @@ Component delegate: Rectangle { width: parent.width - height: childrenRect.height + 2 * UM.Theme.getSize("default_margin").height + height: childrenRect.height + UM.Theme.getSize("default_margin").height id: base property var collapsed: true @@ -89,7 +91,7 @@ Component anchors.top: parent.top width: 50 height: 50 - color: "blue" + color: modelData.activePrintJob != undefined ? UM.Theme.getColor("primary") : UM.Theme.getColor("setting_control_disabled") } Label @@ -249,6 +251,86 @@ Component } } } + + ProgressBar + { + property var progress: + { + var result = modelData.activePrintJob.timeElapsed / modelData.activePrintJob.timeTotal + if(result > 1.0) + { + result = 1.0 + } + return result + } + + id: jobProgressBar + width: parent.width + value: progress + anchors.top: detailedInfo.bottom + anchors.topMargin: UM.Theme.getSize("default_margin").height + + visible: modelData.activePrintJob != null && modelData.activePrintJob != undefined + + style: ProgressBarStyle + { + property var progressText: + { + if(modelData.activePrintJob == null) + { + return "" + } + + if(modelData.activePrintJob.state == "wait_cleanup") + { + return "Finshed" + } + else if(modelData.activePrintJob.state == "pre_print") + { + return "Preparing" + } + else + { + return OutputDevice.formatDuration(modelData.activePrintJob.timeTotal - modelData.activePrintJob.timeElapsed) + } + } + + background: Rectangle + { + implicitWidth: 100 + implicitHeight: visible ? 24 : 0 + color: UM.Theme.getColor("viewport_background") + } + + progress: Rectangle + { + color: UM.Theme.getColor("primary") + id: progressItem + function getTextOffset() + { + if(progressItem.width + progressLabel.width < control.width) + { + return progressItem.width + UM.Theme.getSize("default_margin").width + } + else + { + return progressItem.width - progressLabel.width - UM.Theme.getSize("default_margin").width + } + } + + Label + { + id: progressLabel + anchors.left: parent.left + anchors.leftMargin: getTextOffset() + text: progressText + anchors.verticalCenter: parent.verticalCenter + color: progressItem.width + progressLabel.width < control.width ? "black" : "white" + width: contentWidth + } + } + } + } } } } From b0d9dc6fddd6f9dd8c12daaf1c90e059911be352 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 23 Aug 2018 15:53:32 +0200 Subject: [PATCH 22/67] Added DropShadow to the printer & printjob tiles CL-893 && CL-894 --- .../UM3NetworkPrinting/ClusterControlItem.qml | 29 ++++++++++++++----- .../UM3NetworkPrinting/PrintJobInfoBlock.qml | 25 ++++++++++++++-- 2 files changed, 43 insertions(+), 11 deletions(-) diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index da9bf1d457..75c31a7a58 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -1,12 +1,13 @@ -import QtQuick 2.2 +import QtQuick 2.3 import QtQuick.Controls 1.4 import QtQuick.Controls.Styles 1.3 +import QtGraphicalEffects 1.0 + import UM 1.3 as UM import Cura 1.0 as Cura - Component { Rectangle @@ -57,15 +58,25 @@ Component { anchors.fill: parent spacing: UM.Theme.getSize("default_margin").height - + displayMarginBeginning: 2 model: OutputDevice.printers delegate: Rectangle { - width: parent.width + width: parent.width - 2 * shadowRadius height: childrenRect.height + UM.Theme.getSize("default_margin").height - + anchors.horizontalCenter: parent.horizontalCenter id: base + property var shadowRadius: 5 property var collapsed: true + + layer.enabled: true + layer.effect: DropShadow + { + radius: base.shadowRadius + verticalOffset: 2 + color: "#3F000000" // 25% shadow + } + Item { id: printerInfo @@ -136,11 +147,13 @@ Component { id: detailedInfo property var printJob: modelData.activePrintJob - visible: !base.collapsed + visible: height == childrenRect.height anchors.top: printerInfo.bottom width: parent.width - height: visible ? childrenRect.height : 0 - + height: !base.collapsed ? childrenRect.height : 0 + opacity: visible ? 1 : 0 + Behavior on height { NumberAnimation { duration: 100 } } + Behavior on opacity { NumberAnimation { duration: 50 } } Rectangle { id: topSpacer diff --git a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml index d1d3b176bd..ea3aafb5cc 100644 --- a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml +++ b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml @@ -1,15 +1,16 @@ import QtQuick 2.2 import QtQuick.Controls 2.0 import QtQuick.Controls.Styles 1.4 - +import QtGraphicalEffects 1.0 import UM 1.3 as UM Item { + id: base property var printJob: null - + property var shadowRadius: 5 function getPrettyTime(time) { return OutputDevice.formatDuration(time) @@ -24,7 +25,25 @@ Item Rectangle { id: background - anchors.fill: parent + anchors + { + top: parent.top + topMargin: 3 + left: parent.left + leftMargin: base.shadowRadius + rightMargin: base.shadowRadius + right: parent.right + bottom: parent.bottom + bottomMargin: base.shadowRadius + } + + layer.enabled: true + layer.effect: DropShadow + { + radius: base.shadowRadius + verticalOffset: 2 + color: "#3F000000" // 25% shadow + } Item { From dab2efab7f087fc252e3f3fc62c34002efd536e3 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 23 Aug 2018 17:29:48 +0200 Subject: [PATCH 23/67] Updated margins & layout for the monitor page CL-896 --- .../UM3NetworkPrinting/ClusterControlItem.qml | 41 +++++++++++++------ .../UM3NetworkPrinting/ClusterMonitorItem.qml | 12 +++--- .../PrintCoreConfiguration.qml | 25 +++++++---- .../UM3NetworkPrinting/PrintJobInfoBlock.qml | 8 ++-- 4 files changed, 57 insertions(+), 29 deletions(-) diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index 75c31a7a58..bd94872183 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -51,15 +51,27 @@ Component top: activePrintersLabel.bottom left: parent.left right: parent.right - margins: UM.Theme.getSize("default_margin").width + topMargin: UM.Theme.getSize("default_margin").height bottom: parent.bottom } + + style: UM.Theme.styles.scrollview + ListView { - anchors.fill: parent + anchors + { + top: parent.top + bottom: parent.bottom + left: parent.left + right: parent.right + leftMargin: 2 * UM.Theme.getSize("default_margin").width + rightMargin: 2 * UM.Theme.getSize("default_margin").width + } spacing: UM.Theme.getSize("default_margin").height displayMarginBeginning: 2 model: OutputDevice.printers + delegate: Rectangle { width: parent.width - 2 * shadowRadius @@ -100,6 +112,8 @@ Component { id: machineIcon anchors.top: parent.top + anchors.leftMargin: UM.Theme.getSize("default_margin").width + anchors.left: parent.left width: 50 height: 50 color: modelData.activePrintJob != undefined ? UM.Theme.getColor("primary") : UM.Theme.getColor("setting_control_disabled") @@ -157,7 +171,7 @@ Component Rectangle { id: topSpacer - color: "grey" + color: UM.Theme.getColor("viewport_background") height: 1 anchors { @@ -165,6 +179,7 @@ Component right: parent.right margins: UM.Theme.getSize("default_margin").width top: parent.top + topMargin: 2 * UM.Theme.getSize("default_margin").width } } @@ -172,11 +187,11 @@ Component { id: extrudersInfo anchors.top: topSpacer.bottom - anchors.topMargin : UM.Theme.getSize("default_margin").height + anchors.topMargin: 2 * UM.Theme.getSize("default_margin").height anchors.left: parent.left - anchors.leftMargin: UM.Theme.getSize("default_margin").width + anchors.leftMargin: 2 * UM.Theme.getSize("default_margin").width anchors.right: parent.right - anchors.rightMargin: UM.Theme.getSize("default_margin").width + anchors.rightMargin: 2 * UM.Theme.getSize("default_margin").width height: childrenRect.height spacing: UM.Theme.getSize("default_margin").width @@ -198,7 +213,7 @@ Component Rectangle { id: jobSpacer - color: "grey" + color: UM.Theme.getColor("viewport_background") height: 1 anchors { @@ -206,6 +221,7 @@ Component right: parent.right margins: UM.Theme.getSize("default_margin").width top: extrudersInfo.bottom + topMargin: 2 * UM.Theme.getSize("default_margin").height } } @@ -215,10 +231,12 @@ Component property var showJobInfo: modelData.activePrintJob != null && modelData.activePrintJob.state != "queued" anchors.top: jobSpacer.bottom + anchors.topMargin: 2 * UM.Theme.getSize("default_margin").height anchors.left: parent.left anchors.right: parent.right anchors.margins: UM.Theme.getSize("default_margin").width - height: showJobInfo ? childrenRect.height + UM.Theme.getSize("default_margin").height: 0 + anchors.leftMargin: 2 * UM.Theme.getSize("default_margin").width + height: showJobInfo ? childrenRect.height + 3 * UM.Theme.getSize("default_margin").height: 0 visible: showJobInfo Label { @@ -246,12 +264,11 @@ Component Rectangle { id: showCameraIcon - width: 30 * screenScaleFactor + width: 35 * screenScaleFactor height: width - radius: width + radius: 0.5 * width anchors.left: parent.left - anchors.rightMargin: UM.Theme.getSize("default_margin").width - anchors.bottom: printJobPreview.bottom + anchors.top: printJobPreview.bottom color: UM.Theme.getColor("setting_control_border_highlight") Image { diff --git a/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml b/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml index 3bc9fedc9c..1fd217cbdf 100644 --- a/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml @@ -79,15 +79,16 @@ Component margins: UM.Theme.getSize("default_margin").width top: activePrintersLabel.bottom left: parent.left - leftMargin: UM.Theme.getSize("default_lining").width // To ensure border can be drawn. - rightMargin: UM.Theme.getSize("default_lining").width + bottomMargin: 0 right: parent.right bottom: parent.bottom } + style: UM.Theme.styles.scrollview ListView { anchors.fill: parent + anchors.margins: UM.Theme.getSize("default_margin").height spacing: UM.Theme.getSize("default_margin").height model: OutputDevice.queuedPrintJobs @@ -95,11 +96,10 @@ Component delegate: PrintJobInfoBlock { printJob: modelData - width: Math.min(800 * screenScaleFactor, maximumWidth) + anchors.left: parent.left + anchors.right: parent.right + anchors.rightMargin: UM.Theme.getSize("default_margin").height height: 125 * screenScaleFactor - - // Add a 1 pix margin, as the border is sometimes cut off otherwise. - anchors.horizontalCenter: parent.horizontalCenter } } } diff --git a/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml b/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml index 46e45feac9..c8825cd197 100644 --- a/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml +++ b/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml @@ -47,7 +47,6 @@ Item { id: materialLabel text: - { if(printCoreConfiguration != undefined && printCoreConfiguration.activeMaterial != undefined) { @@ -55,11 +54,15 @@ Item } return "" } - elide: Text.ElideRight - width: parent.width font: UM.Theme.getFont("default_bold") - anchors.left: extruderCircle.right - anchors.leftMargin: UM.Theme.getSize("default_margin").height + elide: Text.ElideRight + + anchors + { + right: parent.right + left: extruderCircle.right + margins: UM.Theme.getSize("default_margin").width + } } Label @@ -75,8 +78,14 @@ Item } anchors.top: materialLabel.bottom elide: Text.ElideRight - width: parent.width - anchors.left: extruderCircle.right - anchors.leftMargin: UM.Theme.getSize("default_margin").height + + anchors + { + top: materialLabel.bottom + right: parent.right + left: extruderCircle.right + leftMargin: UM.Theme.getSize("default_margin").width + rightMargin: UM.Theme.getSize("default_margin").width + } } } diff --git a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml index ea3aafb5cc..1be58a35b8 100644 --- a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml +++ b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml @@ -54,7 +54,8 @@ Item bottom: parent.bottom left: parent.left right: parent.horizontalCenter - margins: UM.Theme.getSize("default_margin").width + margins: 2 * UM.Theme.getSize("default_margin").width + rightMargin: UM.Theme.getSize("default_margin").width } Label @@ -101,7 +102,8 @@ Item bottom: parent.bottom left: parent.horizontalCenter right: parent.right - margins: UM.Theme.getSize("default_margin").width + margins: 2 * UM.Theme.getSize("default_margin").width + leftMargin: UM.Theme.getSize("default_margin").width } Label @@ -254,7 +256,7 @@ Item Rectangle { - color: "grey" + color: UM.Theme.getColor("viewport_background") width: 1 anchors.top: parent.top From c703d15cd3b9558bc3f9f551b75161ed14156b1f Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 23 Aug 2018 18:05:13 +0200 Subject: [PATCH 24/67] Updated the styling of the context hover CL-896 --- .../UM3NetworkPrinting/ClusterMonitorItem.qml | 2 +- .../UM3NetworkPrinting/PrintJobInfoBlock.qml | 33 +++++++++++++++---- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml b/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml index 1fd217cbdf..be52eea214 100644 --- a/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml @@ -99,7 +99,7 @@ Component anchors.left: parent.left anchors.right: parent.right anchors.rightMargin: UM.Theme.getSize("default_margin").height - height: 125 * screenScaleFactor + height: 175 * screenScaleFactor } } } diff --git a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml index 1be58a35b8..5722f332cc 100644 --- a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml +++ b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml @@ -142,8 +142,8 @@ Item { id: contextButton text: "\u22EE" //Unicode; Three stacked points. - - width: 30 + font.pixelSize: 25 + width: 35 height: width anchors { @@ -158,8 +158,9 @@ Item width: contextButton.width height: contextButton.height radius: 0.5 * width - color: "grey" + color: UM.Theme.getColor("viewport_background") } + onClicked: parent.switchPopupState() } @@ -175,7 +176,7 @@ Item width: 200 height: contentItem.height + 2 * padding visible: false - padding: UM.Theme.getSize("default_lining").width + transformOrigin: Popup.Top contentItem: Item { @@ -188,6 +189,12 @@ Item onClicked: OutputDevice.sendJobToTop(printJob.key) width: parent.width enabled: OutputDevice.printJobs[0].key != printJob.key + hoverEnabled: true + background: Rectangle + { + opacity: sendToTopButton.down || sendToTopButton.hovered ? 1 : 0 + color: UM.Theme.getColor("viewport_background") + } } Button { @@ -196,14 +203,28 @@ Item onClicked: OutputDevice.deleteJobFromQueue(printJob.key) width: parent.width anchors.top: sendToTopButton.bottom + hoverEnabled: true + background: Rectangle + { + opacity: deleteButton.down || deleteButton.hovered ? 1 : 0 + color: UM.Theme.getColor("viewport_background") + } } } background: Rectangle { color: UM.Theme.getColor("setting_control") - border.color: UM.Theme.getColor("setting_control_border") - height: popup.height + height: popup.height - 10 // - 2 times the radius of the dropshadow. + width: popup.width - 10 + layer.enabled: true + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + layer.effect: DropShadow + { + radius: 5 + color: "#3F000000" // 25% shadow + } } exit: Transition From e9d4c36b320deb2424b461cffa384c021513675c Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 23 Aug 2018 18:16:39 +0200 Subject: [PATCH 25/67] Updated labels --- .../UM3NetworkPrinting/ClusterControlItem.qml | 2 +- .../UM3NetworkPrinting/ClusterMonitorItem.qml | 37 +++++-------------- 2 files changed, 11 insertions(+), 28 deletions(-) diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index bd94872183..807a18c1ea 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -39,7 +39,7 @@ Component right: parent.right } - text: OutputDevice.name + text: catalog.i18nc("@label", "Printing") elide: Text.ElideRight } diff --git a/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml b/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml index be52eea214..b39266b3e6 100644 --- a/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml @@ -40,34 +40,16 @@ Component visible: OutputDevice.printers.length == 0 } - Item + Label { - anchors.topMargin: UM.Theme.getSize("default_margin").height + id: queuedLabel + anchors.left: queuedPrintJobs.left anchors.top: parent.top - anchors.horizontalCenter: parent.horizontalCenter - - width: Math.min(800 * screenScaleFactor, maximumWidth) - height: children.height - visible: OutputDevice.printers.length != 0 - - Label - { - id: addRemovePrintersLabel - anchors.right: parent.right - text: catalog.i18nc("@label link to connect manager", "Add/Remove printers") - font: UM.Theme.getFont("default") - color: UM.Theme.getColor("text") - linkColor: UM.Theme.getColor("text_link") - } - - MouseArea - { - anchors.fill: addRemovePrintersLabel - hoverEnabled: true - onClicked: Cura.MachineManager.printerOutputDevices[0].openPrinterControlPanel() - onEntered: addRemovePrintersLabel.font.underline = true - onExited: addRemovePrintersLabel.font.underline = false - } + anchors.topMargin: 2 * UM.Theme.getSize("default_margin").height + anchors.leftMargin: 3 * UM.Theme.getSize("default_margin").width + text: catalog.i18nc("@label", "Queued") + font: UM.Theme.getFont("large") + color: UM.Theme.getColor("text") } ScrollView @@ -77,7 +59,8 @@ Component anchors { margins: UM.Theme.getSize("default_margin").width - top: activePrintersLabel.bottom + top: queuedLabel.bottom + topMargin: 0 left: parent.left bottomMargin: 0 right: parent.right From 6bfa2fed966c8e8cee5370ef9589665fb5e2207d Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 23 Aug 2018 19:46:14 +0200 Subject: [PATCH 26/67] Updated display states and fixed some more margins CL-896 --- .../UM3NetworkPrinting/ClusterControlItem.qml | 38 ++++++++++++------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index 807a18c1ea..2e67668741 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -53,6 +53,7 @@ Component right: parent.right topMargin: UM.Theme.getSize("default_margin").height bottom: parent.bottom + bottomMargin: UM.Theme.getSize("default_margin").height } style: UM.Theme.styles.scrollview @@ -69,7 +70,6 @@ Component rightMargin: 2 * UM.Theme.getSize("default_margin").width } spacing: UM.Theme.getSize("default_margin").height - displayMarginBeginning: 2 model: OutputDevice.printers delegate: Rectangle @@ -167,7 +167,7 @@ Component height: !base.collapsed ? childrenRect.height : 0 opacity: visible ? 1 : 0 Behavior on height { NumberAnimation { duration: 100 } } - Behavior on opacity { NumberAnimation { duration: 50 } } + Behavior on opacity { NumberAnimation { duration: 100 } } Rectangle { id: topSpacer @@ -179,7 +179,7 @@ Component right: parent.right margins: UM.Theme.getSize("default_margin").width top: parent.top - topMargin: 2 * UM.Theme.getSize("default_margin").width + topMargin: UM.Theme.getSize("default_margin").width } } @@ -236,7 +236,7 @@ Component anchors.right: parent.right anchors.margins: UM.Theme.getSize("default_margin").width anchors.leftMargin: 2 * UM.Theme.getSize("default_margin").width - height: showJobInfo ? childrenRect.height + 3 * UM.Theme.getSize("default_margin").height: 0 + height: showJobInfo ? childrenRect.height + 2 * UM.Theme.getSize("default_margin").height: 0 visible: showJobInfo Label { @@ -286,6 +286,10 @@ Component { property var progress: { + if(modelData.activePrintJob == null) + { + return 0 + } var result = modelData.activePrintJob.timeElapsed / modelData.activePrintJob.timeTotal if(result > 1.0) { @@ -311,17 +315,23 @@ Component return "" } - if(modelData.activePrintJob.state == "wait_cleanup") + switch(modelData.activePrintJob.state) { - return "Finshed" - } - else if(modelData.activePrintJob.state == "pre_print") - { - return "Preparing" - } - else - { - return OutputDevice.formatDuration(modelData.activePrintJob.timeTotal - modelData.activePrintJob.timeElapsed) + case "wait_cleanup": + return catalog.i18nc("@label:status", "Finshed") + case "pre_print": + case "sent_to_printer": + return catalog.i18nc("@label:status", "Preparing") + case "aborted": + case "wait_user_action": + return catalog.i18nc("@label:status", "Aborted") + case "pausing": + case "paused": + return catalog.i18nc("@label:status", "Paused") + case "resuming": + return catalog.i18nc("@label:status", "Resuming") + default: + OutputDevice.formatDuration(modelData.activePrintJob.timeTotal - modelData.activePrintJob.timeElapsed) } } From fc83520ad9ccfc385db4d88e1f81e9b0152253c1 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 23 Aug 2018 20:34:20 +0200 Subject: [PATCH 27/67] Added camera view back to cluster screen CL-893 --- cura/CameraImageProvider.py | 8 ++++++- .../UM3NetworkPrinting/ClusterControlItem.qml | 8 +++++++ .../UM3NetworkPrinting/ClusterMonitorItem.qml | 7 ++++--- .../ClusterUM3OutputDevice.py | 20 ++++++++++++++++++ .../UM3NetworkPrinting/PrinterVideoStream.qml | 21 +++++++++++-------- 5 files changed, 51 insertions(+), 13 deletions(-) diff --git a/cura/CameraImageProvider.py b/cura/CameraImageProvider.py index ff5c51f24b..6a07f6b029 100644 --- a/cura/CameraImageProvider.py +++ b/cura/CameraImageProvider.py @@ -19,5 +19,11 @@ class CameraImageProvider(QQuickImageProvider): return image, QSize(15, 15) except AttributeError: - pass + try: + image = output_device.activeCamera.getImage() + + return image, QSize(15, 15) + except AttributeError: + pass + return QImage(), QSize(15, 15) diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index 2e67668741..50419c48ff 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -278,6 +278,14 @@ Component anchors.rightMargin: parent.rightMargin source: "camera-icon.svg" } + MouseArea + { + anchors.fill:parent + onClicked: + { + OutputDevice.setActiveCamera(modelData.camera) + } + } } } } diff --git a/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml b/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml index b39266b3e6..ff5fad5abd 100644 --- a/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml @@ -89,17 +89,18 @@ Component PrinterVideoStream { - visible: OutputDevice.activePrinter != null + visible: OutputDevice.activeCamera != null anchors.fill: parent + camera: OutputDevice.activeCamera } onVisibleChanged: { - if (!monitorFrame.visible) + if (monitorFrame != null && !monitorFrame.visible) { // After switching the Tab ensure that active printer is Null, the video stream image // might be active - OutputDevice.setActivePrinter(null) + OutputDevice.setActiveCamera(null) } } } diff --git a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py index 6fffe2e3bf..7506a870a9 100644 --- a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py +++ b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py @@ -46,6 +46,7 @@ i18n_catalog = i18nCatalog("cura") class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): printJobsChanged = pyqtSignal() activePrinterChanged = pyqtSignal() + activeCameraChanged = pyqtSignal() # This is a bit of a hack, as the notify can only use signals that are defined by the class that they are in. # Inheritance doesn't seem to work. Tying them together does work, but i'm open for better suggestions. @@ -96,6 +97,8 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): self._latest_reply_handler = None # type: Optional[QNetworkReply] self._sending_job = None + self._active_camera = None # type: Optional[NetworkCamera] + def requestWrite(self, nodes: List[SceneNode], file_name: Optional[str] = None, limit_mimetypes: bool = False, file_handler: Optional[FileHandler] = None, **kwargs: str) -> None: self.writeStarted.emit(self) @@ -256,6 +259,10 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): def activePrinter(self) -> Optional[PrinterOutputModel]: return self._active_printer + @pyqtProperty(QObject, notify=activeCameraChanged) + def activeCamera(self) -> Optional[NetworkCamera]: + return self._active_camera + @pyqtSlot(QObject) def setActivePrinter(self, printer: Optional[PrinterOutputModel]) -> None: if self._active_printer != printer: @@ -264,6 +271,19 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): self._active_printer = printer self.activePrinterChanged.emit() + @pyqtSlot(QObject) + def setActiveCamera(self, camera: Optional[NetworkCamera]) -> None: + if self._active_camera != camera: + if self._active_camera: + self._active_camera.stop() + + self._active_camera = camera + + if self._active_camera: + self._active_camera.start() + + self.activeCameraChanged.emit() + def _onPostPrintJobFinished(self, reply: QNetworkReply) -> None: if self._progress_message: self._progress_message.hide() diff --git a/plugins/UM3NetworkPrinting/PrinterVideoStream.qml b/plugins/UM3NetworkPrinting/PrinterVideoStream.qml index 68758e095e..74c8ec8483 100644 --- a/plugins/UM3NetworkPrinting/PrinterVideoStream.qml +++ b/plugins/UM3NetworkPrinting/PrinterVideoStream.qml @@ -7,6 +7,8 @@ import UM 1.3 as UM Item { + property var camera: null + Rectangle { anchors.fill:parent @@ -17,7 +19,7 @@ Item MouseArea { anchors.fill: parent - onClicked: OutputDevice.setActivePrinter(null) + onClicked: OutputDevice.setActiveCamera(null) z: 0 } @@ -32,7 +34,7 @@ Item width: 20 * screenScaleFactor height: 20 * screenScaleFactor - onClicked: OutputDevice.setActivePrinter(null) + onClicked: OutputDevice.setActiveCamera(null) style: ButtonStyle { @@ -65,23 +67,24 @@ Item { if(visible) { - if(OutputDevice.activePrinter != null && OutputDevice.activePrinter.camera != null) + if(camera != null) { - OutputDevice.activePrinter.camera.start() + camera.start() } } else { - if(OutputDevice.activePrinter != null && OutputDevice.activePrinter.camera != null) + if(camera != null) { - OutputDevice.activePrinter.camera.stop() + camera.stop() } } } + source: { - if(OutputDevice.activePrinter != null && OutputDevice.activePrinter.camera != null && OutputDevice.activePrinter.camera.latestImage) + if(camera != null && camera.latestImage != null) { - return OutputDevice.activePrinter.camera.latestImage; + return camera.latestImage; } return ""; } @@ -92,7 +95,7 @@ Item anchors.fill: cameraImage onClicked: { - OutputDevice.setActivePrinter(null) + OutputDevice.setActiveCamera(null) } z: 1 } From 3e623a6fe6b7dda7747849c6b91bd4a62508d0fd Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 24 Aug 2018 11:02:05 +0200 Subject: [PATCH 28/67] Added pointer to context popup CL-894 --- .../UM3NetworkPrinting/PrintJobInfoBlock.qml | 52 +++++++++++++++---- 1 file changed, 43 insertions(+), 9 deletions(-) diff --git a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml index 5722f332cc..c9a4f14116 100644 --- a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml +++ b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml @@ -181,7 +181,7 @@ Item contentItem: Item { width: popup.width - 2 * popup.padding - height: childrenRect.height + height: childrenRect.height + 15 Button { id: sendToTopButton @@ -189,6 +189,8 @@ Item onClicked: OutputDevice.sendJobToTop(printJob.key) width: parent.width enabled: OutputDevice.printJobs[0].key != printJob.key + anchors.top: parent.top + anchors.topMargin: 10 hoverEnabled: true background: Rectangle { @@ -196,6 +198,7 @@ Item color: UM.Theme.getColor("viewport_background") } } + Button { id: deleteButton @@ -212,18 +215,49 @@ Item } } - background: Rectangle + background: Item { - color: UM.Theme.getColor("setting_control") - height: popup.height - 10 // - 2 times the radius of the dropshadow. - width: popup.width - 10 - layer.enabled: true - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - layer.effect: DropShadow + width: popup.width + height: popup.height + + DropShadow { + anchors.fill: pointedRectangle radius: 5 color: "#3F000000" // 25% shadow + source: pointedRectangle + transparentBorder: true + } + + Item + { + id: pointedRectangle + width: parent.width -10 + height: parent.height -10 + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + + Rectangle + { + id: point + height: 13 + width: 13 + color: UM.Theme.getColor("setting_control") + transform: Rotation { angle: 45} + anchors.right: bloop.right + y: 1 + } + + Rectangle + { + id: bloop + color: UM.Theme.getColor("setting_control") + width: parent.width + anchors.top: parent.top + anchors.topMargin: 10 + anchors.bottom: parent.bottom + anchors.bottomMargin: 5 + } } } From c13f25219357e87d041a99f0e07c08da3375618a Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 24 Aug 2018 13:41:33 +0200 Subject: [PATCH 29/67] Some spacing / anchoring fixes CL-896 --- .../UM3NetworkPrinting/ClusterControlItem.qml | 19 +++++++++-------- .../UM3NetworkPrinting/PrintJobInfoBlock.qml | 21 ++++++++++++------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index 50419c48ff..a89da54e1b 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -19,7 +19,7 @@ Component property var cornerRadius: 4 * screenScaleFactor // TODO: Should be linked to theme. visible: OutputDevice != null anchors.fill: parent - color: UM.Theme.getColor("viewport_background") + color: "white" UM.I18nCatalog { @@ -29,11 +29,12 @@ Component Label { - id: activePrintersLabel + id: printingLabel font: UM.Theme.getFont("large") anchors { - margins: UM.Theme.getSize("default_margin").width + margins: 2 * UM.Theme.getSize("default_margin").width + leftMargin: 4 * UM.Theme.getSize("default_margin").width top: parent.top left: parent.left right: parent.right @@ -48,10 +49,10 @@ Component { anchors { - top: activePrintersLabel.bottom + top: printingLabel.bottom left: parent.left right: parent.right - topMargin: UM.Theme.getSize("default_margin").height + topMargin: 2 * UM.Theme.getSize("default_margin").height bottom: parent.bottom bottomMargin: UM.Theme.getSize("default_margin").height } @@ -172,7 +173,7 @@ Component { id: topSpacer color: UM.Theme.getColor("viewport_background") - height: 1 + height: 2 anchors { left: parent.left @@ -214,7 +215,7 @@ Component { id: jobSpacer color: UM.Theme.getColor("viewport_background") - height: 1 + height: 2 anchors { left: parent.left @@ -257,7 +258,7 @@ Component source: modelData.activePrintJob != null ? modelData.activePrintJob.preview_image_url : "" anchors.top: ownerName.bottom anchors.horizontalCenter: parent.horizontalCenter - width: parent.width / 3 + width: parent.width / 2 height: width } @@ -268,7 +269,7 @@ Component height: width radius: 0.5 * width anchors.left: parent.left - anchors.top: printJobPreview.bottom + anchors.bottom: printJobPreview.bottom color: UM.Theme.getColor("setting_control_border_highlight") Image { diff --git a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml index c9a4f14116..8562eb3c61 100644 --- a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml +++ b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml @@ -77,7 +77,7 @@ Item source: printJob.preview_image_url anchors.top: ownerName.bottom anchors.horizontalCenter: parent.horizontalCenter - anchors.bottom: totalTimeLabel.top + anchors.bottom: totalTimeLabel.bottom width: height } @@ -186,7 +186,11 @@ Item { id: sendToTopButton text: catalog.i18nc("@label", "Move to top") - onClicked: OutputDevice.sendJobToTop(printJob.key) + onClicked: + { + OutputDevice.sendJobToTop(printJob.key) + popup.close() + } width: parent.width enabled: OutputDevice.printJobs[0].key != printJob.key anchors.top: parent.top @@ -198,12 +202,16 @@ Item color: UM.Theme.getColor("viewport_background") } } - + Button { id: deleteButton text: catalog.i18nc("@label", "Delete") - onClicked: OutputDevice.deleteJobFromQueue(printJob.key) + onClicked: + { + OutputDevice.deleteJobFromQueue(printJob.key) + popup.close() + } width: parent.width anchors.top: sendToTopButton.bottom hoverEnabled: true @@ -312,14 +320,11 @@ Item Rectangle { color: UM.Theme.getColor("viewport_background") - width: 1 - + width: 2 anchors.top: parent.top anchors.bottom: parent.bottom anchors.margins: UM.Theme.getSize("default_margin").height anchors.horizontalCenter: parent.horizontalCenter - } - } } \ No newline at end of file From bc651fea92d959b2505109ada790663faad49973 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 24 Aug 2018 13:50:52 +0200 Subject: [PATCH 30/67] First printer tile no longer has shadow cut off from top CL-894 --- .../UM3NetworkPrinting/ClusterControlItem.qml | 499 +++++++++--------- 1 file changed, 252 insertions(+), 247 deletions(-) diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index a89da54e1b..95a823d950 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -70,312 +70,317 @@ Component leftMargin: 2 * UM.Theme.getSize("default_margin").width rightMargin: 2 * UM.Theme.getSize("default_margin").width } - spacing: UM.Theme.getSize("default_margin").height + spacing: UM.Theme.getSize("default_margin").height -10 model: OutputDevice.printers - delegate: Rectangle + delegate: Item { - width: parent.width - 2 * shadowRadius - height: childrenRect.height + UM.Theme.getSize("default_margin").height - anchors.horizontalCenter: parent.horizontalCenter - id: base - property var shadowRadius: 5 - property var collapsed: true - - layer.enabled: true - layer.effect: DropShadow + width: parent.width + height: base.height + 2 * base.shadowRadius // To ensure that the shadow doesn't get cut off. + Rectangle { - radius: base.shadowRadius - verticalOffset: 2 - color: "#3F000000" // 25% shadow - } + width: parent.width - 2 * shadowRadius + height: childrenRect.height + UM.Theme.getSize("default_margin").height + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + id: base + property var shadowRadius: 5 + property var collapsed: true - Item - { - id: printerInfo - height: machineIcon.height - anchors + layer.enabled: true + layer.effect: DropShadow { - top: parent.top - left: parent.left - right: parent.right - - margins: UM.Theme.getSize("default_margin").width + radius: base.shadowRadius + verticalOffset: 2 + color: "#3F000000" // 25% shadow } - MouseArea + Item { - anchors.fill: parent - onClicked: base.collapsed = !base.collapsed - } - - Rectangle - { - id: machineIcon - anchors.top: parent.top - anchors.leftMargin: UM.Theme.getSize("default_margin").width - anchors.left: parent.left - width: 50 - height: 50 - color: modelData.activePrintJob != undefined ? UM.Theme.getColor("primary") : UM.Theme.getColor("setting_control_disabled") - } - - Label - { - id: machineNameLabel - text: modelData.name - anchors.top: machineIcon.top - anchors.left: machineIcon.right - anchors.leftMargin: UM.Theme.getSize("default_margin").width - anchors.right: collapseIcon.left - anchors.rightMargin: UM.Theme.getSize("default_margin").width - elide: Text.ElideRight - } - - UM.RecolorImage - { - id: collapseIcon - width: 15 - height: 15 - sourceSize.width: width - sourceSize.height: height - source: base.collapsed ? UM.Theme.getIcon("arrow_left") : UM.Theme.getIcon("arrow_bottom") - anchors.verticalCenter: parent.verticalCenter - anchors.right: parent.right - anchors.rightMargin: UM.Theme.getSize("default_margin").width - color: "black" - } - - Label - { - id: activeJobLabel - text: modelData.activePrintJob != null ? modelData.activePrintJob.name : "waiting" - anchors.top: machineNameLabel.bottom - anchors.left: machineNameLabel.left - anchors.right: collapseIcon.left - anchors.rightMargin: UM.Theme.getSize("default_margin").width - elide: Text.ElideRight - } - } - - Item - { - id: detailedInfo - property var printJob: modelData.activePrintJob - visible: height == childrenRect.height - anchors.top: printerInfo.bottom - width: parent.width - height: !base.collapsed ? childrenRect.height : 0 - opacity: visible ? 1 : 0 - Behavior on height { NumberAnimation { duration: 100 } } - Behavior on opacity { NumberAnimation { duration: 100 } } - Rectangle - { - id: topSpacer - color: UM.Theme.getColor("viewport_background") - height: 2 + id: printerInfo + height: machineIcon.height anchors { - left: parent.left - right: parent.right - margins: UM.Theme.getSize("default_margin").width top: parent.top - topMargin: UM.Theme.getSize("default_margin").width - } - } - - Row - { - id: extrudersInfo - anchors.top: topSpacer.bottom - anchors.topMargin: 2 * UM.Theme.getSize("default_margin").height - anchors.left: parent.left - anchors.leftMargin: 2 * UM.Theme.getSize("default_margin").width - anchors.right: parent.right - anchors.rightMargin: 2 * UM.Theme.getSize("default_margin").width - height: childrenRect.height - spacing: UM.Theme.getSize("default_margin").width - - PrintCoreConfiguration - { - id: leftExtruderInfo - width: Math.round(parent.width / 2) - printCoreConfiguration: modelData.printerConfiguration.extruderConfigurations[0] - } - - PrintCoreConfiguration - { - id: rightExtruderInfo - width: Math.round(parent.width / 2) - printCoreConfiguration: modelData.printerConfiguration.extruderConfigurations[1] - } - } - - Rectangle - { - id: jobSpacer - color: UM.Theme.getColor("viewport_background") - height: 2 - anchors - { left: parent.left right: parent.right margins: UM.Theme.getSize("default_margin").width - top: extrudersInfo.bottom - topMargin: 2 * UM.Theme.getSize("default_margin").height + } + + MouseArea + { + anchors.fill: parent + onClicked: base.collapsed = !base.collapsed + } + + Rectangle + { + id: machineIcon + anchors.top: parent.top + anchors.leftMargin: UM.Theme.getSize("default_margin").width + anchors.left: parent.left + width: 50 + height: 50 + color: modelData.activePrintJob != undefined ? UM.Theme.getColor("primary") : UM.Theme.getColor("setting_control_disabled") + } + + Label + { + id: machineNameLabel + text: modelData.name + anchors.top: machineIcon.top + anchors.left: machineIcon.right + anchors.leftMargin: UM.Theme.getSize("default_margin").width + anchors.right: collapseIcon.left + anchors.rightMargin: UM.Theme.getSize("default_margin").width + elide: Text.ElideRight + } + + UM.RecolorImage + { + id: collapseIcon + width: 15 + height: 15 + sourceSize.width: width + sourceSize.height: height + source: base.collapsed ? UM.Theme.getIcon("arrow_left") : UM.Theme.getIcon("arrow_bottom") + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + anchors.rightMargin: UM.Theme.getSize("default_margin").width + color: "black" + } + + Label + { + id: activeJobLabel + text: modelData.activePrintJob != null ? modelData.activePrintJob.name : "waiting" + anchors.top: machineNameLabel.bottom + anchors.left: machineNameLabel.left + anchors.right: collapseIcon.left + anchors.rightMargin: UM.Theme.getSize("default_margin").width + elide: Text.ElideRight } } Item { - id: jobInfo - property var showJobInfo: modelData.activePrintJob != null && modelData.activePrintJob.state != "queued" - - anchors.top: jobSpacer.bottom - anchors.topMargin: 2 * UM.Theme.getSize("default_margin").height - anchors.left: parent.left - anchors.right: parent.right - anchors.margins: UM.Theme.getSize("default_margin").width - anchors.leftMargin: 2 * UM.Theme.getSize("default_margin").width - height: showJobInfo ? childrenRect.height + 2 * UM.Theme.getSize("default_margin").height: 0 - visible: showJobInfo - Label + id: detailedInfo + property var printJob: modelData.activePrintJob + visible: height == childrenRect.height + anchors.top: printerInfo.bottom + width: parent.width + height: !base.collapsed ? childrenRect.height : 0 + opacity: visible ? 1 : 0 + Behavior on height { NumberAnimation { duration: 100 } } + Behavior on opacity { NumberAnimation { duration: 100 } } + Rectangle { - id: printJobName - text: modelData.activePrintJob != null ? modelData.activePrintJob.name : "" - font: UM.Theme.getFont("default_bold") - } - Label - { - id: ownerName - anchors.top: printJobName.bottom - text: modelData.activePrintJob != null ? modelData.activePrintJob.owner : "" + id: topSpacer + color: UM.Theme.getColor("viewport_background") + height: 2 + anchors + { + left: parent.left + right: parent.right + margins: UM.Theme.getSize("default_margin").width + top: parent.top + topMargin: UM.Theme.getSize("default_margin").width + } } - Image + Row { - id: printJobPreview - source: modelData.activePrintJob != null ? modelData.activePrintJob.preview_image_url : "" - anchors.top: ownerName.bottom - anchors.horizontalCenter: parent.horizontalCenter - width: parent.width / 2 - height: width + id: extrudersInfo + anchors.top: topSpacer.bottom + anchors.topMargin: 2 * UM.Theme.getSize("default_margin").height + anchors.left: parent.left + anchors.leftMargin: 2 * UM.Theme.getSize("default_margin").width + anchors.right: parent.right + anchors.rightMargin: 2 * UM.Theme.getSize("default_margin").width + height: childrenRect.height + spacing: UM.Theme.getSize("default_margin").width + + PrintCoreConfiguration + { + id: leftExtruderInfo + width: Math.round(parent.width / 2) + printCoreConfiguration: modelData.printerConfiguration.extruderConfigurations[0] + } + + PrintCoreConfiguration + { + id: rightExtruderInfo + width: Math.round(parent.width / 2) + printCoreConfiguration: modelData.printerConfiguration.extruderConfigurations[1] + } } Rectangle { - id: showCameraIcon - width: 35 * screenScaleFactor - height: width - radius: 0.5 * width + id: jobSpacer + color: UM.Theme.getColor("viewport_background") + height: 2 + anchors + { + left: parent.left + right: parent.right + margins: UM.Theme.getSize("default_margin").width + top: extrudersInfo.bottom + topMargin: 2 * UM.Theme.getSize("default_margin").height + } + } + + Item + { + id: jobInfo + property var showJobInfo: modelData.activePrintJob != null && modelData.activePrintJob.state != "queued" + + anchors.top: jobSpacer.bottom + anchors.topMargin: 2 * UM.Theme.getSize("default_margin").height anchors.left: parent.left - anchors.bottom: printJobPreview.bottom - color: UM.Theme.getColor("setting_control_border_highlight") + anchors.right: parent.right + anchors.margins: UM.Theme.getSize("default_margin").width + anchors.leftMargin: 2 * UM.Theme.getSize("default_margin").width + height: showJobInfo ? childrenRect.height + 2 * UM.Theme.getSize("default_margin").height: 0 + visible: showJobInfo + Label + { + id: printJobName + text: modelData.activePrintJob != null ? modelData.activePrintJob.name : "" + font: UM.Theme.getFont("default_bold") + } + Label + { + id: ownerName + anchors.top: printJobName.bottom + text: modelData.activePrintJob != null ? modelData.activePrintJob.owner : "" + } + Image { - width: parent.width + id: printJobPreview + source: modelData.activePrintJob != null ? modelData.activePrintJob.preview_image_url : "" + anchors.top: ownerName.bottom + anchors.horizontalCenter: parent.horizontalCenter + width: parent.width / 2 height: width - anchors.right: parent.right - anchors.rightMargin: parent.rightMargin - source: "camera-icon.svg" } - MouseArea + + Rectangle { - anchors.fill:parent - onClicked: + id: showCameraIcon + width: 35 * screenScaleFactor + height: width + radius: 0.5 * width + anchors.left: parent.left + anchors.bottom: printJobPreview.bottom + color: UM.Theme.getColor("setting_control_border_highlight") + Image { - OutputDevice.setActiveCamera(modelData.camera) + width: parent.width + height: width + anchors.right: parent.right + anchors.rightMargin: parent.rightMargin + source: "camera-icon.svg" + } + MouseArea + { + anchors.fill:parent + onClicked: + { + OutputDevice.setActiveCamera(modelData.camera) + } } } } } - } - ProgressBar - { - property var progress: + ProgressBar { - if(modelData.activePrintJob == null) - { - return 0 - } - var result = modelData.activePrintJob.timeElapsed / modelData.activePrintJob.timeTotal - if(result > 1.0) - { - result = 1.0 - } - return result - } - - id: jobProgressBar - width: parent.width - value: progress - anchors.top: detailedInfo.bottom - anchors.topMargin: UM.Theme.getSize("default_margin").height - - visible: modelData.activePrintJob != null && modelData.activePrintJob != undefined - - style: ProgressBarStyle - { - property var progressText: + property var progress: { if(modelData.activePrintJob == null) { - return "" + return 0 } - - switch(modelData.activePrintJob.state) + var result = modelData.activePrintJob.timeElapsed / modelData.activePrintJob.timeTotal + if(result > 1.0) { - case "wait_cleanup": - return catalog.i18nc("@label:status", "Finshed") - case "pre_print": - case "sent_to_printer": - return catalog.i18nc("@label:status", "Preparing") - case "aborted": - case "wait_user_action": - return catalog.i18nc("@label:status", "Aborted") - case "pausing": - case "paused": - return catalog.i18nc("@label:status", "Paused") - case "resuming": - return catalog.i18nc("@label:status", "Resuming") - default: - OutputDevice.formatDuration(modelData.activePrintJob.timeTotal - modelData.activePrintJob.timeElapsed) + result = 1.0 } + return result } - background: Rectangle - { - implicitWidth: 100 - implicitHeight: visible ? 24 : 0 - color: UM.Theme.getColor("viewport_background") - } + id: jobProgressBar + width: parent.width + value: progress + anchors.top: detailedInfo.bottom + anchors.topMargin: UM.Theme.getSize("default_margin").height - progress: Rectangle + visible: modelData.activePrintJob != null && modelData.activePrintJob != undefined + + style: ProgressBarStyle { - color: UM.Theme.getColor("primary") - id: progressItem - function getTextOffset() + property var progressText: { - if(progressItem.width + progressLabel.width < control.width) + if(modelData.activePrintJob == null) { - return progressItem.width + UM.Theme.getSize("default_margin").width + return "" } - else + + switch(modelData.activePrintJob.state) { - return progressItem.width - progressLabel.width - UM.Theme.getSize("default_margin").width + case "wait_cleanup": + return catalog.i18nc("@label:status", "Finshed") + case "pre_print": + case "sent_to_printer": + return catalog.i18nc("@label:status", "Preparing") + case "aborted": + case "wait_user_action": + return catalog.i18nc("@label:status", "Aborted") + case "pausing": + case "paused": + return catalog.i18nc("@label:status", "Paused") + case "resuming": + return catalog.i18nc("@label:status", "Resuming") + default: + OutputDevice.formatDuration(modelData.activePrintJob.timeTotal - modelData.activePrintJob.timeElapsed) } } - Label + background: Rectangle { - id: progressLabel - anchors.left: parent.left - anchors.leftMargin: getTextOffset() - text: progressText - anchors.verticalCenter: parent.verticalCenter - color: progressItem.width + progressLabel.width < control.width ? "black" : "white" - width: contentWidth + implicitWidth: 100 + implicitHeight: visible ? 24 : 0 + color: UM.Theme.getColor("viewport_background") + } + + progress: Rectangle + { + color: UM.Theme.getColor("primary") + id: progressItem + function getTextOffset() + { + if(progressItem.width + progressLabel.width < control.width) + { + return progressItem.width + UM.Theme.getSize("default_margin").width + } + else + { + return progressItem.width - progressLabel.width - UM.Theme.getSize("default_margin").width + } + } + + Label + { + id: progressLabel + anchors.left: parent.left + anchors.leftMargin: getTextOffset() + text: progressText + anchors.verticalCenter: parent.verticalCenter + color: progressItem.width + progressLabel.width < control.width ? "black" : "white" + width: contentWidth + } } } } From 36da9cc9e5ddb33208360dcf1f20244ced10cb17 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 24 Aug 2018 13:52:34 +0200 Subject: [PATCH 31/67] Added verticalOffset to popup shadow. This way it's more in line with the rest of the elements CL-896 --- plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml index 8562eb3c61..a6b35ca44a 100644 --- a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml +++ b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml @@ -235,6 +235,7 @@ Item color: "#3F000000" // 25% shadow source: pointedRectangle transparentBorder: true + verticalOffset: 2 } Item From 5605ff3b4629ad294b5a5924297c5d842f812d86 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 24 Aug 2018 14:07:56 +0200 Subject: [PATCH 32/67] Fixed fonts CL-896 --- plugins/UM3NetworkPrinting/ClusterControlItem.qml | 8 +++++++- plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml | 3 +++ plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml | 6 ++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index 95a823d950..0574a2eba5 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -52,7 +52,7 @@ Component top: printingLabel.bottom left: parent.left right: parent.right - topMargin: 2 * UM.Theme.getSize("default_margin").height + topMargin: 1 * UM.Theme.getSize("default_margin").height bottom: parent.bottom bottomMargin: UM.Theme.getSize("default_margin").height } @@ -134,6 +134,7 @@ Component anchors.right: collapseIcon.left anchors.rightMargin: UM.Theme.getSize("default_margin").width elide: Text.ElideRight + font: UM.Theme.getFont("default_bold") } UM.RecolorImage @@ -159,6 +160,8 @@ Component anchors.right: collapseIcon.left anchors.rightMargin: UM.Theme.getSize("default_margin").width elide: Text.ElideRight + font: UM.Theme.getFont("default") + opacity: 0.6 } } @@ -254,6 +257,8 @@ Component id: ownerName anchors.top: printJobName.bottom text: modelData.activePrintJob != null ? modelData.activePrintJob.owner : "" + font: UM.Theme.getFont("default") + opacity: 0.6 } Image @@ -380,6 +385,7 @@ Component anchors.verticalCenter: parent.verticalCenter color: progressItem.width + progressLabel.width < control.width ? "black" : "white" width: contentWidth + font: UM.Theme.getFont("default") } } } diff --git a/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml b/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml index c8825cd197..ddac895d29 100644 --- a/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml +++ b/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml @@ -79,6 +79,9 @@ Item anchors.top: materialLabel.bottom elide: Text.ElideRight + opacity: 0.6 + font: UM.Theme.getFont("default") + anchors { top: materialLabel.bottom diff --git a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml index a6b35ca44a..e7b5e1c59d 100644 --- a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml +++ b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml @@ -70,6 +70,8 @@ Item id: ownerName anchors.top: printJobName.bottom text: printJob.owner + font: UM.Theme.getFont("default") + opacity: 0.6 } Image @@ -84,10 +86,10 @@ Item Label { id: totalTimeLabel - + opacity: 0.6 anchors.bottom: parent.bottom anchors.right: parent.right - + font: UM.Theme.getFont("default") text: printJob != null ? getPrettyTime(printJob.timeTotal) : "" elide: Text.ElideRight } From 86f872ae706ef7be6b15725bf28fa0c28378ae35 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 24 Aug 2018 14:12:49 +0200 Subject: [PATCH 33/67] Decreased the spacing between printJob tiles in the queueuueueu CL-896 --- plugins/UM3NetworkPrinting/ClusterControlItem.qml | 1 - plugins/UM3NetworkPrinting/ClusterMonitorItem.qml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index 0574a2eba5..7100fb0fd7 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -44,7 +44,6 @@ Component elide: Text.ElideRight } - ScrollView { anchors diff --git a/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml b/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml index ff5fad5abd..8d46ac94c6 100644 --- a/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml @@ -72,7 +72,7 @@ Component { anchors.fill: parent anchors.margins: UM.Theme.getSize("default_margin").height - spacing: UM.Theme.getSize("default_margin").height + spacing: UM.Theme.getSize("default_margin").height - 10 // 2x the shadow radius model: OutputDevice.queuedPrintJobs From aee90081e59ab94bebd18ee86b143d385dccc7b5 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 24 Aug 2018 14:51:13 +0200 Subject: [PATCH 34/67] Added machine icons --- plugins/UM3NetworkPrinting/UM3-icon.svg | 1 + plugins/UM3NetworkPrinting/UM3x-icon.svg | 1 + plugins/UM3NetworkPrinting/UMs5-icon.svg | 1 + 3 files changed, 3 insertions(+) create mode 100644 plugins/UM3NetworkPrinting/UM3-icon.svg create mode 100644 plugins/UM3NetworkPrinting/UM3x-icon.svg create mode 100644 plugins/UM3NetworkPrinting/UMs5-icon.svg diff --git a/plugins/UM3NetworkPrinting/UM3-icon.svg b/plugins/UM3NetworkPrinting/UM3-icon.svg new file mode 100644 index 0000000000..6b5d4e4895 --- /dev/null +++ b/plugins/UM3NetworkPrinting/UM3-icon.svg @@ -0,0 +1 @@ +UM3-icon \ No newline at end of file diff --git a/plugins/UM3NetworkPrinting/UM3x-icon.svg b/plugins/UM3NetworkPrinting/UM3x-icon.svg new file mode 100644 index 0000000000..3708173dc5 --- /dev/null +++ b/plugins/UM3NetworkPrinting/UM3x-icon.svg @@ -0,0 +1 @@ +UM3x-icon \ No newline at end of file diff --git a/plugins/UM3NetworkPrinting/UMs5-icon.svg b/plugins/UM3NetworkPrinting/UMs5-icon.svg new file mode 100644 index 0000000000..78437465b3 --- /dev/null +++ b/plugins/UM3NetworkPrinting/UMs5-icon.svg @@ -0,0 +1 @@ +UMs5-icon \ No newline at end of file From d7e907f1a56c1fdf89e8316cdad51b5ef65889b0 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 24 Aug 2018 15:13:29 +0200 Subject: [PATCH 35/67] Icons are now displayed in the printerTile CL-896 --- .../UM3NetworkPrinting/ClusterControlItem.qml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index 7100fb0fd7..34b097b006 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -112,14 +112,27 @@ Component onClicked: base.collapsed = !base.collapsed } - Rectangle + UM.RecolorImage { id: machineIcon anchors.top: parent.top anchors.leftMargin: UM.Theme.getSize("default_margin").width anchors.left: parent.left - width: 50 - height: 50 + source: + { + switch(modelData.type) + { + case "Ultimaker 3": + return "UM3-icon.svg" + case "Ultimaker 3 Extended": + return "UM3x-icon.svg" + case "Ultimaker S5": + return "UMs5-icon.svg" + } + } + width: sourceSize.width + height: sourceSize.height + color: modelData.activePrintJob != undefined ? UM.Theme.getColor("primary") : UM.Theme.getColor("setting_control_disabled") } From 9564f98ccc639fa718b933f632aeaa2d55586307 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 24 Aug 2018 16:06:29 +0200 Subject: [PATCH 36/67] Added context menu to printerTile CL-893 --- .../UM3NetworkPrinting/ClusterControlItem.qml | 160 +++++++++++++++++- .../ClusterUM3PrinterOutputController.py | 2 - .../UM3NetworkPrinting/PrintJobInfoBlock.qml | 1 - 3 files changed, 159 insertions(+), 4 deletions(-) diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index 34b097b006..753197cdca 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -3,6 +3,7 @@ import QtQuick.Controls 1.4 import QtQuick.Controls.Styles 1.3 import QtGraphicalEffects 1.0 +import QtQuick.Controls 2.0 as Controls2 import UM 1.3 as UM import Cura 1.0 as Cura @@ -132,7 +133,7 @@ Component } width: sourceSize.width height: sourceSize.height - + color: modelData.activePrintJob != undefined ? UM.Theme.getColor("primary") : UM.Theme.getColor("setting_control_disabled") } @@ -272,6 +273,163 @@ Component font: UM.Theme.getFont("default") opacity: 0.6 } + function switchPopupState() + { + popup.visible ? popup.close() : popup.open() + } + Controls2.Button + { + id: contextButton + text: "\u22EE" //Unicode; Three stacked points. + font.pixelSize: 25 + width: 35 + height: width + anchors + { + right: parent.right + top: parent.top + } + hoverEnabled: true + + background: Rectangle + { + opacity: contextButton.down || contextButton.hovered ? 1 : 0 + width: contextButton.width + height: contextButton.height + radius: 0.5 * width + color: UM.Theme.getColor("viewport_background") + } + + onClicked: parent.switchPopupState() + } + + Controls2.Popup + { + // TODO Change once updating to Qt5.10 - The 'opened' property is in 5.10 but the behavior is now implemented with the visible property + id: popup + clip: true + closePolicy: Controls2.Popup.CloseOnPressOutsideParent + x: parent.width - width + y: contextButton.height + width: 200 + height: contentItem.height + 2 * padding + visible: false + + transformOrigin: Controls2.Popup.Top + contentItem: Item + { + width: popup.width - 2 * popup.padding + height: childrenRect.height + 15 + Controls2.Button + { + id: pauseButton + text: modelData.activePrintJob.state == "paused" ? catalog.i18nc("@label", "Resume") : catalog.i18nc("@label", "Pause") + onClicked: + { + if(modelData.activePrintJob.state == "paused") + { + modelData.activePrintJob.setState("print") + } + else if(modelData.activePrintJob.state == "printing") + { + modelData.activePrintJob.setState("pause") + } + popup.close() + } + width: parent.width + enabled: ["paused", "printing"].indexOf(modelData.activePrintJob.state) >= 0 + anchors.top: parent.top + anchors.topMargin: 10 + hoverEnabled: true + background: Rectangle + { + opacity: pauseButton.down || pauseButton.hovered ? 1 : 0 + color: UM.Theme.getColor("viewport_background") + } + } + + Controls2.Button + { + id: abortButton + text: catalog.i18nc("@label", "Abort") + onClicked: + { + modelData.activePrintJob.setState("abort") + popup.close() + } + width: parent.width + anchors.top: pauseButton.bottom + hoverEnabled: true + enabled: ["paused", "printing", "pre_print"].indexOf(modelData.activePrintJob.state) >= 0 + background: Rectangle + { + opacity: abortButton.down || abortButton.hovered ? 1 : 0 + color: UM.Theme.getColor("viewport_background") + } + } + } + + background: Item + { + width: popup.width + height: popup.height + + DropShadow + { + anchors.fill: pointedRectangle + radius: 5 + color: "#3F000000" // 25% shadow + source: pointedRectangle + transparentBorder: true + verticalOffset: 2 + } + + Item + { + id: pointedRectangle + width: parent.width -10 + height: parent.height -10 + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + + Rectangle + { + id: point + height: 13 + width: 13 + color: UM.Theme.getColor("setting_control") + transform: Rotation { angle: 45} + anchors.right: bloop.right + y: 1 + } + + Rectangle + { + id: bloop + color: UM.Theme.getColor("setting_control") + width: parent.width + anchors.top: parent.top + anchors.topMargin: 10 + anchors.bottom: parent.bottom + anchors.bottomMargin: 5 + } + } + } + + exit: Transition + { + // This applies a default NumberAnimation to any changes a state change makes to x or y properties + NumberAnimation { property: "visible"; duration: 75; } + } + enter: Transition + { + // This applies a default NumberAnimation to any changes a state change makes to x or y properties + NumberAnimation { property: "visible"; duration: 75; } + } + + onClosed: visible = false + onOpened: visible = true + } Image { diff --git a/plugins/UM3NetworkPrinting/ClusterUM3PrinterOutputController.py b/plugins/UM3NetworkPrinting/ClusterUM3PrinterOutputController.py index 4a0319cafc..fcced0b883 100644 --- a/plugins/UM3NetworkPrinting/ClusterUM3PrinterOutputController.py +++ b/plugins/UM3NetworkPrinting/ClusterUM3PrinterOutputController.py @@ -6,8 +6,6 @@ from cura.PrinterOutput.PrinterOutputController import PrinterOutputController MYPY = False if MYPY: from cura.PrinterOutput.PrintJobOutputModel import PrintJobOutputModel - from cura.PrinterOutput.PrinterOutputModel import PrinterOutputModel - class ClusterUM3PrinterOutputController(PrinterOutputController): def __init__(self, output_device): diff --git a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml index e7b5e1c59d..427aa8b851 100644 --- a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml +++ b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml @@ -166,7 +166,6 @@ Item onClicked: parent.switchPopupState() } - Popup { // TODO Change once updating to Qt5.10 - The 'opened' property is in 5.10 but the behavior is now implemented with the visible property From d57f166b082ef7fc1f72decfed29568ab90a49f9 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 24 Aug 2018 16:26:51 +0200 Subject: [PATCH 37/67] Added opacity to preview if print is done / paused CL-896 --- .../UM3NetworkPrinting/ClusterControlItem.qml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index 753197cdca..ca1ae07585 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -439,6 +439,23 @@ Component anchors.horizontalCenter: parent.horizontalCenter width: parent.width / 2 height: width + opacity: + { + if(modelData.activePrintJob == null) + { + return 1.0 + } + + switch(modelData.activePrintJob.state) + { + case "wait_cleanup": + case "wait_user_action": + case "paused": + return 0.5 + default: + return 1.0 + } + } } Rectangle From 39b12fed770c4e32b753b5e0007a75c0ddd788fd Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 24 Aug 2018 16:47:46 +0200 Subject: [PATCH 38/67] Added icons to beter indicate printjob state CL-896 --- .../UM3NetworkPrinting/ClusterControlItem.qml | 32 +++++++++++++++++++ plugins/UM3NetworkPrinting/aborted-icon.svg | 1 + plugins/UM3NetworkPrinting/approved-icon.svg | 1 + plugins/UM3NetworkPrinting/paused-icon.svg | 1 + 4 files changed, 35 insertions(+) create mode 100644 plugins/UM3NetworkPrinting/aborted-icon.svg create mode 100644 plugins/UM3NetworkPrinting/approved-icon.svg create mode 100644 plugins/UM3NetworkPrinting/paused-icon.svg diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index ca1ae07585..01aeb85cde 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -456,6 +456,38 @@ Component return 1.0 } } + + + } + + UM.RecolorImage + { + id: statusImage + anchors.centerIn: printJobPreview + source: + { + if(modelData.activePrintJob == null) + { + return "" + } + switch(modelData.activePrintJob.state) + { + case "paused": + return "paused-icon.svg" + case "wait_cleanup": + return "approved-icon.svg" + case "wait_user_action": + return "aborted-icon.svg" + default: + return "" + } + } + visible: source != "" + width: 0.5 * printJobPreview.width + height: 0.5 * printJobPreview.height + sourceSize.width: width + sourceSize.height: height + color: "black" } Rectangle diff --git a/plugins/UM3NetworkPrinting/aborted-icon.svg b/plugins/UM3NetworkPrinting/aborted-icon.svg new file mode 100644 index 0000000000..7ef82c8911 --- /dev/null +++ b/plugins/UM3NetworkPrinting/aborted-icon.svg @@ -0,0 +1 @@ +aborted-icon \ No newline at end of file diff --git a/plugins/UM3NetworkPrinting/approved-icon.svg b/plugins/UM3NetworkPrinting/approved-icon.svg new file mode 100644 index 0000000000..671957d709 --- /dev/null +++ b/plugins/UM3NetworkPrinting/approved-icon.svg @@ -0,0 +1 @@ +approved-icon \ No newline at end of file diff --git a/plugins/UM3NetworkPrinting/paused-icon.svg b/plugins/UM3NetworkPrinting/paused-icon.svg new file mode 100644 index 0000000000..a66217d662 --- /dev/null +++ b/plugins/UM3NetworkPrinting/paused-icon.svg @@ -0,0 +1 @@ +paused-icon \ No newline at end of file From 1749a6f9d5c06205721b07606eef6f95aadab392 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 24 Aug 2018 17:08:32 +0200 Subject: [PATCH 39/67] Fixed some QML errors --- plugins/UM3NetworkPrinting/ClusterControlItem.qml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index 01aeb85cde..12381d3f7a 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -323,7 +323,7 @@ Component Controls2.Button { id: pauseButton - text: modelData.activePrintJob.state == "paused" ? catalog.i18nc("@label", "Resume") : catalog.i18nc("@label", "Pause") + text: modelData.activePrintJob != null && modelData.activePrintJob.state == "paused" ? catalog.i18nc("@label", "Resume") : catalog.i18nc("@label", "Pause") onClicked: { if(modelData.activePrintJob.state == "paused") @@ -337,7 +337,7 @@ Component popup.close() } width: parent.width - enabled: ["paused", "printing"].indexOf(modelData.activePrintJob.state) >= 0 + enabled: modelData.activePrintJob != null && ["paused", "printing"].indexOf(modelData.activePrintJob.state) >= 0 anchors.top: parent.top anchors.topMargin: 10 hoverEnabled: true @@ -360,7 +360,7 @@ Component width: parent.width anchors.top: pauseButton.bottom hoverEnabled: true - enabled: ["paused", "printing", "pre_print"].indexOf(modelData.activePrintJob.state) >= 0 + enabled: modelData.activePrintJob != null && ["paused", "printing", "pre_print"].indexOf(modelData.activePrintJob.state) >= 0 background: Rectangle { opacity: abortButton.down || abortButton.hovered ? 1 : 0 From 60353bcd67836225537aef9de182760e6fa9bbae Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 29 Aug 2018 11:00:24 +0200 Subject: [PATCH 40/67] Added missing elides CL-896 --- plugins/UM3NetworkPrinting/ClusterControlItem.qml | 6 ++++++ plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index 12381d3f7a..153adce252 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -264,6 +264,8 @@ Component id: printJobName text: modelData.activePrintJob != null ? modelData.activePrintJob.name : "" font: UM.Theme.getFont("default_bold") + width: parent.width + elide: Text.ElideRight } Label { @@ -272,11 +274,15 @@ Component text: modelData.activePrintJob != null ? modelData.activePrintJob.owner : "" font: UM.Theme.getFont("default") opacity: 0.6 + width: parent.width + elide: Text.ElideRight } + function switchPopupState() { popup.visible ? popup.close() : popup.open() } + Controls2.Button { id: contextButton diff --git a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml index 427aa8b851..5024e8eef1 100644 --- a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml +++ b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml @@ -63,6 +63,8 @@ Item id: printJobName text: printJob.name font: UM.Theme.getFont("default_bold") + width: parent.width + elide: Text.ElideRight } Label @@ -72,6 +74,8 @@ Item text: printJob.owner font: UM.Theme.getFont("default") opacity: 0.6 + width: parent.width + elide: Text.ElideRight } Image From 14f253017b3c6a1fe57572ae8e6d061f06fedf37 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 30 Aug 2018 10:21:50 +0200 Subject: [PATCH 41/67] Align printer name & printjob name with center of printer icon CL-896 --- .../UM3NetworkPrinting/ClusterControlItem.qml | 56 +++++++++++-------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index 153adce252..e2a77063b5 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -137,17 +137,38 @@ Component color: modelData.activePrintJob != undefined ? UM.Theme.getColor("primary") : UM.Theme.getColor("setting_control_disabled") } - Label + Item { - id: machineNameLabel - text: modelData.name - anchors.top: machineIcon.top - anchors.left: machineIcon.right - anchors.leftMargin: UM.Theme.getSize("default_margin").width - anchors.right: collapseIcon.left - anchors.rightMargin: UM.Theme.getSize("default_margin").width - elide: Text.ElideRight - font: UM.Theme.getFont("default_bold") + height: childrenRect.height + anchors + { + right: collapseIcon.left + rightMargin: UM.Theme.getSize("default_margin").width + left: machineIcon.right + leftMargin: UM.Theme.getSize("default_margin").width + + verticalCenter: machineIcon.verticalCenter + } + + Label + { + id: machineNameLabel + text: modelData.name + width: parent.width + elide: Text.ElideRight + font: UM.Theme.getFont("default_bold") + } + + Label + { + id: activeJobLabel + text: modelData.activePrintJob != null ? modelData.activePrintJob.name : "waiting" + anchors.top: machineNameLabel.bottom + width: parent.width + elide: Text.ElideRight + font: UM.Theme.getFont("default") + opacity: 0.6 + } } UM.RecolorImage @@ -163,19 +184,6 @@ Component anchors.rightMargin: UM.Theme.getSize("default_margin").width color: "black" } - - Label - { - id: activeJobLabel - text: modelData.activePrintJob != null ? modelData.activePrintJob.name : "waiting" - anchors.top: machineNameLabel.bottom - anchors.left: machineNameLabel.left - anchors.right: collapseIcon.left - anchors.rightMargin: UM.Theme.getSize("default_margin").width - elide: Text.ElideRight - font: UM.Theme.getFont("default") - opacity: 0.6 - } } Item @@ -573,6 +581,8 @@ Component return catalog.i18nc("@label:status", "Paused") case "resuming": return catalog.i18nc("@label:status", "Resuming") + case "queued": + return catalog.i18nc("@label:status", "Configuration change") default: OutputDevice.formatDuration(modelData.activePrintJob.timeTotal - modelData.activePrintJob.timeElapsed) } From fd1b0a80e7330d61eeefb7dd4b4a3196070ccb63 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 30 Aug 2018 10:32:37 +0200 Subject: [PATCH 42/67] Fixed alignment of printCoreConfiguration CL-896 --- .../PrintCoreConfiguration.qml | 64 +++++++++---------- 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml b/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml index ddac895d29..e6f2372874 100644 --- a/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml +++ b/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml @@ -18,6 +18,8 @@ Item id: extruderCircle width: 30 height: 30 + + anchors.verticalCenter: printAndMaterialLabel.verticalCenter opacity: { if(printCoreConfiguration == undefined || printCoreConfiguration.activeMaterial == undefined || printCoreConfiguration.hotendID == undefined) @@ -31,7 +33,7 @@ Item { anchors.fill: parent radius: Math.round(width / 2) - border.width: 1 + border.width: 2 border.color: "black" } @@ -43,52 +45,48 @@ Item } } - Label + Item { - id: materialLabel - text: - { - if(printCoreConfiguration != undefined && printCoreConfiguration.activeMaterial != undefined) - { - return printCoreConfiguration.activeMaterial.name - } - return "" - } - font: UM.Theme.getFont("default_bold") - elide: Text.ElideRight - + id: printAndMaterialLabel anchors { right: parent.right left: extruderCircle.right margins: UM.Theme.getSize("default_margin").width } - } + height: childrenRect.height - Label - { - id: printCoreLabel - text: + Label { - if(printCoreConfiguration != undefined && printCoreConfiguration.hotendID != undefined) + id: materialLabel + text: { - return printCoreConfiguration.hotendID + if(printCoreConfiguration != undefined && printCoreConfiguration.activeMaterial != undefined) + { + return printCoreConfiguration.activeMaterial.name + } + return "" } - return "" + font: UM.Theme.getFont("default_bold") + elide: Text.ElideRight } - anchors.top: materialLabel.bottom - elide: Text.ElideRight - opacity: 0.6 - font: UM.Theme.getFont("default") - - anchors + Label { - top: materialLabel.bottom - right: parent.right - left: extruderCircle.right - leftMargin: UM.Theme.getSize("default_margin").width - rightMargin: UM.Theme.getSize("default_margin").width + id: printCoreLabel + text: + { + if(printCoreConfiguration != undefined && printCoreConfiguration.hotendID != undefined) + { + return printCoreConfiguration.hotendID + } + return "" + } + anchors.top: materialLabel.bottom + elide: Text.ElideRight + + opacity: 0.6 + font: UM.Theme.getFont("default") } } } From e2bcf4dfa82611412f99b553237c8a2f9f8f7a24 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 30 Aug 2018 17:18:48 +0200 Subject: [PATCH 43/67] Show correct labels & status icon if print was aborted CL-896 --- plugins/UM3NetworkPrinting/ClusterControlItem.qml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index e2a77063b5..4978ce821a 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -489,6 +489,10 @@ Component case "paused": return "paused-icon.svg" case "wait_cleanup": + if(modelData.activePrintJob.timeElapsed < modelData.activePrintJob.timeTotal) + { + return "aborted-icon.svg" + } return "approved-icon.svg" case "wait_user_action": return "aborted-icon.svg" @@ -569,7 +573,11 @@ Component switch(modelData.activePrintJob.state) { case "wait_cleanup": - return catalog.i18nc("@label:status", "Finshed") + if(modelData.activePrintJob.timeTotal > modelData.activePrintJob.timeElapsed) + { + return catalog.i18nc("@label:status", "Aborted") + } + return catalog.i18nc("@label:status", "Finished") case "pre_print": case "sent_to_printer": return catalog.i18nc("@label:status", "Preparing") From 3ce9b481a29dae0eb73b287c4f3a4b437d1dd94b Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 31 Aug 2018 15:01:54 +0200 Subject: [PATCH 44/67] Add rabithole links to cluster monitor page CL-896 --- .../UM3NetworkPrinting/ClusterControlItem.qml | 22 +++++++++++++++++++ .../UM3NetworkPrinting/ClusterMonitorItem.qml | 21 ++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index 4978ce821a..2ee5054fc0 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -45,8 +45,30 @@ Component elide: Text.ElideRight } + Label + { + id: managePrintersLabel + anchors.rightMargin: 4 * UM.Theme.getSize("default_margin").width + anchors.right: printerScrollView.right + anchors.bottom: printingLabel.bottom + text: catalog.i18nc("@label link to connect manager", "Manage printers") + font: UM.Theme.getFont("default") + color: UM.Theme.getColor("primary") + linkColor: UM.Theme.getColor("primary") + } + + MouseArea + { + anchors.fill: managePrintersLabel + hoverEnabled: true + onClicked: Cura.MachineManager.printerOutputDevices[0].openPrinterControlPanel() + onEntered: managePrintersLabel.font.underline = true + onExited: managePrintersLabel.font.underline = false + } + ScrollView { + id: printerScrollView anchors { top: printingLabel.bottom diff --git a/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml b/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml index 8d46ac94c6..a7a18753fb 100644 --- a/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml @@ -40,6 +40,27 @@ Component visible: OutputDevice.printers.length == 0 } + Label + { + id: manageQueueLabel + anchors.rightMargin: 5 * UM.Theme.getSize("default_margin").width + anchors.right: queuedPrintJobs.right + anchors.bottom: queuedLabel.bottom + text: catalog.i18nc("@label link to connect manager", "Manage queue") + font: UM.Theme.getFont("default") + color: UM.Theme.getColor("primary") + linkColor: UM.Theme.getColor("primary") + } + + MouseArea + { + anchors.fill: manageQueueLabel + hoverEnabled: true + onClicked: Cura.MachineManager.printerOutputDevices[0].openPrintJobControlPanel() + onEntered: manageQueueLabel.font.underline = true + onExited: manageQueueLabel.font.underline = false + } + Label { id: queuedLabel From 485058c3def4bc56afc55c9c663a71822941a784 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 31 Aug 2018 15:50:34 +0200 Subject: [PATCH 45/67] Made queue have a max width CL-896 --- plugins/UM3NetworkPrinting/ClusterMonitorItem.qml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml b/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml index a7a18753fb..3ff012d6d4 100644 --- a/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml @@ -79,20 +79,18 @@ Component anchors { - margins: UM.Theme.getSize("default_margin").width top: queuedLabel.bottom topMargin: 0 - left: parent.left + horizontalCenter: parent.horizontalCenter bottomMargin: 0 - right: parent.right bottom: parent.bottom } style: UM.Theme.styles.scrollview - + width: Math.min(800 * screenScaleFactor, maximumWidth) ListView { anchors.fill: parent - anchors.margins: UM.Theme.getSize("default_margin").height + //anchors.margins: UM.Theme.getSize("default_margin").height spacing: UM.Theme.getSize("default_margin").height - 10 // 2x the shadow radius model: OutputDevice.queuedPrintJobs @@ -103,6 +101,7 @@ Component anchors.left: parent.left anchors.right: parent.right anchors.rightMargin: UM.Theme.getSize("default_margin").height + anchors.leftMargin: UM.Theme.getSize("default_margin").height height: 175 * screenScaleFactor } } From 224108c342a45d10b005e18ffaf089e24df2fad3 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 31 Aug 2018 15:55:22 +0200 Subject: [PATCH 46/67] Decrease width of popups for cluster monitor CL-896 --- plugins/UM3NetworkPrinting/ClusterControlItem.qml | 2 +- plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index 2ee5054fc0..068d5769ee 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -347,7 +347,7 @@ Component closePolicy: Controls2.Popup.CloseOnPressOutsideParent x: parent.width - width y: contextButton.height - width: 200 + width: 160 height: contentItem.height + 2 * padding visible: false diff --git a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml index 5024e8eef1..e54e70043e 100644 --- a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml +++ b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml @@ -178,7 +178,7 @@ Item closePolicy: Popup.CloseOnPressOutsideParent x: parent.width - width y: contextButton.height - width: 200 + width: 160 height: contentItem.height + 2 * padding visible: false From 8aef7216ec21580c2c987ed16d5e2768d1adff07 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 31 Aug 2018 16:11:20 +0200 Subject: [PATCH 47/67] Increase the margin between print montior header and tiles CL-896 --- plugins/UM3NetworkPrinting/ClusterControlItem.qml | 2 +- plugins/UM3NetworkPrinting/ClusterMonitorItem.qml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index 068d5769ee..c0dad98708 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -74,7 +74,7 @@ Component top: printingLabel.bottom left: parent.left right: parent.right - topMargin: 1 * UM.Theme.getSize("default_margin").height + topMargin: UM.Theme.getSize("default_margin").height bottom: parent.bottom bottomMargin: UM.Theme.getSize("default_margin").height } diff --git a/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml b/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml index 3ff012d6d4..a3bfdeb843 100644 --- a/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml @@ -80,7 +80,7 @@ Component anchors { top: queuedLabel.bottom - topMargin: 0 + topMargin: UM.Theme.getSize("default_margin").height horizontalCenter: parent.horizontalCenter bottomMargin: 0 bottom: parent.bottom From 98d0ad6c270459b152916197e2f0cb26328240b6 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 31 Aug 2018 16:47:26 +0200 Subject: [PATCH 48/67] Add printer pill type to cluster monitor printer tile CL-896 --- .../UM3NetworkPrinting/ClusterControlItem.qml | 14 ++++++++-- .../UM3NetworkPrinting/PrinterFamilyPill.qml | 28 +++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 plugins/UM3NetworkPrinting/PrinterFamilyPill.qml diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index c0dad98708..dbc5465056 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -233,11 +233,21 @@ Component topMargin: UM.Theme.getSize("default_margin").width } } - + PrinterFamilyPill + { + id: printerFamilyPill + color: UM.Theme.getColor("viewport_background") + anchors.top: topSpacer.bottom + anchors.topMargin: 2 * UM.Theme.getSize("default_margin").height + text: modelData.type + anchors.left: parent.left + anchors.leftMargin: UM.Theme.getSize("default_margin").width + padding: 3 + } Row { id: extrudersInfo - anchors.top: topSpacer.bottom + anchors.top: printerFamilyPill.bottom anchors.topMargin: 2 * UM.Theme.getSize("default_margin").height anchors.left: parent.left anchors.leftMargin: 2 * UM.Theme.getSize("default_margin").width diff --git a/plugins/UM3NetworkPrinting/PrinterFamilyPill.qml b/plugins/UM3NetworkPrinting/PrinterFamilyPill.qml new file mode 100644 index 0000000000..b785cd02b7 --- /dev/null +++ b/plugins/UM3NetworkPrinting/PrinterFamilyPill.qml @@ -0,0 +1,28 @@ +import QtQuick 2.2 +import QtQuick.Controls 1.4 +import UM 1.2 as UM + +Item +{ + property alias color: background.color + property alias text: familyNameLabel.text + property var padding: 0 + implicitHeight: familyNameLabel.contentHeight + 2 * padding // Apply the padding to top and bottom. + implicitWidth: familyNameLabel.contentWidth + implicitHeight // The extra height is added to ensure the radius doesn't cut something off. + Rectangle + { + id: background + height: parent.height + width: parent.width + color: parent.color + anchors.right: parent.right + anchors.horizontalCenter: parent.horizontalCenter + radius: 0.5 * height + } + Label + { + id: familyNameLabel + anchors.centerIn: parent + text: "" + } +} \ No newline at end of file From fb1033ad9903ec197da4f6c339c258afc0bfe7ec Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 3 Sep 2018 10:03:11 +0200 Subject: [PATCH 49/67] Add the compatible machine families property to printerOutputModel This is used by the cluster to indicate by which families of printers the job can be displayed CL-894 --- cura/PrinterOutput/PrintJobOutputModel.py | 15 ++++++++++-- cura/PrinterOutput/PrinterOutputModel.py | 2 +- .../ClusterUM3OutputDevice.py | 4 ++-- .../UM3NetworkPrinting/PrintJobInfoBlock.qml | 23 +++++++++++++++++++ 4 files changed, 39 insertions(+), 5 deletions(-) diff --git a/cura/PrinterOutput/PrintJobOutputModel.py b/cura/PrinterOutput/PrintJobOutputModel.py index 373f816373..535836eb5e 100644 --- a/cura/PrinterOutput/PrintJobOutputModel.py +++ b/cura/PrinterOutput/PrintJobOutputModel.py @@ -2,7 +2,7 @@ # Cura is released under the terms of the LGPLv3 or higher. from PyQt5.QtCore import pyqtSignal, pyqtProperty, QObject, pyqtSlot -from typing import Optional, TYPE_CHECKING +from typing import Optional, TYPE_CHECKING, List from PyQt5.QtCore import QUrl from PyQt5.QtGui import QImage @@ -23,6 +23,7 @@ class PrintJobOutputModel(QObject): ownerChanged = pyqtSignal() configurationChanged = pyqtSignal() previewImageChanged = pyqtSignal() + compatibleMachineFamiliesChanged = pyqtSignal() def __init__(self, output_controller: "PrinterOutputController", key: str = "", name: str = "", parent=None) -> None: super().__init__(parent) @@ -36,11 +37,21 @@ class PrintJobOutputModel(QObject): self._owner = "" # Who started/owns the print job? self._configuration = None # type: Optional[ConfigurationModel] - + self._compatible_machine_families = [] # type: List[str] self._preview_image_id = 0 self._preview_image = None + @pyqtProperty("QStringList", notify=compatibleMachineFamiliesChanged) + def compatibleMachineFamilies(self): + # Hack; Some versions of cluster will return a family more than once... + return set(self._compatible_machine_families) + + def setCompatibleMachineFamilies(self, compatible_machine_families: List[str]) -> None: + if self._compatible_machine_families != compatible_machine_families: + self._compatible_machine_families = compatible_machine_families + self.compatibleMachineFamiliesChanged.emit() + @pyqtProperty(QUrl, notify=previewImageChanged) def preview_image_url(self): self._preview_image_id += 1 diff --git a/cura/PrinterOutput/PrinterOutputModel.py b/cura/PrinterOutput/PrinterOutputModel.py index ba567b7bac..f009a33178 100644 --- a/cura/PrinterOutput/PrinterOutputModel.py +++ b/cura/PrinterOutput/PrinterOutputModel.py @@ -35,7 +35,7 @@ class PrinterOutputModel(QObject): self._key = "" # Unique identifier self._controller = output_controller self._extruders = [ExtruderOutputModel(printer = self, position = i) for i in range(number_of_extruders)] - self._printer_configuration = ConfigurationModel() # Indicates the current configuration setup in this printer + self._printer_configuration = ConfigurationModel() # Indicates the current configuration setup in this printer self._head_position = Vector(0, 0, 0) self._active_print_job = None # type: Optional[PrintJobOutputModel] self._firmware_version = firmware_version diff --git a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py index 7506a870a9..e0d996c80e 100644 --- a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py +++ b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py @@ -131,7 +131,7 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): raise OutputDeviceError.WriteRequestFailedError(i18n_catalog.i18nc("@info:status", "There are no file formats available to write with!")) preferred_format = file_formats[0] - #J ust take the first file format available. + # Just take the first file format available. if file_handler is not None: writer = file_handler.getWriterByMimeType(cast(str, preferred_format["mime_type"])) else: @@ -552,7 +552,7 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): configuration.setExtruderConfigurations(extruders) print_job.updateConfiguration(configuration) - + print_job.setCompatibleMachineFamilies(data["compatible_machine_families"]) print_job.stateChanged.connect(self._printJobStateChanged) return print_job diff --git a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml index e54e70043e..1d5e5e6ce5 100644 --- a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml +++ b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml @@ -290,7 +290,30 @@ Item onOpened: visible = true } + Row + { + id: printerFamilyPills + spacing: 0.5 * UM.Theme.getSize("default_margin").width + anchors + { + left: parent.left + right: parent.right + bottom: extrudersInfo.top + bottomMargin: UM.Theme.getSize("default_margin").height + } + height: childrenRect.height + Repeater + { + model: printJob.compatibleMachineFamilies + delegate: PrinterFamilyPill + { + text: modelData + color: UM.Theme.getColor("viewport_background") + padding: 3 + } + } + } // PrintCore && Material config Row { From 2e5b11af9d1c60b72cc2c9bca3e4a1410e4e60a5 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 3 Sep 2018 10:05:20 +0200 Subject: [PATCH 50/67] Fixed codestyle issue Switching between codestyles is hard :( --- cura/PrinterOutput/PrintJobOutputModel.py | 2 +- plugins/UM3NetworkPrinting/ClusterControlItem.qml | 2 +- plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cura/PrinterOutput/PrintJobOutputModel.py b/cura/PrinterOutput/PrintJobOutputModel.py index 535836eb5e..c8d813f17c 100644 --- a/cura/PrinterOutput/PrintJobOutputModel.py +++ b/cura/PrinterOutput/PrintJobOutputModel.py @@ -53,7 +53,7 @@ class PrintJobOutputModel(QObject): self.compatibleMachineFamiliesChanged.emit() @pyqtProperty(QUrl, notify=previewImageChanged) - def preview_image_url(self): + def previewImageUrl(self): self._preview_image_id += 1 # There is an image provider that is called "camera". In order to ensure that the image qml object, that # requires a QUrl to function, updates correctly we add an increasing number. This causes to see the QUrl diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index dbc5465056..aa81ad85ff 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -480,7 +480,7 @@ Component Image { id: printJobPreview - source: modelData.activePrintJob != null ? modelData.activePrintJob.preview_image_url : "" + source: modelData.activePrintJob != null ? modelData.activePrintJob.previewImageUrl : "" anchors.top: ownerName.bottom anchors.horizontalCenter: parent.horizontalCenter width: parent.width / 2 diff --git a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml index 1d5e5e6ce5..c3e445d933 100644 --- a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml +++ b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml @@ -80,7 +80,7 @@ Item Image { - source: printJob.preview_image_url + source: printJob.previewImageUrl anchors.top: ownerName.bottom anchors.horizontalCenter: parent.horizontalCenter anchors.bottom: totalTimeLabel.bottom From b7d7091de88315415e39365985873a6ecd06f515 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 3 Sep 2018 10:26:27 +0200 Subject: [PATCH 51/67] Add padding around the printer icons CL-893 --- .../UM3NetworkPrinting/ClusterControlItem.qml | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index aa81ad85ff..3a0c37e830 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -135,30 +135,38 @@ Component onClicked: base.collapsed = !base.collapsed } - UM.RecolorImage + Item { id: machineIcon + // Yeah, this is hardcoded now, but I can't think of a good way to fix this. + // The UI is going to get another update soon, so it's probably not worth the effort... + width: 58 + height: 58 anchors.top: parent.top anchors.leftMargin: UM.Theme.getSize("default_margin").width anchors.left: parent.left - source: + + UM.RecolorImage { - switch(modelData.type) + anchors.centerIn: parent + source: { - case "Ultimaker 3": - return "UM3-icon.svg" - case "Ultimaker 3 Extended": - return "UM3x-icon.svg" - case "Ultimaker S5": - return "UMs5-icon.svg" + switch(modelData.type) + { + case "Ultimaker 3": + return "UM3-icon.svg" + case "Ultimaker 3 Extended": + return "UM3x-icon.svg" + case "Ultimaker S5": + return "UMs5-icon.svg" + } } + width: sourceSize.width + height: sourceSize.height + + color: modelData.activePrintJob != undefined ? UM.Theme.getColor("primary") : UM.Theme.getColor("setting_control_disabled") } - width: sourceSize.width - height: sourceSize.height - - color: modelData.activePrintJob != undefined ? UM.Theme.getColor("primary") : UM.Theme.getColor("setting_control_disabled") } - Item { height: childrenRect.height From 39694637580695978fac3a52b268272a6e64d535 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 3 Sep 2018 11:16:17 +0200 Subject: [PATCH 52/67] Remove the old "not setup as group" notification CL-896 --- .../UM3NetworkPrinting/ClusterMonitorItem.qml | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml b/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml index a3bfdeb843..73ddbaf61a 100644 --- a/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml @@ -23,23 +23,6 @@ Component name: "cura" } - Label - { - id: activePrintersLabel - font: UM.Theme.getFont("large") - - anchors - { - top: parent.top - topMargin: UM.Theme.getSize("default_margin").height * 2 // a bit more spacing to give it some breathing room - horizontalCenter: parent.horizontalCenter - } - - text: OutputDevice.printers.length == 0 ? catalog.i18nc("@label: arg 1 is group name", "%1 is not set up to host a group of connected Ultimaker 3 printers").arg(Cura.MachineManager.printerOutputDevices[0].name) : "" - - visible: OutputDevice.printers.length == 0 - } - Label { id: manageQueueLabel From dd778f0450219cbc2f7309eeb08bc20065bd51af Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 4 Sep 2018 13:27:17 +0200 Subject: [PATCH 53/67] Add enabled state to printer, so that it can be displayed. This ensures that if a printer is set to "Not available", that the interface can correctly show it CL-896 --- cura/PrinterOutput/PrinterOutputModel.py | 11 +++++++++++ plugins/UM3NetworkPrinting/ClusterControlItem.qml | 13 ++++++++++++- plugins/UM3NetworkPrinting/ClusterMonitorItem.qml | 1 + .../UM3NetworkPrinting/ClusterUM3OutputDevice.py | 1 + 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/cura/PrinterOutput/PrinterOutputModel.py b/cura/PrinterOutput/PrinterOutputModel.py index f009a33178..36ae04fe48 100644 --- a/cura/PrinterOutput/PrinterOutputModel.py +++ b/cura/PrinterOutput/PrinterOutputModel.py @@ -26,6 +26,7 @@ class PrinterOutputModel(QObject): buildplateChanged = pyqtSignal() cameraChanged = pyqtSignal() configurationChanged = pyqtSignal() + enabledChanged = pyqtSignal() def __init__(self, output_controller: "PrinterOutputController", number_of_extruders: int = 1, parent=None, firmware_version = "") -> None: super().__init__(parent) @@ -43,12 +44,22 @@ class PrinterOutputModel(QObject): self._is_preheating = False self._printer_type = "" self._buildplate_name = None + self._enabled = True self._printer_configuration.extruderConfigurations = [extruder.extruderConfiguration for extruder in self._extruders] self._camera = None + @pyqtProperty(bool, notify=enabledChanged) + def enabled(self) -> bool: + return self._enabled + + def updateEnabled(self, enabled: bool) -> None: + if self._enabled != enabled: + self._enabled = enabled + self.enabledChanged.emit() + @pyqtProperty(str, constant = True) def firmwareVersion(self): return self._firmware_version diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index 3a0c37e830..e91d2844a8 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -192,7 +192,18 @@ Component Label { id: activeJobLabel - text: modelData.activePrintJob != null ? modelData.activePrintJob.name : "waiting" + text: + { + if(!modelData.enabled) + { + return catalog.i18nc("@label:status", "Not available") + } + if(modelData.activePrintjob != null) + { + return modelData.activePrintJob.name + } + return catalog.i18nc("@label:status", "Waiting") + } anchors.top: machineNameLabel.bottom width: parent.width elide: Text.ElideRight diff --git a/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml b/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml index 73ddbaf61a..3132dca81c 100644 --- a/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml @@ -23,6 +23,7 @@ Component name: "cura" } + Label { id: manageQueueLabel diff --git a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py index e0d996c80e..3b7d575938 100644 --- a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py +++ b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py @@ -595,6 +595,7 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): printer.updateName(data["friendly_name"]) printer.updateKey(data["uuid"]) printer.updateType(data["machine_variant"]) + printer.updateEnabled(data["enabled"]) # Do not store the build plate information that comes from connect if the current printer has not build plate information if "build_plate" in data and machine_definition.getMetaDataEntry("has_variant_buildplates", False): From 132366fa61a685068fa1e9dc246ed533c0960bac Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 4 Sep 2018 13:42:24 +0200 Subject: [PATCH 54/67] Revert "Add enabled state to printer, so that it can be displayed." This reverts commit dd778f0450219cbc2f7309eeb08bc20065bd51af. --- cura/PrinterOutput/PrinterOutputModel.py | 11 ----------- plugins/UM3NetworkPrinting/ClusterControlItem.qml | 13 +------------ plugins/UM3NetworkPrinting/ClusterMonitorItem.qml | 1 - .../UM3NetworkPrinting/ClusterUM3OutputDevice.py | 1 - 4 files changed, 1 insertion(+), 25 deletions(-) diff --git a/cura/PrinterOutput/PrinterOutputModel.py b/cura/PrinterOutput/PrinterOutputModel.py index 36ae04fe48..f009a33178 100644 --- a/cura/PrinterOutput/PrinterOutputModel.py +++ b/cura/PrinterOutput/PrinterOutputModel.py @@ -26,7 +26,6 @@ class PrinterOutputModel(QObject): buildplateChanged = pyqtSignal() cameraChanged = pyqtSignal() configurationChanged = pyqtSignal() - enabledChanged = pyqtSignal() def __init__(self, output_controller: "PrinterOutputController", number_of_extruders: int = 1, parent=None, firmware_version = "") -> None: super().__init__(parent) @@ -44,22 +43,12 @@ class PrinterOutputModel(QObject): self._is_preheating = False self._printer_type = "" self._buildplate_name = None - self._enabled = True self._printer_configuration.extruderConfigurations = [extruder.extruderConfiguration for extruder in self._extruders] self._camera = None - @pyqtProperty(bool, notify=enabledChanged) - def enabled(self) -> bool: - return self._enabled - - def updateEnabled(self, enabled: bool) -> None: - if self._enabled != enabled: - self._enabled = enabled - self.enabledChanged.emit() - @pyqtProperty(str, constant = True) def firmwareVersion(self): return self._firmware_version diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index e91d2844a8..3a0c37e830 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -192,18 +192,7 @@ Component Label { id: activeJobLabel - text: - { - if(!modelData.enabled) - { - return catalog.i18nc("@label:status", "Not available") - } - if(modelData.activePrintjob != null) - { - return modelData.activePrintJob.name - } - return catalog.i18nc("@label:status", "Waiting") - } + text: modelData.activePrintJob != null ? modelData.activePrintJob.name : "waiting" anchors.top: machineNameLabel.bottom width: parent.width elide: Text.ElideRight diff --git a/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml b/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml index 3132dca81c..73ddbaf61a 100644 --- a/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml @@ -23,7 +23,6 @@ Component name: "cura" } - Label { id: manageQueueLabel diff --git a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py index 3b7d575938..e0d996c80e 100644 --- a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py +++ b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py @@ -595,7 +595,6 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): printer.updateName(data["friendly_name"]) printer.updateKey(data["uuid"]) printer.updateType(data["machine_variant"]) - printer.updateEnabled(data["enabled"]) # Do not store the build plate information that comes from connect if the current printer has not build plate information if "build_plate" in data and machine_definition.getMetaDataEntry("has_variant_buildplates", False): From be4357c6355f1010165bdf4a29c84f2ed84c7a98 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 4 Sep 2018 13:45:16 +0200 Subject: [PATCH 55/67] Show different state when printer is disabled CL-896 --- plugins/UM3NetworkPrinting/ClusterControlItem.qml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index 3a0c37e830..3ab2a2411e 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -192,7 +192,18 @@ Component Label { id: activeJobLabel - text: modelData.activePrintJob != null ? modelData.activePrintJob.name : "waiting" + text: + { + if (modelData.state == "disabled") + { + return catalog.i18nc("@label", "Not available") + } + if (modelData.activePrintJob != null) + { + return modelData.activePrintJob.name + } + return catalog.i18nc("@label", "Waiting") + } anchors.top: machineNameLabel.bottom width: parent.width elide: Text.ElideRight From a0302684d6f7b62d50ac738794f01e91315e919b Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 5 Sep 2018 10:06:37 +0200 Subject: [PATCH 56/67] Add handling for cluster print jobs that are in error state CL-896 --- .../ClusterUM3OutputDevice.py | 17 ++++++++++++--- .../UM3NetworkPrinting/PrintJobInfoBlock.qml | 21 ++++++++++++++++++- plugins/UM3NetworkPrinting/warning-icon.svg | 1 + 3 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 plugins/UM3NetworkPrinting/warning-icon.svg diff --git a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py index e0d996c80e..3e562adf14 100644 --- a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py +++ b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py @@ -352,7 +352,7 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): @pyqtProperty("QVariantList", notify = printJobsChanged) def queuedPrintJobs(self) -> List[PrintJobOutputModel]: - return [print_job for print_job in self._print_jobs if print_job.state == "queued"] + return [print_job for print_job in self._print_jobs if print_job.state == "queued" or print_job.state == "error"] @pyqtProperty("QVariantList", notify = printJobsChanged) def activePrintJobs(self) -> List[PrintJobOutputModel]: @@ -474,7 +474,7 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): self._updatePrintJob(print_job, print_job_data) - if print_job.state != "queued": # Print job should be assigned to a printer. + if print_job.state != "queued" and print_job.state != "error": # Print job should be assigned to a printer. if print_job.state in ["failed", "finished", "aborted", "none"]: # Print job was already completed, so don't attach it to a printer. printer = None @@ -559,9 +559,20 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): def _updatePrintJob(self, print_job: PrintJobOutputModel, data: Dict[str, Any]) -> None: print_job.updateTimeTotal(data["time_total"]) print_job.updateTimeElapsed(data["time_elapsed"]) - print_job.updateState(data["status"]) + impediments_to_printing = data.get("impediments_to_printing", []) print_job.updateOwner(data["owner"]) + status_set_by_impediment = False + for impediment in impediments_to_printing: + if impediment["severity"] == "UNFIXABLE": + status_set_by_impediment = True + print_job.updateState("error") + break + + if not status_set_by_impediment: + print_job.updateState(data["status"]) + + def _createMaterialOutputModel(self, material_data) -> MaterialOutputModel: containers = ContainerRegistry.getInstance().findInstanceContainers(type="material", GUID=material_data["guid"]) if containers: diff --git a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml index c3e445d933..2cd0a4b206 100644 --- a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml +++ b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml @@ -80,11 +80,26 @@ Item Image { + id: printJobPreview source: printJob.previewImageUrl anchors.top: ownerName.bottom anchors.horizontalCenter: parent.horizontalCenter anchors.bottom: totalTimeLabel.bottom width: height + opacity: printJob.state == "error" ? 0.5 : 1.0 + } + + UM.RecolorImage + { + id: statusImage + anchors.centerIn: printJobPreview + source: printJob.state == "error" ? "aborted-icon.svg" : "" + visible: source != "" + width: 0.5 * printJobPreview.width + height: 0.5 * printJobPreview.height + sourceSize.width: width + sourceSize.height: height + color: "black" } Label @@ -121,7 +136,11 @@ Item { if(printJob.assignedPrinter == null) { - return catalog.i18nc("@label", "Waiting for: first available") + if(printJob.state == "error") + { + return catalog.i18nc("@label", "Waiting for: Unavailable printer") + } + return catalog.i18nc("@label", "Waiting for: First available") } else { diff --git a/plugins/UM3NetworkPrinting/warning-icon.svg b/plugins/UM3NetworkPrinting/warning-icon.svg new file mode 100644 index 0000000000..1e5359a5eb --- /dev/null +++ b/plugins/UM3NetworkPrinting/warning-icon.svg @@ -0,0 +1 @@ +warning-icon \ No newline at end of file From 7ad2e670743f57bd75fe90681bc299c81c8c0cc2 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 5 Sep 2018 10:09:44 +0200 Subject: [PATCH 57/67] Fix margins for active print job name in printer tile for cluster CL-896 --- plugins/UM3NetworkPrinting/ClusterControlItem.qml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index 3ab2a2411e..92e07afba6 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -323,7 +323,9 @@ Component id: printJobName text: modelData.activePrintJob != null ? modelData.activePrintJob.name : "" font: UM.Theme.getFont("default_bold") - width: parent.width + anchors.left: parent.left + anchors.right: contextButton.left + anchors.rightMargin: UM.Theme.getSize("default_margin").width elide: Text.ElideRight } Label From 1b9deb27908f1c1bac036ac49da26491d32d5f60 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 5 Sep 2018 10:25:20 +0200 Subject: [PATCH 58/67] Add unreachable label if a printer can not be reached inside a cluster CL-896 --- plugins/UM3NetworkPrinting/ClusterControlItem.qml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index 92e07afba6..2084612772 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -197,6 +197,9 @@ Component if (modelData.state == "disabled") { return catalog.i18nc("@label", "Not available") + } else if (modelData.state == "unreachable") + { + return catalog.i18nc("@label", "Unreachable") } if (modelData.activePrintJob != null) { From 882cc000acffeb14df0869a70f4bc6dac27a5b07 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 5 Sep 2018 13:15:09 +0200 Subject: [PATCH 59/67] Move to top is now disabled for the first job CL-896 --- plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml index 2cd0a4b206..723ccfe456 100644 --- a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml +++ b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml @@ -216,7 +216,7 @@ Item popup.close() } width: parent.width - enabled: OutputDevice.printJobs[0].key != printJob.key + enabled: OutputDevice.queuedPrintJobs[0].key != printJob.key anchors.top: parent.top anchors.topMargin: 10 hoverEnabled: true From cd6832544bd97659a25b3891002309f0abf8f631 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 5 Sep 2018 13:17:33 +0200 Subject: [PATCH 60/67] Fix for compatible_machine_families breaking for older firmwares Older firmwares didn't have the compatible_machine_families field yet. Cl-894 --- plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py index 3e562adf14..353a67ccd0 100644 --- a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py +++ b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py @@ -552,7 +552,7 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): configuration.setExtruderConfigurations(extruders) print_job.updateConfiguration(configuration) - print_job.setCompatibleMachineFamilies(data["compatible_machine_families"]) + print_job.setCompatibleMachineFamilies(data.get("compatible_machine_families", [])) print_job.stateChanged.connect(self._printJobStateChanged) return print_job From 7096c7382b4899662fbd7c880c92b97a5d6ebbcc Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 5 Sep 2018 13:43:24 +0200 Subject: [PATCH 61/67] Add width to labels in printcore qml object. This ensures that the elide works correctly CL-896 --- plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml | 3 ++- plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml b/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml index e6f2372874..539d8385c9 100644 --- a/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml +++ b/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml @@ -69,6 +69,7 @@ Item } font: UM.Theme.getFont("default_bold") elide: Text.ElideRight + width: parent.width } Label @@ -84,7 +85,7 @@ Item } anchors.top: materialLabel.bottom elide: Text.ElideRight - + width: parent.width opacity: 0.6 font: UM.Theme.getFont("default") } diff --git a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml index 723ccfe456..d50ee769d3 100644 --- a/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml +++ b/plugins/UM3NetworkPrinting/PrintJobInfoBlock.qml @@ -351,7 +351,7 @@ Item PrintCoreConfiguration { id: leftExtruderInfo - width: Math.round(parent.width / 2) + width: Math.round(parent.width / 2) printCoreConfiguration: printJob.configuration.extruderConfigurations[0] } From 5be65688a06093873af4b0672837ccce385f5c72 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 5 Sep 2018 13:48:47 +0200 Subject: [PATCH 62/67] Change label to action required In some cases it's not a configuration change that's required, so this is a more correct label CL-896 --- plugins/UM3NetworkPrinting/ClusterControlItem.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index 2084612772..ac5ec325b0 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -646,7 +646,7 @@ Component case "resuming": return catalog.i18nc("@label:status", "Resuming") case "queued": - return catalog.i18nc("@label:status", "Configuration change") + return catalog.i18nc("@label:status", "Action required") default: OutputDevice.formatDuration(modelData.activePrintJob.timeTotal - modelData.activePrintJob.timeElapsed) } From 23cd46824fd656199adfb197430fb2aee54ec271 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 5 Sep 2018 13:52:41 +0200 Subject: [PATCH 63/67] Ensure that printer icon has disabled color if the printer is disabled CL-896 --- plugins/UM3NetworkPrinting/ClusterControlItem.qml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index ac5ec325b0..9dbe386195 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -164,7 +164,20 @@ Component width: sourceSize.width height: sourceSize.height - color: modelData.activePrintJob != undefined ? UM.Theme.getColor("primary") : UM.Theme.getColor("setting_control_disabled") + color: + { + if(modelData.state == "disabled") + { + return UM.Theme.getColor("setting_control_disabled") + } + + if(modelData.activePrintJob != undefined) + { + return UM.Theme.getColor("primary") + } + + return UM.Theme.getColor("setting_control_disabled") + } } } Item From 8e66686d6fbe304af54059539697bc0eb4966c9e Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 5 Sep 2018 14:06:18 +0200 Subject: [PATCH 64/67] Change "waiting" lable to "available" Cl-896 --- plugins/UM3NetworkPrinting/ClusterControlItem.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index 9dbe386195..689922de8a 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -218,7 +218,7 @@ Component { return modelData.activePrintJob.name } - return catalog.i18nc("@label", "Waiting") + return catalog.i18nc("@label", "Available") } anchors.top: machineNameLabel.bottom width: parent.width From 534e60d8e124fdd5ebe58e9f32985806705f229b Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 5 Sep 2018 14:22:41 +0200 Subject: [PATCH 65/67] Added pausing text for pausing state CL-896 --- plugins/UM3NetworkPrinting/ClusterControlItem.qml | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index 689922de8a..2b2c683bee 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -654,6 +654,7 @@ Component case "wait_user_action": return catalog.i18nc("@label:status", "Aborted") case "pausing": + return catalog.i18nc("@label:status", "Pausing") case "paused": return catalog.i18nc("@label:status", "Paused") case "resuming": From 57a7c3bcd289856297c964bad8175214f89429eb Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 5 Sep 2018 14:26:11 +0200 Subject: [PATCH 66/67] Decrease margin for "manage queue" label CL-896 --- plugins/UM3NetworkPrinting/ClusterMonitorItem.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml b/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml index 73ddbaf61a..82b1f554b7 100644 --- a/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml @@ -26,7 +26,7 @@ Component Label { id: manageQueueLabel - anchors.rightMargin: 5 * UM.Theme.getSize("default_margin").width + anchors.rightMargin: 4 * UM.Theme.getSize("default_margin").width anchors.right: queuedPrintJobs.right anchors.bottom: queuedLabel.bottom text: catalog.i18nc("@label link to connect manager", "Manage queue") From 4cc1b6ce02a5aa629d3083f97b6a2cc61a14f971 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Thu, 6 Sep 2018 16:57:45 +0200 Subject: [PATCH 67/67] Add typings and fix code style --- cura/PrintJobPreviewImageProvider.py | 2 +- .../ExtruderConfigurationModel.py | 8 ++-- cura/PrinterOutput/ExtruderOutputModel.py | 6 +-- .../NetworkedPrinterOutputDevice.py | 47 ++++++++++++------- cura/PrinterOutput/PrintJobOutputModel.py | 6 +-- .../UM3NetworkPrinting/ClusterControlItem.qml | 9 +++- .../UM3NetworkPrinting/ClusterMonitorItem.qml | 2 - .../ClusterUM3OutputDevice.py | 18 +++---- .../PrintCoreConfiguration.qml | 2 +- 9 files changed, 61 insertions(+), 39 deletions(-) diff --git a/cura/PrintJobPreviewImageProvider.py b/cura/PrintJobPreviewImageProvider.py index d3521bf0af..a8df5aa273 100644 --- a/cura/PrintJobPreviewImageProvider.py +++ b/cura/PrintJobPreviewImageProvider.py @@ -10,7 +10,7 @@ class PrintJobPreviewImageProvider(QQuickImageProvider): super().__init__(QQuickImageProvider.Image) ## Request a new image. - def requestImage(self, id, size): + def requestImage(self, id: str, size: QSize) -> QImage: # The id will have an uuid and an increment separated by a slash. As we don't care about the value of the # increment, we need to strip that first. uuid = id[id.find("/") + 1:] diff --git a/cura/PrinterOutput/ExtruderConfigurationModel.py b/cura/PrinterOutput/ExtruderConfigurationModel.py index 75ee4b6ab3..da0ad6b0b2 100644 --- a/cura/PrinterOutput/ExtruderConfigurationModel.py +++ b/cura/PrinterOutput/ExtruderConfigurationModel.py @@ -11,7 +11,7 @@ class ExtruderConfigurationModel(QObject): extruderConfigurationChanged = pyqtSignal() - def __init__(self, position: int = -1): + def __init__(self, position: int = -1) -> None: super().__init__() self._position = position # type: int self._material = None # type: Optional[MaterialOutputModel] @@ -24,17 +24,17 @@ class ExtruderConfigurationModel(QObject): def position(self) -> int: return self._position - def setMaterial(self, material: Optional[MaterialOutputModel]): + def setMaterial(self, material: Optional[MaterialOutputModel]) -> None: if self._hotend_id != material: self._material = material self.extruderConfigurationChanged.emit() @pyqtProperty(QObject, fset = setMaterial, notify = extruderConfigurationChanged) - def activeMaterial(self) -> MaterialOutputModel: + def activeMaterial(self) -> Optional[MaterialOutputModel]: return self._material @pyqtProperty(QObject, fset=setMaterial, notify=extruderConfigurationChanged) - def material(self) -> MaterialOutputModel: + def material(self) -> Optional[MaterialOutputModel]: return self._material def setHotendID(self, hotend_id: Optional[str]) -> None: diff --git a/cura/PrinterOutput/ExtruderOutputModel.py b/cura/PrinterOutput/ExtruderOutputModel.py index c7fd58c098..30d53bbd85 100644 --- a/cura/PrinterOutput/ExtruderOutputModel.py +++ b/cura/PrinterOutput/ExtruderOutputModel.py @@ -22,8 +22,8 @@ class ExtruderOutputModel(QObject): super().__init__(parent) self._printer = printer # type: PrinterOutputModel self._position = position - self._target_hotend_temperature = 0 # type: float - self._hotend_temperature = 0 # type: float + self._target_hotend_temperature = 0.0 # type: float + self._hotend_temperature = 0.0 # type: float self._is_preheating = False @@ -50,7 +50,7 @@ class ExtruderOutputModel(QObject): def activeMaterial(self) -> Optional["MaterialOutputModel"]: return self._extruder_configuration.activeMaterial - def updateActiveMaterial(self, material: Optional["MaterialOutputModel"]): + def updateActiveMaterial(self, material: Optional["MaterialOutputModel"]) -> None: self._extruder_configuration.setMaterial(material) ## Update the hotend temperature. This only changes it locally. diff --git a/cura/PrinterOutput/NetworkedPrinterOutputDevice.py b/cura/PrinterOutput/NetworkedPrinterOutputDevice.py index 36369feabb..94f86f19a3 100644 --- a/cura/PrinterOutput/NetworkedPrinterOutputDevice.py +++ b/cura/PrinterOutput/NetworkedPrinterOutputDevice.py @@ -197,31 +197,43 @@ class NetworkedPrinterOutputDevice(PrinterOutputDevice): self._validateManager() request = self._createEmptyRequest(target) self._last_request_time = time() - reply = self._manager.put(request, data.encode()) - self._registerOnFinishedCallback(reply, on_finished) + if self._manager is not None: + reply = self._manager.put(request, data.encode()) + self._registerOnFinishedCallback(reply, on_finished) + else: + Logger.log("e", "Could not find manager.") def delete(self, target: str, on_finished: Optional[Callable[[QNetworkReply], None]]) -> None: self._validateManager() request = self._createEmptyRequest(target) self._last_request_time = time() - reply = self._manager.deleteResource(request) - self._registerOnFinishedCallback(reply, on_finished) + if self._manager is not None: + reply = self._manager.deleteResource(request) + self._registerOnFinishedCallback(reply, on_finished) + else: + Logger.log("e", "Could not find manager.") def get(self, target: str, on_finished: Optional[Callable[[QNetworkReply], None]]) -> None: self._validateManager() request = self._createEmptyRequest(target) self._last_request_time = time() - reply = self._manager.get(request) - self._registerOnFinishedCallback(reply, on_finished) + if self._manager is not None: + reply = self._manager.get(request) + self._registerOnFinishedCallback(reply, on_finished) + else: + Logger.log("e", "Could not find manager.") def post(self, target: str, data: str, on_finished: Optional[Callable[[QNetworkReply], None]], on_progress: Callable = None) -> None: self._validateManager() request = self._createEmptyRequest(target) self._last_request_time = time() - reply = self._manager.post(request, data) - if on_progress is not None: - reply.uploadProgress.connect(on_progress) - self._registerOnFinishedCallback(reply, on_finished) + if self._manager is not None: + reply = self._manager.post(request, data) + if on_progress is not None: + reply.uploadProgress.connect(on_progress) + self._registerOnFinishedCallback(reply, on_finished) + else: + Logger.log("e", "Could not find manager.") def postFormWithParts(self, target: str, parts: List[QHttpPart], on_finished: Optional[Callable[[QNetworkReply], None]], on_progress: Callable = None) -> QNetworkReply: self._validateManager() @@ -232,15 +244,18 @@ class NetworkedPrinterOutputDevice(PrinterOutputDevice): self._last_request_time = time() - reply = self._manager.post(request, multi_post_part) + if self._manager is not None: + reply = self._manager.post(request, multi_post_part) - self._kept_alive_multiparts[reply] = multi_post_part + self._kept_alive_multiparts[reply] = multi_post_part - if on_progress is not None: - reply.uploadProgress.connect(on_progress) - self._registerOnFinishedCallback(reply, on_finished) + if on_progress is not None: + reply.uploadProgress.connect(on_progress) + self._registerOnFinishedCallback(reply, on_finished) - return reply + return reply + else: + Logger.log("e", "Could not find manager.") def postForm(self, target: str, header_data: str, body_data: bytes, on_finished: Optional[Callable[[QNetworkReply], None]], on_progress: Callable = None) -> None: post_part = QHttpPart() diff --git a/cura/PrinterOutput/PrintJobOutputModel.py b/cura/PrinterOutput/PrintJobOutputModel.py index c8d813f17c..7366b95f86 100644 --- a/cura/PrinterOutput/PrintJobOutputModel.py +++ b/cura/PrinterOutput/PrintJobOutputModel.py @@ -40,7 +40,7 @@ class PrintJobOutputModel(QObject): self._compatible_machine_families = [] # type: List[str] self._preview_image_id = 0 - self._preview_image = None + self._preview_image = None # type: Optional[QImage] @pyqtProperty("QStringList", notify=compatibleMachineFamiliesChanged) def compatibleMachineFamilies(self): @@ -61,10 +61,10 @@ class PrintJobOutputModel(QObject): temp = "image://print_job_preview/" + str(self._preview_image_id) + "/" + self._key return QUrl(temp, QUrl.TolerantMode) - def getPreviewImage(self): + def getPreviewImage(self) -> Optional[QImage]: return self._preview_image - def updatePreviewImage(self, preview_image: Optional[QImage]): + def updatePreviewImage(self, preview_image: Optional[QImage]) -> None: if self._preview_image != preview_image: self._preview_image = preview_image self.previewImageChanged.emit() diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index 2b2c683bee..be72d3c07a 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -357,7 +357,14 @@ Component function switchPopupState() { - popup.visible ? popup.close() : popup.open() + if (popup.visible) + { + popup.close() + } + else + { + popup.open() + } } Controls2.Button diff --git a/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml b/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml index 82b1f554b7..71b598d05c 100644 --- a/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml @@ -101,8 +101,6 @@ Component { if (monitorFrame != null && !monitorFrame.visible) { - // After switching the Tab ensure that active printer is Null, the video stream image - // might be active OutputDevice.setActiveCamera(null) } } diff --git a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py index 353a67ccd0..8345de049c 100644 --- a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py +++ b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py @@ -146,14 +146,15 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): Logger.log("e", "Missing file or mesh writer!") return self._sending_job = self._sendPrintJob(writer, preferred_format, nodes) - self._sending_job.send(None) # Start the generator. + if self._sending_job is not None: + self._sending_job.send(None) # Start the generator. - if len(self._printers) > 1: # We need to ask the user. - self._spawnPrinterSelectionDialog() - is_job_sent = True - else: # Just immediately continue. - self._sending_job.send("") # No specifically selected printer. - is_job_sent = self._sending_job.send(None) + if len(self._printers) > 1: # We need to ask the user. + self._spawnPrinterSelectionDialog() + is_job_sent = True + else: # Just immediately continue. + self._sending_job.send("") # No specifically selected printer. + is_job_sent = self._sending_job.send(None) def _spawnPrinterSelectionDialog(self): if self._printer_selection_dialog is None: @@ -171,7 +172,8 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): # \param target_printer The name of the printer to target. @pyqtSlot(str) def selectPrinter(self, target_printer: str = "") -> None: - self._sending_job.send(target_printer) + if self._sending_job is not None: + self._sending_job.send(target_printer) @pyqtSlot() def cancelPrintSelection(self) -> None: diff --git a/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml b/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml index 539d8385c9..0ae1fec920 100644 --- a/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml +++ b/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml @@ -22,7 +22,7 @@ Item anchors.verticalCenter: printAndMaterialLabel.verticalCenter opacity: { - if(printCoreConfiguration == undefined || printCoreConfiguration.activeMaterial == undefined || printCoreConfiguration.hotendID == undefined) + if(printCoreConfiguration == null || printCoreConfiguration.activeMaterial == null || printCoreConfiguration.hotendID == null) { return 0.5 }