Fix #1963699 [Inconsistent initial display of Tweaks dialog](https://bugs.launchpad.net/calibre/+bug/1963699)

This commit is contained in:
Kovid Goyal 2022-03-16 10:50:11 +05:30
parent 47a24ae092
commit a509c9cb38
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -485,11 +485,13 @@ class ConfigWidget(ConfigWidgetBase):
self.tweaks.set_plugin_tweaks(l) self.tweaks.set_plugin_tweaks(l)
self.changed() self.changed()
def current_changed(self, current, previous): def current_changed(self, *a):
self.tweaks_view.scrollTo(current) current = self.tweaks_view.currentIndex()
tweak = self.tweaks.data(current, Qt.ItemDataRole.UserRole) if current.isValid():
self.help.setPlainText(tweak.doc) self.tweaks_view.scrollTo(current)
self.edit_tweak.setPlainText(tweak.edit_text) tweak = self.tweaks.data(current, Qt.ItemDataRole.UserRole)
self.help.setPlainText(tweak.doc)
self.edit_tweak.setPlainText(tweak.edit_text)
def changed(self, *args): def changed(self, *args):
self.changed_signal.emit() self.changed_signal.emit()
@ -497,6 +499,7 @@ class ConfigWidget(ConfigWidgetBase):
def initialize(self): def initialize(self):
self.tweaks = self._model = Tweaks() self.tweaks = self._model = Tweaks()
self.tweaks_view.setModel(self.tweaks) self.tweaks_view.setModel(self.tweaks)
self.tweaks_view.setCurrentIndex(self.tweaks_view.model().index(0))
def restore_to_default(self, *args): def restore_to_default(self, *args):
idx = self.tweaks_view.currentIndex() idx = self.tweaks_view.currentIndex()