Improve tabwidget state saving
Previously, state saying was handled by a function being called in the destructor.
The destructor is typically only called when Kleopatra exists cleanly. When closed in other ways,
the state would thus not save, resulting in a subpar user experience. This patch changes it
to save whenever a relevant value changes.
(cherry picked from commit 3846715f209d5f61174fe646a2eabaf6395d1fad)