Files
crosspoint-reader-mod/src/RecentBooksStore.h
cottongin a1ac11ab51 feat: port upstream PRs #852, #965, #972, #971, #977, #975
Port 6 upstream PRs (PR #939 was already ported):

- #852: Complete HalPowerManager with RAII Lock class, WiFi check in
  setPowerSaving, skipLoopDelay overrides for ClearCache/OtaUpdate,
  and power lock in Activity render task loops
- #965: Fix paragraph formatting inside list items by tracking
  listItemUntilDepth to prevent unwanted line breaks
- #972: Micro-optimizations: std::move in insertFont, const ref for
  getDataFromBook parameter
- #971: Remove redundant hasPrintableChars pre-rendering pass from
  EpdFont, EpdFontFamily, and GfxRenderer
- #977: Skip unsupported image formats before extraction, add
  PARSE_BUFFER_SIZE constant and chapter parse timing
- #975: Fix UITheme memory leak by replacing raw pointer with
  std::unique_ptr for currentTheme

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-18 15:45:06 -05:00

50 lines
1.4 KiB
C++

#pragma once
#include <string>
#include <vector>
struct RecentBook {
std::string path;
std::string title;
std::string author;
std::string coverBmpPath;
bool operator==(const RecentBook& other) const { return path == other.path; }
};
class RecentBooksStore {
// Static instance
static RecentBooksStore instance;
std::vector<RecentBook> recentBooks;
public:
~RecentBooksStore() = default;
// Get singleton instance
static RecentBooksStore& getInstance() { return instance; }
// Add a book to the recent list (moves to front if already exists)
void addBook(const std::string& path, const std::string& title, const std::string& author,
const std::string& coverBmpPath);
void updateBook(const std::string& path, const std::string& title, const std::string& author,
const std::string& coverBmpPath);
// Remove a book from the recent list by path
void removeBook(const std::string& path);
// Get the list of recent books (most recent first)
const std::vector<RecentBook>& getBooks() const { return recentBooks; }
// Get the count of recent books
int getCount() const { return static_cast<int>(recentBooks.size()); }
bool saveToFile() const;
bool loadFromFile();
RecentBook getDataFromBook(const std::string& path) const;
};
// Helper macro to access recent books store
#define RECENT_BOOKS RecentBooksStore::getInstance()