Picking up some itsthisjutin ideas

This commit is contained in:
jpirnay
2026-04-19 19:03:43 +02:00
parent 174a08831d
commit d6292920d9
18 changed files with 337 additions and 41 deletions
+20 -2
View File
@@ -637,8 +637,26 @@ void EpubReaderActivity::launchKOReaderSync(const SyncLaunchMode mode) {
sync.spineIndex = currentSpineIndex;
sync.page = currentPage;
sync.totalPagesInSpine = totalPages;
sync.paragraphIndex = 0;
sync.hasParagraphIndex = false;
// Populate paragraph index and XHTML seek hint from section LUT if available.
if (section) {
if (const auto pIdx = section->getParagraphIndexForPage(static_cast<uint16_t>(currentPage))) {
sync.paragraphIndex = *pIdx;
sync.hasParagraphIndex = true;
if (const auto hint = section->getXhtmlByteOffsetForPage(static_cast<uint16_t>(currentPage))) {
sync.xhtmlSeekHint = *hint;
} else {
sync.xhtmlSeekHint = 0;
}
} else {
sync.paragraphIndex = 0;
sync.hasParagraphIndex = false;
sync.xhtmlSeekHint = 0;
}
} else {
sync.paragraphIndex = 0;
sync.hasParagraphIndex = false;
sync.xhtmlSeekHint = 0;
}
sync.intent = syncIntent;
sync.outcome = KOReaderSyncOutcomeState::PENDING;
sync.resultSpineIndex = 0;
@@ -651,8 +651,8 @@ bool KOReaderSyncActivity::computeLocalProgressAndChapter() {
return false;
}
CrossPointPosition localPos = {currentSpineIndex, currentPage, totalPagesInSpine, localParagraphIndex,
hasLocalParagraphIndex};
CrossPointPosition localPos = {currentSpineIndex, currentPage, totalPagesInSpine, localParagraphIndex,
hasLocalParagraphIndex, localXhtmlSeekHint};
localProgress = ProgressMapper::toKOReader(epub, localPos);
const int localTocIndex = epub->getTocIndexForSpineIndex(currentSpineIndex);
+3 -1
View File
@@ -34,7 +34,7 @@ class KOReaderSyncActivity final : public Activity {
public:
explicit KOReaderSyncActivity(GfxRenderer& renderer, MappedInputManager& mappedInput, const std::string& epubPath,
int currentSpineIndex, int currentPage, int totalPagesInSpine,
uint16_t paragraphIndex = 0, bool hasParagraphIndex = false,
uint16_t paragraphIndex = 0, bool hasParagraphIndex = false, uint32_t xhtmlSeekHint = 0,
KOReaderSyncIntentState syncIntent = KOReaderSyncIntentState::COMPARE)
: Activity("KOReaderSync", renderer, mappedInput),
epubPath(epubPath),
@@ -43,6 +43,7 @@ class KOReaderSyncActivity final : public Activity {
totalPagesInSpine(totalPagesInSpine),
localParagraphIndex(paragraphIndex),
hasLocalParagraphIndex(hasParagraphIndex),
localXhtmlSeekHint(xhtmlSeekHint),
syncIntent(syncIntent),
remoteProgress{},
remotePosition{},
@@ -75,6 +76,7 @@ class KOReaderSyncActivity final : public Activity {
int totalPagesInSpine;
uint16_t localParagraphIndex;
bool hasLocalParagraphIndex;
uint32_t localXhtmlSeekHint;
KOReaderSyncIntentState syncIntent = KOReaderSyncIntentState::COMPARE;
State state = WIFI_SELECTION;