feat: remember & restore the last-selected workflow tab

Add last_tab to DEFAULT_CONFIG; main_window restores it in _restore_preferences
(only enabled/implemented tabs 0/1; setCurrentIndex before connecting the persist
slot to avoid an echo write) and persists via _on_tab_persist on currentChanged.
Mirrors the existing last_template/last_batch_mode pattern. Document the key in
docs/02 §9. Offscreen-verified (restore 0/1, disabled 2 -> 0, persist); suite green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-22 11:44:09 +08:00
co-authored by Claude Opus 4.8
parent d851978634
commit c1cbef26ef
3 changed files with 17 additions and 0 deletions
+14
View File
@@ -557,11 +557,19 @@ class MainWindow(QMainWindow):
# AI outfit panel: inject last paths/settings + load models/prompt
self.ai_outfit_panel.apply_config(self._config)
# Restore the last-selected tab (only implemented + enabled tabs).
last_tab = self._config.get("last_tab", 0)
if (isinstance(last_tab, int) and last_tab in (0, 1)
and self._tab_bar.isTabEnabled(last_tab)
and last_tab != self._tab_bar.currentIndex()):
self._tab_bar.setCurrentIndex(last_tab) # fires _on_tab_changed -> stack
# Persist future changes (connected after restore to avoid echo writes)
self.template_panel.template_changed.connect(self._on_template_persist)
self.queue_panel.batch_mode_changed.connect(self._on_batch_mode_persist)
self.image_list_panel.garment_folder_opened.connect(self._on_garment_dir_persist)
self.image_list_panel.print_folder_opened.connect(self._on_print_dir_persist)
self._tab_bar.currentChanged.connect(self._on_tab_persist)
def _on_template_persist(self, name):
self._config["last_template"] = name
@@ -571,6 +579,12 @@ class MainWindow(QMainWindow):
self._config["last_batch_mode"] = getattr(mode, "value", str(mode))
save_config(self._config)
def _on_tab_persist(self, index):
"""Remember the last-selected tab (only implemented tabs)."""
if index in (0, 1):
self._config["last_tab"] = index
save_config(self._config)
def _on_garment_dir_persist(self, path):
self._config["last_garment_dir"] = path
save_config(self._config)
+1
View File
@@ -11,6 +11,7 @@ DEFAULT_CONFIG = {
"last_print_dir": "",
"last_template": "", # name of the last-selected template
"last_batch_mode": "full_combo", # BatchMode value of the last-used mode
"last_tab": 0, # last-selected workflow tab (0=添加印花, 1=AI 穿搭)
"update_source": "", # HTTP(S) manifest source (empty = no update check)
"update_user": "", # HTTP Basic Auth user (empty = anonymous)
"update_pass": "", # HTTP Basic Auth password (empty = anonymous)