Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/artiq
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 73795ff7889b
Choose a base ref
...
head repository: m-labs/artiq
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1d94cfd8ed46
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Apr 6, 2016

  1. Copy the full SHA
    04d4067 View commit details
  2. Copy the full SHA
    1d94cfd View commit details
Showing with 16 additions and 3 deletions.
  1. +15 −3 artiq/gui/applets.py
  2. +1 −0 artiq/gui/state.py
18 changes: 15 additions & 3 deletions artiq/gui/applets.py
Original file line number Diff line number Diff line change
@@ -264,6 +264,10 @@ def cell_changed(self, row, column):
name = name.text()
dock = self.create(item.applet_uid, name, command)
item.applet_dock = dock
if item.applet_geometry is not None:
dock.restoreGeometry(item.applet_geometry)
# geometry is now handled by main window state
item.applet_geometry = None
self.dock_to_checkbox[dock] = item
else:
dock = item.applet_dock
@@ -280,9 +284,10 @@ def cell_changed(self, row, column):
dock.command = new_value

def on_dock_closed(self, dock):
asyncio.ensure_future(dock.terminate())
checkbox_item = self.dock_to_checkbox[dock]
checkbox_item.applet_dock = None
checkbox_item.applet_geometry = dock.saveGeometry()
asyncio.ensure_future(dock.terminate())
del self.dock_to_checkbox[dock]
checkbox_item.setCheckState(QtCore.Qt.Unchecked)

@@ -301,6 +306,7 @@ def new(self, uid=None):
checkbox.setCheckState(QtCore.Qt.Unchecked)
checkbox.applet_uid = uid
checkbox.applet_dock = None
checkbox.applet_geometry = None
self.table.setItem(row, 0, checkbox)
self.table.setItem(row, 1, QtWidgets.QTableWidgetItem())
self.table.setItem(row, 2, QtWidgets.QTableWidgetItem())
@@ -344,17 +350,23 @@ def save_state(self):
enabled = self.table.item(row, 0).checkState() == QtCore.Qt.Checked
name = self.table.item(row, 1).text()
command = self.table.item(row, 2).text()
state.append((uid, enabled, name, command))
geometry = self.table.item(row, 0).applet_geometry
if geometry is not None:
geometry = bytes(geometry)
state.append((uid, enabled, name, command, geometry))
return state

def restore_state(self, state):
for uid, enabled, name, command in state:
for uid, enabled, name, command, geometry in state:
row = self.new(uid)
item = QtWidgets.QTableWidgetItem()
item.setText(name)
self.table.setItem(row, 1, item)
item = QtWidgets.QTableWidgetItem()
item.setText(command)
self.table.setItem(row, 2, item)
if geometry is not None:
geometry = QtCore.QByteArray(geometry)
self.table.item(row, 0).applet_geometry = geometry
if enabled:
self.table.item(row, 0).setCheckState(QtCore.Qt.Checked)
1 change: 1 addition & 0 deletions artiq/gui/state.py
Original file line number Diff line number Diff line change
@@ -51,6 +51,7 @@ def load(self):
# To help address this problem, state is restored in the opposite
# order as the stateful objects are registered.
for name, obj in reversed(list(self.stateful_objects.items())):
logger.info("Restoring state of object '%s'", name)
state = data.get(name, None)
if state is not None:
try: