From f0218c194dd1684fa78839d7284832e668103d8d Mon Sep 17 00:00:00 2001 From: jpirnay Date: Thu, 30 Apr 2026 12:19:27 +0200 Subject: [PATCH] Review changes --- src/CrossPointSettings.h | 2 +- src/RecentBooksStore.cpp | 23 ++++++++++++++++++++ src/activities/reader/EpubReaderActivity.cpp | 7 ++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/CrossPointSettings.h b/src/CrossPointSettings.h index 4daddaf5..d970db53 100644 --- a/src/CrossPointSettings.h +++ b/src/CrossPointSettings.h @@ -286,8 +286,8 @@ class CrossPointSettings { BTN_PREV_SECTION, BTN_EXIT_READER, BTN_READER_MENU, - BTN_TOGGLE_BIONIC_READING, BTN_KOREADER_SYNC, + BTN_TOGGLE_BIONIC_READING, BUTTON_ACTION_COUNT }; diff --git a/src/RecentBooksStore.cpp b/src/RecentBooksStore.cpp index ab21fba0..7dc1d2e0 100644 --- a/src/RecentBooksStore.cpp +++ b/src/RecentBooksStore.cpp @@ -85,6 +85,29 @@ RecentBook RecentBooksStore::getBookByPath(const std::string& path) const { return RecentBook{}; } +bool RecentBooksStore::setReaderOverrides(const std::string& path, const int8_t embeddedStyleOverride, + const int8_t imageRenderingOverride) { + auto it = + std::find_if(recentBooks.begin(), recentBooks.end(), [&](const RecentBook& book) { return book.path == path; }); + if (it == recentBooks.end()) { + return false; + } + return setReaderOverrides(path, embeddedStyleOverride, imageRenderingOverride, it->fontFamilyOverride, + it->fontSizeOverride, it->bionicReadingOverride); +} + +bool RecentBooksStore::setReaderOverrides(const std::string& path, const int8_t embeddedStyleOverride, + const int8_t imageRenderingOverride, const int8_t fontFamilyOverride, + const int8_t fontSizeOverride) { + auto it = + std::find_if(recentBooks.begin(), recentBooks.end(), [&](const RecentBook& book) { return book.path == path; }); + if (it == recentBooks.end()) { + return false; + } + return setReaderOverrides(path, embeddedStyleOverride, imageRenderingOverride, fontFamilyOverride, fontSizeOverride, + it->bionicReadingOverride); +} + bool RecentBooksStore::setReaderOverrides(const std::string& path, const int8_t embeddedStyleOverride, const int8_t imageRenderingOverride, const bool bionicReadingOverride) { auto it = diff --git a/src/activities/reader/EpubReaderActivity.cpp b/src/activities/reader/EpubReaderActivity.cpp index 9e4e1744..bc08abbf 100644 --- a/src/activities/reader/EpubReaderActivity.cpp +++ b/src/activities/reader/EpubReaderActivity.cpp @@ -2007,6 +2007,13 @@ void EpubReaderActivity::onButtonAction(const CrossPointSettings::BUTTON_ACTION openReaderMenu(); } break; + case BA::BTN_TOGGLE_BIONIC_READING: + if (epub) { + applyBookReaderOverrides(bookEmbeddedStyleOverride, bookImageRenderingOverride, bookFontFamilyOverride, + bookFontSizeOverride, !bookBionicReadingOverride); + requestUpdate(); + } + break; case BA::BTN_KOREADER_SYNC: launchKOReaderSync(SyncLaunchMode::COMPARE); break;