Merge branch 'STAR-322_cloud-connection' of github.com:Ultimaker/Cura into STAR-322_cloud-connection

This commit is contained in:
Marijn Deé 2018-12-04 13:06:33 +01:00
commit 99bdb9c93f
8 changed files with 69 additions and 68 deletions

View file

@ -180,10 +180,11 @@ class NetworkedPrinterOutputDevice(PrinterOutputDevice):
self._createNetworkManager() self._createNetworkManager()
assert (self._manager is not None) assert (self._manager is not None)
def put(self, target: str, data: Union[str, bytes], on_finished: Optional[Callable[[QNetworkReply], None]], def put(self, target: str, data: Union[str, bytes], content_type: str = None,
on_finished: Optional[Callable[[QNetworkReply], None]] = None,
on_progress: Optional[Callable] = None) -> None: on_progress: Optional[Callable] = None) -> None:
self._validateManager() self._validateManager()
request = self._createEmptyRequest(target) request = self._createEmptyRequest(target, content_type = content_type)
self._last_request_time = time() self._last_request_time = time()
if self._manager is not None: if self._manager is not None:
reply = self._manager.put(request, data if isinstance(data, bytes) else data.encode()) reply = self._manager.put(request, data if isinstance(data, bytes) else data.encode())

View file

@ -6,7 +6,7 @@ import os
from json import JSONDecodeError from json import JSONDecodeError
from typing import List, Optional, Dict, cast, Union, Tuple from typing import List, Optional, Dict, cast, Union, Tuple
from PyQt5.QtCore import QObject, pyqtSignal, QUrl, pyqtProperty from PyQt5.QtCore import QObject, pyqtSignal, QUrl, pyqtProperty, pyqtSlot
from PyQt5.QtNetwork import QNetworkReply, QNetworkRequest from PyQt5.QtNetwork import QNetworkReply, QNetworkRequest
from UM import i18nCatalog from UM import i18nCatalog
@ -209,6 +209,16 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
return [print_job for print_job in self._print_jobs return [print_job for print_job in self._print_jobs
if print_job.state == "queued" or print_job.state == "error"] if print_job.state == "queued" or print_job.state == "error"]
## Get remote print jobs that are assigned to a printer.
@pyqtProperty("QVariantList", notify = printJobsChanged)
def activePrintJobs(self) -> List[UM3PrintJobOutputModel]:
return [print_job for print_job in self._print_jobs if
print_job.assignedPrinter is not None and print_job.state != "queued"]
@pyqtProperty(bool, notify = printJobsChanged)
def receivedPrintJobs(self) -> bool:
return not self._sending_job
## Called when the connection to the cluster changes. ## Called when the connection to the cluster changes.
def connect(self) -> None: def connect(self) -> None:
super().connect() super().connect()
@ -375,7 +385,7 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
# TODO: Multipart upload # TODO: Multipart upload
job_response = JobUploadResponse(**response.get("data")) job_response = JobUploadResponse(**response.get("data"))
Logger.log("i", "Print job created successfully: %s", job_response.__dict__) Logger.log("i", "Print job created successfully: %s", job_response.__dict__)
self.put(job_response.upload_url, data = mesh, self.put(job_response.upload_url, data = mesh, content_type = job_response.content_type,
on_finished = lambda r: self._onPrintJobUploaded(job_response.job_id, r), on_finished = lambda r: self._onPrintJobUploaded(job_response.job_id, r),
on_progress = self._onUploadPrintJobProgress) on_progress = self._onUploadPrintJobProgress)
@ -448,3 +458,22 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
message.show() message.show()
self._sending_job = False # the upload has finished so we're not sending a job anymore self._sending_job = False # the upload has finished so we're not sending a job anymore
self.writeFinished.emit() self.writeFinished.emit()
## TODO: The following methods are required by the monitor page QML, but are not actually available using cloud.
# TODO: We fake the methods here to not break the monitor page.
@pyqtProperty(QObject, notify = printersChanged)
def activePrinter(self) -> Optional[PrinterOutputModel]:
return self._printers[0] or None
@pyqtSlot(QObject)
def setActivePrinter(self, printer: Optional[PrinterOutputModel]) -> None:
pass
@pyqtProperty(QUrl, notify = printersChanged)
def activeCameraUrl(self) -> "QUrl":
return QUrl()
@pyqtSlot(QUrl)
def setActiveCameraUrl(self, camera_url: "QUrl") -> None:
pass

