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.
pull/7255/head
poire-z 3 years ago committed by GitHub
parent 893026a2ef
commit c7e97ca3cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -156,18 +156,19 @@ function ReaderHighlight:init()
end
-- Links
if self.selected_link ~= nil then
self:addToHighlightDialog("10_follow_link", function(_self)
return {
text = _("Follow Link"),
callback = function()
local link = _self.selected_link.link or _self.selected_link
_self.ui.link:onGotoLink(link)
_self:onClose()
end,
}
end)
end
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)
_self:onClose()
end,
}
end)
self.ui:registerPostInitCallback(function()
self.ui.menu:registerToMainMenu(self)
@ -657,11 +658,14 @@ function ReaderHighlight:onShowHighlightMenu()
local columns = 2
for idx, fn_button in ffiUtil.orderedPairs(self._highlight_buttons) do
if #highlight_buttons[#highlight_buttons] >= columns then
table.insert(highlight_buttons, {})
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], button)
logger.dbg("ReaderHighlight", idx..": line "..#highlight_buttons..", col "..#highlight_buttons[#highlight_buttons])
end
table.insert(highlight_buttons[#highlight_buttons], fn_button(self))
logger.dbg("ReaderHighlight", idx..": line "..#highlight_buttons..", col "..#highlight_buttons[#highlight_buttons])
end
self.highlight_dialog = ButtonDialog:new{

Loading…
Cancel
Save