Local overrides for css and img display

This commit is contained in:
jpirnay
2026-03-20 18:17:34 +01:00
parent a01bb2902e
commit 09e65c30a3
8 changed files with 185 additions and 25 deletions
+11
View File
@@ -302,6 +302,8 @@ bool JsonSettingsIO::saveRecentBooks(const RecentBooksStore& store, const char*
obj["title"] = book.title;
obj["author"] = book.author;
obj["coverBmpPath"] = book.coverBmpPath;
obj["embeddedStyleOverride"] = book.embeddedStyleOverride;
obj["imageRenderingOverride"] = book.imageRenderingOverride;
}
String json;
@@ -319,6 +321,13 @@ bool JsonSettingsIO::loadRecentBooks(RecentBooksStore& store, const char* json)
store.recentBooks.clear();
JsonArray arr = doc["books"].as<JsonArray>();
auto clampInt8 = [](int value, int minValue, int maxValue, int8_t fallback) -> int8_t {
if (value < minValue || value > maxValue) {
return fallback;
}
return static_cast<int8_t>(value);
};
for (JsonObject obj : arr) {
if (store.getCount() >= 10) break;
RecentBook book;
@@ -326,6 +335,8 @@ bool JsonSettingsIO::loadRecentBooks(RecentBooksStore& store, const char* json)
book.title = obj["title"] | std::string("");
book.author = obj["author"] | std::string("");
book.coverBmpPath = obj["coverBmpPath"] | std::string("");
book.embeddedStyleOverride = clampInt8(obj["embeddedStyleOverride"] | -1, -1, 1, -1);
book.imageRenderingOverride = clampInt8(obj["imageRenderingOverride"] | -1, -1, 2, -1);
store.recentBooks.push_back(book);
}