mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 07:27:29 -06:00
Ensured that sidebar has the right properties to show again
CL-541
This commit is contained in:
parent
7d9af8e345
commit
52a137a68c
4 changed files with 48 additions and 7 deletions
|
@ -22,7 +22,7 @@ class PrintJobOutputModel(QObject):
|
|||
self._state = ""
|
||||
self._time_total = 0
|
||||
self._time_elapsed = 0
|
||||
self._name = "" # Human readable name
|
||||
self._name = name # Human readable name
|
||||
self._key = key # Unique identifier
|
||||
self._assigned_printer = None
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ class PrinterOutputModel(QObject):
|
|||
nameChanged = pyqtSignal()
|
||||
headPositionChanged = pyqtSignal()
|
||||
keyChanged = pyqtSignal()
|
||||
typeChanged = pyqtSignal()
|
||||
|
||||
def __init__(self, output_controller: "PrinterOutputController", number_of_extruders: int = 1, parent=None):
|
||||
super().__init__(parent)
|
||||
|
@ -35,6 +36,17 @@ class PrinterOutputModel(QObject):
|
|||
|
||||
self._printer_state = "unknown"
|
||||
|
||||
self._type = ""
|
||||
|
||||
@pyqtProperty(str, notify = typeChanged)
|
||||
def type(self):
|
||||
return self._type
|
||||
|
||||
def updateType(self, type):
|
||||
if self._type != type:
|
||||
self._type = type
|
||||
self.typeChanged.emit()
|
||||
|
||||
@pyqtProperty(str, notify=keyChanged)
|
||||
def key(self):
|
||||
return self._key
|
||||
|
|
|
@ -10,13 +10,12 @@ Component
|
|||
{
|
||||
id: base
|
||||
property var manager: Cura.MachineManager.printerOutputDevices[0]
|
||||
anchors.fill: parent
|
||||
color: UM.Theme.getColor("viewport_background")
|
||||
|
||||
property var lineColor: "#DCDCDC" // TODO: Should be linked to theme.
|
||||
property var cornerRadius: 4 * screenScaleFactor // TODO: Should be linked to theme.
|
||||
|
||||
visible: manager != null
|
||||
anchors.fill: parent
|
||||
color: UM.Theme.getColor("viewport_background")
|
||||
|
||||
UM.I18nCatalog
|
||||
{
|
||||
|
@ -97,7 +96,7 @@ Component
|
|||
}
|
||||
Label
|
||||
{
|
||||
text: manager.numJobsPrinting
|
||||
text: manager.activePrintJobs.length
|
||||
font: UM.Theme.getFont("small")
|
||||
anchors.right: parent.right
|
||||
}
|
||||
|
@ -114,7 +113,7 @@ Component
|
|||
}
|
||||
Label
|
||||
{
|
||||
text: manager.numJobsQueued
|
||||
text: manager.queuedPrintJobs.length
|
||||
font: UM.Theme.getFont("small")
|
||||
anchors.right: parent.right
|
||||
}
|
||||
|
|
|
@ -12,13 +12,15 @@ from cura.PrinterOutput.MaterialOutputModel import MaterialOutputModel
|
|||
|
||||
from PyQt5.QtNetwork import QNetworkRequest, QNetworkReply
|
||||
from PyQt5.QtGui import QDesktopServices
|
||||
from PyQt5.QtCore import pyqtSlot, QUrl
|
||||
from PyQt5.QtCore import pyqtSlot, QUrl, pyqtSignal, pyqtProperty
|
||||
|
||||
import json
|
||||
import os
|
||||
|
||||
|
||||
class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
|
||||
printJobsChanged = pyqtSignal()
|
||||
printersChanged = pyqtSignal()
|
||||
def __init__(self, device_id, address, properties, parent = None):
|
||||
super().__init__(device_id = device_id, address = address, properties=properties, parent = parent)
|
||||
self._api_prefix = "/cluster-api/v1/"
|
||||
|
@ -40,6 +42,31 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
|
|||
Logger.log("d", "Opening printer control panel...")
|
||||
QDesktopServices.openUrl(QUrl("http://" + self._address + "/printers"))
|
||||
|
||||
@pyqtProperty("QVariantList", notify=printJobsChanged)
|
||||
def printJobs(self):
|
||||
return self._print_jobs
|
||||
|
||||
@pyqtProperty("QVariantList", notify=printJobsChanged)
|
||||
def queuedPrintJobs(self):
|
||||
return [print_job for print_job in self._print_jobs if print_job.assignedPrinter is None]
|
||||
|
||||
@pyqtProperty("QVariantList", notify=printJobsChanged)
|
||||
def activePrintJobs(self):
|
||||
return [print_job for print_job in self._print_jobs if print_job.assignedPrinter is not None]
|
||||
|
||||
@pyqtProperty("QVariantList", notify=printersChanged)
|
||||
def connectedPrintersTypeCount(self):
|
||||
printer_count = {}
|
||||
for printer in self._printers:
|
||||
if printer.type in printer_count:
|
||||
printer_count[printer.type] += 1
|
||||
else:
|
||||
printer_count[printer.type] = 1
|
||||
result = []
|
||||
for machine_type in printer_count:
|
||||
result.append({"machine_type": machine_type, "count": printer_count[machine_type]})
|
||||
return result
|
||||
|
||||
def _update(self):
|
||||
if not super()._update():
|
||||
return
|
||||
|
@ -82,6 +109,7 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
|
|||
old_job.assignedPrinter.updateActivePrintJob(None)
|
||||
|
||||
self._print_jobs = print_jobs_seen
|
||||
self.printJobsChanged.emit()
|
||||
|
||||
def _onGetPrintersDataFinished(self, reply: QNetworkReply):
|
||||
status_code = reply.attribute(QNetworkRequest.HttpStatusCodeAttribute)
|
||||
|
@ -92,6 +120,7 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
|
|||
Logger.log("w", "Received an invalid printers state message: Not valid JSON.")
|
||||
return
|
||||
|
||||
# TODO: Ensure that printers that have been removed are also removed locally.
|
||||
for printer_data in result:
|
||||
uuid = printer_data["uuid"]
|
||||
|
||||
|
@ -107,6 +136,7 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
|
|||
|
||||
printer.updateName(printer_data["friendly_name"])
|
||||
printer.updateKey(uuid)
|
||||
printer.updateType(printer_data["machine_variant"])
|
||||
|
||||
for index in range(0, self._number_of_extruders):
|
||||
extruder = printer.extruders[index]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue