From 5c2f1a935a4a95dd842d3b4392f84cb53406dcfe Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 1 Feb 2017 17:31:36 +0100 Subject: [PATCH 01/84] Move monitorLabel into PrintMonitor.qml It's a label that belongs to the print monitor after all. Let the print monitor file decide how it's going to look. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 13 ++++++++++++- resources/qml/Sidebar.qml | 17 ++--------------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index cd2f2a7376..887c70f457 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -1,4 +1,4 @@ -// Copyright (c) 2016 Ultimaker B.V. +// Copyright (c) 2017 Ultimaker B.V. // Cura is released under the terms of the AGPLv3 or higher. import QtQuick 2.2 @@ -20,6 +20,17 @@ Column simpleNames: true } + Label { + id: monitorLabel + text: catalog.i18nc("@label","Printer Monitor"); + anchors.left: parent.left + anchors.leftMargin: UM.Theme.getSize("default_margin").width; + width: parent.width * 0.45 + font: UM.Theme.getFont("large") + color: UM.Theme.getColor("text") + visible: monitoringPrint + } + Item { width: base.width - 2 * UM.Theme.getSize("default_margin").width diff --git a/resources/qml/Sidebar.qml b/resources/qml/Sidebar.qml index 148606679f..45dc49d076 100644 --- a/resources/qml/Sidebar.qml +++ b/resources/qml/Sidebar.qml @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Ultimaker B.V. +// Copyright (c) 2017 Ultimaker B.V. // Cura is released under the terms of the AGPLv3 or higher. import QtQuick 2.2 @@ -455,19 +455,6 @@ Rectangle } } - Label { - id: monitorLabel - text: catalog.i18nc("@label","Printer Monitor"); - anchors.left: parent.left - anchors.leftMargin: UM.Theme.getSize("default_margin").width; - anchors.top: headerSeparator.bottom - anchors.topMargin: UM.Theme.getSize("default_margin").height - width: parent.width * 0.45 - font: UM.Theme.getFont("large") - color: UM.Theme.getColor("text") - visible: monitoringPrint - } - StackView { id: sidebarContents @@ -511,7 +498,7 @@ Rectangle Loader { anchors.bottom: footerSeparator.top - anchors.top: monitorLabel.bottom + anchors.top: headerSeparator.bottom anchors.topMargin: UM.Theme.getSize("default_margin").height anchors.left: base.left anchors.leftMargin: UM.Theme.getSize("default_margin").width From cda5ee1dca80daa5072b071467e45204b57d1bec Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Thu, 2 Feb 2017 14:27:49 +0100 Subject: [PATCH 02/84] Separate name from address in properties This way we can display them separately. Contributes to issue CURA-3161. --- .../NetworkPrinterOutputDevice.py | 9 +++++++-- .../NetworkPrinterOutputDevicePlugin.py | 19 +++++++++++++++---- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py index 549c0905d6..c1e75e6181 100644 --- a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py +++ b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Ultimaker B.V. +# Copyright (c) 2017 Ultimaker B.V. # Cura is released under the terms of the AGPLv3 or higher. from UM.i18n import i18nCatalog @@ -100,7 +100,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): self.setPriority(2) # Make sure the output device gets selected above local file output self.setName(key) - self.setShortDescription(i18n_catalog.i18nc("@action:button Preceded by 'Ready to'.", "Print over network")) + self.setShortDescription(i18n_catalog.i18nc("@action:button Preceded by 'Ready to'.", "print over network")) self.setDescription(i18n_catalog.i18nc("@properties:tooltip", "Print over network")) self.setIconName("print") @@ -220,6 +220,11 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): def getKey(self): return self._key + ## The IP address of the printer. + @pyqtProperty(str, constant = True) + def address(self): + return self._properties.get(b"address", b"0.0.0.0").decode("utf-8") + ## Name of the printer (as returned from the zeroConf properties) @pyqtProperty(str, constant = True) def name(self): diff --git a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevicePlugin.py b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevicePlugin.py index 2725fa8d17..9165bd5273 100644 --- a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevicePlugin.py +++ b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevicePlugin.py @@ -1,3 +1,6 @@ +# Copyright (c) 2017 Ultimaker B.V. +# Cura is released under the terms of the AGPLv3 or higher. + from UM.OutputDevice.OutputDevicePlugin import OutputDevicePlugin from . import NetworkPrinterOutputDevice @@ -75,9 +78,13 @@ class NetworkPrinterOutputDevicePlugin(OutputDevicePlugin): self._manual_instances.append(address) self._preferences.setValue("um3networkprinting/manual_instances", ",".join(self._manual_instances)) - name = address instance_name = "manual:%s" % address - properties = { b"name": name.encode("utf-8"), b"manual": b"true", b"incomplete": b"true" } + properties = { + b"name": address.encode("utf-8"), + b"address": address.encode("utf-8"), + b"manual": b"true", + b"incomplete": b"true" + } if instance_name not in self._printers: # Add a preliminary printer instance @@ -112,10 +119,14 @@ class NetworkPrinterOutputDevicePlugin(OutputDevicePlugin): if status_code == 200: system_info = json.loads(bytes(reply.readAll()).decode("utf-8")) address = reply.url().host() - name = ("%s (%s)" % (system_info["name"], address)) instance_name = "manual:%s" % address - properties = { b"name": name.encode("utf-8"), b"firmware_version": system_info["firmware"].encode("utf-8"), b"manual": b"true" } + properties = { + b"name": system_info["name"].encode("utf-8"), + b"address": address.encode("utf-8"), + b"firmware_version": system_info["firmware"].encode("utf-8"), + b"manual": b"true" + } if instance_name in self._printers: # Only replace the printer if it is still in the list of (manual) printers self.removePrinter(instance_name) From 1f0bcc1abdb601ebb5355c7f0d4aba9fd8f481bf Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Thu, 2 Feb 2017 14:34:40 +0100 Subject: [PATCH 03/84] Add header bar for print monitor It lists the name of the printer it is connected to, and the address on the right side. This won't work for USB printing (it'll give errors there). I'll solve that later. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index 887c70f457..e4d9d84ac7 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -20,6 +20,42 @@ Column simpleNames: true } + Rectangle + { + id: connectedPrinterHeader + width: parent.width + height: UM.Theme.getSize("sidebar_header").height + color: UM.Theme.getColor("setting_category") + + Label + { + id: connectedPrinterNameLabel + text: printerConnected ? connectedPrinter.name : catalog.i18nc("@info:status", "No printer connected") + font: UM.Theme.getFont("large") + color: UM.Theme.getColor("text") + anchors.left: parent.left + anchors.leftMargin: UM.Theme.getSize("default_margin").width + anchors.top: parent.top + anchors.topMargin: UM.Theme.getSize("default_margin").height + anchors.right: parent.right + anchors.rightMargin: UM.Theme.getSize("default_margin").width + } + Label + { + id: connectedPrinterAddressLabel + text: printerConnected ? connectedPrinter.address : "" + font: UM.Theme.getFont("small") + color: UM.Theme.getColor("text_inactive") + anchors.left: parent.left + anchors.leftMargin: UM.Theme.getSize("default_margin").width + anchors.top: parent.top + anchors.topMargin: UM.Theme.getSize("default_margin").height + anchors.right: parent.right + anchors.rightMargin: UM.Theme.getSize("default_margin").width + horizontalAlignment: Text.AlignRight + } + } + Label { id: monitorLabel text: catalog.i18nc("@label","Printer Monitor"); From c7a91f07d25128b6484c0367b936df666b454c00 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Thu, 2 Feb 2017 14:45:44 +0100 Subject: [PATCH 04/84] Add label for printer connection text to header Also fixed the indenting of the previous two labels to use spaces instead of tabs. I knew I was going to forget putting it back to spaces after working on a different project that uses tabs. The information is duplicated now. I'll remove the old one promptly. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 68 ++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 28 deletions(-) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index e4d9d84ac7..c5bf160657 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -24,36 +24,48 @@ Column { id: connectedPrinterHeader width: parent.width - height: UM.Theme.getSize("sidebar_header").height + height: childrenRect.height + UM.Theme.getSize("default_margin").height * 2 color: UM.Theme.getColor("setting_category") - Label - { - id: connectedPrinterNameLabel - text: printerConnected ? connectedPrinter.name : catalog.i18nc("@info:status", "No printer connected") - font: UM.Theme.getFont("large") - color: UM.Theme.getColor("text") - anchors.left: parent.left - anchors.leftMargin: UM.Theme.getSize("default_margin").width - anchors.top: parent.top - anchors.topMargin: UM.Theme.getSize("default_margin").height - anchors.right: parent.right - anchors.rightMargin: UM.Theme.getSize("default_margin").width - } - Label - { - id: connectedPrinterAddressLabel - text: printerConnected ? connectedPrinter.address : "" - font: UM.Theme.getFont("small") - color: UM.Theme.getColor("text_inactive") - anchors.left: parent.left - anchors.leftMargin: UM.Theme.getSize("default_margin").width - anchors.top: parent.top - anchors.topMargin: UM.Theme.getSize("default_margin").height - anchors.right: parent.right - anchors.rightMargin: UM.Theme.getSize("default_margin").width - horizontalAlignment: Text.AlignRight - } + Label + { + id: connectedPrinterNameLabel + text: printerConnected ? connectedPrinter.name : catalog.i18nc("@info:status", "No printer connected") + font: UM.Theme.getFont("large") + color: UM.Theme.getColor("text") + anchors.left: parent.left + anchors.leftMargin: UM.Theme.getSize("default_margin").width + anchors.top: parent.top + anchors.topMargin: UM.Theme.getSize("default_margin").height + anchors.right: parent.right + anchors.rightMargin: UM.Theme.getSize("default_margin").width + } + Label + { + id: connectedPrinterAddressLabel + text: printerConnected ? connectedPrinter.address : "" + font: UM.Theme.getFont("small") + color: UM.Theme.getColor("text_inactive") + anchors.left: parent.left + anchors.leftMargin: UM.Theme.getSize("default_margin").width + anchors.top: parent.top + anchors.topMargin: UM.Theme.getSize("default_margin").height + anchors.right: parent.right + anchors.rightMargin: UM.Theme.getSize("default_margin").width + horizontalAlignment: Text.AlignRight + } + Label + { + text: printerConnected ? connectedPrinter.connectionText : catalog.i18nc("@info:status", "The printer is not connected.") + color: printerConnected && printerAcceptsCommands ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text") + font: UM.Theme.getFont("default") + wrapMode: Text.WordWrap + 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: connectedPrinterNameLabel.bottom + } } Label { From 7b8d41cb8f956bdb175dd5dfef81949166dc841c Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Thu, 2 Feb 2017 14:48:06 +0100 Subject: [PATCH 05/84] Remove old connected printer header It has been replaced by a nicer header. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index c5bf160657..97ecfeb46a 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -68,34 +68,6 @@ Column } } - Label { - id: monitorLabel - text: catalog.i18nc("@label","Printer Monitor"); - anchors.left: parent.left - anchors.leftMargin: UM.Theme.getSize("default_margin").width; - width: parent.width * 0.45 - font: UM.Theme.getFont("large") - color: UM.Theme.getColor("text") - visible: monitoringPrint - } - - Item - { - width: base.width - 2 * UM.Theme.getSize("default_margin").width - height: childrenRect.height + UM.Theme.getSize("default_margin").height - anchors.left: parent.left - anchors.leftMargin: UM.Theme.getSize("default_margin").width - - Label - { - text: printerConnected ? connectedPrinter.connectionText : catalog.i18nc("@info:status", "The printer is not connected.") - color: printerConnected && printerAcceptsCommands ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text") - font: UM.Theme.getFont("default") - wrapMode: Text.WordWrap - width: parent.width - } - } - Loader { sourceComponent: monitorSection From 7b41e844cc6f0832d8ff9496761a38a771de38cd Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Thu, 2 Feb 2017 15:19:56 +0100 Subject: [PATCH 06/84] Fix name and address for USB printing devices As address it uses the serial port, which would be COM# for Windows and /dev/ttyUSB# for Linux. I don't know what it would display there on OSX, probably a drive directory. Contributes to issue CURA-3161. --- plugins/USBPrinting/USBPrinterOutputDevice.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugins/USBPrinting/USBPrinterOutputDevice.py b/plugins/USBPrinting/USBPrinterOutputDevice.py index e344caee1d..e30ba613bc 100644 --- a/plugins/USBPrinting/USBPrinterOutputDevice.py +++ b/plugins/USBPrinting/USBPrinterOutputDevice.py @@ -124,6 +124,16 @@ class USBPrinterOutputDevice(PrinterOutputDevice): def _homeBed(self): self._sendCommand("G28 Z") + ## A name for the device. + @pyqtProperty(str, constant = True) + def name(self): + return self.getName() + + ## The address of the device. + @pyqtProperty(str, constant = True) + def address(self): + return self._serial_port + def startPrint(self): self.writeStarted.emit(self) gcode_list = getattr( Application.getInstance().getController().getScene(), "gcode_list") From 9546c85967492ef46c73a277748238a190fc68e0 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 3 Feb 2017 13:50:17 +0100 Subject: [PATCH 07/84] Add boxes containing information on extruders These are meant to eventually replace the bullet-list of information we currently have. Contributes to issue CURA-3161. --- .../NetworkPrinterOutputDevice.py | 2 +- resources/qml/PrintMonitor.qml | 42 ++++++++++++++++++- resources/themes/cura/theme.json | 6 +++ 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py index c1e75e6181..32ebd354ee 100644 --- a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py +++ b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py @@ -100,7 +100,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): self.setPriority(2) # Make sure the output device gets selected above local file output self.setName(key) - self.setShortDescription(i18n_catalog.i18nc("@action:button Preceded by 'Ready to'.", "print over network")) + self.setShortDescription(i18n_catalog.i18nc("@action:button Preceded by 'Ready to'.", "Print over network")) self.setDescription(i18n_catalog.i18nc("@properties:tooltip", "Print over network")) self.setIconName("print") diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index 97ecfeb46a..556f500348 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -58,7 +58,7 @@ Column { text: printerConnected ? connectedPrinter.connectionText : catalog.i18nc("@info:status", "The printer is not connected.") color: printerConnected && printerAcceptsCommands ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text") - font: UM.Theme.getFont("default") + font: UM.Theme.getFont("very_small") wrapMode: Text.WordWrap anchors.left: parent.left anchors.leftMargin: UM.Theme.getSize("default_margin").width @@ -68,6 +68,46 @@ Column } } + GridLayout + { + id: extrudersGrid + columns: 2 + columnSpacing: UM.Theme.getSize("sidebar_lining_thin").width + rowSpacing: UM.Theme.getSize("sidebar_lining_thin").height + width: parent.width + + Repeater + { + model: machineExtruderCount.properties.value + delegate: Rectangle + { + id: extruderRectangle + color: UM.Theme.getColor("sidebar") + width: extrudersGrid.width / 2 - UM.Theme.getSize("sidebar_lining_thin").width / 2 + height: UM.Theme.getSize("sidebar_extruder_box").height + + Text //Extruder name. + { + text: machineExtruderCount.properties.value > 1 ? extrudersModel.getItem(index).name : catalog.i18nc("@label", "Hotend") + color: UM.Theme.getColor("text") + 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 //Temperature indication. + { + text: printerConnected ? Math.round(connectedPrinter.hotendTemperatures[index]) + "°C" : "" + font: UM.Theme.getFont("large") + anchors.right: parent.right + anchors.rightMargin: UM.Theme.getSize("default_margin").width + anchors.top: parent.top + anchors.topMargin: UM.Theme.getSize("default_margin").height + } + } + } + } + Loader { sourceComponent: monitorSection diff --git a/resources/themes/cura/theme.json b/resources/themes/cura/theme.json index 23ebacd7f9..80fe6a3236 100644 --- a/resources/themes/cura/theme.json +++ b/resources/themes/cura/theme.json @@ -24,6 +24,10 @@ "bold": true, "family": "Open Sans" }, + "very_small": { + "size": 1.0, + "family": "Open Sans" + }, "button_tooltip": { "size": 1.0, "family": "Open Sans" @@ -247,9 +251,11 @@ "sidebar_header_mode_toggle": [0.0, 2.0], "sidebar_header_mode_tabs": [0.0, 3.0], "sidebar_lining": [0.5, 0.5], + "sidebar_lining_thin": [0.2, 0.2], "sidebar_setup": [0.0, 2.0], "sidebar_tabs": [0.0, 3.5], "sidebar_inputfields": [0.0, 2.0], + "sidebar_extruder_box": [0.0, 4.0], "simple_mode_infill_caption": [0.0, 5.0], "simple_mode_infill_height": [0.0, 8.0], From 687cdcc30ea4c74dc02e5012f82c445c105b87e7 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 3 Feb 2017 13:54:37 +0100 Subject: [PATCH 08/84] Add grey border between extruder boxes This is done by fitting tightly a rectangle around the grid of boxes. The boxes themselves have a white background but there is spacing between the boxes, which results in the little border. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 65 +++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index 556f500348..2db524a794 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -68,41 +68,48 @@ Column } } - GridLayout + Rectangle { - id: extrudersGrid - columns: 2 - columnSpacing: UM.Theme.getSize("sidebar_lining_thin").width - rowSpacing: UM.Theme.getSize("sidebar_lining_thin").height + color: UM.Theme.getColor("sidebar_lining") width: parent.width + height: childrenRect.height - Repeater + GridLayout { - model: machineExtruderCount.properties.value - delegate: Rectangle - { - id: extruderRectangle - color: UM.Theme.getColor("sidebar") - width: extrudersGrid.width / 2 - UM.Theme.getSize("sidebar_lining_thin").width / 2 - height: UM.Theme.getSize("sidebar_extruder_box").height + id: extrudersGrid + columns: 2 + columnSpacing: UM.Theme.getSize("sidebar_lining_thin").width + rowSpacing: UM.Theme.getSize("sidebar_lining_thin").height + width: parent.width - Text //Extruder name. + Repeater + { + model: machineExtruderCount.properties.value + delegate: Rectangle { - text: machineExtruderCount.properties.value > 1 ? extrudersModel.getItem(index).name : catalog.i18nc("@label", "Hotend") - color: UM.Theme.getColor("text") - 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 //Temperature indication. - { - text: printerConnected ? Math.round(connectedPrinter.hotendTemperatures[index]) + "°C" : "" - font: UM.Theme.getFont("large") - anchors.right: parent.right - anchors.rightMargin: UM.Theme.getSize("default_margin").width - anchors.top: parent.top - anchors.topMargin: UM.Theme.getSize("default_margin").height + id: extruderRectangle + color: UM.Theme.getColor("sidebar") + width: extrudersGrid.width / 2 - UM.Theme.getSize("sidebar_lining_thin").width / 2 + height: UM.Theme.getSize("sidebar_extruder_box").height + + Text //Extruder name. + { + text: machineExtruderCount.properties.value > 1 ? extrudersModel.getItem(index).name : catalog.i18nc("@label", "Hotend") + color: UM.Theme.getColor("text") + 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 //Temperature indication. + { + text: printerConnected ? Math.round(connectedPrinter.hotendTemperatures[index]) + "°C" : "" + font: UM.Theme.getFont("large") + anchors.right: parent.right + anchors.rightMargin: UM.Theme.getSize("default_margin").width + anchors.top: parent.top + anchors.topMargin: UM.Theme.getSize("default_margin").height + } } } } From ee3e0ba6abb659cd1a1b5322b6da6ab3d75ba18b Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 3 Feb 2017 14:52:09 +0100 Subject: [PATCH 09/84] Add material indication to extruder boxes Only if a material is known of course. But the case where it is unknown is not tested. Contributes to issue CURA-3161. --- cura/PrinterOutputDevice.py | 22 ++++++++++++++++++++++ resources/qml/PrintMonitor.qml | 24 ++++++++++++++++++++++++ resources/themes/cura/theme.json | 2 +- 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/cura/PrinterOutputDevice.py b/cura/PrinterOutputDevice.py index 6e7305b27b..ed67bbb1ca 100644 --- a/cura/PrinterOutputDevice.py +++ b/cura/PrinterOutputDevice.py @@ -323,6 +323,28 @@ class PrinterOutputDevice(QObject, OutputDevice): result.append(i18n_catalog.i18nc("@item:material", "Unknown material")) return result + ## List of the colours of the currently loaded materials. + # + # The list is in order of extruders. If there is no material in an + # extruder, the colour is shown as transparent. + # + # The colours are returned in hex-format AARRGGBB or RRGGBB + # (e.g. #800000ff for transparent blue or #00ff00 for pure green). + @pyqtProperty("QVariantList", notify = materialIdChanged) + def materialColors(self): + result = [] + for material_id in self._material_ids: + if material_id is None: + result.append("#800000FF") #No material. + continue + + containers = self._container_registry.findInstanceContainers(type = "material", GUID = material_id) + if containers: + result.append(containers[0].getMetaDataEntry("color_code")) + else: + result.append("#800000FF") #Unknown material. + return result + ## Protected setter for the current material id. # /param index Index of the extruder # /param material_id id of the material diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index 2db524a794..537adc53e5 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -110,6 +110,30 @@ Column anchors.top: parent.top anchors.topMargin: UM.Theme.getSize("default_margin").height } + Rectangle //Material colour indication. + { + id: materialColor + width: materialName.height * 0.75 + height: materialName.height * 0.75 + color: printerConnected ? connectedPrinter.materialColors[index] : [0, 0, 0, 0] //Need to check for printerConnected or materialColors[index] gives an error. + border.width: UM.Theme.getSize("default_lining").width + border.color: UM.Theme.getColor("lining") + visible: printerConnected + anchors.left: parent.left + anchors.leftMargin: UM.Theme.getSize("default_margin").width + anchors.verticalCenter: materialName.verticalCenter + } + Text //Material name. + { + id: materialName + text: printerConnected ? connectedPrinter.materialNames[index] : "" + font: UM.Theme.getFont("default") + color: UM.Theme.getColor("text") + anchors.left: materialColor.right + anchors.leftMargin: UM.Theme.getSize("default_margin").width + anchors.bottom: parent.bottom + anchors.bottomMargin: UM.Theme.getSize("default_margin").height + } } } } diff --git a/resources/themes/cura/theme.json b/resources/themes/cura/theme.json index 80fe6a3236..acce27b74e 100644 --- a/resources/themes/cura/theme.json +++ b/resources/themes/cura/theme.json @@ -255,7 +255,7 @@ "sidebar_setup": [0.0, 2.0], "sidebar_tabs": [0.0, 3.5], "sidebar_inputfields": [0.0, 2.0], - "sidebar_extruder_box": [0.0, 4.0], + "sidebar_extruder_box": [0.0, 6.0], "simple_mode_infill_caption": [0.0, 5.0], "simple_mode_infill_height": [0.0, 8.0], From 41c94fd247cd5400e39a66961fab560fefe53cb3 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 3 Feb 2017 15:03:24 +0100 Subject: [PATCH 10/84] Add variant names to extruder boxes In the bottom-right corner. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index 537adc53e5..c23d732d62 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -134,6 +134,16 @@ Column anchors.bottom: parent.bottom anchors.bottomMargin: UM.Theme.getSize("default_margin").height } + Text //Variant name. + { + text: printerConnected ? connectedPrinter.hotendIds[index] : "" + font: UM.Theme.getFont("default") + color: UM.Theme.getColor("text") + anchors.right: parent.right + anchors.rightMargin: UM.Theme.getSize("default_margin").width + anchors.bottom: parent.bottom + anchors.bottomMargin: UM.Theme.getSize("default_margin").height + } } } } From a6c244f969aaab248e5b20865d068b8faf0c339b Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 3 Feb 2017 15:06:21 +0100 Subject: [PATCH 11/84] Use setting separator margin between material colour and name It's a bit smaller. Looks like it belongs together now. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index c23d732d62..debc7657f8 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -130,7 +130,7 @@ Column font: UM.Theme.getFont("default") color: UM.Theme.getColor("text") anchors.left: materialColor.right - anchors.leftMargin: UM.Theme.getSize("default_margin").width + anchors.leftMargin: UM.Theme.getSize("setting_unit_margin").width anchors.bottom: parent.bottom anchors.bottomMargin: UM.Theme.getSize("default_margin").height } From 1305dd88d74909e28a1aaf34014d025e0708002e Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 3 Feb 2017 15:20:24 +0100 Subject: [PATCH 12/84] Remove old extruder monitoring code It has been replaced by these fancy new boxes. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index debc7657f8..616b90fe72 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -149,21 +149,6 @@ Column } } - Loader - { - sourceComponent: monitorSection - property string label: catalog.i18nc("@label", "Temperatures") - } - Repeater - { - model: machineExtruderCount.properties.value - delegate: Loader - { - sourceComponent: monitorItem - property string label: machineExtruderCount.properties.value > 1 ? extrudersModel.getItem(index).name : catalog.i18nc("@label", "Hotend") - property string value: printerConnected ? Math.round(connectedPrinter.hotendTemperatures[index]) + "°C" : "" - } - } Repeater { model: machineHeatedBed.properties.value == "True" ? 1 : 0 From 03e16b53982a5efba061043a42ab431391bb97be Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 3 Feb 2017 15:49:18 +0100 Subject: [PATCH 13/84] Fix material colour when no printer is selected It's invisible anyway, but the hex colour gives no errors at least. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index 616b90fe72..d74f769fd5 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -115,7 +115,7 @@ Column id: materialColor width: materialName.height * 0.75 height: materialName.height * 0.75 - color: printerConnected ? connectedPrinter.materialColors[index] : [0, 0, 0, 0] //Need to check for printerConnected or materialColors[index] gives an error. + color: printerConnected ? connectedPrinter.materialColors[index] : "#00000000" //Need to check for printerConnected or materialColors[index] gives an error. border.width: UM.Theme.getSize("default_lining").width border.color: UM.Theme.getColor("lining") visible: printerConnected From abb9b8d7f09174a73ae4ec4609427299cbaee325 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 3 Feb 2017 15:52:14 +0100 Subject: [PATCH 14/84] Add box for build plate monitoring This one's a bit bigger. It is supposed to contain the pre-heat button. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 41 +++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index d74f769fd5..e0c1d7ceca 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -149,14 +149,43 @@ Column } } - Repeater + Rectangle { - model: machineHeatedBed.properties.value == "True" ? 1 : 0 - delegate: Loader + color: UM.Theme.getColor("sidebar") + width: parent.width + height: machineHeatedBed.properties.value == "True" ? UM.Theme.getSize("sidebar_extruder_box").height : 0 + visible: machineHeatedBed.properties.value == "True" + + Label //Build plate label. { - sourceComponent: monitorItem - property string label: catalog.i18nc("@label", "Build plate") - property string value: printerConnected ? Math.round(connectedPrinter.bedTemperature) + "°C" : "" + text: catalog.i18nc("@label", "Build plate") + font: UM.Theme.getFont("default") + color: UM.Theme.getColor("text") + 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 //Target temperature. + { + id: bedTargetTemperature + text: printerConnected ? connectedPrinter.targetBedTemperature + "°C" : "" + font: UM.Theme.getFont("small") + color: UM.Theme.getColor("text_inactive") + anchors.right: parent.right + anchors.rightMargin: UM.Theme.getSize("default_margin").width + anchors.bottom: bedCurrentTemperature.bottom + } + Text //Current temperature. + { + id: bedCurrentTemperature + text: printerConnected ? connectedPrinter.bedTemperature + "°C" : "" + font: UM.Theme.getFont("large") + color: UM.Theme.getColor("text") + anchors.right: bedTargetTemperature.left + anchors.rightMargin: UM.Theme.getSize("setting_unit_margin").width + anchors.top: parent.top + anchors.topMargin: UM.Theme.getSize("default_margin").height } } From 3fb625109e0ec75ae26e2f1453765cdf5c1d5c1f Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 3 Feb 2017 17:04:31 +0100 Subject: [PATCH 15/84] Add text field for target pre-heat temperature I'm sure it's quite buggy on all sides though. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 75 ++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index e0c1d7ceca..56f16ed7c2 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -187,6 +187,81 @@ Column anchors.top: parent.top anchors.topMargin: UM.Theme.getSize("default_margin").height } + Rectangle //Input field for pre-heat temperature. + { + id: preheatTemperatureControl + color: UM.Theme.getColor("setting_validation_ok") + border.width: UM.Theme.getSize("default_lining").width + border.color: hovered ? UM.Theme.getColor("setting_control_border_highlight") : UM.Theme.getColor("setting_control_border") + anchors.left: parent.left + anchors.leftMargin: UM.Theme.getSize("default_margin").width + anchors.bottom: parent.bottom + anchors.bottomMargin: UM.Theme.getSize("default_margin").height + width: UM.Theme.getSize("setting_control").width + height: UM.Theme.getSize("setting_control").height + + Rectangle //Highlight of input field. + { + anchors.fill: parent + anchors.margins: UM.Theme.getSize("default_lining").width + color: UM.Theme.getColor("setting_control_highlight") + opacity: preheatTemperatureControl.hovered ? 1.0 : 0 + } + Label //Maximum temperature indication. + { + text: "MAXTEMP" //TODO: Placeholder! + color: UM.Theme.getColor("setting_unit") + font: UM.Theme.getFont("default") + anchors.right: parent.right + anchors.rightMargin: UM.Theme.getSize("setting_unit_margin").width + anchors.verticalCenter: parent.verticalCenter + } + MouseArea //Change cursor on hovering. + { + id: mouseArea + anchors.fill: parent + cursorShape: Qt.IBeamCursor + } + TextInput + { + id: preheatTemperatureInput + font: UM.Theme.getFont("default") + color: UM.Theme.getColor("setting_control_text") + selectByMouse: true + maximumLength: 10 + validator: RegExpValidator { regExp: /^-?[0-9]{0,9}[.,]?[0-9]{0,10}$/ } //Floating point regex. + anchors.left: parent.left + anchors.leftMargin: UM.Theme.getSize("setting_unit_margin").width + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + + text: "60" //TODO: Bind this to the default. + /*Binding + { + target: preheatTemperatureInput + property: "text" + value: { + // Stacklevels + // 0: user -> unsaved change + // 1: quality changes -> saved change + // 2: quality + // 3: material -> user changed material in materialspage + // 4: variant + // 5: machine_changes + // 6: machine + if ((base.resolve != "None" && base.resolve) && (stackLevel != 0) && (stackLevel != 1)) { + // We have a resolve function. Indicates that the setting is not settable per extruder and that + // we have to choose between the resolved value (default) and the global value + // (if user has explicitly set this). + return base.resolve; + } else { + return propertyProvider.properties.value; + } + } + when: !preheatTemperatureInput.activeFocus + }*/ + } + } } Loader From 27ff55d75b6ee2cfce95e1b9d5adb4dc49f0bdbb Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Mon, 6 Feb 2017 15:09:18 +0100 Subject: [PATCH 16/84] Add binding to current maximum bed temperature Instead of the MAXTEMP placeholder. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index 56f16ed7c2..b61d56feec 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -209,7 +209,7 @@ Column } Label //Maximum temperature indication. { - text: "MAXTEMP" //TODO: Placeholder! + text: bedTemperature.properties.maximum_value color: UM.Theme.getColor("setting_unit") font: UM.Theme.getFont("default") anchors.right: parent.right @@ -264,6 +264,15 @@ Column } } + UM.SettingPropertyProvider + { + id: bedTemperature + containerStackId: Cura.MachineManager.activeMachineId + key: "material_bed_temperature" + watchedProperties: ["value", "minimum_value", "maximum_value", "minimum_value_warning", "maximum_value_warning"] + storeIndex: 0 + } + Loader { sourceComponent: monitorSection From 78fed0531dc39dfb228c99153493e11b5b9a1538 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Mon, 6 Feb 2017 15:17:59 +0100 Subject: [PATCH 17/84] Fix hovering the setting box The 'hovered' property was taken from the example of the setting item, but that doesn't exist apparently. I looked up how it is normally done in QML. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index b61d56feec..b28944f008 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -192,7 +192,7 @@ Column id: preheatTemperatureControl color: UM.Theme.getColor("setting_validation_ok") border.width: UM.Theme.getSize("default_lining").width - border.color: hovered ? UM.Theme.getColor("setting_control_border_highlight") : UM.Theme.getColor("setting_control_border") + border.color: mouseArea.containsMouse ? UM.Theme.getColor("setting_control_border_highlight") : UM.Theme.getColor("setting_control_border") anchors.left: parent.left anchors.leftMargin: UM.Theme.getSize("default_margin").width anchors.bottom: parent.bottom @@ -219,6 +219,7 @@ Column MouseArea //Change cursor on hovering. { id: mouseArea + hoverEnabled: true anchors.fill: parent cursorShape: Qt.IBeamCursor } From b1a8b28e87415c4f71d43a7c39dd79d027a252d4 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Mon, 6 Feb 2017 15:44:40 +0100 Subject: [PATCH 18/84] Bind default pre-heat temperature to current build plate temperature Currently the setting 'resets' when you go out of the print monitor mode. That wasn't the original intention but it works kind of nicely. We'll bring it up in a meeting whether this needs to be changed. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index b28944f008..49f49502a6 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -236,12 +236,12 @@ Column anchors.right: parent.right anchors.verticalCenter: parent.verticalCenter - text: "60" //TODO: Bind this to the default. - /*Binding + Binding { target: preheatTemperatureInput property: "text" - value: { + value: + { // Stacklevels // 0: user -> unsaved change // 1: quality changes -> saved change @@ -250,17 +250,20 @@ Column // 4: variant // 5: machine_changes // 6: machine - if ((base.resolve != "None" && base.resolve) && (stackLevel != 0) && (stackLevel != 1)) { + if ((bedTemperature.resolve != "None" && bedTemperature.resolve) && (bedTemperature.stackLevels[0] != 0) && (bedTemperature.stackLevels[0] != 1)) + { // We have a resolve function. Indicates that the setting is not settable per extruder and that // we have to choose between the resolved value (default) and the global value // (if user has explicitly set this). - return base.resolve; - } else { - return propertyProvider.properties.value; + return bedTemperature.resolve; + } + else + { + return bedTemperature.properties.value; } } when: !preheatTemperatureInput.activeFocus - }*/ + } } } } @@ -270,8 +273,10 @@ Column id: bedTemperature containerStackId: Cura.MachineManager.activeMachineId key: "material_bed_temperature" - watchedProperties: ["value", "minimum_value", "maximum_value", "minimum_value_warning", "maximum_value_warning"] + watchedProperties: ["value", "minimum_value", "maximum_value", "minimum_value_warning", "maximum_value_warning", "resolve"] storeIndex: 0 + + property var resolve: Cura.MachineManager.activeStackId != Cura.MachineManager.activeMachineId ? properties.resolve : "None" } Loader From b1448887ba05a5e6dae8230f0cc73a96b7b6bf4c Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Mon, 6 Feb 2017 16:45:52 +0100 Subject: [PATCH 19/84] Add button to pre-heat build plate This is the one. The actual commit that implements the issue. It doesn't do anything yet, this button, but it's how it should look. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 98 ++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index 49f49502a6..ee7fb1a692 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -266,6 +266,104 @@ Column } } } + + Button //The pre-heat button. + { + text: catalog.i18nc("@button", "Pre-heat") + tooltip: catalog.i18nc("@tooltip of pre-heat", "Heat the bed in advance before printing. You can continue adjusting your print while it is heating, and you won't have to wait for the bed to heat up when you're ready to print.") + height: UM.Theme.getSize("setting_control").height + anchors.right: parent.right + anchors.rightMargin: UM.Theme.getSize("default_margin").width + anchors.bottom: parent.bottom + anchors.bottomMargin: UM.Theme.getSize("default_margin").height + style: ButtonStyle { + background: Rectangle + { + border.width: UM.Theme.getSize("default_lining").width + implicitWidth: actualLabel.contentWidth + (UM.Theme.getSize("default_margin").width * 2) + border.color: + { + if(!control.enabled) + { + return UM.Theme.getColor("action_button_disabled_border"); + } + else if(control.pressed) + { + return UM.Theme.getColor("action_button_active_border"); + } + else if(control.hovered) + { + return UM.Theme.getColor("action_button_hovered_border"); + } + else + { + return UM.Theme.getColor("action_button_border"); + } + } + color: + { + if(!control.enabled) + { + return UM.Theme.getColor("action_button_disabled"); + } + else if(control.pressed) + { + return UM.Theme.getColor("action_button_active"); + } + else if(control.hovered) + { + return UM.Theme.getColor("action_button_hovered"); + } + else + { + return UM.Theme.getColor("action_button"); + } + } + Behavior on color + { + ColorAnimation + { + duration: 50 + } + } + + Label + { + id: actualLabel + anchors.centerIn: parent + color: + { + if(!control.enabled) + { + return UM.Theme.getColor("action_button_disabled_text"); + } + else if(control.pressed) + { + return UM.Theme.getColor("action_button_active_text"); + } + else if(control.hovered) + { + return UM.Theme.getColor("action_button_hovered_text"); + } + else + { + return UM.Theme.getColor("action_button_text"); + } + } + font: UM.Theme.getFont("action_button") + text: control.text; + } + } + label: Item + { + } + } + + onClicked: + { + print("Click!"); + } + } } UM.SettingPropertyProvider From f24d778cc5269fe8e4fef61c9610e65d03f644b0 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 7 Feb 2017 12:51:02 +0100 Subject: [PATCH 20/84] Disable pre-heat button when not connected This covers the case when there is no printer added as well as the case where a printer is added but not connected. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index ee7fb1a692..c1fbdef983 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -272,6 +272,7 @@ Column text: catalog.i18nc("@button", "Pre-heat") tooltip: catalog.i18nc("@tooltip of pre-heat", "Heat the bed in advance before printing. You can continue adjusting your print while it is heating, and you won't have to wait for the bed to heat up when you're ready to print.") height: UM.Theme.getSize("setting_control").height + enabled: printerConnected anchors.right: parent.right anchors.rightMargin: UM.Theme.getSize("default_margin").width anchors.bottom: parent.bottom From cfbcf567399449beff2e9db8b22ab0f2c289c0e5 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 7 Feb 2017 13:18:41 +0100 Subject: [PATCH 21/84] Add function to pre-head bed This makes a PUT-request to the printer with the new API function call. Contributes to issue CURA-3161. --- .../UM3NetworkPrinting/NetworkPrinterOutputDevice.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py index 32ebd354ee..99d07a8b81 100644 --- a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py +++ b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py @@ -240,6 +240,18 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): def ipAddress(self): return self._address + ## Pre-heats the heated bed of the printer. + # + # \param temperature The temperature to heat the bed to, in degrees + # Celsius. + # \param duration How long the bed should stay warm, in seconds. + def preheatBed(self, temperature, duration): + url = QUrl("http://" + self._address + self._api_prefix + "printer/bed/pre_heat") + data = """{"temperature": "{temperature}", "timeout": "{timeout}"}""".format(temperature=temperature, timeout=duration) + put_request = QNetworkRequest(url) + put_request.setHeader(QNetworkRequest.ContentTypeHeader, "application/json") + self._manager.put(put_request, data.encode()) + def _stopCamera(self): self._camera_timer.stop() if self._image_reply: From 9d8034d14fcc4dc1665226ccb480ff7dc79a24ce Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 7 Feb 2017 13:22:21 +0100 Subject: [PATCH 22/84] Add default for duration parameter of preheatBed It defaults to 15 minutes. Contributes to issue CURA-3161. --- plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py index 99d07a8b81..5ac06e7154 100644 --- a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py +++ b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py @@ -244,8 +244,9 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): # # \param temperature The temperature to heat the bed to, in degrees # Celsius. - # \param duration How long the bed should stay warm, in seconds. - def preheatBed(self, temperature, duration): + # \param duration How long the bed should stay warm, in seconds. Defaults + # to a quarter hour. + def preheatBed(self, temperature, duration=900): url = QUrl("http://" + self._address + self._api_prefix + "printer/bed/pre_heat") data = """{"temperature": "{temperature}", "timeout": "{timeout}"}""".format(temperature=temperature, timeout=duration) put_request = QNetworkRequest(url) From d7bf23ca21616788cb0345bf3da71432ede3bec5 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 7 Feb 2017 13:23:56 +0100 Subject: [PATCH 23/84] Add function to cancel pre-heating the bed You could also do this by calling preheatBed with a temperature of 0. In fact, that's what this function does. Contributes to issue CURA-3161. --- plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py index 5ac06e7154..470d0efa0a 100644 --- a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py +++ b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py @@ -253,6 +253,12 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): put_request.setHeader(QNetworkRequest.ContentTypeHeader, "application/json") self._manager.put(put_request, data.encode()) + ## Cancels pre-heating the heated bed of the printer. + # + # If the bed is not pre-heated, nothing happens. + def cancelPreheatBed(self): + self.preheatBed(temperature=0) + def _stopCamera(self): self._camera_timer.stop() if self._image_reply: From 0df4afff33a823cfaebcf2b1538791c37abaa5f5 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 7 Feb 2017 13:26:10 +0100 Subject: [PATCH 24/84] Convert parameters to string before including them This way you can provide normal floating point values instead of providing strings with numbers in them. Contributes to issue CURA-3161. --- plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py index 470d0efa0a..e43e522c0c 100644 --- a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py +++ b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py @@ -248,7 +248,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): # to a quarter hour. def preheatBed(self, temperature, duration=900): url = QUrl("http://" + self._address + self._api_prefix + "printer/bed/pre_heat") - data = """{"temperature": "{temperature}", "timeout": "{timeout}"}""".format(temperature=temperature, timeout=duration) + data = """{"temperature": "{temperature}", "timeout": "{timeout}"}""".format(temperature=str(temperature), timeout=str(duration)) put_request = QNetworkRequest(url) put_request.setHeader(QNetworkRequest.ContentTypeHeader, "application/json") self._manager.put(put_request, data.encode()) From 559b40867ef88c37379244fed2947743058f7da2 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 7 Feb 2017 13:29:57 +0100 Subject: [PATCH 25/84] Call pre-heat if pre-heat button is pressed Contributes to issue CURA-3161. --- plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py | 2 ++ resources/qml/PrintMonitor.qml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py index e43e522c0c..59c04dd822 100644 --- a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py +++ b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py @@ -246,6 +246,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): # Celsius. # \param duration How long the bed should stay warm, in seconds. Defaults # to a quarter hour. + @pyqtSlot(float, float) def preheatBed(self, temperature, duration=900): url = QUrl("http://" + self._address + self._api_prefix + "printer/bed/pre_heat") data = """{"temperature": "{temperature}", "timeout": "{timeout}"}""".format(temperature=str(temperature), timeout=str(duration)) @@ -256,6 +257,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): ## Cancels pre-heating the heated bed of the printer. # # If the bed is not pre-heated, nothing happens. + @pyqtSlot() def cancelPreheatBed(self): self.preheatBed(temperature=0) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index c1fbdef983..4ff6d02c54 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -362,7 +362,7 @@ Column onClicked: { - print("Click!"); + connectedPrinter.preheatBed(preheatTemperatureInput.text, 900) } } } From 3618ae0d4f9e9435ac7ba093927f9ac7de83b862 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 7 Feb 2017 13:35:09 +0100 Subject: [PATCH 26/84] Properly float-format input of preheatBed It rounds to 3 digits. The specification of the feature in the API doesn't mention how detailed the temperature and duration can go, but thousands seems more than enough. This also eliminates pesky problems with the JSON brackets in the format function. Contributes to issue CURA-3161. --- plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py index 59c04dd822..87986afbf3 100644 --- a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py +++ b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py @@ -249,7 +249,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): @pyqtSlot(float, float) def preheatBed(self, temperature, duration=900): url = QUrl("http://" + self._address + self._api_prefix + "printer/bed/pre_heat") - data = """{"temperature": "{temperature}", "timeout": "{timeout}"}""".format(temperature=str(temperature), timeout=str(duration)) + data = """{"temperature": "%0.3f", "timeout": "%0.3f"}""" % (temperature, duration) put_request = QNetworkRequest(url) put_request.setHeader(QNetworkRequest.ContentTypeHeader, "application/json") self._manager.put(put_request, data.encode()) From b27a9e65352db035de78edddb01797ef6b5600ba Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 7 Feb 2017 13:52:44 +0100 Subject: [PATCH 27/84] Implement tracking target bed temperature I had already assumed it was tracking this but apparently it wasn't. This works though. Contributes to issue CURA-3161. --- .../UM3NetworkPrinting/NetworkPrinterOutputDevice.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py index 87986afbf3..c4177953fe 100644 --- a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py +++ b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py @@ -97,6 +97,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): self._material_ids = [""] * self._num_extruders self._hotend_ids = [""] * self._num_extruders + self._target_bed_temperature = 0 self.setPriority(2) # Make sure the output device gets selected above local file output self.setName(key) @@ -261,6 +262,15 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): def cancelPreheatBed(self): self.preheatBed(temperature=0) + ## Changes the target bed temperature and makes sure that its signal is + # emitted. + # + # /param temperature The new target temperature of the bed. + def _setTargetBedTemperature(self, temperature): + if self._target_bed_temperature != temperature: + self._target_bed_temperature = temperature + self.targetBedTemperatureChanged.emit() + def _stopCamera(self): self._camera_timer.stop() if self._image_reply: @@ -492,6 +502,8 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): bed_temperature = self._json_printer_state["bed"]["temperature"]["current"] self._setBedTemperature(bed_temperature) + target_bed_temperature = self._json_printer_state["bed"]["temperature"]["target"] + self._setTargetBedTemperature(target_bed_temperature) head_x = self._json_printer_state["heads"][0]["position"]["x"] head_y = self._json_printer_state["heads"][0]["position"]["y"] From d751285713b57177f79e007133e4d4c4cb1f03d4 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 7 Feb 2017 14:39:56 +0100 Subject: [PATCH 28/84] Provide pre-heat command with integer parameters The firmware only accepts integers, apparently. Contributes to issue CURA-3161. --- plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py index c4177953fe..3d2d4bbc07 100644 --- a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py +++ b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py @@ -247,10 +247,10 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): # Celsius. # \param duration How long the bed should stay warm, in seconds. Defaults # to a quarter hour. - @pyqtSlot(float, float) + @pyqtSlot(int, int) def preheatBed(self, temperature, duration=900): url = QUrl("http://" + self._address + self._api_prefix + "printer/bed/pre_heat") - data = """{"temperature": "%0.3f", "timeout": "%0.3f"}""" % (temperature, duration) + data = """{"temperature": "%i", "timeout": "%i"}""" % (temperature, duration) put_request = QNetworkRequest(url) put_request.setHeader(QNetworkRequest.ContentTypeHeader, "application/json") self._manager.put(put_request, data.encode()) From d3d36d47ebbb2e3d31f2a11ffc08df4ea6e7ac75 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 7 Feb 2017 16:22:47 +0100 Subject: [PATCH 29/84] Add countdown timer for pre-heat time Not happy with how there is '900' in multiple places in the code. I might do something about that later. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 47 +++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index 4ff6d02c54..9bc30f324e 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -267,8 +267,47 @@ Column } } + Timer + { + id: preheatCountdownTimer + interval: 100 //Update every 100ms. You want to update every 1s, but then you have one timer for the updating running out of sync with the actual date timer and you might skip seconds. + running: false + repeat: true + onTriggered: update() + property var endTime: new Date() + function update() + { + var now = new Date(); + if (now.getTime() < endTime.getTime()) + { + var remaining = endTime - now; //This is in milliseconds. + var minutes = Math.floor(remaining / 60 / 1000); + var seconds = Math.floor((remaining / 1000) % 60); + preheatCountdown.text = minutes + ":" + (seconds < 10 ? "0" + seconds : seconds); + preheatCountdown.visible = true; + } + else + { + preheatCountdown.visible = false; + running = false; + } + } + } + Text + { + id: preheatCountdown + text: "0:00" + visible: false //It only becomes visible when the timer is running. + font: UM.Theme.getFont("default") + color: UM.Theme.getColor("text") + anchors.right: preheatButton.left + anchors.rightMargin: UM.Theme.getSize("default_margin").width + anchors.verticalCenter: preheatButton.verticalCenter + } + Button //The pre-heat button. { + id: preheatButton text: catalog.i18nc("@button", "Pre-heat") tooltip: catalog.i18nc("@tooltip of pre-heat", "Heat the bed in advance before printing. You can continue adjusting your print while it is heating, and you won't have to wait for the bed to heat up when you're ready to print.") height: UM.Theme.getSize("setting_control").height @@ -362,7 +401,13 @@ Column onClicked: { - connectedPrinter.preheatBed(preheatTemperatureInput.text, 900) + connectedPrinter.preheatBed(preheatTemperatureInput.text, 900); + var now = new Date(); + var end_time = new Date(); + end_time.setTime(now.getTime() + 900 * 1000); //*1000 because time is in milliseconds here. + preheatCountdownTimer.endTime = end_time; + preheatCountdownTimer.start(); + preheatCountdownTimer.update(); //Update once before the first timer is triggered. } } } From d705fb1d763e3f1065c7774cb4ed74d35927d3d4 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 7 Feb 2017 16:24:28 +0100 Subject: [PATCH 30/84] Document why we set endTime to the current date initially Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index 9bc30f324e..0a34eb8f31 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -274,7 +274,7 @@ Column running: false repeat: true onTriggered: update() - property var endTime: new Date() + property var endTime: new Date() //Set initial endTime to be the current date, so that the endTime has initially already passed and the timer text becomes invisible if you were to update. function update() { var now = new Date(); From 1a902b21bb8704dca2fea80a2199a8fe2c699a86 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 7 Feb 2017 16:29:41 +0100 Subject: [PATCH 31/84] Store default pre-heat time in central location Its default is 900s or 15 minutes. QML now requests the time-out time and sends it on to the printer. Contributes to issue CURA-3161. --- cura/PrinterOutputDevice.py | 6 ++++++ plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py | 4 ++-- resources/qml/PrintMonitor.qml | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/cura/PrinterOutputDevice.py b/cura/PrinterOutputDevice.py index ed67bbb1ca..56ae34b6f4 100644 --- a/cura/PrinterOutputDevice.py +++ b/cura/PrinterOutputDevice.py @@ -45,6 +45,7 @@ class PrinterOutputDevice(QObject, OutputDevice): self._job_name = "" self._error_text = "" self._accepts_commands = True + self._preheat_bed_timeout = 900 #Default time-out for pre-heating the bed, in seconds. self._printer_state = "" self._printer_type = "unknown" @@ -199,6 +200,11 @@ class PrinterOutputDevice(QObject, OutputDevice): self._target_bed_temperature = temperature self.targetBedTemperatureChanged.emit() + ## + @pyqtProperty(int) + def preheatBedTimeout(self): + return self._preheat_bed_timeout + ## Time the print has been printing. # Note that timeTotal - timeElapsed should give time remaining. @pyqtProperty(float, notify = timeElapsedChanged) diff --git a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py index 3d2d4bbc07..bf708f23d7 100644 --- a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py +++ b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py @@ -248,7 +248,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): # \param duration How long the bed should stay warm, in seconds. Defaults # to a quarter hour. @pyqtSlot(int, int) - def preheatBed(self, temperature, duration=900): + def preheatBed(self, temperature, duration): url = QUrl("http://" + self._address + self._api_prefix + "printer/bed/pre_heat") data = """{"temperature": "%i", "timeout": "%i"}""" % (temperature, duration) put_request = QNetworkRequest(url) @@ -260,7 +260,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): # If the bed is not pre-heated, nothing happens. @pyqtSlot() def cancelPreheatBed(self): - self.preheatBed(temperature=0) + self.preheatBed(temperature = 0, duration = 0) ## Changes the target bed temperature and makes sure that its signal is # emitted. diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index 0a34eb8f31..65a56b3441 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -404,7 +404,7 @@ Column connectedPrinter.preheatBed(preheatTemperatureInput.text, 900); var now = new Date(); var end_time = new Date(); - end_time.setTime(now.getTime() + 900 * 1000); //*1000 because time is in milliseconds here. + end_time.setTime(now.getTime() + connectedPrinter.preheatBedTimeout * 1000); //*1000 because time is in milliseconds here. preheatCountdownTimer.endTime = end_time; preheatCountdownTimer.start(); preheatCountdownTimer.update(); //Update once before the first timer is triggered. From 8e25a1c73fbc7430b0f2e2a3c7b682eb2c882668 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 7 Feb 2017 16:32:36 +0100 Subject: [PATCH 32/84] Also use central pre-heat time when sending time to printer Oops. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index 65a56b3441..277ae9b325 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -401,7 +401,7 @@ Column onClicked: { - connectedPrinter.preheatBed(preheatTemperatureInput.text, 900); + connectedPrinter.preheatBed(preheatTemperatureInput.text, connectedPrinter.preheatBedTimeout); var now = new Date(); var end_time = new Date(); end_time.setTime(now.getTime() + connectedPrinter.preheatBedTimeout * 1000); //*1000 because time is in milliseconds here. From 9b235aebf2cf829ec89413f57a1bab1a1804a0f1 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 7 Feb 2017 16:38:28 +0100 Subject: [PATCH 33/84] Add clock icon to pre-heat countdown It's aligned left of the pre-heat countdown and only visible if the countdown is visible. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index 277ae9b325..30f021675b 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -267,6 +267,21 @@ Column } } + UM.RecolorImage + { + id: preheatCountdownIcon + width: UM.Theme.getSize("save_button_specs_icons").width + height: UM.Theme.getSize("save_button_specs_icons").height + sourceSize.width: width + sourceSize.height: height + color: UM.Theme.getColor("text") + visible: preheatCountdown.visible + source: UM.Theme.getIcon("print_time") + anchors.right: preheatCountdown.left + anchors.rightMargin: UM.Theme.getSize("default_margin").width / 2 + anchors.verticalCenter: preheatCountdown.verticalCenter + } + Timer { id: preheatCountdownTimer From 8d09c538967e5cf841064e38cd4a80526a443da8 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 7 Feb 2017 16:46:22 +0100 Subject: [PATCH 34/84] Make pre-heat button cancel if currently heating This is based on the timer, which is locally. Eventually we'd want to make the timer update every now and then or so. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index 30f021675b..848aa5f9a5 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -323,7 +323,7 @@ Column Button //The pre-heat button. { id: preheatButton - text: catalog.i18nc("@button", "Pre-heat") + text: preheatCountdownTimer.running ? catalog.i18nc("@button Cancel pre-heating", "Cancel") : catalog.i18nc("@button", "Pre-heat") tooltip: catalog.i18nc("@tooltip of pre-heat", "Heat the bed in advance before printing. You can continue adjusting your print while it is heating, and you won't have to wait for the bed to heat up when you're ready to print.") height: UM.Theme.getSize("setting_control").height enabled: printerConnected @@ -416,13 +416,22 @@ Column onClicked: { - connectedPrinter.preheatBed(preheatTemperatureInput.text, connectedPrinter.preheatBedTimeout); - var now = new Date(); - var end_time = new Date(); - end_time.setTime(now.getTime() + connectedPrinter.preheatBedTimeout * 1000); //*1000 because time is in milliseconds here. - preheatCountdownTimer.endTime = end_time; - preheatCountdownTimer.start(); - preheatCountdownTimer.update(); //Update once before the first timer is triggered. + if (!preheatCountdownTimer.running) + { + connectedPrinter.preheatBed(preheatTemperatureInput.text, connectedPrinter.preheatBedTimeout); + var now = new Date(); + var end_time = new Date(); + end_time.setTime(now.getTime() + connectedPrinter.preheatBedTimeout * 1000); //*1000 because time is in milliseconds here. + preheatCountdownTimer.endTime = end_time; + preheatCountdownTimer.start(); + preheatCountdownTimer.update(); //Update once before the first timer is triggered. + } + else + { + connectedPrinter.cancelPreheatBed(); + preheatCountdownTimer.endTime = new Date(); + preheatCountdownTimer.update(); + } } } } From 785f10966efaf2e3e584384d41f185e96bf0f794 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 7 Feb 2017 16:48:27 +0100 Subject: [PATCH 35/84] Don't send a time-out for preheat if timeout is 0 The printer doesn't accept 0. Contributes to issue CURA-3161. --- plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py index bf708f23d7..074bc92cda 100644 --- a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py +++ b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py @@ -250,7 +250,10 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): @pyqtSlot(int, int) def preheatBed(self, temperature, duration): url = QUrl("http://" + self._address + self._api_prefix + "printer/bed/pre_heat") - data = """{"temperature": "%i", "timeout": "%i"}""" % (temperature, duration) + if duration > 0: + data = """{"temperature": "%i", "timeout": "%i"}""" % (temperature, duration) + else: + data = """{"temperature": "%i"}""" % temperature put_request = QNetworkRequest(url) put_request.setHeader(QNetworkRequest.ContentTypeHeader, "application/json") self._manager.put(put_request, data.encode()) From 4ccadc6208796ea98aa5611621deaa6877e58c98 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 7 Feb 2017 16:57:20 +0100 Subject: [PATCH 36/84] Round pre-heat temperature and duration to integer but allow floats We want to allow floats in the interface since the interface needs to be agnostic of what device it is connected to. But the UM3 API only allows integers, so we still need to round it to the nearest integer. Contributes to issue CURA-3161. --- plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py index 074bc92cda..3694ada361 100644 --- a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py +++ b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py @@ -247,8 +247,10 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): # Celsius. # \param duration How long the bed should stay warm, in seconds. Defaults # to a quarter hour. - @pyqtSlot(int, int) + @pyqtSlot(float, float) def preheatBed(self, temperature, duration): + temperature = round(temperature) #The API doesn't allow floating point. + duration = round(duration) url = QUrl("http://" + self._address + self._api_prefix + "printer/bed/pre_heat") if duration > 0: data = """{"temperature": "%i", "timeout": "%i"}""" % (temperature, duration) From 57ec987cd9a350db4b08998695d26a9fcf3667ca Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 7 Feb 2017 17:13:36 +0100 Subject: [PATCH 37/84] Disable pre-heat if temperature is invalid Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index 848aa5f9a5..598b9489d9 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -326,7 +326,7 @@ Column text: preheatCountdownTimer.running ? catalog.i18nc("@button Cancel pre-heating", "Cancel") : catalog.i18nc("@button", "Pre-heat") tooltip: catalog.i18nc("@tooltip of pre-heat", "Heat the bed in advance before printing. You can continue adjusting your print while it is heating, and you won't have to wait for the bed to heat up when you're ready to print.") height: UM.Theme.getSize("setting_control").height - enabled: printerConnected + enabled: printerConnected && (preheatCountdownTimer.running || (parseInt(preheatTemperatureInput.text) >= parseInt(bedTemperature.properties.minimum_value) && parseInt(preheatTemperatureInput.text) <= parseInt(bedTemperature.properties.maximum_value))) anchors.right: parent.right anchors.rightMargin: UM.Theme.getSize("default_margin").width anchors.bottom: parent.bottom From d30430381f5e37094aea9a4743861132e4675092 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 7 Feb 2017 17:16:19 +0100 Subject: [PATCH 38/84] Add default implementations for preheatBed and cancelPreheatBed It is a no-op implementation that gives a warning. I'd rather give an exception and have that handled by whatever calls it, but this is how the other methods here do it. Contributes to issue CURA-3161. --- cura/PrinterOutputDevice.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/cura/PrinterOutputDevice.py b/cura/PrinterOutputDevice.py index 56ae34b6f4..f7b5ccbe05 100644 --- a/cura/PrinterOutputDevice.py +++ b/cura/PrinterOutputDevice.py @@ -260,6 +260,23 @@ class PrinterOutputDevice(QObject, OutputDevice): def _setTargetBedTemperature(self, temperature): Logger.log("w", "_setTargetBedTemperature is not implemented by this output device") + ## Pre-heats the heated bed of the printer. + # + # \param temperature The temperature to heat the bed to, in degrees + # Celsius. + # \param duration How long the bed should stay warm, in seconds. Defaults + # to a quarter hour. + @pyqtSlot(float, float) + def preheatBed(self, temperature, duration): + Logger.log("w", "preheatBed is not implemented by this output device.") + + ## Cancels pre-heating the heated bed of the printer. + # + # If the bed is not pre-heated, nothing happens. + @pyqtSlot() + def cancelPreheatBed(self): + Logger.log("w", "cancelPreheatBed is not implemented by this output device.") + ## Protected setter for the current bed temperature. # This simply sets the bed temperature, but ensures that a signal is emitted. # /param temperature temperature of the bed. From 9354a80504a03bf4e265468539be9416994fe03e Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 7 Feb 2017 17:17:45 +0100 Subject: [PATCH 39/84] Document no longer that pre-heating defaults to 15m Because that was removed. Contributes to issue CURA-3161. --- cura/PrinterOutputDevice.py | 3 +-- plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/cura/PrinterOutputDevice.py b/cura/PrinterOutputDevice.py index f7b5ccbe05..3cba132f9a 100644 --- a/cura/PrinterOutputDevice.py +++ b/cura/PrinterOutputDevice.py @@ -264,8 +264,7 @@ class PrinterOutputDevice(QObject, OutputDevice): # # \param temperature The temperature to heat the bed to, in degrees # Celsius. - # \param duration How long the bed should stay warm, in seconds. Defaults - # to a quarter hour. + # \param duration How long the bed should stay warm, in seconds. @pyqtSlot(float, float) def preheatBed(self, temperature, duration): Logger.log("w", "preheatBed is not implemented by this output device.") diff --git a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py index 3694ada361..6ce3a4fcc5 100644 --- a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py +++ b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py @@ -245,8 +245,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): # # \param temperature The temperature to heat the bed to, in degrees # Celsius. - # \param duration How long the bed should stay warm, in seconds. Defaults - # to a quarter hour. + # \param duration How long the bed should stay warm, in seconds. @pyqtSlot(float, float) def preheatBed(self, temperature, duration): temperature = round(temperature) #The API doesn't allow floating point. From b05697b0d57b3dc9d5ca93fceb39eb61834a44c0 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 7 Feb 2017 17:21:14 +0100 Subject: [PATCH 40/84] Also cancel pre-heating bed from Cura after time-out Printers that don't automatically turn off their heated bed will get the task to do so by Cura then. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index 598b9489d9..f52ea86312 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -305,6 +305,10 @@ Column { preheatCountdown.visible = false; running = false; + if (printerConnected) + { + connectedPrinter.cancelPreheatBed() + } } } } From 7cf81412ae4cc46e94013c3e9706069764601424 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 7 Feb 2017 17:26:44 +0100 Subject: [PATCH 41/84] Implement bed pre-heating via USB It just calls the bed heating command without implementing the time-out. Implementing the time-out is impossible via just g-code. Contributes to issue CURA-3161. --- plugins/USBPrinting/USBPrinterOutputDevice.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/plugins/USBPrinting/USBPrinterOutputDevice.py b/plugins/USBPrinting/USBPrinterOutputDevice.py index e30ba613bc..9fd5bf02e0 100644 --- a/plugins/USBPrinting/USBPrinterOutputDevice.py +++ b/plugins/USBPrinting/USBPrinterOutputDevice.py @@ -641,3 +641,20 @@ class USBPrinterOutputDevice(PrinterOutputDevice): self._update_firmware_thread.daemon = True self.connect() + + ## Pre-heats the heated bed of the printer, if it has one. + # + # \param temperature The temperature to heat the bed to, in degrees + # Celsius. + # \param duration How long the bed should stay warm, in seconds. This is + # ignored because there is no g-code to set this. + @pyqtSlot(float, float) + def preheatBed(self, temperature, duration): + self._setTargetBedTemperature(temperature) + + ## Cancels pre-heating the heated bed of the printer. + # + # If the bed is not pre-heated, nothing happens. + @pyqtSlot() + def cancelPreheatBed(self): + self._setTargetBedTemperature(0) \ No newline at end of file From e9b30daad6b6ba079a739dd9c9d0b182adc21db5 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 7 Feb 2017 17:30:15 +0100 Subject: [PATCH 42/84] Write out pre-heat button enabled condition It should be equivalent. This needs to be done because the line is getting long and I need to add additional checks for if the properties are even set. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index f52ea86312..ee3f68ad17 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -330,7 +330,26 @@ Column text: preheatCountdownTimer.running ? catalog.i18nc("@button Cancel pre-heating", "Cancel") : catalog.i18nc("@button", "Pre-heat") tooltip: catalog.i18nc("@tooltip of pre-heat", "Heat the bed in advance before printing. You can continue adjusting your print while it is heating, and you won't have to wait for the bed to heat up when you're ready to print.") height: UM.Theme.getSize("setting_control").height - enabled: printerConnected && (preheatCountdownTimer.running || (parseInt(preheatTemperatureInput.text) >= parseInt(bedTemperature.properties.minimum_value) && parseInt(preheatTemperatureInput.text) <= parseInt(bedTemperature.properties.maximum_value))) + enabled: + { + if (!printerConnected) + { + return false; //Can't preheat if not connected. + } + if (preheatCountdownTimer.running) + { + return true; //Can always cancel if the timer is running. + } + if (parseInt(preheatTemperatureInput.text) < parseInt(bedTemperature.properties.minimum_value)) + { + return false; //Target temperature too low. + } + if (parseInt(preheatTemperatureInput.text) > parseInt(bedTemperature.properties.maximum_value)) + { + return false; //Target temperature too high. + } + return true; //Preconditions are met. + } anchors.right: parent.right anchors.rightMargin: UM.Theme.getSize("default_margin").width anchors.bottom: parent.bottom From 0b10df01b01d06b3c7b75d23211cd4705bb70b2e Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 7 Feb 2017 17:33:59 +0100 Subject: [PATCH 43/84] Don't check for min/max temperature if we have no min/max If we have no minimum/maximum bed temperature, the property returns 'None'. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index ee3f68ad17..2d989aeb43 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -340,11 +340,11 @@ Column { return true; //Can always cancel if the timer is running. } - if (parseInt(preheatTemperatureInput.text) < parseInt(bedTemperature.properties.minimum_value)) + if (bedTemperature.properties.minimum_value != "None" && parseInt(preheatTemperatureInput.text) < parseInt(bedTemperature.properties.minimum_value)) { return false; //Target temperature too low. } - if (parseInt(preheatTemperatureInput.text) > parseInt(bedTemperature.properties.maximum_value)) + if (bedTemperature.properties.maximum_value != "None" && parseInt(preheatTemperatureInput.text) > parseInt(bedTemperature.properties.maximum_value)) { return false; //Target temperature too high. } From be9823e94fe07123bda7d4f588fe0ec7023eb288 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 7 Feb 2017 17:39:45 +0100 Subject: [PATCH 44/84] Hide maximum bed temperature if there is no maximum Instead of the ugly 'None' it would display. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index 2d989aeb43..34cb3d438a 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -210,6 +210,7 @@ Column Label //Maximum temperature indication. { text: bedTemperature.properties.maximum_value + visible: bedTemperature.properties.maximum_value != "None" color: UM.Theme.getColor("setting_unit") font: UM.Theme.getFont("default") anchors.right: parent.right From 2cdf06413bb48628449594bc3c3ef8d2ef89d632 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 8 Feb 2017 09:41:42 +0100 Subject: [PATCH 45/84] Remove margin on the left of print monitor For the other side bar objects this margin was applied doubly, so that makes it very easy to remove. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 2 +- resources/qml/Sidebar.qml | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index 34cb3d438a..ea33dad592 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -533,7 +533,7 @@ Column Rectangle { color: UM.Theme.getColor("setting_category") - width: base.width - 2 * UM.Theme.getSize("default_margin").width + width: base.width height: UM.Theme.getSize("section").height Label diff --git a/resources/qml/Sidebar.qml b/resources/qml/Sidebar.qml index 45dc49d076..ab3032e7f1 100644 --- a/resources/qml/Sidebar.qml +++ b/resources/qml/Sidebar.qml @@ -499,9 +499,7 @@ Rectangle { anchors.bottom: footerSeparator.top anchors.top: headerSeparator.bottom - anchors.topMargin: UM.Theme.getSize("default_margin").height anchors.left: base.left - anchors.leftMargin: UM.Theme.getSize("default_margin").width anchors.right: base.right source: monitoringPrint ? "PrintMonitor.qml": "SidebarContents.qml" } From 34f929c9df3ce7ebf49d1dc826feffd3f3e2549d Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 8 Feb 2017 10:18:21 +0100 Subject: [PATCH 46/84] Disable preheat button if printer is busy It is allowed to preheat the bed if the printer is waiting for the bed to clean up or for stuff to cool down after a print. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index ea33dad592..861b6d2bc1 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -337,6 +337,10 @@ Column { return false; //Can't preheat if not connected. } + if (connectedPrinter.jobState == "printing" || connectedPrinter.jobState == "pre_print" || connectedPrinter.jobState == "pausing" || connectedPrinter.jobState == "resuming" || connectedPrinter.jobState == "error" || connectedPrinter.jobState == "offline") + { + return false; //Printer is in a state where it can't react to pre-heating. + } if (preheatCountdownTimer.running) { return true; //Can always cancel if the timer is running. From 98e3e2a25a8774c9c48a943fd017d67d9c7f4546 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 8 Feb 2017 10:19:20 +0100 Subject: [PATCH 47/84] Allow pre-heating bed while pausing It is allowed during the pause. So it should also be allowed when transitioning towards the pause. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index 861b6d2bc1..8bf3d41322 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -337,7 +337,7 @@ Column { return false; //Can't preheat if not connected. } - if (connectedPrinter.jobState == "printing" || connectedPrinter.jobState == "pre_print" || connectedPrinter.jobState == "pausing" || connectedPrinter.jobState == "resuming" || connectedPrinter.jobState == "error" || connectedPrinter.jobState == "offline") + if (connectedPrinter.jobState == "printing" || connectedPrinter.jobState == "pre_print" || connectedPrinter.jobState == "resuming" || connectedPrinter.jobState == "error" || connectedPrinter.jobState == "offline") { return false; //Printer is in a state where it can't react to pre-heating. } From 28e488dad712a5e5b3ce01d1e457e80b1c809263 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 8 Feb 2017 11:37:04 +0100 Subject: [PATCH 48/84] Fix setting target bed temperature The previous implementation just emitted the signal twice, once in setTargetBedTemperature and once in _setTargetBedTemperature. I've made the private one actually set the temperature. Contributes to issue CURA-3161. --- .../NetworkPrinterOutputDevice.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py index 6ce3a4fcc5..5f7a36f316 100644 --- a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py +++ b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py @@ -266,14 +266,17 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): def cancelPreheatBed(self): self.preheatBed(temperature = 0, duration = 0) - ## Changes the target bed temperature and makes sure that its signal is - # emitted. + ## Changes the target bed temperature on the printer. # # /param temperature The new target temperature of the bed. def _setTargetBedTemperature(self, temperature): - if self._target_bed_temperature != temperature: - self._target_bed_temperature = temperature - self.targetBedTemperatureChanged.emit() + if self._target_bed_temperature == temperature: + return + url = QUrl("http://" + self._address + self._api_prefix + "printer/bed/temperature") + data = """{"target": "%i"}""" % temperature + put_request = QNetworkRequest(url) + put_request.setHeader(QNetworkRequest.ContentTypeHeader, "application/json") + self._manager.put(put_request, data.encode()) def _stopCamera(self): self._camera_timer.stop() From da4574cb32d78a169b000b5edb79d9affb7d63bb Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 8 Feb 2017 11:38:03 +0100 Subject: [PATCH 49/84] Use fallback without time-out if preheating bed on old firmware It manually sets the temperature just like what happens when you print via USB. Contributes to issue CURA-3161. --- plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py index 5f7a36f316..44aead8e5b 100644 --- a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py +++ b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py @@ -9,6 +9,7 @@ from UM.Signal import signalemitter from UM.Message import Message import UM.Settings +import UM.Version #To compare firmware version numbers. from cura.PrinterOutputDevice import PrinterOutputDevice, ConnectionState import cura.Settings.ExtruderManager @@ -250,6 +251,9 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): def preheatBed(self, temperature, duration): temperature = round(temperature) #The API doesn't allow floating point. duration = round(duration) + if UM.Version(self.firmwareVersion) < UM.Version("3.5.92"): #Real bed pre-heating support is implemented from 3.5.92 and up. + self.setTargetBedTemperature(temperature = temperature) #No firmware-side duration support then. + return url = QUrl("http://" + self._address + self._api_prefix + "printer/bed/pre_heat") if duration > 0: data = """{"temperature": "%i", "timeout": "%i"}""" % (temperature, duration) From 9f66ad1132e213fdd0c50a4e2a40e3259b3c32f8 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 8 Feb 2017 11:40:40 +0100 Subject: [PATCH 50/84] Remove superfluous empty item Don't know where that came from. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 3 --- 1 file changed, 3 deletions(-) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index 8bf3d41322..4b811f1806 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -437,9 +437,6 @@ Column text: control.text; } } - label: Item - { - } } onClicked: From 2a114f1e533bef64e8b48a001e12998e63937275 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 8 Feb 2017 11:59:19 +0100 Subject: [PATCH 51/84] Display last item with double width if there's room on the right side If it's on the left side and it's the last item, it gets the entire width. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index 4b811f1806..b707b41151 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -91,6 +91,7 @@ Column color: UM.Theme.getColor("sidebar") width: extrudersGrid.width / 2 - UM.Theme.getSize("sidebar_lining_thin").width / 2 height: UM.Theme.getSize("sidebar_extruder_box").height + Layout.fillWidth: index == machineExtruderCount.properties.value - 1 && index % 2 == 0 Text //Extruder name. { From d7b0336c2411711acf944c4f2bb296caf80c34be Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 8 Feb 2017 12:42:40 +0100 Subject: [PATCH 52/84] Fix colour of unknown material The other colour was just used for debugging. Contributes to issue CURA-3161. --- cura/PrinterOutputDevice.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cura/PrinterOutputDevice.py b/cura/PrinterOutputDevice.py index 3cba132f9a..f989bf26cd 100644 --- a/cura/PrinterOutputDevice.py +++ b/cura/PrinterOutputDevice.py @@ -1,3 +1,6 @@ +# Copyright (c) 2017 Ultimaker B.V. +# Cura is released under the terms of the AGPLv3 or higher. + from UM.i18n import i18nCatalog from UM.OutputDevice.OutputDevice import OutputDevice from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject @@ -357,14 +360,14 @@ class PrinterOutputDevice(QObject, OutputDevice): result = [] for material_id in self._material_ids: if material_id is None: - result.append("#800000FF") #No material. + result.append("#00000000") #No material. continue containers = self._container_registry.findInstanceContainers(type = "material", GUID = material_id) if containers: result.append(containers[0].getMetaDataEntry("color_code")) else: - result.append("#800000FF") #Unknown material. + result.append("#00000000") #Unknown material. return result ## Protected setter for the current material id. From 1395735ecef792e50a886231d13d43197f0086cb Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 8 Feb 2017 12:53:54 +0100 Subject: [PATCH 53/84] No longer mention printer name in status The printer name is displayed right above it, so mentioning the name again is double. Contributes to issue CURA-3161. --- plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py index 44aead8e5b..69d5c8abc2 100644 --- a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py +++ b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py @@ -318,14 +318,14 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): if auth_state == AuthState.AuthenticationRequested: Logger.log("d", "Authentication state changed to authentication requested.") self.setAcceptsCommands(False) - self.setConnectionText(i18n_catalog.i18nc("@info:status", "Connected over the network to {0}. Please approve the access request on the printer.").format(self.name)) + self.setConnectionText(i18n_catalog.i18nc("@info:status", "Connected over the network. Please approve the access request on the printer.")) self._authentication_requested_message.show() self._authentication_request_active = True self._authentication_timer.start() # Start timer so auth will fail after a while. elif auth_state == AuthState.Authenticated: Logger.log("d", "Authentication state changed to authenticated") self.setAcceptsCommands(True) - self.setConnectionText(i18n_catalog.i18nc("@info:status", "Connected over the network to {0}.").format(self.name)) + self.setConnectionText(i18n_catalog.i18nc("@info:status", "Connected over the network.")) self._authentication_requested_message.hide() if self._authentication_request_active: self._authentication_succeeded_message.show() @@ -338,7 +338,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): self.sendMaterialProfiles() elif auth_state == AuthState.AuthenticationDenied: self.setAcceptsCommands(False) - self.setConnectionText(i18n_catalog.i18nc("@info:status", "Connected over the network to {0}. No access to control the printer.").format(self.name)) + self.setConnectionText(i18n_catalog.i18nc("@info:status", "Connected over the network. No access to control the printer.")) self._authentication_requested_message.hide() if self._authentication_request_active: if self._authentication_timer.remainingTime() > 0: From bcab0d7be90d54da310901b69f318d284908b2ad Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 8 Feb 2017 14:00:06 +0100 Subject: [PATCH 54/84] Add unit to maximum temperature indication Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index b707b41151..90111265f0 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -210,8 +210,7 @@ Column } Label //Maximum temperature indication. { - text: bedTemperature.properties.maximum_value - visible: bedTemperature.properties.maximum_value != "None" + text: (bedTemperature.properties.maximum_value != "None" ? bedTemperature.properties.maximum_value : "") + "°C" color: UM.Theme.getColor("setting_unit") font: UM.Theme.getFont("default") anchors.right: parent.right From 4013b500632f1cca1342910ec9ecba9afacdc484 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 8 Feb 2017 14:01:07 +0100 Subject: [PATCH 55/84] Only allow pre-heating if authenticated Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index 90111265f0..b34d1af252 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -337,6 +337,10 @@ Column { return false; //Can't preheat if not connected. } + if (!connectedPrinter.acceptsCommands) + { + return false; //Not allowed to do anything. + } if (connectedPrinter.jobState == "printing" || connectedPrinter.jobState == "pre_print" || connectedPrinter.jobState == "resuming" || connectedPrinter.jobState == "error" || connectedPrinter.jobState == "offline") { return false; //Printer is in a state where it can't react to pre-heating. From c5655d4d8c1a3d1c02fd5092202803bae806fc91 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Thu, 9 Feb 2017 09:32:14 +0100 Subject: [PATCH 56/84] Document preheatBedTimeout Must've slipped through the cracks. Contributes to issue CURA-3161. --- cura/PrinterOutputDevice.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cura/PrinterOutputDevice.py b/cura/PrinterOutputDevice.py index f989bf26cd..c6bc3e8f3d 100644 --- a/cura/PrinterOutputDevice.py +++ b/cura/PrinterOutputDevice.py @@ -203,7 +203,9 @@ class PrinterOutputDevice(QObject, OutputDevice): self._target_bed_temperature = temperature self.targetBedTemperatureChanged.emit() - ## + ## The duration of the time-out to pre-heat the bed, in seconds. + # + # \return The duration of the time-out to pre-heat the bed, in seconds. @pyqtProperty(int) def preheatBedTimeout(self): return self._preheat_bed_timeout From e37d8b949e5427d7564da6e3c1af4cc9cbf04bcc Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Thu, 9 Feb 2017 10:31:35 +0100 Subject: [PATCH 57/84] Add fallback in PrinterOutputDevice for getting address The fallback gives a warning that it's not implemented. Contributes to issue CURA-3161. --- cura/PrinterOutputDevice.py | 5 +++++ resources/qml/PrintMonitor.qml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cura/PrinterOutputDevice.py b/cura/PrinterOutputDevice.py index c6bc3e8f3d..8f03bdff79 100644 --- a/cura/PrinterOutputDevice.py +++ b/cura/PrinterOutputDevice.py @@ -165,6 +165,11 @@ class PrinterOutputDevice(QObject, OutputDevice): self._job_name = name self.jobNameChanged.emit() + ## Gives a human-readable address where the device can be found. + @pyqtProperty(str, constant = True) + def address(self): + Logger.log("w", "address is not implemented by this output device.") + @pyqtProperty(str, notify = errorTextChanged) def errorText(self): return self._error_text diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index b34d1af252..8ce094cbd3 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -43,7 +43,7 @@ Column Label { id: connectedPrinterAddressLabel - text: printerConnected ? connectedPrinter.address : "" + text: (printerConnected && connectedPrinter.address != null) ? connectedPrinter.address : "" font: UM.Theme.getFont("small") color: UM.Theme.getColor("text_inactive") anchors.left: parent.left From 27c30006da20b8cf1e849c2f5adfa1e4535c179e Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Thu, 9 Feb 2017 10:33:14 +0100 Subject: [PATCH 58/84] Give no address instead of a wrong address if unknown Contributes to issue CURA-3161. --- plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py index 69d5c8abc2..5790cdab77 100644 --- a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py +++ b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py @@ -225,7 +225,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): ## The IP address of the printer. @pyqtProperty(str, constant = True) def address(self): - return self._properties.get(b"address", b"0.0.0.0").decode("utf-8") + return self._properties.get(b"address", b"").decode("utf-8") ## Name of the printer (as returned from the zeroConf properties) @pyqtProperty(str, constant = True) From 0c9b9a3033cfe7e110103db15ce9acd7ec5a5b8a Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Thu, 9 Feb 2017 17:34:51 +0100 Subject: [PATCH 59/84] Add fallback name property in PrinterOutputDevice It'll call this property, which gives an empty string, if the device doesn't implement giving a name. Contributes to issue CURA-3161. --- cura/PrinterOutputDevice.py | 6 ++++++ plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cura/PrinterOutputDevice.py b/cura/PrinterOutputDevice.py index 8f03bdff79..8a95748cf1 100644 --- a/cura/PrinterOutputDevice.py +++ b/cura/PrinterOutputDevice.py @@ -170,6 +170,12 @@ class PrinterOutputDevice(QObject, OutputDevice): def address(self): Logger.log("w", "address is not implemented by this output device.") + ## A human-readable name for the device. + @pyqtProperty(str, constant = True) + def name(self): + Logger.log("w", "name is not implemented by this output device.") + return "" + @pyqtProperty(str, notify = errorTextChanged) def errorText(self): return self._error_text diff --git a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py index 5790cdab77..7df3c7bf23 100644 --- a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py +++ b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py @@ -227,12 +227,12 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): def address(self): return self._properties.get(b"address", b"").decode("utf-8") - ## Name of the printer (as returned from the zeroConf properties) + ## Name of the printer (as returned from the ZeroConf properties) @pyqtProperty(str, constant = True) def name(self): return self._properties.get(b"name", b"").decode("utf-8") - ## Firmware version (as returned from the zeroConf properties) + ## Firmware version (as returned from the ZeroConf properties) @pyqtProperty(str, constant=True) def firmwareVersion(self): return self._properties.get(b"firmware_version", b"").decode("utf-8") From 45c045131baccacee688adf46ab366cc768b801e Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 10 Feb 2017 09:38:38 +0100 Subject: [PATCH 60/84] Fix rendering pre-heat button text twice It was rendered by the button and again by the style for the button. I'm just using the style since it has the proper styling. Thanks, fieldOfView. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index 8ce094cbd3..db58927cfa 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -328,7 +328,6 @@ Column Button //The pre-heat button. { id: preheatButton - text: preheatCountdownTimer.running ? catalog.i18nc("@button Cancel pre-heating", "Cancel") : catalog.i18nc("@button", "Pre-heat") tooltip: catalog.i18nc("@tooltip of pre-heat", "Heat the bed in advance before printing. You can continue adjusting your print while it is heating, and you won't have to wait for the bed to heat up when you're ready to print.") height: UM.Theme.getSize("setting_control").height enabled: @@ -438,7 +437,7 @@ Column } } font: UM.Theme.getFont("action_button") - text: control.text; + text: preheatCountdownTimer.running ? catalog.i18nc("@button Cancel pre-heating", "Cancel") : catalog.i18nc("@button", "Pre-heat") } } } From 4ce755021abb5b18053878ab32e626d7efa73fb6 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 10 Feb 2017 11:11:39 +0100 Subject: [PATCH 61/84] Don't use printerConnected from Sidebar.qml We don't need it if we just check for connectedPrinter to not be null each time. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 38 +++++++++++++++++----------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index db58927cfa..b39cec34b2 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -12,7 +12,7 @@ import Cura 1.0 as Cura Column { id: printMonitor - property var connectedPrinter: printerConnected ? Cura.MachineManager.printerOutputDevices[0] : null + property var connectedPrinter: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null Cura.ExtrudersModel { @@ -30,7 +30,7 @@ Column Label { id: connectedPrinterNameLabel - text: printerConnected ? connectedPrinter.name : catalog.i18nc("@info:status", "No printer connected") + text: connectedPrinter != null ? connectedPrinter.name : catalog.i18nc("@info:status", "No printer connected") font: UM.Theme.getFont("large") color: UM.Theme.getColor("text") anchors.left: parent.left @@ -43,7 +43,7 @@ Column Label { id: connectedPrinterAddressLabel - text: (printerConnected && connectedPrinter.address != null) ? connectedPrinter.address : "" + text: (connectedPrinter != null && connectedPrinter.address != null) ? connectedPrinter.address : "" font: UM.Theme.getFont("small") color: UM.Theme.getColor("text_inactive") anchors.left: parent.left @@ -56,8 +56,8 @@ Column } Label { - text: printerConnected ? connectedPrinter.connectionText : catalog.i18nc("@info:status", "The printer is not connected.") - color: printerConnected && printerAcceptsCommands ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text") + text: connectedPrinter != null ? connectedPrinter.connectionText : catalog.i18nc("@info:status", "The printer is not connected.") + color: connectedPrinter != null && printerAcceptsCommands ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text") font: UM.Theme.getFont("very_small") wrapMode: Text.WordWrap anchors.left: parent.left @@ -104,7 +104,7 @@ Column } Text //Temperature indication. { - text: printerConnected ? Math.round(connectedPrinter.hotendTemperatures[index]) + "°C" : "" + text: connectedPrinter != null ? Math.round(connectedPrinter.hotendTemperatures[index]) + "°C" : "" font: UM.Theme.getFont("large") anchors.right: parent.right anchors.rightMargin: UM.Theme.getSize("default_margin").width @@ -116,10 +116,10 @@ Column id: materialColor width: materialName.height * 0.75 height: materialName.height * 0.75 - color: printerConnected ? connectedPrinter.materialColors[index] : "#00000000" //Need to check for printerConnected or materialColors[index] gives an error. + color: connectedPrinter != null ? connectedPrinter.materialColors[index] : "#00000000" border.width: UM.Theme.getSize("default_lining").width border.color: UM.Theme.getColor("lining") - visible: printerConnected + visible: connectedPrinter != null anchors.left: parent.left anchors.leftMargin: UM.Theme.getSize("default_margin").width anchors.verticalCenter: materialName.verticalCenter @@ -127,7 +127,7 @@ Column Text //Material name. { id: materialName - text: printerConnected ? connectedPrinter.materialNames[index] : "" + text: connectedPrinter != null ? connectedPrinter.materialNames[index] : "" font: UM.Theme.getFont("default") color: UM.Theme.getColor("text") anchors.left: materialColor.right @@ -137,7 +137,7 @@ Column } Text //Variant name. { - text: printerConnected ? connectedPrinter.hotendIds[index] : "" + text: connectedPrinter != null ? connectedPrinter.hotendIds[index] : "" font: UM.Theme.getFont("default") color: UM.Theme.getColor("text") anchors.right: parent.right @@ -170,7 +170,7 @@ Column Text //Target temperature. { id: bedTargetTemperature - text: printerConnected ? connectedPrinter.targetBedTemperature + "°C" : "" + text: connectedPrinter != null ? connectedPrinter.targetBedTemperature + "°C" : "" font: UM.Theme.getFont("small") color: UM.Theme.getColor("text_inactive") anchors.right: parent.right @@ -180,7 +180,7 @@ Column Text //Current temperature. { id: bedCurrentTemperature - text: printerConnected ? connectedPrinter.bedTemperature + "°C" : "" + text: connectedPrinter != null ? connectedPrinter.bedTemperature + "°C" : "" font: UM.Theme.getFont("large") color: UM.Theme.getColor("text") anchors.right: bedTargetTemperature.left @@ -306,7 +306,7 @@ Column { preheatCountdown.visible = false; running = false; - if (printerConnected) + if (connectedPrinter != null) { connectedPrinter.cancelPreheatBed() } @@ -332,7 +332,7 @@ Column height: UM.Theme.getSize("setting_control").height enabled: { - if (!printerConnected) + if (!connectedPrinter != null) { return false; //Can't preheat if not connected. } @@ -484,19 +484,19 @@ Column { sourceComponent: monitorItem property string label: catalog.i18nc("@label", "Job Name") - property string value: printerConnected ? connectedPrinter.jobName : "" + property string value: connectedPrinter != null ? connectedPrinter.jobName : "" } Loader { sourceComponent: monitorItem property string label: catalog.i18nc("@label", "Printing Time") - property string value: printerConnected ? getPrettyTime(connectedPrinter.timeTotal) : "" + property string value: connectedPrinter != null ? getPrettyTime(connectedPrinter.timeTotal) : "" } Loader { sourceComponent: monitorItem property string label: catalog.i18nc("@label", "Estimated time left") - property string value: printerConnected ? getPrettyTime(connectedPrinter.timeTotal - connectedPrinter.timeElapsed) : "" + property string value: connectedPrinter != null ? getPrettyTime(connectedPrinter.timeTotal - connectedPrinter.timeElapsed) : "" } Component @@ -515,7 +515,7 @@ Column width: parent.width * 0.4 anchors.verticalCenter: parent.verticalCenter text: label - color: printerConnected && printerAcceptsCommands ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text") + color: connectedPrinter != null && printerAcceptsCommands ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text") font: UM.Theme.getFont("default") elide: Text.ElideRight } @@ -524,7 +524,7 @@ Column width: parent.width * 0.6 anchors.verticalCenter: parent.verticalCenter text: value - color: printerConnected && printerAcceptsCommands ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text") + color: connectedPrinter != null && printerAcceptsCommands ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text") font: UM.Theme.getFont("default") elide: Text.ElideRight } From 17a03d777ca01dd0b0e69b15770c64f629c7ee8d Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 10 Feb 2017 11:14:28 +0100 Subject: [PATCH 62/84] No longer use printerAcceptsCommands It's an external variable we don't need. Just ask the currently connected printer. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index b39cec34b2..7984cd59c5 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -57,7 +57,7 @@ Column Label { text: connectedPrinter != null ? connectedPrinter.connectionText : catalog.i18nc("@info:status", "The printer is not connected.") - color: connectedPrinter != null && printerAcceptsCommands ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text") + color: connectedPrinter != null && connectedPrinter.acceptsCommands ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text") font: UM.Theme.getFont("very_small") wrapMode: Text.WordWrap anchors.left: parent.left @@ -515,7 +515,7 @@ Column width: parent.width * 0.4 anchors.verticalCenter: parent.verticalCenter text: label - color: connectedPrinter != null && printerAcceptsCommands ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text") + color: connectedPrinter != null && connectedPrinter.acceptsCommands ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text") font: UM.Theme.getFont("default") elide: Text.ElideRight } @@ -524,7 +524,7 @@ Column width: parent.width * 0.6 anchors.verticalCenter: parent.verticalCenter text: value - color: connectedPrinter != null && printerAcceptsCommands ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text") + color: connectedPrinter != null && connectedPrinter.acceptsCommands ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text") font: UM.Theme.getFont("default") elide: Text.ElideRight } From 60812139b78c927b52b91c8264adaa8ff4bb7989 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 10 Feb 2017 11:27:45 +0100 Subject: [PATCH 63/84] Use global margins instead of specific per cardinal direction Makes it a bit shorter. But also makes it use the width of the margins for vertical margin, which is unintuitive. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index 7984cd59c5..6a78a23348 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -34,11 +34,8 @@ Column font: UM.Theme.getFont("large") color: UM.Theme.getColor("text") anchors.left: parent.left - anchors.leftMargin: UM.Theme.getSize("default_margin").width anchors.top: parent.top - anchors.topMargin: UM.Theme.getSize("default_margin").height - anchors.right: parent.right - anchors.rightMargin: UM.Theme.getSize("default_margin").width + anchors.margins: UM.Theme.getSize("default_margin").width } Label { @@ -46,12 +43,9 @@ Column text: (connectedPrinter != null && connectedPrinter.address != null) ? connectedPrinter.address : "" font: UM.Theme.getFont("small") color: UM.Theme.getColor("text_inactive") - anchors.left: parent.left - anchors.leftMargin: UM.Theme.getSize("default_margin").width anchors.top: parent.top - anchors.topMargin: UM.Theme.getSize("default_margin").height anchors.right: parent.right - anchors.rightMargin: UM.Theme.getSize("default_margin").width + anchors.margins: UM.Theme.getSize("default_margin").width horizontalAlignment: Text.AlignRight } Label @@ -98,18 +92,16 @@ Column text: machineExtruderCount.properties.value > 1 ? extrudersModel.getItem(index).name : catalog.i18nc("@label", "Hotend") color: UM.Theme.getColor("text") anchors.left: parent.left - anchors.leftMargin: UM.Theme.getSize("default_margin").width anchors.top: parent.top - anchors.topMargin: UM.Theme.getSize("default_margin").height + anchors.margins: UM.Theme.getSize("default_margin").width } Text //Temperature indication. { text: connectedPrinter != null ? Math.round(connectedPrinter.hotendTemperatures[index]) + "°C" : "" font: UM.Theme.getFont("large") anchors.right: parent.right - anchors.rightMargin: UM.Theme.getSize("default_margin").width anchors.top: parent.top - anchors.topMargin: UM.Theme.getSize("default_margin").height + anchors.margins: UM.Theme.getSize("default_margin").width } Rectangle //Material colour indication. { @@ -131,9 +123,8 @@ Column font: UM.Theme.getFont("default") color: UM.Theme.getColor("text") anchors.left: materialColor.right - anchors.leftMargin: UM.Theme.getSize("setting_unit_margin").width anchors.bottom: parent.bottom - anchors.bottomMargin: UM.Theme.getSize("default_margin").height + anchors.margins: UM.Theme.getSize("default_margin").width } Text //Variant name. { @@ -141,9 +132,8 @@ Column font: UM.Theme.getFont("default") color: UM.Theme.getColor("text") anchors.right: parent.right - anchors.rightMargin: UM.Theme.getSize("default_margin").width anchors.bottom: parent.bottom - anchors.bottomMargin: UM.Theme.getSize("default_margin").height + anchors.margins: UM.Theme.getSize("default_margin").width } } } @@ -163,9 +153,8 @@ Column font: UM.Theme.getFont("default") color: UM.Theme.getColor("text") anchors.left: parent.left - anchors.leftMargin: UM.Theme.getSize("default_margin").width anchors.top: parent.top - anchors.topMargin: UM.Theme.getSize("default_margin").height + anchors.margins: UM.Theme.getSize("default_margin").width } Text //Target temperature. { @@ -184,9 +173,8 @@ Column font: UM.Theme.getFont("large") color: UM.Theme.getColor("text") anchors.right: bedTargetTemperature.left - anchors.rightMargin: UM.Theme.getSize("setting_unit_margin").width anchors.top: parent.top - anchors.topMargin: UM.Theme.getSize("default_margin").height + anchors.margins: UM.Theme.getSize("default_margin").width } Rectangle //Input field for pre-heat temperature. { @@ -359,9 +347,8 @@ Column return true; //Preconditions are met. } anchors.right: parent.right - anchors.rightMargin: UM.Theme.getSize("default_margin").width anchors.bottom: parent.bottom - anchors.bottomMargin: UM.Theme.getSize("default_margin").height + anchors.margins: UM.Theme.getSize("default_margin").width style: ButtonStyle { background: Rectangle { From 6ed0e81492c46f8c9291df0bd805aabcaf5e1d88 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 10 Feb 2017 11:30:05 +0100 Subject: [PATCH 64/84] Remove unnecessary alignment It is single-line text and already aligned to the right side via the anchors. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 1 - 1 file changed, 1 deletion(-) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index 6a78a23348..29f3210c2d 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -46,7 +46,6 @@ Column anchors.top: parent.top anchors.right: parent.right anchors.margins: UM.Theme.getSize("default_margin").width - horizontalAlignment: Text.AlignRight } Label { From f6fe4f9fd306c10332854b19abaff46fed6b86bd Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 10 Feb 2017 11:56:37 +0100 Subject: [PATCH 65/84] Use Label for all text, not just labels The fonts use better fallbacks if they fail to load for labels. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index 29f3210c2d..7666c175d2 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -86,7 +86,7 @@ Column height: UM.Theme.getSize("sidebar_extruder_box").height Layout.fillWidth: index == machineExtruderCount.properties.value - 1 && index % 2 == 0 - Text //Extruder name. + Label //Extruder name. { text: machineExtruderCount.properties.value > 1 ? extrudersModel.getItem(index).name : catalog.i18nc("@label", "Hotend") color: UM.Theme.getColor("text") @@ -94,7 +94,7 @@ Column anchors.top: parent.top anchors.margins: UM.Theme.getSize("default_margin").width } - Text //Temperature indication. + Label //Temperature indication. { text: connectedPrinter != null ? Math.round(connectedPrinter.hotendTemperatures[index]) + "°C" : "" font: UM.Theme.getFont("large") @@ -115,7 +115,7 @@ Column anchors.leftMargin: UM.Theme.getSize("default_margin").width anchors.verticalCenter: materialName.verticalCenter } - Text //Material name. + Label //Material name. { id: materialName text: connectedPrinter != null ? connectedPrinter.materialNames[index] : "" @@ -125,7 +125,7 @@ Column anchors.bottom: parent.bottom anchors.margins: UM.Theme.getSize("default_margin").width } - Text //Variant name. + Label //Variant name. { text: connectedPrinter != null ? connectedPrinter.hotendIds[index] : "" font: UM.Theme.getFont("default") @@ -155,7 +155,7 @@ Column anchors.top: parent.top anchors.margins: UM.Theme.getSize("default_margin").width } - Text //Target temperature. + Label //Target temperature. { id: bedTargetTemperature text: connectedPrinter != null ? connectedPrinter.targetBedTemperature + "°C" : "" @@ -165,7 +165,7 @@ Column anchors.rightMargin: UM.Theme.getSize("default_margin").width anchors.bottom: bedCurrentTemperature.bottom } - Text //Current temperature. + Label //Current temperature. { id: bedCurrentTemperature text: connectedPrinter != null ? connectedPrinter.bedTemperature + "°C" : "" @@ -300,7 +300,7 @@ Column } } } - Text + Label { id: preheatCountdown text: "0:00" From be5b656ef7139309e2de662d7917ccafc2f96255 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 10 Feb 2017 13:28:59 +0100 Subject: [PATCH 66/84] Hide extruder information when hotend/material is not provided This happens when there is no extruder in the machine or the machine simply doesn't provide enough information. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index 7666c175d2..cf15973c11 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -96,7 +96,7 @@ Column } Label //Temperature indication. { - text: connectedPrinter != null ? Math.round(connectedPrinter.hotendTemperatures[index]) + "°C" : "" + text: (connectedPrinter != null && connectedPrinter.hotendTemperatures[index] != null) ? Math.round(connectedPrinter.hotendTemperatures[index]) + "°C" : "" font: UM.Theme.getFont("large") anchors.right: parent.right anchors.top: parent.top @@ -107,10 +107,10 @@ Column id: materialColor width: materialName.height * 0.75 height: materialName.height * 0.75 - color: connectedPrinter != null ? connectedPrinter.materialColors[index] : "#00000000" + color: (connectedPrinter != null && connectedPrinter.materialColors[index] != null) ? connectedPrinter.materialColors[index] : "#00000000" border.width: UM.Theme.getSize("default_lining").width border.color: UM.Theme.getColor("lining") - visible: connectedPrinter != null + visible: (connectedPrinter != null && connectedPrinter.materialColors[index] != null) anchors.left: parent.left anchors.leftMargin: UM.Theme.getSize("default_margin").width anchors.verticalCenter: materialName.verticalCenter @@ -118,7 +118,7 @@ Column Label //Material name. { id: materialName - text: connectedPrinter != null ? connectedPrinter.materialNames[index] : "" + text: (connectedPrinter != null && connectedPrinter.materialNames[index] != null) ? connectedPrinter.materialNames[index] : "" font: UM.Theme.getFont("default") color: UM.Theme.getColor("text") anchors.left: materialColor.right @@ -127,7 +127,7 @@ Column } Label //Variant name. { - text: connectedPrinter != null ? connectedPrinter.hotendIds[index] : "" + text: (connectedPrinter != null && connectedPrinter.hotendIds[index] != null) ? connectedPrinter.hotendIds[index] : "" font: UM.Theme.getFont("default") color: UM.Theme.getColor("text") anchors.right: parent.right From b3bd488c07bffec191a96dfdab564d176e2188ab Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 10 Feb 2017 14:40:31 +0100 Subject: [PATCH 67/84] Use stylised tooltip for pre-heat button Took some figuring out, this one... But it works. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index cf15973c11..bead30d85b 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -315,7 +315,6 @@ Column Button //The pre-heat button. { id: preheatButton - tooltip: catalog.i18nc("@tooltip of pre-heat", "Heat the bed in advance before printing. You can continue adjusting your print while it is heating, and you won't have to wait for the bed to heat up when you're ready to print.") height: UM.Theme.getSize("setting_control").height enabled: { @@ -447,6 +446,22 @@ Column preheatCountdownTimer.update(); } } + + onHoveredChanged: + { + if (hovered) + { + base.showTooltip( + base, + {x: 0, y: preheatButton.mapToItem(base, 0, 0).y}, + catalog.i18nc("@tooltip of pre-heat", "Heat the bed in advance before printing. You can continue adjusting your print while it is heating, and you won't have to wait for the bed to heat up when you're ready to print.") + ); + } + else + { + base.hideTooltip(); + } + } } } From 2f8fc0518157065ecdac1c83411478015fcc7b9f Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 10 Feb 2017 14:43:31 +0100 Subject: [PATCH 68/84] Fix button enabled state depending on printer connection I think I made a mistake when I removed one of the global variables here. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index bead30d85b..6e9eafaf78 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -318,7 +318,7 @@ Column height: UM.Theme.getSize("setting_control").height enabled: { - if (!connectedPrinter != null) + if (connectedPrinter == null) { return false; //Can't preheat if not connected. } From b69ec56f66fd0050f7d4bf60578887df97f9294a Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 10 Feb 2017 14:55:06 +0100 Subject: [PATCH 69/84] Make extruder name recover if it returns null If it returns null, you'd get an error that it can't assign [undefined] to a text field. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index 6e9eafaf78..f088e49c85 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -88,7 +88,7 @@ Column Label //Extruder name. { - text: machineExtruderCount.properties.value > 1 ? extrudersModel.getItem(index).name : catalog.i18nc("@label", "Hotend") + text: (machineExtruderCount.properties.value > 1 && extrudersModel.getItem(index).name != null) ? extrudersModel.getItem(index).name : catalog.i18nc("@label", "Hotend") color: UM.Theme.getColor("text") anchors.left: parent.left anchors.top: parent.top From 6629c8d0cf3cbf296d237f65675877718cc147e3 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 10 Feb 2017 15:27:32 +0100 Subject: [PATCH 70/84] Anchor last-row extruder box to left and right to stretch it Layout.fillwidth seems to only stretch the box to full width on the first row, but without it the entire thing doesn't stretch. Leaving the width out will make the entire left column stretch so that the right column is no longer visible. It's all a bit weird, this QML stuff. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index f088e49c85..8abc5ec2c4 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -85,6 +85,8 @@ Column width: extrudersGrid.width / 2 - UM.Theme.getSize("sidebar_lining_thin").width / 2 height: UM.Theme.getSize("sidebar_extruder_box").height Layout.fillWidth: index == machineExtruderCount.properties.value - 1 && index % 2 == 0 + anchors.right: (index == machineExtruderCount.properties.value - 1 && index % 2 == 0) ? parent.right : undefined + anchors.left: (index == machineExtruderCount.properties.value - 1 && index % 2 == 0) ? parent.left : undefined Label //Extruder name. { From 440508f0025d2f35b01964b95294eb332034d4de Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 10 Feb 2017 16:05:18 +0100 Subject: [PATCH 71/84] Don't display material if an unknown material is given This makes it more clear for the cases other than UM3. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index 8abc5ec2c4..6f8345aae7 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -109,10 +109,10 @@ Column id: materialColor width: materialName.height * 0.75 height: materialName.height * 0.75 - color: (connectedPrinter != null && connectedPrinter.materialColors[index] != null) ? connectedPrinter.materialColors[index] : "#00000000" + color: (connectedPrinter != null && connectedPrinter.materialColors[index] != null && connectedPrinter.materialIds[index] != "") ? connectedPrinter.materialColors[index] : "#00000000" border.width: UM.Theme.getSize("default_lining").width border.color: UM.Theme.getColor("lining") - visible: (connectedPrinter != null && connectedPrinter.materialColors[index] != null) + visible: connectedPrinter != null && connectedPrinter.materialColors[index] != null && connectedPrinter.materialIds[index] != "" anchors.left: parent.left anchors.leftMargin: UM.Theme.getSize("default_margin").width anchors.verticalCenter: materialName.verticalCenter @@ -120,7 +120,7 @@ Column Label //Material name. { id: materialName - text: (connectedPrinter != null && connectedPrinter.materialNames[index] != null) ? connectedPrinter.materialNames[index] : "" + text: (connectedPrinter != null && connectedPrinter.materialNames[index] != null && connectedPrinter.materialIds[index] != "") ? connectedPrinter.materialNames[index] : "" font: UM.Theme.getFont("default") color: UM.Theme.getColor("text") anchors.left: materialColor.right From d3147a6e97f1bbc6b64d177e841b458734127264 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 10 Feb 2017 16:07:16 +0100 Subject: [PATCH 72/84] Add font for extruder name label This allows it to get stylised. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index 6f8345aae7..686dd11e3a 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -92,6 +92,7 @@ Column { text: (machineExtruderCount.properties.value > 1 && extrudersModel.getItem(index).name != null) ? extrudersModel.getItem(index).name : catalog.i18nc("@label", "Hotend") color: UM.Theme.getColor("text") + font: UM.Them.getFont("default") anchors.left: parent.left anchors.top: parent.top anchors.margins: UM.Theme.getSize("default_margin").width From a3170041f8b70a3144e2cd676baf166dbad6aa70 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Mon, 13 Feb 2017 09:15:58 +0100 Subject: [PATCH 73/84] Fix typo of theme This was giving a warning that we couldn't get a font from undefined. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index 686dd11e3a..7e3c4e4b45 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -92,7 +92,7 @@ Column { text: (machineExtruderCount.properties.value > 1 && extrudersModel.getItem(index).name != null) ? extrudersModel.getItem(index).name : catalog.i18nc("@label", "Hotend") color: UM.Theme.getColor("text") - font: UM.Them.getFont("default") + font: UM.Theme.getFont("default") anchors.left: parent.left anchors.top: parent.top anchors.margins: UM.Theme.getSize("default_margin").width From 2722ac5a8f93f50529bed24bb8931c9a13f2ee27 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Mon, 13 Feb 2017 09:32:16 +0100 Subject: [PATCH 74/84] Re-use repeater count instead of listening to machineExtruderCount everywhere Might be slightly more efficient and/or update stuff in the correct order. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index 7e3c4e4b45..43f771296a 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -77,6 +77,7 @@ Column Repeater { + id: extrudersRepeater model: machineExtruderCount.properties.value delegate: Rectangle { @@ -84,13 +85,13 @@ Column color: UM.Theme.getColor("sidebar") width: extrudersGrid.width / 2 - UM.Theme.getSize("sidebar_lining_thin").width / 2 height: UM.Theme.getSize("sidebar_extruder_box").height - Layout.fillWidth: index == machineExtruderCount.properties.value - 1 && index % 2 == 0 - anchors.right: (index == machineExtruderCount.properties.value - 1 && index % 2 == 0) ? parent.right : undefined - anchors.left: (index == machineExtruderCount.properties.value - 1 && index % 2 == 0) ? parent.left : undefined + Layout.fillWidth: index == extrudersRepeater.count - 1 && index % 2 == 0 + anchors.right: (index == extrudersRepeater.count - 1 && index % 2 == 0) ? parent.right : undefined + anchors.left: (index == extrudersRepeater.count - 1 && index % 2 == 0) ? parent.left : undefined Label //Extruder name. { - text: (machineExtruderCount.properties.value > 1 && extrudersModel.getItem(index).name != null) ? extrudersModel.getItem(index).name : catalog.i18nc("@label", "Hotend") + text: (extrudersRepeater.count > 1 && extrudersModel.getItem(index).name != null) ? extrudersModel.getItem(index).name : catalog.i18nc("@label", "Hotend") color: UM.Theme.getColor("text") font: UM.Theme.getFont("default") anchors.left: parent.left From c2c61c4331f3861225d0db5790ca1af30002c616 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Mon, 13 Feb 2017 09:35:09 +0100 Subject: [PATCH 75/84] Improve condition for extruder name fallback In effect this has no change. But semantically it is better: If there are no extruders or the extruders have no name, use 'hotend'. Otherwise use the available name. It has nothing to do with the amount of extruders. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index 43f771296a..9865f94232 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -91,7 +91,7 @@ Column Label //Extruder name. { - text: (extrudersRepeater.count > 1 && extrudersModel.getItem(index).name != null) ? extrudersModel.getItem(index).name : catalog.i18nc("@label", "Hotend") + text: (extrudersModel.getItem(index) != null && extrudersModel.getItem(index).name != null) ? extrudersModel.getItem(index).name : catalog.i18nc("@label", "Hotend") color: UM.Theme.getColor("text") font: UM.Theme.getFont("default") anchors.left: parent.left From 40f32449c6d3747755b3d3193fa59174d694116e Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Mon, 13 Feb 2017 09:38:02 +0100 Subject: [PATCH 76/84] Remove unnecessary watched properties from machineExtruderCount Since we don't change the colour of the input box right now, we won't need the warning values. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index 9865f94232..c10fd03464 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -474,7 +474,7 @@ Column id: bedTemperature containerStackId: Cura.MachineManager.activeMachineId key: "material_bed_temperature" - watchedProperties: ["value", "minimum_value", "maximum_value", "minimum_value_warning", "maximum_value_warning", "resolve"] + watchedProperties: ["value", "minimum_value", "maximum_value", "resolve"] storeIndex: 0 property var resolve: Cura.MachineManager.activeStackId != Cura.MachineManager.activeMachineId ? properties.resolve : "None" From adbcd874a84d831d7c9028e918382d20be95815a Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Mon, 13 Feb 2017 11:52:46 +0100 Subject: [PATCH 77/84] Add SettingPropertyProvider for machineExtruderCount here too It's not necessary, but this keeps it more localised. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index c10fd03464..ac7297b4ab 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -480,6 +480,14 @@ Column property var resolve: Cura.MachineManager.activeStackId != Cura.MachineManager.activeMachineId ? properties.resolve : "None" } + UM.SettingPropertyProvider + { + id: machineExtruderCount + containerStackId: Cura.MachineManager.activeMachineId + key: "machine_extruder_count" + watchedProperties: ["value"] + } + Loader { sourceComponent: monitorSection From 77f07bbc1d3f921613d99470ffadf3dded5ad622 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Mon, 13 Feb 2017 11:54:12 +0100 Subject: [PATCH 78/84] Use Flow for extruder boxes instead of GridLayout Flow makes things a lot more simple with the double-width item at the bottom. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index ac7297b4ab..93cbaafffb 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -67,27 +67,23 @@ Column width: parent.width height: childrenRect.height - GridLayout + Flow { id: extrudersGrid - columns: 2 - columnSpacing: UM.Theme.getSize("sidebar_lining_thin").width - rowSpacing: UM.Theme.getSize("sidebar_lining_thin").height + spacing: UM.Theme.getSize("sidebar_lining_thin").width width: parent.width Repeater { id: extrudersRepeater model: machineExtruderCount.properties.value + delegate: Rectangle { id: extruderRectangle color: UM.Theme.getColor("sidebar") - width: extrudersGrid.width / 2 - UM.Theme.getSize("sidebar_lining_thin").width / 2 + width: index == machineExtruderCount.properties.value - 1 && index % 2 == 0 ? extrudersGrid.width : extrudersGrid.width / 2 - UM.Theme.getSize("sidebar_lining_thin").width / 2 height: UM.Theme.getSize("sidebar_extruder_box").height - Layout.fillWidth: index == extrudersRepeater.count - 1 && index % 2 == 0 - anchors.right: (index == extrudersRepeater.count - 1 && index % 2 == 0) ? parent.right : undefined - anchors.left: (index == extrudersRepeater.count - 1 && index % 2 == 0) ? parent.left : undefined Label //Extruder name. { From 34dccfd6a63fba57b872c68891b49a36000e41fc Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Mon, 13 Feb 2017 11:57:01 +0100 Subject: [PATCH 79/84] Fix updating extruder names on machine switch The extruder name is asked from the extruder manager, so that the signal from extruder manager properly updates it once the new name is available. Contributes to issue CURA-3161. --- cura/Settings/ExtruderManager.py | 10 ++++++++++ resources/qml/PrintMonitor.qml | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/cura/Settings/ExtruderManager.py b/cura/Settings/ExtruderManager.py index 81579f74d0..77e8683e06 100644 --- a/cura/Settings/ExtruderManager.py +++ b/cura/Settings/ExtruderManager.py @@ -103,6 +103,16 @@ class ExtruderManager(QObject): def activeExtruderIndex(self): return self._active_extruder_index + ## Gets the extruder name of an extruder of the currently active machine. + # + # \param index The index of the extruder whose name to get. + @pyqtSlot(int, result = str) + def getExtruderName(self, index): + try: + return list(self.getActiveExtruderStacks())[index].getName() + except IndexError: + return "" + def getActiveExtruderStack(self): global_container_stack = UM.Application.getInstance().getGlobalContainerStack() if global_container_stack: diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index 93cbaafffb..7c220ab7a2 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -87,7 +87,7 @@ Column Label //Extruder name. { - text: (extrudersModel.getItem(index) != null && extrudersModel.getItem(index).name != null) ? extrudersModel.getItem(index).name : catalog.i18nc("@label", "Hotend") + text: ExtruderManager.getExtruderName(index) != "" ? ExtruderManager.getExtruderName(index) : catalog.i18nc("@label", "Hotend") color: UM.Theme.getColor("text") font: UM.Theme.getFont("default") anchors.left: parent.left From 2724af7508208a8e5119a1f48b3deaf1e020e54c Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Mon, 13 Feb 2017 12:01:27 +0100 Subject: [PATCH 80/84] Add lining between bottom of extruders and build plate boxes Using margins for this is not applicable since it was the background of the rectangle around the flow that has the correct lining colour. So this is manually adding a line. Contributes to issue CURA-3161. --- resources/qml/PrintMonitor.qml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index 7c220ab7a2..7a150a1757 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -139,6 +139,13 @@ Column } } + Rectangle + { + color: UM.Theme.getColor("sidebar_lining") + width: parent.width + height: UM.Theme.getSize("sidebar_lining_thin").width + } + Rectangle { color: UM.Theme.getColor("sidebar") From 8d7b813318d8a6f552d7c5bfa362ca384c1d50cd Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 13 Feb 2017 13:26:36 +0100 Subject: [PATCH 81/84] All good 20x http replies are now accepted --- plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py index 7df3c7bf23..2b2f24e5fd 100644 --- a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py +++ b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py @@ -1022,7 +1022,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): self._progress_message.hide() elif reply.operation() == QNetworkAccessManager.PutOperation: - if status_code == 204: + if status_code in [200, 201, 202, 204]: pass # Request was successful! else: Logger.log("d", "Something went wrong when trying to update data of API (%s). Message: %s Statuscode: %s", reply_url, reply.readAll(), status_code) From 6deaf5bd6523b781d523833a41fae581ef7fcaa9 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 13 Feb 2017 13:28:32 +0100 Subject: [PATCH 82/84] Failure logging for network printing is now more explicit (also prints what the operation was) --- .../UM3NetworkPrinting/NetworkPrinterOutputDevice.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py index 2b2f24e5fd..1c8426c053 100644 --- a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py +++ b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py @@ -1025,7 +1025,17 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): if status_code in [200, 201, 202, 204]: pass # Request was successful! else: - Logger.log("d", "Something went wrong when trying to update data of API (%s). Message: %s Statuscode: %s", reply_url, reply.readAll(), status_code) + operation_type = "Unknown" + if reply.operation() == QNetworkAccessManager.GetOperation: + operation_type = "Get" + elif reply.operation() == QNetworkAccessManager.PutOperation: + operation_type = "Put" + elif reply.operation() == QNetworkAccessManager.PostOperation: + operation_type = "Post" + elif reply.operation() == QNetworkAccessManager.DeleteOperation: + operation_type = "Delete" + + Logger.log("d", "Something went wrong when trying to update data of API (%s). Message: %s Statuscode: %s, operation: %s", reply_url, reply.readAll(), status_code, operation_type) else: Logger.log("d", "NetworkPrinterOutputDevice got an unhandled operation %s", reply.operation()) From f62030dae5e9e30979634b6ed1ae2749d3c8d438 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 13 Feb 2017 13:30:51 +0100 Subject: [PATCH 83/84] setTargetBed temperature now directly sets target temp This is instead of sending /bed/temperature a json which contains target & temp as keyvalue. --- plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py index 1c8426c053..ea15fc597e 100644 --- a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py +++ b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py @@ -276,8 +276,8 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): def _setTargetBedTemperature(self, temperature): if self._target_bed_temperature == temperature: return - url = QUrl("http://" + self._address + self._api_prefix + "printer/bed/temperature") - data = """{"target": "%i"}""" % temperature + url = QUrl("http://" + self._address + self._api_prefix + "printer/bed/temperature/target") + data = str(temperature) put_request = QNetworkRequest(url) put_request.setHeader(QNetworkRequest.ContentTypeHeader, "application/json") self._manager.put(put_request, data.encode()) From cc396d535777b263d441c788113ba2c479251d5c Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 13 Feb 2017 14:16:22 +0100 Subject: [PATCH 84/84] Fixed target temp never updating --- plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py index ea15fc597e..18229f9d2d 100644 --- a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py +++ b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py @@ -276,6 +276,9 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): def _setTargetBedTemperature(self, temperature): if self._target_bed_temperature == temperature: return + self._target_bed_temperature = temperature + self.targetBedTemperatureChanged.emit() + url = QUrl("http://" + self._address + self._api_prefix + "printer/bed/temperature/target") data = str(temperature) put_request = QNetworkRequest(url)