Skip to content

Add scroll margin to TOC keyboard navigation (toc_scroll_margin) - #1675

Open
httpsrichard wants to merge 1 commit into
ahrm:developmentfrom
httpsrichard:development
Open

Add scroll margin to TOC keyboard navigation (toc_scroll_margin)#1675
httpsrichard wants to merge 1 commit into
ahrm:developmentfrom
httpsrichard:development

Conversation

@httpsrichard

Copy link
Copy Markdown

Problem

TOC keyboard navigation has no scroll margin — it relies entirely on Qt's default scrollTo(index, EnsureVisible), which only scrolls the bare minimum needed to bring the current row into view. Moving down gives almost no look-ahead before the selection hits the last visible row, and reversing direction after scrolling down leaves the viewport frozen until the selection reaches the edge of whatever's already on screen.

Fix

Adds SioyekTreeView, a QTreeView subclass used by the TOC, that overrides scrollTo() to keep toc_scroll_margin rows of context visible above/below the current row at all times. New config option, default 3, range 0100; 0 restores the previous behavior exactly.

Touches pdf_viewer/ui.h (new class + wiring), pdf_viewer/config.cpp (registers the option), pdf_viewer/prefs.config (documents the default). The QListView-backed menus (bookmarks, highlights, flat TOC) likely have the same gap — out of scope here, but a natural follow-up.

Testing

Verified interactively against real documents, and with a headless Qt6 (QT_QPA_PLATFORM=offscreen) reproduction that drives a real QTreeView the same way sioyek does internally (synthetic Key_Up/Key_Down via postEvent): stock QTreeView shows ~0 look-ahead and a frozen viewport when reversing near an edge; the patched view holds a constant margin in both directions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant