diff --git a/app/logic/image_processing.py b/app/logic/image_processing.py index 1674b6e..26c399f 100644 --- a/app/logic/image_processing.py +++ b/app/logic/image_processing.py @@ -64,16 +64,20 @@ class ImageProcessingMixin: def show_next_image(self, event=None) -> None: if not getattr(self, "image_paths", None): return - next_index = getattr(self, "current_image_index", -1) + 1 - if next_index < len(self.image_paths): - self._display_image_by_index(next_index) + if not self.image_paths: + return + current = getattr(self, "current_image_index", -1) + next_index = (current + 1) % len(self.image_paths) + self._display_image_by_index(next_index) def show_previous_image(self, event=None) -> None: if not getattr(self, "image_paths", None): return - prev_index = getattr(self, "current_image_index", -1) - 1 - if prev_index >= 0: - self._display_image_by_index(prev_index) + if not self.image_paths: + return + current = getattr(self, "current_image_index", -1) + prev_index = (current - 1) % len(self.image_paths) + self._display_image_by_index(prev_index) def _set_image_collection(self, paths: Sequence[Path], start_index: int) -> None: self.image_paths = list(paths)