lint refactor

This commit is contained in:
Agel committed 2026-10-30 16:48:58 +01:00
1 parent da8abf0332
commit 85ae0d4ad9
53 files changed
+891 -670

No files matched your search

+16 -11
View File
@@ -104,20 +104,23 @@ Pre-configured tasks, launch configurations, and CMake presets are available:
## Architecture
Backend (C++) handles all file I/O, format parsing, text layout calculation, and image decoding. QML handles UI. Communication is through `QObject` models and context properties.
Backend (C++) handles all file I/O, format parsing, text layout calculation, and image decoding. QML handles UI. Communication is through declarative compile-time singletons and types registered in the `Asteria` QML module via `QmlRegistrations.h` and `qt_add_qml_module`.
### QObjects Exposed to QML
| Object | Responsibility |
### Declarative Singletons & Types Exposed to QML (`Asteria` module)
| Type / Singleton | 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`), 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`). |
| `isDebugBuild` | Boolean constant indicating debug build. |
| `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`), 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`). |
| `AppInfo` | Exposes compile-time build configuration (e.g. `AppInfo.isDebugBuild`). |
Backend singletons are exposed using `QML_FOREIGN` wrapper structs in `src/backend/QmlRegistrations.h`. This decouples backend classes from Qt QML engine headers in headless unit test suites while enabling static type checking, Ahead-Of-Time compilation via `qmlcachegen`, and zero-warning `qmllint` passes.
### Additional Registered Types & Providers
- **`KnuthPlassItem`** (`Asteria` module): Custom `QQuickPaintedItem` that draws `ChunkLayout` via `QPainter`. Supports `useBookColours`, `surfaceColor`, theme colour overrides, and WCAG contrast safety fallback for publisher colours.
- **`KnuthPlassItem`** (`Asteria` module): Custom `QQuickPaintedItem` registered declaratively via `QML_ELEMENT` that draws `ChunkLayout` via `QPainter`. Supports `useBookColours`, `surfaceColor`, theme colour overrides, and WCAG contrast safety fallback for publisher colours.
- **`ThemePalette`** (`Asteria` module): Declarative theme palette base QML type defining all 20 color keys, extended by `DarkTheme`, `LightTheme`, and `ThemeManager.customTheme` for compile-time property verification.
- **`ChunkLayout`**: Declared metatype storing positioned text lines, word runs, inline/block images, rules, and block decorations.
- **Image Providers**:
- `image://fileicon/...`: `FileIconProvider`
@@ -234,6 +237,7 @@ src/
IFileDialogService.h
NativeFileDialogService.h/cpp
PortalFileDialogService.h/cpp
QmlRegistrations.h
ReadingModel.h/cpp
book/
Book.h/cpp
@@ -280,6 +284,7 @@ src/
LightTheme.qml
Main.qml
ThemeManager.qml
ThemePalette.qml
components/
ErrorPopup.qml
FlatIconButton.qml
@@ -334,5 +339,5 @@ tests/
## Qt Conventions
- **Qt 6.10+** preferred — no Qt5 compat shims.
- All UI in **QML**; C++ for logic, parsing, and heavy computation.
- Expose C++ to QML via `rootContext()->setContextProperty()` or `qmlRegisterType`.
- Expose C++ backend singletons declaratively in the `Asteria` QML module via `QML_FOREIGN` wrappers (`QmlRegistrations.h`) and `QML_ELEMENT` for custom items (`KnuthPlassItem`). Avoid runtime `rootContext()->setContextProperty()` so `qmllint` and `qmlcachegen` statically type-check all bindings and properties ahead of time.
- Main window starts with opacity 0 and ticks to 1 on a short timer to prevent white window flash during initial render.