mirror of
https://github.com/koreader/koreader.git
synced 2025-12-13 20:36:53 +01:00
ReaderBack: allow for disabling back history (#3862)
Mostly useful for developers for quick launch & quit of the emulator.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user