forked from M-Labs/artiq
1
0
Fork 0

gui/applets: save dock UID in state

This commit is contained in:
Sebastien Bourdeauducq 2016-02-08 21:57:07 +01:00
parent 7584b02d66
commit 4733c4ba1e
1 changed files with 8 additions and 6 deletions

View File

@ -248,7 +248,8 @@ class AppletsDock(dockarea.Dock):
del self.dock_to_checkbox[dock]
checkbox_item.setCheckState(QtCore.Qt.Unchecked)
def new(self):
def new(self, uid=None):
if uid is None:
uid = next(iter(set(range(len(self.applet_uids) + 1))
- self.applet_uids))
self.applet_uids.add(uid)
@ -301,16 +302,17 @@ class AppletsDock(dockarea.Dock):
def save_state(self):
state = []
for row in range(self.table.rowCount()):
uid = self.table.item(row, 0).applet_uid
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((enabled, name, command))
state.append((uid, enabled, name, command))
return state
def restore_state(self, state):
self.workaround_pyqtgraph_bug = True
for enabled, name, command in state:
row = self.new()
for uid, enabled, name, command in state:
row = self.new(uid)
item = QtWidgets.QTableWidgetItem()
item.setText(name)
self.table.setItem(row, 1, item)