diff --git a/docs/02-prd.md b/docs/02-prd.md index 46c9e71..e2480ec 100644 --- a/docs/02-prd.md +++ b/docs/02-prd.md @@ -331,6 +331,7 @@ CMBot/ "last_print_dir": "", "last_template": "正方形模板", "last_batch_mode": "full_combo", + "last_tab": 0, "update_source": "", "update_user": "", "update_pass": "" @@ -343,6 +344,7 @@ CMBot/ - `last_garment_dir` / `last_print_dir`:上次打开的衣服 / 印花文件夹路径,用于让文件夹对话框定位到上次位置。 - `last_template`:上次选中的模板名称,用于启动恢复。 - `last_batch_mode`:上次选择的批量模式(取 `BatchMode` 枚举值,如 `full_combo` / `many_garments` / `many_prints` / `one_to_one`)。 +- `last_tab`:上次选择的流程页签(0=添加印花,1=AI 穿搭),启动恢复;仅恢复已启用的已实现页签。 - `update_source`:在线更新源 `manifest.json` 的 HTTP(S) 地址。为空时不做更新检查。详见 `docs/10-lan-update.md`。 - `update_user` / `update_pass`:更新源 HTTP Basic Auth 凭据,更新源开启鉴权时使用,为空表示匿名。 - 偏好的读取、分发与「改一次存一次」由主窗口集中处理,UI 控件不直接读写配置文件。 diff --git a/src/app/main_window.py b/src/app/main_window.py index b7cfb5c..2272468 100644 --- a/src/app/main_window.py +++ b/src/app/main_window.py @@ -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) diff --git a/src/services/config_service.py b/src/services/config_service.py index 6854a44..faa2026 100644 --- a/src/services/config_service.py +++ b/src/services/config_service.py @@ -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)