[ui] add more explicit doc for QML helpers singleton

This commit is contained in:
Yann Lanthony 2019-05-07 11:03:54 +02:00
parent 6d07323580
commit 9ce077778b
No known key found for this signature in database
GPG key ID: 519FAE6DF7A70642
2 changed files with 13 additions and 7 deletions

View file

@ -84,14 +84,20 @@ class MeshroomApp(QApplication):
# expose available node types that can be instantiated
self.engine.rootContext().setContextProperty("_nodeTypes", sorted(nodesDesc.keys()))
# instantiate Reconstruction object
r = Reconstruction(parent=self)
self.engine.rootContext().setContextProperty("_reconstruction", r)
pm = PaletteManager(self.engine, parent=self)
self.engine.rootContext().setContextProperty("_PaletteManager", pm)
fpHelper = FilepathHelper(parent=self)
self.engine.rootContext().setContextProperty("Filepath", fpHelper)
scene3DHelper = Scene3DHelper(parent=self)
self.engine.rootContext().setContextProperty("Scene3DHelper", scene3DHelper)
# those helpers should be available from QML Utils module as singletons, but:
# - qmlRegisterUncreatableType is not yet available in PySide2
# - declaring them as singleton in qmldir file causes random crash at exit
# => expose them as context properties instead
self.engine.rootContext().setContextProperty("Filepath", FilepathHelper(parent=self))
self.engine.rootContext().setContextProperty("Scene3DHelper", Scene3DHelper(parent=self))
# additional context properties
self.engine.rootContext().setContextProperty("_PaletteManager", PaletteManager(self.engine, parent=self))
self.engine.rootContext().setContextProperty("MeshroomApp", self)
# Request any potential computation to stop on exit
self.aboutToQuit.connect(r.stopExecution)