Fix remaining references to NetworkCamera and OutputDevice.activeCamera

This commit is contained in:
fieldOfView 2018-10-26 15:23:51 +02:00
parent 736bf040a8
commit e0d6bac37d
7 changed files with 23 additions and 28 deletions

View file

@ -54,7 +54,7 @@ class PrintJobOutputModel(QObject):
@pyqtProperty(QUrl, notify=previewImageChanged) @pyqtProperty(QUrl, notify=previewImageChanged)
def previewImageUrl(self): def previewImageUrl(self):
self._preview_image_id += 1 self._preview_image_id += 1
# There is an image provider that is called "camera". In order to ensure that the image qml object, that # There is an image provider that is called "print_job_preview". In order to ensure that the image qml object, that
# requires a QUrl to function, updates correctly we add an increasing number. This causes to see the QUrl # requires a QUrl to function, updates correctly we add an increasing number. This causes to see the QUrl
# as new (instead of relying on cached version and thus forces an update. # as new (instead of relying on cached version and thus forces an update.
temp = "image://print_job_preview/" + str(self._preview_image_id) + "/" + self._key temp = "image://print_job_preview/" + str(self._preview_image_id) + "/" + self._key

View file

@ -11,7 +11,6 @@ MYPY = False
if MYPY: if MYPY:
from cura.PrinterOutput.PrintJobOutputModel import PrintJobOutputModel from cura.PrinterOutput.PrintJobOutputModel import PrintJobOutputModel
from cura.PrinterOutput.PrinterOutputController import PrinterOutputController from cura.PrinterOutput.PrinterOutputController import PrinterOutputController
from cura.PrinterOutput.NetworkCamera import NetworkCamera
class PrinterOutputModel(QObject): class PrinterOutputModel(QObject):

View file

@ -31,10 +31,10 @@ Rectangle {
anchors.fill: parent; anchors.fill: parent;
hoverEnabled: true; hoverEnabled: true;
onClicked: { onClicked: {
if (OutputDevice.activeCamera !== null) { if (OutputDevice.activeCameraUrl !== null) {
OutputDevice.setActiveCamera(null) OutputDevice.setActiveCameraUrl(null)
} else { } else {
OutputDevice.setActiveCamera(modelData.camera); OutputDevice.setActiveCameraUrl(modelData.cameraUrl);
} }
} }
} }

View file

@ -16,7 +16,7 @@ Component {
height: maximumHeight; height: maximumHeight;
onVisibleChanged: { onVisibleChanged: {
if (monitorFrame != null && !monitorFrame.visible) { if (monitorFrame != null && !monitorFrame.visible) {
OutputDevice.setActiveCamera(null); OutputDevice.setActiveCameraUrl(null);
} }
} }
width: maximumWidth; width: maximumWidth;
@ -125,8 +125,8 @@ Component {
PrinterVideoStream { PrinterVideoStream {
anchors.fill: parent; anchors.fill: parent;
camera: OutputDevice.activeCamera; cameraUrl: OutputDevice.activeCameraUrl;
visible: OutputDevice.activeCamera != null; visible: OutputDevice.activeCameraUrl != null;
} }
} }
} }

View file

