ReaderGoto: adds Go to % (#8395)

reviewable/pr8432/r1
hius07 3 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 else
input_hint = T("@%1 (1 - %2)", curr_page, self.document:getPageCount()) input_hint = T("@%1 (1 - %2)", curr_page, self.document:getPageCount())
end end
input_hint = input_hint .. string.format(" %.2f%%", curr_page / self.document:getPageCount() * 100)
self.goto_dialog = InputDialog:new{ self.goto_dialog = InputDialog:new{
title = _("Enter page number"), title = _("Enter page number or percentage"),
input_hint = input_hint, input_hint = input_hint,
description = self.document:hasHiddenFlows() and description = self.document:hasHiddenFlows() and
_([[ _([[
@ -55,36 +56,42 @@ x for an absolute page number
buttons = { buttons = {
{ {
{ {
text = _("Cancel"), text = _("Skim"),
callback = function() callback = function()
self:close() 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, end,
}, },
{ {
text = _("Go to page"), text = _("Go to %"),
is_enter_default = true,
callback = function() callback = function()
self:gotoPage() self:gotoPercent()
end, end,
} }
}, },
{ {
{ {
text = _("Skim document"), text = _("Cancel"),
callback = function() callback = function()
self:close() 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, end,
}, },
{
text = _("Go to page"),
is_enter_default = true,
callback = function()
self:gotoPage()
end,
}
}, },
}, },
input_type = "number", input_type = "number",
@ -161,6 +168,15 @@ function ReaderGoto:gotoPage()
end end
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() function ReaderGoto:onGoToBeginning()
local new_page = self.ui.document:getNextPage(0) local new_page = self.ui.document:getNextPage(0)
if new_page then if new_page then

Loading…
Cancel
Save