end of document: add go to beginning (#5814)

* ReaderGoto: goto beginning and end

* end of the document: add go to beginning
reviewable/pr5819/r1
yparitcher 4 years ago committed by GitHub
parent 80c1e5290c
commit a3173ec275
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -119,4 +119,19 @@ function ReaderGoto:gotoPage()
end
end
function ReaderGoto:onGoToBeginning()
self.ui.link:addCurrentLocationToStack()
self.ui:handleEvent(Event:new("GotoPage", 1))
return true
end
function ReaderGoto:onGoToEnd()
local endpage = self.document:getPageCount()
if endpage then
self.ui.link:addCurrentLocationToStack()
self.ui:handleEvent(Event:new("GotoPage", endpage))
end
return true
end
return ReaderGoto

@ -2,6 +2,7 @@ local BD = require("ui/bidi")
local BookStatusWidget = require("ui/widget/bookstatuswidget")
local ButtonDialogTitle = require("ui/widget/buttondialogtitle")
local Device = require("device")
local Event = require("ui/event")
local InfoMessage = require("ui/widget/infomessage")
local InputContainer = require("ui/widget/container/inputcontainer")
local UIManager = require("ui/uimanager")
@ -80,9 +81,9 @@ function ReaderStatus:onEndOfBook()
},
{
{
text = _("Delete file"),
text = _("Go to beginning"),
callback = function()
self:deleteFile(self.document.file, false)
self.ui:handleEvent(Event:new("GoToBeginning"))
UIManager:close(choose_action)
end,
},
@ -97,8 +98,9 @@ function ReaderStatus:onEndOfBook()
},
{
{
text = _("Cancel"),
text = _("Delete file"),
callback = function()
self:deleteFile(self.document.file, false)
UIManager:close(choose_action)
end,
},
@ -110,6 +112,14 @@ function ReaderStatus:onEndOfBook()
end,
},
},
{
{
text = _("Cancel"),
callback = function()
UIManager:close(choose_action)
end,
},
},
}
choose_action = ButtonDialogTitle:new{
title = _("You've reached the end of the document.\nWhat would you like to do?"),
@ -134,6 +144,8 @@ function ReaderStatus:onEndOfBook()
text = _("Could not open next file. Sort by last read date does not support this feature."),
})
end
elseif settings == "goto_beginning" then
self.ui:handleEvent(Event:new("GoToBeginning"))
elseif settings == "file_browser" then
self:openFileBrowser()
elseif settings == "mark_read" then

@ -504,6 +504,15 @@ common_settings.document = {
G_reader_settings:saveSetting("end_document_action", "next_file")
end,
},
{
text = _("Go to beginning"),
checked_func = function()
return G_reader_settings:readSetting("end_document_action") == "goto_beginning"
end,
callback = function()
G_reader_settings:saveSetting("end_document_action", "goto_beginning")
end,
},
{
text = _("Return to file browser"),
checked_func = function()

Loading…
Cancel
Save