mirror of https://github.com/m-labs/artiq.git
gui/applets: save dock UID in state
This commit is contained in:
parent
7584b02d66
commit
4733c4ba1e
|
@ -248,9 +248,10 @@ class AppletsDock(dockarea.Dock):
|
||||||
del self.dock_to_checkbox[dock]
|
del self.dock_to_checkbox[dock]
|
||||||
checkbox_item.setCheckState(QtCore.Qt.Unchecked)
|
checkbox_item.setCheckState(QtCore.Qt.Unchecked)
|
||||||
|
|
||||||
def new(self):
|
def new(self, uid=None):
|
||||||
uid = next(iter(set(range(len(self.applet_uids) + 1))
|
if uid is None:
|
||||||
- self.applet_uids))
|
uid = next(iter(set(range(len(self.applet_uids) + 1))
|
||||||
|
- self.applet_uids))
|
||||||
self.applet_uids.add(uid)
|
self.applet_uids.add(uid)
|
||||||
|
|
||||||
row = self.table.rowCount()
|
row = self.table.rowCount()
|
||||||
|
@ -301,16 +302,17 @@ class AppletsDock(dockarea.Dock):
|
||||||
def save_state(self):
|
def save_state(self):
|
||||||
state = []
|
state = []
|
||||||
for row in range(self.table.rowCount()):
|
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
|
enabled = self.table.item(row, 0).checkState() == QtCore.Qt.Checked
|
||||||
name = self.table.item(row, 1).text()
|
name = self.table.item(row, 1).text()
|
||||||
command = self.table.item(row, 2).text()
|
command = self.table.item(row, 2).text()
|
||||||
state.append((enabled, name, command))
|
state.append((uid, enabled, name, command))
|
||||||
return state
|
return state
|
||||||
|
|
||||||
def restore_state(self, state):
|
def restore_state(self, state):
|
||||||
self.workaround_pyqtgraph_bug = True
|
self.workaround_pyqtgraph_bug = True
|
||||||
for enabled, name, command in state:
|
for uid, enabled, name, command in state:
|
||||||
row = self.new()
|
row = self.new(uid)
|
||||||
item = QtWidgets.QTableWidgetItem()
|
item = QtWidgets.QTableWidgetItem()
|
||||||
item.setText(name)
|
item.setText(name)
|
||||||
self.table.setItem(row, 1, item)
|
self.table.setItem(row, 1, item)
|
||||||
|
|
Loading…
Reference in New Issue