View file

@ -131,6 +131,7 @@ class CloudOutputDeviceManager(NetworkClient):
device = CloudOutputDevice(cluster.cluster_id) device = CloudOutputDevice(cluster.cluster_id)
self._output_device_manager.addOutputDevice(device) self._output_device_manager.addOutputDevice(device)
self._remote_clusters[cluster.cluster_id] = device self._remote_clusters[cluster.cluster_id] = device
device.connect() # TODO: remove this
self._connectToActiveMachine() self._connectToActiveMachine()
## Remove a CloudOutputDevice ## Remove a CloudOutputDevice

View file

@ -112,6 +112,8 @@ Column
id: previewStageShortcut id: previewStageShortcut
height: UM.Theme.getSize("action_panel_button").height height: UM.Theme.getSize("action_panel_button").height
leftPadding: UM.Theme.getSize("default_margin").width
rightPadding: UM.Theme.getSize("default_margin").width
text: catalog.i18nc("@button", "Preview") text: catalog.i18nc("@button", "Preview")
onClicked: UM.Controller.setActiveStage("PreviewStage") onClicked: UM.Controller.setActiveStage("PreviewStage")

View file

@ -11,9 +11,6 @@ UM.RecolorImage
{ {
id: widget id: widget
//implicitHeight: UM.Theme.getSize("section_icon").height
//implicitWidth: UM.Theme.getSize("section_icon").width
source: UM.Theme.getIcon("info") source: UM.Theme.getIcon("info")
width: UM.Theme.getSize("section_icon").width width: UM.Theme.getSize("section_icon").width
height: UM.Theme.getSize("section_icon").height height: UM.Theme.getSize("section_icon").height

View file

@ -44,7 +44,7 @@ Column
{ {
id: autoSlicingLabel id: autoSlicingLabel
width: parent.width width: parent.width
visible: prepareButtons.autoSlice && widget.backendState == UM.Backend.Processing visible: prepareButtons.autoSlice && (widget.backendState == UM.Backend.Processing || widget.backendState == UM.Backend.NotStarted)
text: catalog.i18nc("@label:PrintjobStatus", "Auto slicing...") text: catalog.i18nc("@label:PrintjobStatus", "Auto slicing...")
color: UM.Theme.getColor("text") color: UM.Theme.getColor("text")
@ -71,7 +71,8 @@ Column
width: parent.width width: parent.width
height: UM.Theme.getSize("progressbar").height height: UM.Theme.getSize("progressbar").height
value: progress value: progress
visible: widget.backendState == UM.Backend.Processing indeterminate: widget.backendState == UM.Backend.NotStarted
visible: (widget.backendState == UM.Backend.Processing || (prepareButtons.autoSlice && widget.backendState == UM.Backend.NotStarted))
background: Rectangle background: Rectangle
{ {

View file

@ -115,6 +115,7 @@ Item
} }
radius: UM.Theme.getSize("default_radius").width radius: UM.Theme.getSize("default_radius").width
color: UM.Theme.getColor("lining") color: UM.Theme.getColor("lining")
visible: extrudersModel.items.length > 1
} }
Column Column
@ -131,8 +132,7 @@ Item
id: extruders id: extruders
width: childrenRect.width width: childrenRect.width
height: childrenRect.height height: childrenRect.height
property var _model: Cura.ExtrudersModel { id: extrudersModel } model: extrudersModel.items.length > 1 ? extrudersModel : 0
model: _model.items.length > 1 ? _model : 0
delegate: ExtruderButton delegate: ExtruderButton
{ {
@ -144,13 +144,18 @@ Item
} }
} }
Cura.ExtrudersModel
{
id: extrudersModel
}
UM.PointingRectangle UM.PointingRectangle
{ {
id: panelBorder; id: panelBorder
anchors.left: parent.right; anchors.left: parent.right
anchors.leftMargin: UM.Theme.getSize("default_margin").width; anchors.leftMargin: UM.Theme.getSize("default_margin").width
anchors.top: base.top; anchors.top: base.top
anchors.topMargin: base.activeY anchors.topMargin: base.activeY
z: buttons.z - 1 z: buttons.z - 1
@ -161,14 +166,14 @@ Item
{ {
if (panel.item && panel.width > 0) if (panel.item && panel.width > 0)
{ {
return Math.max(panel.width + 2 * UM.Theme.getSize("default_margin").width); return Math.max(panel.width + 2 * UM.Theme.getSize("default_margin").width)
} }
else else
{ {
return 0; return 0;
} }
} }
height: panel.item ? panel.height + 2 * UM.Theme.getSize("default_margin").height : 0; height: panel.item ? panel.height + 2 * UM.Theme.getSize("default_margin").height : 0
opacity: panel.item && panel.width > 0 ? 1 : 0 opacity: panel.item && panel.width > 0 ? 1 : 0
Behavior on opacity { NumberAnimation { duration: 100 } } Behavior on opacity { NumberAnimation { duration: 100 } }
@ -186,11 +191,11 @@ Item
{ {
id: panel id: panel
x: UM.Theme.getSize("default_margin").width; x: UM.Theme.getSize("default_margin").width
y: UM.Theme.getSize("default_margin").height; y: UM.Theme.getSize("default_margin").height
source: UM.ActiveTool.valid ? UM.ActiveTool.activeToolPanel : "" source: UM.ActiveTool.valid ? UM.ActiveTool.activeToolPanel : ""
enabled: UM.Controller.toolsEnabled; enabled: UM.Controller.toolsEnabled
} }
} }

