Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaime van Kessel <nallath@gmail.com>2017-07-20 12:39:12 +0300
committerJaime van Kessel <nallath@gmail.com>2017-07-20 12:39:12 +0300
commit216b1a7a14c1cfd093b9af28a4bf4473ead1232b (patch)
tree3cc19da3743611b6398cf9de73b80727496e51f2 /cura/PrinterOutputDevice.py
parente45d0458805e126efdb5c115c4b7bd64728d63bc (diff)
Added control item to printOutputDevice
CURA-4057
Diffstat (limited to 'cura/PrinterOutputDevice.py')
-rw-r--r--cura/PrinterOutputDevice.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/cura/PrinterOutputDevice.py b/cura/PrinterOutputDevice.py
index e23efc0f5a..60df3c3f6e 100644
--- a/cura/PrinterOutputDevice.py
+++ b/cura/PrinterOutputDevice.py
@@ -65,6 +65,11 @@ class PrinterOutputDevice(QObject, OutputDevice):
self._monitor_view_qml_path = ""
self._monitor_component = None
self._monitor_item = None
+
+ self._control_view_qml_path = ""
+ self._control_component = None
+ self._control_item = None
+
self._qml_context = None
def requestWrite(self, nodes, file_name = None, filter_by_machine = False, file_handler = None):
@@ -131,6 +136,29 @@ class PrinterOutputDevice(QObject, OutputDevice):
return self._monitor_item
+ @pyqtProperty(QObject, constant=True)
+ def controlItem(self):
+ if not self._control_component:
+ self._createControlViewFromQML()
+
+ return self._control_item
+
+ def _createControlViewFromQML(self):
+ path = QUrl.fromLocalFile(self._monitor_view_qml_path)
+
+ # Because of garbage collection we need to keep this referenced by python.
+ self._control_component = QQmlComponent(Application.getInstance()._engine, path)
+
+ # Check if the context was already requested before (Printer output device might have multiple items in the future)
+ if self._qml_context is None:
+ self._qml_context = QQmlContext(Application.getInstance()._engine.rootContext())
+ self._qml_context.setContextProperty("OutputDevice", self)
+
+ self._control_item = self._control_component.create(self._qml_context)
+ if self._control_item is None:
+ Logger.log("e", "QQmlComponent status %s", self._control_component.status())
+ Logger.log("e", "QQmlComponent error string %s", self._control_component.errorString())
+
def _createMonitorViewFromQML(self):
path = QUrl.fromLocalFile(self._monitor_view_qml_path)