From afa8148b2bd650d94b2a2dc8ed5a66cc2663fa29 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Mon, 30 Nov 2015 11:40:50 +0800 Subject: [PATCH] gui/experiments: save/restore state --- artiq/frontend/artiq_gui.py | 1 + artiq/gui/experiments.py | 28 +++++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/artiq/frontend/artiq_gui.py b/artiq/frontend/artiq_gui.py index 1ab99299b..43bfb276c 100755 --- a/artiq/frontend/artiq_gui.py +++ b/artiq/frontend/artiq_gui.py @@ -99,6 +99,7 @@ def main(): sub_clients["explist"], sub_clients["schedule"], rpc_clients["schedule"]) + smgr.register(expmgr) d_explorer = explorer.ExplorerDock(win, status_bar, expmgr, sub_clients["explist"], rpc_clients["schedule"], diff --git a/artiq/gui/experiments.py b/artiq/gui/experiments.py index bca980ce3..88b819eab 100644 --- a/artiq/gui/experiments.py +++ b/artiq/gui/experiments.py @@ -13,6 +13,8 @@ from artiq.gui.scan import ScanController logger = logging.getLogger(__name__) +# TODO: disable mouse wheel on entry widget like QDoubleSpinBox and QComboBox +# (interferes with QTreeWidget scrolling) class _StringEntry(QtGui.QLineEdit): def __init__(self, argument): QtGui.QLineEdit.__init__(self) @@ -219,6 +221,12 @@ class _ExperimentDock(dockarea.Dock): def submit_clicked(self): self.manager.submit(self.expname) + def save_state(self): + return self.argeditor.save_state() + + def restore_state(self, state): + self.argeditor.restore_state(state) + class ExperimentManager: def __init__(self, status_bar, dock_area, @@ -287,12 +295,13 @@ class ExperimentManager: def open_experiment(self, expname): if expname in self.open_experiments: - return + return self.open_experiments[expname] dock = _ExperimentDock(self, expname) self.open_experiments[expname] = dock self.dock_area.addDock(dock) self.dock_area.floatDock(dock) dock.sigClosed.connect(partial(self.on_dock_closed, expname)) + return dock def on_dock_closed(self, expname): del self.open_experiments[expname] @@ -347,8 +356,21 @@ class ExperimentManager: asyncio.ensure_future(self._request_term_multiple(rids)) def save_state(self): - return dict() + docks = {expname: dock.save_state() + for expname, dock in self.open_experiments.items()} + return { + "scheduling": self.submission_scheduling, + "options": self.submission_options, + "arguments": self.submission_arguments, + "docks": docks + } - def restore_state(self): + def restore_state(self, state): if self.open_experiments: raise NotImplementedError + self.submission_scheduling = state["scheduling"] + self.submission_options = state["options"] + self.submission_arguments = state["arguments"] + for expname, dock_state in state["docks"].items(): + dock = self.open_experiment(expname) + dock.restore_state(dock_state)