ReaderFooter: fix minor issues with pages left & chapter progress

When using Reference page numbers, "Pages left" was showing the
same info as "Current page", because Reference pages, being strings,
couldn't be used for arithmetics. But we can just count the number
of items left in the Reference pages array of strings.

Also fix edge case with "page progress" with hidden flow when
we are before the first chapter with a hidden flow before.
This commit is contained in:
poire-z
2024-05-22 21:25:22 +02:00
parent 20d8a5c313
commit 54a0cdd737
2 changed files with 14 additions and 5 deletions

View File

@@ -265,9 +265,12 @@ local footerTextGeneratorMap = {
if footer.pageno then
if footer.ui.pagemap and footer.ui.pagemap:wantsPageLabels() then
-- (Page labels might not be numbers)
return ("%s %s / %s"):format(prefix,
footer.ui.pagemap:getCurrentPageLabel(true),
footer.ui.pagemap:getLastPageLabel(true))
local label, idx, count = footer.ui.pagemap:getCurrentPageLabel(false) -- luacheck: no unused
local remaining = count - idx
if footer.settings.pages_left_includes_current_page then
remaining = remaining + 1
end
return ("%s %s / %s"):format(prefix, remaining, footer.ui.pagemap:getLastPageLabel(true))
end
if footer.ui.document:hasHiddenFlows() then
-- i.e., if we are hiding non-linear fragments and there's anything to hide,
@@ -2488,6 +2491,9 @@ function ReaderFooter:getChapterProgress(get_percentage, pageno)
current = current + 1
else
current = pageno
if self.ui.document:hasHiddenFlows() then
current = self.ui.document:getPageNumberInFlow(pageno)
end
end
local total = self.ui.toc:getChapterPageCount(pageno) or self.pages
if get_percentage then