ReaderBack: allow for disabling back history (#3862)

Mostly useful for developers for quick launch & quit of
the emulator.
This commit is contained in:
poire-z
2018-04-12 08:41:59 +02:00
committed by Frans de Jonge
parent dd8e08fd00
commit f63975d9db

View File

@@ -9,6 +9,9 @@ local ReaderBack = EventListener:new{
location_stack = {},
-- a limit not intended to be a practical limit but just a failsafe
max_stack = 5000,
-- allow for disabling back history, and having Back key
-- quit immediately (useful for some developers)
disabled = G_reader_settings:isFalse("enable_back_history"),
}
function ReaderBack:init()
@@ -48,11 +51,13 @@ end
-- Scroll mode crengine
function ReaderBack:onPosUpdate()
if self.disabled then return end
self:addCurrentLocationToStack()
end
-- Paged media
function ReaderBack:onPageUpdate()
if self.disabled then return end
self:addCurrentLocationToStack()
end
@@ -64,7 +69,9 @@ end
function ReaderBack:onBack()
local location_stack = self.location_stack
if #location_stack > 1 then
if self.disabled then
self.ui:handleEvent(Event:new("Close"))
elseif #location_stack > 1 then
local saved_location = table.remove(location_stack)
if saved_location then