Adds choice of default action when highlighting (#4486)

New menu Document > Highlight action.
pull/4491/head
Galunid 5 years ago committed by poire-z
parent b15c2ed0c5
commit 0678d75438

@ -520,8 +520,10 @@ function ReaderHighlight:onHoldRelease()
self:onHoldPan(nil, {pos=self.hold_ges_pos})
end
end
if self.selected_text then
logger.dbg("show highlight dialog")
local default_highlight_action = G_reader_settings:readSetting("default_highlight_action")
if not default_highlight_action then
local highlight_buttons = {
{
{
@ -613,6 +615,16 @@ function ReaderHighlight:onHoldRelease()
tap_close_callback = function() self:handleEvent(Event:new("Tap")) end,
}
UIManager:show(self.highlight_dialog)
elseif default_highlight_action == "highlight" then
self:saveHighlight()
self:onClose()
elseif default_highlight_action == "translate" then
self:translate(self.selected_text)
self:onClose()
elseif default_highlight_action == "wikipedia" then
self:lookupWikipedia()
self:onClose()
end
elseif self.selected_word then
self:lookup(self.selected_word, self.selected_link)
self.selected_word = nil

@ -337,6 +337,47 @@ common_settings.document = {
}
},
{
text = _("Highlight action"),
sub_item_table = {
{
text = _("Ask with popup dialog"),
checked_func = function()
return G_reader_settings:nilOrFalse("default_highlight_action")
end,
callback = function()
G_reader_settings:saveSetting("default_highlight_action", nil)
end,
},
{
text = _("Highlight"),
checked_func = function()
return G_reader_settings:readSetting("default_highlight_action") == "highlight"
end,
callback = function()
G_reader_settings:saveSetting("default_highlight_action", "highlight")
end,
},
{
text = _("Translate"),
checked_func = function()
return G_reader_settings:readSetting("default_highlight_action") == "translate"
end,
callback = function()
G_reader_settings:saveSetting("default_highlight_action", "translate")
end,
},
{
text = _("Wikipedia"),
checked_func = function()
return G_reader_settings:readSetting("default_highlight_action") == "wikipedia"
end,
callback = function()
G_reader_settings:saveSetting("default_highlight_action", "wikipedia")
end,
},
}
},
},
}
common_settings.language = Language:getLangMenuTable()

Loading…
Cancel
Save