Actions for Go to first/last bookmark (#10899)

reviewable/pr10904/r1
hius07 8 months ago committed by GitHub
parent 1f03e76aea
commit be125af949
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -470,8 +470,6 @@ function ReaderBookmark:onShowBookmark(match_table)
item_table = item_table, item_table = item_table,
is_borderless = true, is_borderless = true,
is_popout = false, is_popout = false,
width = Screen:getWidth(),
height = Screen:getHeight(),
items_per_page = items_per_page, items_per_page = items_per_page,
items_font_size = items_font_size, items_font_size = items_font_size,
multilines_show_more_text = multilines_show_more_text, multilines_show_more_text = multilines_show_more_text,
@ -1330,6 +1328,22 @@ function ReaderBookmark:onGotoPreviousBookmarkFromPage(add_current_location_to_s
return true return true
end end
function ReaderBookmark:onGotoFirstBookmark(add_current_location_to_stack)
if add_current_location_to_stack ~= false then -- nil or true
self.ui.link:addCurrentLocationToStack()
end
self:gotoBookmark(self:getFirstBookmarkedPageFromPage(self.ui:getCurrentPage()))
return true
end
function ReaderBookmark:onGotoLastBookmark(add_current_location_to_stack)
if add_current_location_to_stack ~= false then -- nil or true
self.ui.link:addCurrentLocationToStack()
end
self:gotoBookmark(self:getLastBookmarkedPageFromPage(self.ui:getCurrentPage()))
return true
end
function ReaderBookmark:getLatestBookmark() function ReaderBookmark:getLatestBookmark()
local latest_bookmark, latest_bookmark_idx local latest_bookmark, latest_bookmark_idx
local latest_bookmark_datetime = "0" local latest_bookmark_datetime = "0"

@ -28,12 +28,7 @@ function ReaderGoto:addToMainMenu(menu_items)
end end
function ReaderGoto:onShowGotoDialog() function ReaderGoto:onShowGotoDialog()
local curr_page local curr_page = self.ui:getCurrentPage()
if self.document.info.has_pages then
curr_page = self.ui.paging.current_page
else
curr_page = self.document:getCurrentPage()
end
local input_hint local input_hint
if self.ui.pagemap and self.ui.pagemap:wantsPageLabels() then if self.ui.pagemap and self.ui.pagemap:wantsPageLabels() then
input_hint = T("@%1 (%2 - %3)", self.ui.pagemap:getCurrentPageLabel(true), input_hint = T("@%1 (%2 - %3)", self.ui.pagemap:getCurrentPageLabel(true),
@ -58,16 +53,7 @@ x for an absolute page number
text = _("Skim"), text = _("Skim"),
callback = function() callback = function()
self:close() self:close()
self.skimto = SkimToWidget:new{ self:onShowSkimtoDialog()
document = self.document,
ui = self.ui,
callback_switch_to_goto = function()
UIManager:close(self.skimto)
self:onShowGotoDialog()
end,
}
UIManager:show(self.skimto)
end, end,
}, },
{ {

@ -135,7 +135,9 @@ local settingsList = {
skim = {category="none", event="ShowSkimtoDialog", title=_("Skim document"), reader=true}, skim = {category="none", event="ShowSkimtoDialog", title=_("Skim document"), reader=true},
prev_bookmark = {category="none", event="GotoPreviousBookmarkFromPage", title=_("Previous bookmark"), reader=true}, prev_bookmark = {category="none", event="GotoPreviousBookmarkFromPage", title=_("Previous bookmark"), reader=true},
next_bookmark = {category="none", event="GotoNextBookmarkFromPage", title=_("Next bookmark"), reader=true}, next_bookmark = {category="none", event="GotoNextBookmarkFromPage", title=_("Next bookmark"), reader=true},
latest_bookmark = {category="none", event="GoToLatestBookmark", title=_("Go to latest bookmark"), reader=true}, first_bookmark = {category="none", event="GotoFirstBookmark", title=_("First bookmark"), reader=true},
last_bookmark = {category="none", event="GotoLastBookmark", title=_("Last bookmark"), reader=true},
latest_bookmark = {category="none", event="GoToLatestBookmark", title=_("Latest bookmark"), reader=true, separator=true},
back = {category="none", event="Back", title=_("Back"), filemanager=true, reader=true}, back = {category="none", event="Back", title=_("Back"), filemanager=true, reader=true},
previous_location = {category="none", event="GoBackLink", arg=true, title=_("Back to previous location"), reader=true}, previous_location = {category="none", event="GoBackLink", arg=true, title=_("Back to previous location"), reader=true},
next_location = {category="none", event="GoForwardLink", arg=true, title=_("Forward to next location"), reader=true}, next_location = {category="none", event="GoForwardLink", arg=true, title=_("Forward to next location"), reader=true},
@ -331,6 +333,8 @@ local dispatcher_menu_order = {
"skim", "skim",
"prev_bookmark", "prev_bookmark",
"next_bookmark", "next_bookmark",
"first_bookmark",
"last_bookmark",
"latest_bookmark", "latest_bookmark",
"back", "back",
"previous_location", "previous_location",

@ -77,7 +77,6 @@ function SkimToWidget:init()
local button_minus = Button:new{ local button_minus = Button:new{
text = "-1", text = "-1",
radius = 0, radius = 0,
enabled = true,
width = button_width, width = button_width,
show_parent = self, show_parent = self,
vsync = true, vsync = true,
@ -88,7 +87,6 @@ function SkimToWidget:init()
local button_minus_ten = Button:new{ local button_minus_ten = Button:new{
text = "-10", text = "-10",
radius = 0, radius = 0,
enabled = true,
width = button_width, width = button_width,
show_parent = self, show_parent = self,
vsync = true, vsync = true,
@ -99,7 +97,6 @@ function SkimToWidget:init()
local button_plus = Button:new{ local button_plus = Button:new{
text = "+1", text = "+1",
radius = 0, radius = 0,
enabled = true,
width = button_width, width = button_width,
show_parent = self, show_parent = self,
vsync = true, vsync = true,
@ -110,7 +107,6 @@ function SkimToWidget:init()
local button_plus_ten = Button:new{ local button_plus_ten = Button:new{
text = "+10", text = "+10",
radius = 0, radius = 0,
enabled = true,
width = button_width, width = button_width,
show_parent = self, show_parent = self,
vsync = true, vsync = true,
@ -129,7 +125,6 @@ function SkimToWidget:init()
radius = 0, radius = 0,
padding = 0, padding = 0,
bordersize = 0, bordersize = 0,
enabled = true,
width = button_width, width = button_width,
show_parent = self, show_parent = self,
callback = function() callback = function()
@ -151,7 +146,6 @@ function SkimToWidget:init()
local button_chapter_next = Button:new{ local button_chapter_next = Button:new{
text = chapter_next_text, text = chapter_next_text,
radius = 0, radius = 0,
enabled = true,
width = button_width, width = button_width,
show_parent = self, show_parent = self,
vsync = true, vsync = true,
@ -168,7 +162,6 @@ function SkimToWidget:init()
local button_chapter_prev = Button:new{ local button_chapter_prev = Button:new{
text = chapter_prev_text, text = chapter_prev_text,
radius = 0, radius = 0,
enabled = true,
width = button_width, width = button_width,
show_parent = self, show_parent = self,
vsync = true, vsync = true,
@ -185,7 +178,6 @@ function SkimToWidget:init()
local button_bookmark_next = Button:new{ local button_bookmark_next = Button:new{
text = bookmark_next_text, text = bookmark_next_text,
radius = 0, radius = 0,
enabled = true,
width = button_width, width = button_width,
show_parent = self, show_parent = self,
vsync = true, vsync = true,
@ -193,14 +185,12 @@ function SkimToWidget:init()
self:goToByEvent("GotoNextBookmarkFromPage") self:goToByEvent("GotoNextBookmarkFromPage")
end, end,
hold_callback = function() hold_callback = function()
local page = self.ui.bookmark:getLastBookmarkedPageFromPage(self.ui:getCurrentPage()) self:goToByEvent("GotoLastBookmark")
self:goToBookmark(page)
end, end,
} }
local button_bookmark_prev = Button:new{ local button_bookmark_prev = Button:new{
text = bookmark_prev_text, text = bookmark_prev_text,
radius = 0, radius = 0,
enabled = true,
width = button_width, width = button_width,
show_parent = self, show_parent = self,
vsync = true, vsync = true,
@ -208,8 +198,7 @@ function SkimToWidget:init()
self:goToByEvent("GotoPreviousBookmarkFromPage") self:goToByEvent("GotoPreviousBookmarkFromPage")
end, end,
hold_callback = function() hold_callback = function()
local page = self.ui.bookmark:getFirstBookmarkedPageFromPage(self.ui:getCurrentPage()) self:goToByEvent("GotoFirstBookmark")
self:goToBookmark(page)
end, end,
} }
self.button_bookmark_toggle = Button:new{ self.button_bookmark_toggle = Button:new{
@ -217,7 +206,6 @@ function SkimToWidget:init()
return self.ui.view.dogear_visible and bookmark_enabled_text or bookmark_disabled_text return self.ui.view.dogear_visible and bookmark_enabled_text or bookmark_disabled_text
end, end,
radius = 0, radius = 0,
enabled = true,
width = button_width, width = button_width,
show_parent = self, show_parent = self,
callback = function() callback = function()
@ -353,23 +341,12 @@ function SkimToWidget:goToPage(page)
self:update() self:update()
end end
function SkimToWidget:goToBookmark(page)
if page then
self:addOriginToLocationStack()
self.ui.bookmark:gotoBookmark(page)
self.curr_page = self.ui:getCurrentPage()
self:update()
end
end
function SkimToWidget:goToByEvent(event_name) function SkimToWidget:goToByEvent(event_name)
if event_name then self:addOriginToLocationStack()
self:addOriginToLocationStack() self.ui:handleEvent(Event:new(event_name, false))
self.ui:handleEvent(Event:new(event_name, false)) -- add_current_location_to_stack=false, as we handled it here
-- add_current_location_to_stack=false, as we handled it here self.curr_page = self.ui:getCurrentPage()
self.curr_page = self.ui:getCurrentPage() self:update()
self:update()
end
end end
function SkimToWidget:onFirstRowKeyPress(percent) function SkimToWidget:onFirstRowKeyPress(percent)

Loading…
Cancel
Save