Allow folder navigation to wrap around
This commit is contained in:
parent
37c322de75
commit
1247269bb7
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue