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] 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):
if uid is None:
uid = next(iter(set(range(len(self.applet_uids) + 1)) uid = next(iter(set(range(len(self.applet_uids) + 1))
- self.applet_uids)) - self.applet_uids))
self.applet_uids.add(uid) self.applet_uids.add(uid)
@ -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)