@ -8,7 +8,7 @@ import UM 1.3 as UM
import Cura 1.0 as Cura import Cura 1.0 as Cura
Item { Item {
property var camera: null; property var cameraUrl: null;
Rectangle { Rectangle {
anchors.fill:parent; anchors.fill:parent;
@ -18,7 +18,7 @@ Item {
MouseArea { MouseArea {
anchors.fill: parent; anchors.fill: parent;
onClicked: OutputDevice.setActiveCamera(null); onClicked: OutputDevice.setActiveCameraUrl(null);
z: 0; z: 0;
} }
@ -58,7 +58,7 @@ Item {
MouseArea { MouseArea {
anchors.fill: cameraImage; anchors.fill: cameraImage;
onClicked: { onClicked: {
OutputDevice.setActiveCamera(null); OutputDevice.setActiveCameraUrl(null);
} }
z: 1; z: 1;
} }

View file

@ -22,7 +22,6 @@ from cura.PrinterOutput.ExtruderConfigurationModel import ExtruderConfigurationM
from cura.PrinterOutput.NetworkedPrinterOutputDevice import NetworkedPrinterOutputDevice, AuthState from cura.PrinterOutput.NetworkedPrinterOutputDevice import NetworkedPrinterOutputDevice, AuthState
from cura.PrinterOutput.PrinterOutputModel import PrinterOutputModel from cura.PrinterOutput.PrinterOutputModel import PrinterOutputModel
from cura.PrinterOutput.MaterialOutputModel import MaterialOutputModel from cura.PrinterOutput.MaterialOutputModel import MaterialOutputModel
from cura.PrinterOutput.NetworkCamera import NetworkCamera
from .ClusterUM3PrinterOutputController import ClusterUM3PrinterOutputController from .ClusterUM3PrinterOutputController import ClusterUM3PrinterOutputController
from .SendMaterialJob import SendMaterialJob from .SendMaterialJob import SendMaterialJob
@ -47,7 +46,7 @@ i18n_catalog = i18nCatalog("cura")
class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
printJobsChanged = pyqtSignal() printJobsChanged = pyqtSignal()
activePrinterChanged = pyqtSignal() activePrinterChanged = pyqtSignal()
activeCameraChanged = pyqtSignal() activeCameraUrlChanged = pyqtSignal()
receivedPrintJobsChanged = pyqtSignal() receivedPrintJobsChanged = pyqtSignal()
# This is a bit of a hack, as the notify can only use signals that are defined by the class that they are in. # This is a bit of a hack, as the notify can only use signals that are defined by the class that they are in.
@ -100,7 +99,7 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
self._latest_reply_handler = None # type: Optional[QNetworkReply] self._latest_reply_handler = None # type: Optional[QNetworkReply]
self._sending_job = None self._sending_job = None
self._active_camera = None # type: Optional[NetworkCamera] self._active_camera_url = None # type: Optional[QUrl]
def requestWrite(self, nodes: List[SceneNode], file_name: Optional[str] = None, limit_mimetypes: bool = False, file_handler: Optional[FileHandler] = None, **kwargs: str) -> None: def requestWrite(self, nodes: List[SceneNode], file_name: Optional[str] = None, limit_mimetypes: bool = False, file_handler: Optional[FileHandler] = None, **kwargs: str) -> None:
self.writeStarted.emit(self) self.writeStarted.emit(self)
@ -264,30 +263,28 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
def activePrinter(self) -> Optional[PrinterOutputModel]: def activePrinter(self) -> Optional[PrinterOutputModel]:
return self._active_printer return self._active_printer
@pyqtProperty(QObject, notify=activeCameraChanged) @pyqtProperty(QUrl, notify=activeCameraUrlChanged)
def activeCamera(self) -> Optional[NetworkCamera]: def activeCameraUrl(self) -> Optional[QUrl]:
return self._active_camera return self._active_camera_url
@pyqtSlot(QObject) @pyqtSlot(QObject)
def setActivePrinter(self, printer: Optional[PrinterOutputModel]) -> None: def setActivePrinter(self, printer: Optional[PrinterOutputModel]) -> None:
if self._active_printer != printer: if self._active_printer != printer:
if self._active_printer and self._active_printer.camera:
self._active_printer.camera.stop()
self._active_printer = printer self._active_printer = printer
self.activePrinterChanged.emit() self.activePrinterChanged.emit()
@pyqtSlot(QObject) @pyqtSlot(QObject)
def setActiveCamera(self, camera: Optional[NetworkCamera]) -> None: def setActiveCameraUrl(self, camera_url: Optional[QUrl]) -> None:
if self._active_camera != camera: if self._active_camera_url != camera_url:
if self._active_camera: if self._active_camera_url:
self._active_camera.stop() self._active_camera_url.stop()
self._active_camera = camera self._active_camera_url = camera_url
if self._active_camera: if self._active_camera_url:
self._active_camera.start() self._active_camera_url.start()
self.activeCameraChanged.emit() self.activeCameraUrlChanged.emit()
def _onPostPrintJobFinished(self, reply: QNetworkReply) -> None: def _onPostPrintJobFinished(self, reply: QNetworkReply) -> None:
if self._progress_message: if self._progress_message:

View file

@ -7,7 +7,6 @@ from cura.PrinterOutput.NetworkedPrinterOutputDevice import NetworkedPrinterOutp
from cura.PrinterOutput.PrinterOutputModel import PrinterOutputModel from cura.PrinterOutput.PrinterOutputModel import PrinterOutputModel
from cura.PrinterOutput.PrintJobOutputModel import PrintJobOutputModel from cura.PrinterOutput.PrintJobOutputModel import PrintJobOutputModel
from cura.PrinterOutput.MaterialOutputModel import MaterialOutputModel from cura.PrinterOutput.MaterialOutputModel import MaterialOutputModel
from cura.PrinterOutput.NetworkCamera import NetworkCamera
from cura.Settings.ContainerManager import ContainerManager from cura.Settings.ContainerManager import ContainerManager
from cura.Settings.ExtruderManager import ExtruderManager from cura.Settings.ExtruderManager import ExtruderManager