ReaderGoto: adds Go to % (#8395)

reviewable/pr8432/r1
hius07 2 years ago committed by GitHub
parent cdae66a661
commit e6d2c1cae6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -43,8 +43,9 @@ function ReaderGoto:onShowGotoDialog()
else
input_hint = T("@%1 (1 - %2)", curr_page, self.document:getPageCount())
end
input_hint = input_hint .. string.format(" %.2f%%", curr_page / self.document:getPageCount() * 100)
self.goto_dialog = InputDialog:new{
title = _("Enter page number"),
title = _("Enter page number or percentage"),
input_hint = input_hint,
description = self.document:hasHiddenFlows() and
_([[
@ -55,36 +56,42 @@ x for an absolute page number
buttons = {
{
{
text = _("Cancel"),
text = _("Skim"),
callback = function()
self:close()
self.skimto = SkimToWidget:new{
document = self.document,
ui = self.ui,
callback_switch_to_goto = function()
UIManager:close(self.skimto)
self:onShowGotoDialog()
end,
}
UIManager:show(self.skimto)
end,
},
{
text = _("Go to page"),
is_enter_default = true,
text = _("Go to %"),
callback = function()
self:gotoPage()
self:gotoPercent()
end,
}
},
{
{
text = _("Skim document"),
text = _("Cancel"),
callback = function()
self:close()
self.skimto = SkimToWidget:new{
document = self.document,
ui = self.ui,
callback_switch_to_goto = function()
UIManager:close(self.skimto)
self:onShowGotoDialog()
end,
}
UIManager:show(self.skimto)
end,
},
{
text = _("Go to page"),
is_enter_default = true,
callback = function()
self:gotoPage()
end,
}
},
},
input_type = "number",
@ -161,6 +168,15 @@ function ReaderGoto:gotoPage()
end
end
function ReaderGoto:gotoPercent()
local number = self.goto_dialog:getInputValue()
if number then
self.ui.link:addCurrentLocationToStack()
self.ui:handleEvent(Event:new("GotoPercent", number))
self:close()
end
end
function ReaderGoto:onGoToBeginning()
local new_page = self.ui.document:getNextPage(0)
if new_page then

Loading…
Cancel
Save