readerfooter(fix): avoid setting mini footer to invisible when full progress bar is on

Our previous assumption is user will only choose between full or min
bar. The does not hold anymore as many more info has been added to the
mini bar and sometimes user might want to have both of them on. This
patch makes the reader behavior consistent when both bars are set to be
on for a document.
This commit is contained in:
Qingping Hou
2016-07-23 17:57:29 -07:00
parent 06bd4d7afc
commit 1c5543358c
3 changed files with 32 additions and 4 deletions

View File

@@ -314,7 +314,7 @@ function ReaderFooter:updateFooterPos()
end
-- updateFooterText will start as a noop. After onReaderReady event is
-- received, it will initialized as _updateFooterText
-- received, it will initialized as _updateFooterText below
function ReaderFooter:updateFooterText()
end
@@ -484,7 +484,12 @@ function ReaderFooter:onHoldFooter(arg, ges)
end
function ReaderFooter:onSetStatusLine(status_line)
self.view.footer_visible = (status_line == 1)
-- 1 is min progress bar while 0 is full cre header progress bar
if status_line == 1 then
self.view.footer_visible = (self.mode ~= MODE.off)
else
self:applyFooterMode(MODE.off)
end
self.ui.document:setStatusLineProp(status_line)
self.ui:handleEvent(Event:new("UpdatePos"))
end

View File

@@ -643,8 +643,7 @@ function ReaderView:onReadSettings(config)
end
self.state.gamma = config:readSetting("gamma") or DGLOBALGAMMA
local full_screen = config:readSetting("kopt_full_screen") or self.document.configurable.full_screen
local status_line = config:readSetting("copt_status_line") or self.document.configurable.status_line
if full_screen == 0 or status_line == 0 then
if full_screen == 0 then
self.footer_visible = false
end
self:resetLayout()

View File

@@ -315,4 +315,28 @@ describe("Readerfooter module", function()
end
assert.is.same(0, found)
end)
it("should toggle between full and min progress bar for cre documents", function()
local sample_txt = "spec/front/unit/data/sample.txt"
local readerui = ReaderUI:new{
document = DocumentRegistry:openDocument(sample_txt),
}
local footer = readerui.view.footer
footer:applyFooterMode(0)
assert.is.same(0, footer.mode)
assert.falsy(readerui.view.footer_visible)
readerui.view.footer:onSetStatusLine(1)
assert.is.same(0, footer.mode)
assert.falsy(readerui.view.footer_visible)
footer.mode = 1
readerui.view.footer:onSetStatusLine(1)
assert.is.same(1, footer.mode)
assert.truthy(readerui.view.footer_visible)
readerui.view.footer:onSetStatusLine(0)
assert.is.same(0, footer.mode)
assert.falsy(readerui.view.footer_visible)
end)
end)