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,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)