forked from M-Labs/artiq
1
0
Fork 0

dashboard: Add submit/close hooks for custom argument editors

These are used by ndscan, as re-serialising the entire ndscan
parameter metadata tree, which can grow to be quite extensive,
on every single Qt change event is a bit excessive (and would
probably cause a bit of lag while typing for big experiments
on low-end machines).
This commit is contained in:
David Nadlinger 2018-06-27 00:16:00 +01:00 committed by Sébastien Bourdeauducq
parent c4068e6896
commit dbc87f08ff
1 changed files with 11 additions and 0 deletions

View File

@ -216,6 +216,15 @@ class _ArgumentEditor(QtWidgets.QTreeWidget):
pass pass
self.verticalScrollBar().setValue(state["scroll"]) self.verticalScrollBar().setValue(state["scroll"])
# Hooks that allow user-supplied argument editors to react to imminent user
# actions. Here, we always keep the manager-stored submission arguments
# up-to-date, so no further action is required.
def about_to_submit(self):
pass
def about_to_close(self):
pass
log_levels = ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"] log_levels = ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]
@ -369,6 +378,7 @@ class _ExperimentDock(QtWidgets.QMdiSubWindow):
self.hdf5_load_directory = os.path.expanduser("~") self.hdf5_load_directory = os.path.expanduser("~")
def submit_clicked(self): def submit_clicked(self):
self.argeditor.about_to_submit()
try: try:
self.manager.submit(self.expurl) self.manager.submit(self.expurl)
except: except:
@ -473,6 +483,7 @@ class _ExperimentDock(QtWidgets.QMdiSubWindow):
await self._recompute_arguments_task(arguments) await self._recompute_arguments_task(arguments)
def closeEvent(self, event): def closeEvent(self, event):
self.argeditor.about_to_close()
self.sigClosed.emit() self.sigClosed.emit()
QtWidgets.QMdiSubWindow.closeEvent(self, event) QtWidgets.QMdiSubWindow.closeEvent(self, event)