Allow folder navigation to wrap around

This commit is contained in:
lm 2025-10-17 15:48:24 +02:00
parent 37c322de75
commit 1247269bb7
1 changed files with 10 additions and 6 deletions

View File

@ -64,15 +64,19 @@ class ImageProcessingMixin:
def show_next_image(self, event=None) -> None: def show_next_image(self, event=None) -> None:
if not getattr(self, "image_paths", None): if not getattr(self, "image_paths", None):
return return
next_index = getattr(self, "current_image_index", -1) + 1 if not self.image_paths:
if next_index < len(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) self._display_image_by_index(next_index)
def show_previous_image(self, event=None) -> None: def show_previous_image(self, event=None) -> None:
if not getattr(self, "image_paths", None): if not getattr(self, "image_paths", None):
return return
prev_index = getattr(self, "current_image_index", -1) - 1 if not self.image_paths:
if prev_index >= 0: return
current = getattr(self, "current_image_index", -1)
prev_index = (current - 1) % len(self.image_paths)
self._display_image_by_index(prev_index) self._display_image_by_index(prev_index)
def _set_image_collection(self, paths: Sequence[Path], start_index: int) -> None: def _set_image_collection(self, paths: Sequence[Path], start_index: int) -> None: