From b7d227a2cf339ca17bbd93b05b3eec79f3c32e74 Mon Sep 17 00:00:00 2001 From: hius07 <62179190+hius07@users.noreply.github.com> Date: Tue, 28 Oct 2025 08:27:39 +0200 Subject: [PATCH] Status bar fixes (#14518) --- frontend/apps/reader/modules/readerfooter.lua | 50 ++++++++++++++++--- frontend/ui/widget/pagebrowserwidget.lua | 1 + 2 files changed, 44 insertions(+), 7 deletions(-) diff --git a/frontend/apps/reader/modules/readerfooter.lua b/frontend/apps/reader/modules/readerfooter.lua index cb2e37a75..14b78ef97 100644 --- a/frontend/apps/reader/modules/readerfooter.lua +++ b/frontend/apps/reader/modules/readerfooter.lua @@ -2116,14 +2116,10 @@ end function ReaderFooter:onUpdateFooter(force_repaint, full_repaint) if type(self.pageno) ~= "number" then return end + if self.progress_bar.initial_pos_marker then + self:updateProgressBarInitialPercentage() + end if self.settings.chapter_progress_bar then - if self.progress_bar.initial_pos_marker then - if self.ui.toc:getNextChapter(self.pageno) == self.ui.toc:getNextChapter(self.initial_pageno) then - self.progress_bar.initial_percentage = self:getChapterProgress(true, self.initial_pageno) - else -- initial position is not in the current chapter - self.progress_bar.initial_percentage = -1 -- do not draw initial position marker - end - end self.progress_bar:setPercentage(self:getChapterProgress(true)) else self.progress_bar:setPercentage(self:getBookProgress()) @@ -2408,6 +2404,7 @@ function ReaderFooter:onToggleChapterProgressBar() self:setTocMarkers() if self.progress_bar.initial_pos_marker and not self.settings.chapter_progress_bar then self.progress_bar.initial_percentage = self.initial_pageno / self.pages + -- initial marker position in the chapter progress bar is handled in onUpdateFooter end self:refreshFooter(true) end @@ -2419,6 +2416,45 @@ function ReaderFooter:invertProgressBar(invert_direction) end end +function ReaderFooter:updateProgressBarInitialPercentage() + -- If the progress bar shows the flow progress or the chapter progress, + -- the initial position marker may be out of the progress bar pages interval. + -- In that case set initial percentage to -1 to not draw the marker. + if self.ui.document:hasHiddenFlows() then + local initial_flow = self.ui.document:getPageFlow(self.initial_pageno) + local current_flow = self.ui.document:getPageFlow(self.pageno) + if initial_flow == current_flow then + if self.settings.chapter_progress_bar then + if initial_flow == 0 then -- in chapter progress bar, show initial marker for the main flow only + local initial_next_chapter = self.ui.toc:getNextChapter(self.initial_pageno) + local current_next_chapter = self.ui.toc:getNextChapter(self.pageno) + if initial_next_chapter == current_next_chapter then + self.progress_bar.initial_percentage = self:getChapterProgress(true, self.initial_pageno) + else + self.progress_bar.initial_percentage = -1 + end + else + self.progress_bar.initial_percentage = -1 + end + else + local page = self.ui.document:getPageNumberInFlow(self.initial_pageno) + local pages = self.ui.document:getTotalPagesInFlow(initial_flow) + self.progress_bar.initial_percentage = page / pages + end + else + self.progress_bar.initial_percentage = -1 + end + elseif self.settings.chapter_progress_bar then + local initial_next_chapter = self.ui.toc:getNextChapter(self.initial_pageno) + local current_next_chapter = self.ui.toc:getNextChapter(self.pageno) + if initial_next_chapter == current_next_chapter then + self.progress_bar.initial_percentage = self:getChapterProgress(true, self.initial_pageno) + else + self.progress_bar.initial_percentage = -1 + end + end +end + function ReaderFooter:getBookProgress() if self.ui.document:hasHiddenFlows() then local flow = self.ui.document:getPageFlow(self.pageno) diff --git a/frontend/ui/widget/pagebrowserwidget.lua b/frontend/ui/widget/pagebrowserwidget.lua index cf99e936d..7f2686a04 100644 --- a/frontend/ui/widget/pagebrowserwidget.lua +++ b/frontend/ui/widget/pagebrowserwidget.lua @@ -1231,6 +1231,7 @@ function PageBrowserWidget:onClose(close_all_parents) -- As we're getting back to Reader, update the footer and the dogear state -- (we may have toggled bookmark for current page) and do a full flashing -- refresh to remove any ghost trace of thumbnails or black page slots + self.ui.view.footer:setTocMarkers(true) UIManager:broadcastEvent(Event:new("UpdateFooter")) self.ui.bookmark:onPageUpdate(self.ui:getCurrentPage()) UIManager:setDirty(self.ui.dialog, "full")