Add scroll margin to TOC keyboard navigation (toc_scroll_margin) - #1675
Open
httpsrichard wants to merge 1 commit into
Open
Add scroll margin to TOC keyboard navigation (toc_scroll_margin)#1675httpsrichard wants to merge 1 commit into
toc_scroll_margin)#1675httpsrichard wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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, aQTreeViewsubclass used by the TOC, that overridesscrollTo()to keeptoc_scroll_marginrows of context visible above/below the current row at all times. New config option, default3, range0–100;0restores 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). TheQListView-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 realQTreeViewthe same way sioyek does internally (syntheticKey_Up/Key_DownviapostEvent): stockQTreeViewshows ~0 look-ahead and a frozen viewport when reversing near an edge; the patched view holds a constant margin in both directions.