fix: keep print and re-apply selected template on preview switch

Switching the preview garment cleared the scene (print lost), and
re-loading a print used the canvas's hard-coded centred default instead
of the selected template.

- template_panel: add apply_current() to re-emit the selected template
  for the current garment/print sizes and sync _current_state.
- main_window: remember the current print path, restore it after a
  garment switch, and call apply_current() after garment/print changes
  so the selected template stays sticky. Fine-tuned items are unaffected.
- Also feed template_applied into export_panel.set_transform to keep the
  single-export transform in sync.

Docs: record the sticky-template rule (PRD 6.6).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-16 15:39:45 +08:00
co-authored by Claude Opus 4.8
parent 8a34fe93ff
commit 69a6dc892a
3 changed files with 38 additions and 10 deletions
+13
View File
@@ -138,6 +138,19 @@ class TemplatePanel(QWidget):
self._print_w or None, self._print_h or None,
)
def apply_current(self):
"""Re-apply the currently selected template using current garment/print sizes.
Lets the selected template stay 'sticky': callers invoke this after the
preview garment or print changes so the layout is recomputed from the
template instead of falling back to the canvas default.
"""
t = self._current_template()
if t and self._garment_w > 0 and self._garment_h > 0:
state = self._state_for_template(t)
self._current_state = state
self.template_applied.emit(state)
def set_transform(self, state: TransformState):
"""Store current print transform (used when saving a template)."""
self._current_state = state