Remove Book and Close Book menu items and auto-close on navigation
Simplify sidebar navigation by removing the conditional Book and Close Book items so users no longer need to manage a book left open in the background. Because there is no longer a Book item to return to the reader, navigating away from the reader to History or Custom Theme now flushes any pending scroll position and closes the active or in-flight book. Opening the Settings popup still keeps the book open behind the overlay, and clicking Files keeps the current book open until a file is actually selected so cancelling the file dialog preserves the current reading session. This also fixes book-lifecycle edge cases exposed by closing on navigation: - Cancel in-flight async loads in Book::close() and clear loading state so closing mid-load does not jump back to the reader or stall the spinner. - Emit willCloseBook before resetting the reader so AppCoordinator snapshots final progress into HistoryModel and immediately clears UiState.lastFilePath. - Mark Book as loading before clearing the outgoing reader when opening a new file to prevent HistoryPage from flashing between books, and fall back to History on load errors. - Reset ScrollPageView and MangaPageView state when a book closes, and always navigate to the reader on restoreReady so CLI-opened files are not hidden behind a previously saved History page. - Add coverage in BookTest and AppCoordinatorTest and document the behavior in AGENTS.md.
This commit is contained in:
12 files changed
+300
-46
No files matched your search
@@ -231,7 +231,7 @@ public:
|
||||
## Position Restoration & State Persistence
|
||||
- **History Persistence & Ordering**: `AppState` persists the history list. On deserialization (`HistoryModel::load`), timestamps are converted to strongly-typed `QDateTime`, and bogus or unparseable timestamps are immediately dropped. Loaded entries are sorted in descending chronological order (`lastOpened desc`). Runtime updates (`addOrUpdateBook`) preserve this descending chronological order without inversions.
|
||||
- **Position Persistence**: `BookPositionStore` persists `BookPosition` (`chunkIndex`, `intraOffset`, `progress`, `pageShift`, `mangaRTL`, `useBookColours`) indexed by file content MD5 (`contentHash()`), ensuring state survives file renames or moves.
|
||||
- **UI State Persistence**: `UiState` persists `themeName`, `lastPage`, `sidebarOpen`, `barsVisible`, `lastFilePath`, `customTheme`, and window geometry. Distraction-free chrome toggling via spacebar toggles `barsVisible` without destroying the persistent `sidebarOpen` user preference; effective sidebar visibility in reader mode is gated by `(!inReader || barsVisible) && uiState.sidebarOpen`.
|
||||
- **UI State Persistence**: `UiState` persists `themeName`, `lastPage`, `sidebarOpen`, `barsVisible`, `lastFilePath`, `customTheme`, and window geometry. Distraction-free chrome toggling via spacebar toggles `barsVisible` without destroying the persistent `sidebarOpen` user preference; effective sidebar visibility in reader mode is gated by `(!inReader || barsVisible) && uiState.sidebarOpen`. Navigating away from the reader to `History` or `Custom Theme` (or opening a new file) closes the active/loading book via `Book.close()` (cancelling in-flight loads, snapshotting progress into `HistoryModel`, resetting `ReadingModel`, and clearing `UiState.lastFilePath`), while opening the `Settings` popup keeps the current book open.
|
||||
- **Restoration Flow**:
|
||||
- Text mode: `ReadingModel` computes layout for the saved anchor chunk first, then emits `restoreReady(chunkIndex, intraOffset)`. `ScrollPageView` positions the `ListView` at `chunkIndex` and applies `intraOffset`.
|
||||
- Comic mode: `restoreReady(chunkIndex)` triggers `MangaPageView.showPair(pairIndexForChunk(chunkIndex))`.
|
||||
@@ -339,6 +339,7 @@ src/
|
||||
specs/
|
||||
knuth-plass-rendering.allium
|
||||
tests/
|
||||
AppCoordinatorTest.cpp
|
||||
AppStateTest.cpp
|
||||
EntryImageProviderTest.cpp
|
||||
FileIconProviderTest.cpp
|
||||
|
||||
Reference in new issue
Block a user