When re-ordering tabs, save the correct order in settings so they open in the correct order again later

This commit is contained in:
Micah Lee 2019-11-28 14:31:48 -08:00
parent 3fe6d43d9d
commit 695fecd21e
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73

View File

@ -164,6 +164,8 @@ class TabWidget(QtWidgets.QTabWidget):
tab = self.widget(index) tab = self.widget(index)
if tab.settings.get("persistent", "enabled"): if tab.settings.get("persistent", "enabled"):
persistent_tabs.append(tab.settings.id) persistent_tabs.append(tab.settings.id)
# Only save if tabs have actually moved
if persistent_tabs != self.common.settings.get("persistent_tabs"):
self.common.settings.set("persistent_tabs", persistent_tabs) self.common.settings.set("persistent_tabs", persistent_tabs)
self.common.settings.save() self.common.settings.save()
@ -196,11 +198,11 @@ class TabWidget(QtWidgets.QTabWidget):
return True return True
return False return False
def changeEvent(self, event): def paintEvent(self, event):
# TODO: later when I have internet, figure out the right event for re-ordering tabs super(TabWidget, self).paintEvent(event)
# Save the order of persistent tabs whenever a new tab is switched to -- ideally we would
# If tabs get move # do this whenever tabs gets moved, but paintEvent is the only event that seems to get triggered
super(TabWidget, self).changeEvent(event) # when this happens
self.save_persistent_tabs() self.save_persistent_tabs()
def resizeEvent(self, event): def resizeEvent(self, event):