2
0
mirror of https://github.com/koreader/koreader synced 2024-10-31 21:20:20 +00:00

Highlight dialog: fix 'Follow Link' button not shown (#7250)

Since 7bd59330: some checks can't be done at init(),
and have to be done at onShowHighlightMenu() time.
This commit is contained in:
poire-z 2021-02-06 16:59:09 +01:00 committed by GitHub
parent 893026a2ef
commit c7e97ca3cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -156,10 +156,12 @@ function ReaderHighlight:init()
end
-- Links
if self.selected_link ~= nil then
self:addToHighlightDialog("10_follow_link", function(_self)
return {
text = _("Follow Link"),
show_in_highlight_dialog_func = function()
return _self.selected_link ~= nil
end,
callback = function()
local link = _self.selected_link.link or _self.selected_link
_self.ui.link:onGotoLink(link)
@ -167,7 +169,6 @@ function ReaderHighlight:init()
end,
}
end)
end
self.ui:registerPostInitCallback(function()
self.ui.menu:registerToMainMenu(self)
@ -657,12 +658,15 @@ function ReaderHighlight:onShowHighlightMenu()
local columns = 2
for idx, fn_button in ffiUtil.orderedPairs(self._highlight_buttons) do
local button = fn_button(self)
if not button.show_in_highlight_dialog_func or button.show_in_highlight_dialog_func() then
if #highlight_buttons[#highlight_buttons] >= columns then
table.insert(highlight_buttons, {})
end
table.insert(highlight_buttons[#highlight_buttons], fn_button(self))
table.insert(highlight_buttons[#highlight_buttons], button)
logger.dbg("ReaderHighlight", idx..": line "..#highlight_buttons..", col "..#highlight_buttons[#highlight_buttons])
end
end
self.highlight_dialog = ButtonDialog:new{
buttons = highlight_buttons,