View file

@ -1,48 +1,13 @@
<?xml version="1.0" encoding="iso-8859-1"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> <svg width="18px" height="18px" viewBox="0 0 18 18" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" <!-- Generator: Sketch 52.2 (67145) - http://www.bohemiancoding.com/sketch -->
viewBox="0 0 111.577 111.577" style="enable-background:new 0 0 111.577 111.577;" xml:space="preserve"> <title>Icon/ info</title>
<g> <desc>Created with Sketch.</desc>
<path d="M78.962,99.536l-1.559,6.373c-4.677,1.846-8.413,3.251-11.195,4.217c-2.785,0.969-6.021,1.451-9.708,1.451 <g id="Symbols" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
c-5.662,0-10.066-1.387-13.207-4.142c-3.141-2.766-4.712-6.271-4.712-10.523c0-1.646,0.114-3.339,0.351-5.064 <g id="Print-panel/-print" transform="translate(-214.000000, -24.000000)" fill="#08073F" fill-rule="nonzero">
c0.239-1.727,0.619-3.672,1.139-5.846l5.845-20.688c0.52-1.981,0.962-3.858,1.316-5.633c0.359-1.764,0.532-3.387,0.532-4.848 <g id="Icon/-info" transform="translate(214.000000, 24.000000)">
c0-2.642-0.547-4.49-1.636-5.529c-1.089-1.036-3.167-1.562-6.252-1.562c-1.511,0-3.064,0.242-4.647,0.71 <path d="M2.63588391,2.63588391 C-0.878627968,6.15039578 -0.878627968,11.8496042 2.63588391,15.3641161 C6.15039578,18.878628 11.8496042,18.878628 15.3641161,15.3641161 C18.878628,11.8496042 18.878628,6.15039578 15.3641161,2.63588391 C11.8496042,-0.878627968 6.15039578,-0.878627968 2.63588391,2.63588391 Z M9.01034483,3.5 C9.83793103,3.5 10.5,4.17808219 10.5,5 C10.5,5.82191781 9.81724138,6.5 9.01034483,6.5 C8.18275862,6.5 7.5,5.82191781 7.5,4.97945205 C7.5,4.15753425 8.18275862,3.5 9.01034483,3.5 Z M11.488168,13.3648649 C11.4474692,13.4783784 11.3660716,13.6108108 11.2846741,13.6864865 C10.75559,14.1972973 10.1044095,14.5 9.33113276,14.5 C8.96484376,14.5 8.61890416,14.5 8.25261516,14.4432432 C7.66248289,14.3675676 6.9095555,13.6864865 7.01130245,12.9675676 C7.0927,12.4756757 7.17409756,11.9837838 7.25549511,11.4918919 C7.41829022,10.6405405 7.58108533,9.77027027 7.74388044,8.91891892 C7.74388044,8.86216216 7.76422983,8.80540541 7.76422983,8.74864865 C7.76422983,8.38918919 7.6421335,8.25675676 7.25549511,8.21891892 C7.0927,8.2 6.92990489,8.18108108 6.76710978,8.14324324 C6.58396529,8.08648649 6.48221834,7.93513514 6.50256773,7.8027027 C6.52291712,7.65135135 6.62466406,7.55675676 6.82815795,7.51891892 C6.92990489,7.5 7.05200123,7.5 7.17409756,7.5 C7.62178411,7.5 8.06947066,7.5 8.5375066,7.5 C9.02589193,7.5 9.49392787,7.5 9.9823132,7.5 C10.3282528,7.5 10.5317467,7.65135135 10.5317467,7.97297297 C10.5317467,8.23783784 10.4910479,8.5027027 10.4299997,8.76756757 C10.2468553,9.75135135 10.0433614,10.7162162 9.86021687,11.7 C9.7991687,12.0216216 9.71777115,12.3432432 9.67707237,12.6648649 C9.65672298,12.8162162 9.67707237,12.9864865 9.71777115,13.1378378 C9.77881931,13.3459459 9.94161442,13.4594595 10.1654577,13.4405405 C10.3486022,13.4216216 10.5317467,13.3648649 10.7148912,13.2891892 C10.8573369,13.2324324 10.9794332,13.1378378 11.121879,13.1 C11.3660716,13.0243243 11.5492161,13.1567568 11.488168,13.3648649 Z" id="Shape"></path>
c-1.59,0.47-2.949,0.924-4.09,1.346l1.563-6.378c3.829-1.559,7.489-2.894,10.99-4.002c3.501-1.111,6.809-1.667,9.938-1.667
c5.623,0,9.962,1.359,13.009,4.077c3.047,2.72,4.57,6.246,4.57,10.591c0,0.899-0.1,2.483-0.315,4.747
c-0.21,2.269-0.601,4.348-1.171,6.239l-5.82,20.605c-0.477,1.655-0.906,3.547-1.279,5.676c-0.385,2.115-0.569,3.731-0.569,4.815
c0,2.736,0.61,4.604,1.833,5.597c1.232,0.993,3.354,1.487,6.368,1.487c1.415,0,3.025-0.251,4.814-0.744
C76.854,100.348,78.155,99.915,78.962,99.536z M80.438,13.03c0,3.59-1.353,6.656-4.072,9.177c-2.712,2.53-5.98,3.796-9.803,3.796
c-3.835,0-7.111-1.266-9.854-3.796c-2.738-2.522-4.11-5.587-4.11-9.177c0-3.583,1.372-6.654,4.11-9.207
C59.447,1.274,62.729,0,66.563,0c3.822,0,7.091,1.277,9.803,3.823C79.087,6.376,80.438,9.448,80.438,13.03z"/>
</g> </g>
<g>
</g> </g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g> </g>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Before After
Before After