fix page counter

This commit is contained in:
Agel committed 2026-10-30 15:47:53 +01:00
1 parent 511472bc73
commit da8abf0332
13 files changed
+310 -122

No files matched your search

+4 -1
View File
@@ -110,7 +110,7 @@ Backend (C++) handles all file I/O, format parsing, text layout calculation, and
| Object | Responsibility |
|---|---|
| `book` (`Book`) | Open/close book, async loading, error state, metadata (title, author, coverImageUrl). Owns `FormatReader`. |
| `readingModel` (`ReadingModel`) | `QAbstractListModel` exposing chunks (`ContentRole`, `LayoutRole`, `PixelHeightRole`), layout updates, reading mode (`isTextMode`, `isMangaMode`), manga page pairs, and per-book toggles (`pageShift`, `mangaRTL`, `useBookColours`). |
| `readingModel` (`ReadingModel`) | `QAbstractListModel` exposing chunks (`ContentRole`, `LayoutRole`, `PixelHeightRole`), layout updates, reading mode (`isTextMode`, `isMangaMode`), normalized pagination (`currentPage`, `totalPages`, `currentChunk`), manga page pairs, and per-book toggles (`pageShift`, `mangaRTL`, `useBookColours`). |
| `readingPreferences` (`ReadingPreferences`) | Font size, line spacing, horizontal margin, vertical margin (`QSettings`). |
| `uiState` (`UiState`) | Current theme, last page, sidebar open state, reader bars visibility (`barsVisible`), last file path, custom theme colors, window geometry. |
| `historyModel` (`HistoryModel`) | `QAbstractListModel` of recent books with async metadata extraction and reading progress. Entries store strongly-typed `QDateTime lastOpened`, immediately drop bogus/unparseable dates on deserialization, and are maintained strictly in descending chronological order (`lastOpened desc`). |
@@ -181,6 +181,9 @@ public:
- When off: paints with theme palette (`readingText`, `dimText`, `buttonAccent`), omitting publisher backgrounds and border boxes (semantic blockquote bars with only `borderLeft` and no explicit border colour are drawn in `dimText`).
- When on: paints publisher backgrounds and border colours, using WCAG contrast calculation (`contrastRatio < 3.0`) to automatically select high-contrast black or white text when publisher or theme text colours would be unreadable on the effective background.
- Toggling `useBookColours` operates entirely at paint time in `KnuthPlassItem`—zero off-thread relayout, zero position shift, and instant response.
- **Normalized Page Counting & Viewport Invariance**: In text mode, `totalPages` and `currentPage` report normalized pages based on publishing standards (1,800 characters per page "Normopage" / 30 lines × 60 characters, ~250–300 words).
- Derived from an $O(1)$ prefix sum array (`m_chunkCumulativeChars`) and the intra-chunk scroll offset (`intraFraction = intraOffset / totalHeight`), ensuring page numbers and total page counts remain 100% constant across window resizing, maximizing, font scaling, and line spacing adjustments. Standalone illustration images are weighted as 1 standard page (1,800 characters).
- `ReadingModel::currentChunk` exposes the internal 0-based layout chunk index (`0 .. rowCount - 1`) used by `ScrollPageView.qml` and `ChunkLayoutEngine` for layout calculations and scroll anchoring, cleanly decoupled from user-facing `currentPage`.
- Scrolling tracks top visible chunk and `intraOffset`.
### 2. Manga / Comic Mode (`MangaPageView.qml`)