Grid boundary nav: up/down/left/right past edge loads next/prev page
All arrow keys and hjkl now trigger page turns at grid boundaries, not just left/right in preview mode.
This commit is contained in:
parent
be56db1f47
commit
becdb2d18e
@ -284,6 +284,8 @@ class BooruApp(QMainWindow):
|
||||
self._grid.post_activated.connect(self._on_post_activated)
|
||||
self._grid.context_requested.connect(self._on_context_menu)
|
||||
self._grid.multi_context_requested.connect(self._on_multi_context_menu)
|
||||
self._grid.nav_past_end.connect(self._on_nav_past_end)
|
||||
self._grid.nav_before_start.connect(self._on_nav_before_start)
|
||||
self._stack.addWidget(self._grid)
|
||||
|
||||
self._favorites_view = FavoritesView(self._db)
|
||||
@ -477,6 +479,15 @@ class BooruApp(QMainWindow):
|
||||
self._current_page += 1
|
||||
self._do_search()
|
||||
|
||||
def _on_nav_past_end(self) -> None:
|
||||
self._nav_page_turn = "first"
|
||||
self._next_page()
|
||||
|
||||
def _on_nav_before_start(self) -> None:
|
||||
if self._current_page > 1:
|
||||
self._nav_page_turn = "last"
|
||||
self._prev_page()
|
||||
|
||||
def _scroll_next_page(self) -> None:
|
||||
if self._loading:
|
||||
return
|
||||
|
||||
@ -218,6 +218,8 @@ class ThumbnailGrid(QScrollArea):
|
||||
multi_context_requested = Signal(list, object) # list[int], QPoint
|
||||
reached_bottom = Signal() # emitted when scrolled to the bottom
|
||||
reached_top = Signal() # emitted when scrolled to the top
|
||||
nav_past_end = Signal() # keyboard nav past last post
|
||||
nav_before_start = Signal() # keyboard nav before first post
|
||||
|
||||
def __init__(self, parent: QWidget | None = None) -> None:
|
||||
super().__init__(parent)
|
||||
@ -344,13 +346,25 @@ class ThumbnailGrid(QScrollArea):
|
||||
return
|
||||
|
||||
if key in (Qt.Key.Key_Right, Qt.Key.Key_L):
|
||||
self._select(min(idx + 1, len(self._thumbs) - 1))
|
||||
if idx + 1 >= len(self._thumbs):
|
||||
self.nav_past_end.emit()
|
||||
else:
|
||||
self._select(idx + 1)
|
||||
elif key in (Qt.Key.Key_Left, Qt.Key.Key_H):
|
||||
self._select(max(idx - 1, 0))
|
||||
if idx - 1 < 0:
|
||||
self.nav_before_start.emit()
|
||||
else:
|
||||
self._select(idx - 1)
|
||||
elif key in (Qt.Key.Key_Down, Qt.Key.Key_J):
|
||||
self._select(min(idx + cols, len(self._thumbs) - 1))
|
||||
if idx + cols >= len(self._thumbs):
|
||||
self.nav_past_end.emit()
|
||||
else:
|
||||
self._select(idx + cols)
|
||||
elif key in (Qt.Key.Key_Up, Qt.Key.Key_K):
|
||||
self._select(max(idx - cols, 0))
|
||||
if idx - cols < 0:
|
||||
self.nav_before_start.emit()
|
||||
else:
|
||||
self._select(idx - cols)
|
||||
elif key == Qt.Key.Key_Return or key == Qt.Key.Key_Enter:
|
||||
if 0 <= idx < len(self._thumbs):
|
||||
self.post_activated.emit(idx)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user