From 7cf90c1e5c735cfae6df6a27029e6a285ef9045d Mon Sep 17 00:00:00 2001 From: Ethanfel Date: Mon, 8 Jun 2026 13:14:10 +0200 Subject: [PATCH] feat: jump playback to 3s before the new end when the play area shrinks When autoclip (A / back button) or a wheel scroll reduces the clip span, seek playback to 3s before the new end and loop there so the shorter cut point can be reviewed immediately. Growing the play area is unaffected. Co-Authored-By: Claude Opus 4.6 --- main.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 3ec8d81..1e2e0bd 100755 --- a/main.py +++ b/main.py @@ -5784,10 +5784,24 @@ class MainWindow(QMainWindow): eff = 1.0 self._mpv.set_speed(eff) + def _preview_clip_end(self) -> None: + """Jump playback to 3s before the end of the (new) clip span and loop, + so a just-shrunk play area can be reviewed at its cut point.""" + if not self._file_path: + return + end = self._cursor + self._clip_span + target = max(self._cursor, end - 3.0) + self._mpv.play_loop(self._cursor, end, resume=True) + self._mpv.seek(target) + self._timeline.set_play_position(target) + def _change_clip_count(self, delta: int) -> None: """Wheel-scroll over the timeline adds/removes clips (clamped).""" spn = self._spn_clips - spn.setValue(max(spn.minimum(), min(spn.maximum(), spn.value() + delta))) + old = spn.value() + spn.setValue(max(spn.minimum(), min(spn.maximum(), old + delta))) + if spn.value() < old: # play area got smaller + self._preview_clip_end() def _autoclip(self): """Set clip count to fit the current pause position.""" @@ -5800,7 +5814,10 @@ class MainWindow(QMainWindow): spread = self._spn_spread.value() n = int((elapsed - self._clip_dur) / spread) + 1 n = max(1, n) + old_span = self._clip_span self._spn_clips.setValue(n) + if self._clip_span < old_span: # autoclip shrank the play area + self._preview_clip_end() def _step_cursor(self, delta: float) -> None: if not self._file_path: