From 3b51c31772cdfc7c8c0b34a8064edef5af938f5e Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 23 Jun 2016 15:46:12 +0200 Subject: [PATCH] Meta data of the printer is now also visible CURA-336 --- DiscoverUM3Action.py | 2 +- DiscoverUM3Action.qml | 60 +++++++++++++++++++++++++++++++++-- NetworkPrinterOutputDevice.py | 15 +++++++++ 3 files changed, 74 insertions(+), 3 deletions(-) diff --git a/DiscoverUM3Action.py b/DiscoverUM3Action.py index c8dd2eda41..aade48e806 100644 --- a/DiscoverUM3Action.py +++ b/DiscoverUM3Action.py @@ -27,6 +27,6 @@ class DiscoverUM3Action(MachineAction): def foundDevices(self): if self._network_plugin: printers = self._network_plugin.getPrinters() - return [printers[printer].getProperties().get(b"name").decode("utf-8") for printer in printers] + return [printers[printer] for printer in printers] else: return [] diff --git a/DiscoverUM3Action.qml b/DiscoverUM3Action.qml index 100de777c7..fcb529536e 100644 --- a/DiscoverUM3Action.qml +++ b/DiscoverUM3Action.qml @@ -8,7 +8,9 @@ import QtQuick.Window 2.1 Cura.MachineAction { + id: base anchors.fill: parent; + property var selectedPrinter: null Column { anchors.fill: parent; @@ -39,6 +41,7 @@ Cura.MachineAction Row { width: parent.width + spacing: UM.Theme.getSize("default_margin").width ScrollView { id: objectListContainer @@ -54,10 +57,12 @@ Cura.MachineAction ListView { + id: listview model: manager.foundDevices width: parent.width height: 500 currentIndex: activeIndex + onCurrentIndexChanged: base.selectedPrinter = listview.model[currentIndex] delegate: Rectangle { height: childrenRect.height; @@ -68,7 +73,7 @@ Cura.MachineAction anchors.left: parent.left; anchors.leftMargin: UM.Theme.getSize("default_margin").width; anchors.right: parent.right; - text: modelData + text: listview.model[index].name elide: Text.ElideRight } @@ -80,13 +85,64 @@ Cura.MachineAction if(!parent.ListView.isCurrentItem) { parent.ListView.view.currentIndex = index; - //base.itemActivated(); } } } } } } + Column + { + width: parent.width * 0.5 + Label + { + width: parent.width + wrapMode: Text.WordWrap + text: base.selectedPrinter ? base.selectedPrinter.name : "" + font.pointSize: 16; + } + Grid + { + width: parent.width + columns: 2 + Label + { + width: parent.width * 0.5 + wrapMode: Text.WordWrap + text: catalog.i18nc("@label", "Type") + } + Label + { + width: parent.width * 0.5 + wrapMode: Text.WordWrap + text: catalog.i18nc("@label", "Ultimaker 3") + } + Label + { + width: parent.width * 0.5 + wrapMode: Text.WordWrap + text: catalog.i18nc("@label", "Firmware version") + } + Label + { + width: parent.width * 0.5 + wrapMode: Text.WordWrap + text: base.selectedPrinter ? base.selectedPrinter.firmwareVersion : "" + } + Label + { + width: parent.width * 0.5 + wrapMode: Text.WordWrap + text: catalog.i18nc("@label", "IP Address") + } + Label + { + width: parent.width * 0.5 + wrapMode: Text.WordWrap + text: base.selectedPrinter ? base.selectedPrinter.ipAddress : "" + } + } + } } } } \ No newline at end of file diff --git a/NetworkPrinterOutputDevice.py b/NetworkPrinterOutputDevice.py index 02646bbba2..d243d62dcc 100644 --- a/NetworkPrinterOutputDevice.py +++ b/NetworkPrinterOutputDevice.py @@ -92,6 +92,21 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): def getKey(self): return self._key + ## 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) + @pyqtProperty(str, constant=True) + def firmwareVersion(self): + return self._properties.get(b"firmware_version", b"").decode("utf-8") + + ## IPadress of this printer + @pyqtProperty(str, constant=True) + def ipAddress(self): + return self._address + def _update_camera(self): ## Request new image url = QUrl("http://" + self._address + ":8080/?action=snapshot")