Merge branch 'master' of github.com:Ultimaker/JediWifiPrintingPlugin

This commit is contained in:
Jaime van Kessel 2016-06-28 11:53:11 +02:00
commit 804ff66c9a
3 changed files with 19 additions and 18 deletions

View File

@ -4,9 +4,12 @@ from UM.Application import Application
from PyQt5.QtCore import pyqtSignal, pyqtProperty, pyqtSlot from PyQt5.QtCore import pyqtSignal, pyqtProperty, pyqtSlot
from UM.i18n import i18nCatalog
catalog = i18nCatalog("cura")
class DiscoverUM3Action(MachineAction): class DiscoverUM3Action(MachineAction):
def __init__(self): def __init__(self):
super().__init__("DiscoverUM3Action", "Discover printers") super().__init__("DiscoverUM3Action", catalog.i18nc("@action","Connect via Network"))
self._qml_url = "DiscoverUM3Action.qml" self._qml_url = "DiscoverUM3Action.qml"
self._network_plugin = None self._network_plugin = None

View File

@ -16,14 +16,14 @@ Cura.MachineAction
anchors.fill: parent; anchors.fill: parent;
id: discoverUM3Action id: discoverUM3Action
SystemPalette { id: palette } SystemPalette { id: palette }
UM.I18nCatalog { id: catalog; name:"cura"} UM.I18nCatalog { id: catalog; name:"cura" }
Label Label
{ {
id: pageTitle id: pageTitle
width: parent.width width: parent.width
text: catalog.i18nc("@title", "Connect to Networked Printer") text: catalog.i18nc("@title", "Connect to Networked Printer")
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
font.pointSize: 18; font.pointSize: 18
} }
Label Label
@ -31,7 +31,7 @@ Cura.MachineAction
id: pageDescription id: pageDescription
width: parent.width width: parent.width
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
text: catalog.i18nc("@label", "To print directly to your Ultimaker 3 printer over the network, please make sure your ptiner is connected to the network using a network cable of by connecting your printer to your WIFI network. \n\n If you don't want to connect Cura with your Ultimaker 3 now, you can always use a USB drive to transfer g-code files to your Printer.\n\n Select your Ultimaker 3 from the list below:") text: catalog.i18nc("@label", "To print directly to your Ultimaker 3 printer over the network, please make sure your printer is connected to the network using a network cable or by connecting your printer to your WIFI network. \n\nIf you don't want to connect Cura with your Ultimaker 3 now, you can always use a USB drive to transfer g-code files to your printer.\n\nSelect your Ultimaker 3 from the list below:")
} }
Row Row
@ -41,8 +41,9 @@ Cura.MachineAction
ScrollView ScrollView
{ {
id: objectListContainer id: objectListContainer
frameVisible: true; frameVisible: true
width: parent.width * 0.5 width: parent.width * 0.5
height: base.height - parent.y
Rectangle Rectangle
{ {
@ -56,20 +57,21 @@ Cura.MachineAction
id: listview id: listview
model: manager.foundDevices model: manager.foundDevices
width: parent.width width: parent.width
height: 500
currentIndex: activeIndex currentIndex: activeIndex
onCurrentIndexChanged: base.selectedPrinter = listview.model[currentIndex] onCurrentIndexChanged: base.selectedPrinter = listview.model[currentIndex]
Component.onCompleted: manager.startDiscovery()
delegate: Rectangle delegate: Rectangle
{ {
height: childrenRect.height; height: childrenRect.height
color: ListView.isCurrentItem ? palette.highlight : index % 2 ? palette.base : palette.alternateBase color: ListView.isCurrentItem ? palette.highlight : index % 2 ? palette.base : palette.alternateBase
width: parent.width width: parent.width
Label Label
{ {
anchors.left: parent.left; anchors.left: parent.left
anchors.leftMargin: UM.Theme.getSize("default_margin").width; anchors.leftMargin: UM.Theme.getSize("default_margin").width
anchors.right: parent.right; anchors.right: parent.right
text: listview.model[index].name text: listview.model[index].name
color: parent.ListView.isCurrentItem ? palette.highlightedText : palette.text
elide: Text.ElideRight elide: Text.ElideRight
} }
@ -96,7 +98,8 @@ Cura.MachineAction
width: parent.width width: parent.width
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
text: base.selectedPrinter ? base.selectedPrinter.name : "" text: base.selectedPrinter ? base.selectedPrinter.name : ""
font.pointSize: 16; font: UM.Theme.getFont("large")
elide: Text.ElideRight
} }
Grid Grid
{ {
@ -141,11 +144,6 @@ Cura.MachineAction
} }
} }
} }
Button
{
text: catalog.i18nc("@label","Start looking!")
onClicked: manager.startDiscovery()
}
} }
Button Button
{ {

View File

@ -257,13 +257,13 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
if progress == 0: if progress == 0:
progress += 0.001 progress += 0.001
self.setProgress(progress) self.setProgress(progress)
self._updateJobState(json_data["state"]) self._setJobState(json_data["state"])
self.setTimeElapsed(json_data["time_elapsed"]) self.setTimeElapsed(json_data["time_elapsed"])
self.setTimeTotal(json_data["time_total"]) self.setTimeTotal(json_data["time_total"])
self.setJobName(json_data["name"]) self.setJobName(json_data["name"])
elif reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) == 404: elif reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) == 404:
self.setProgress(0) # No print job found, so there can't be progress! self.setProgress(0) # No print job found, so there can't be progress!
self._updateJobState("") self._setJobState("")
elif "snapshot" in reply.url().toString(): # Status update from image: elif "snapshot" in reply.url().toString(): # Status update from image:
if reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) == 200: if reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) == 200:
self._camera_image.loadFromData(reply.readAll()) self._camera_image.loadFromData(reply.readAll())