mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
[UX] Gesture manager: add action - cycle default highlight action (#4791)
Cf. https://github.com/koreader/koreader/issues/4727
This commit is contained in:
@@ -3,6 +3,7 @@ local ConfirmBox = require("ui/widget/confirmbox")
|
||||
local Device = require("device")
|
||||
local Event = require("ui/event")
|
||||
local InfoMessage = require("ui/widget/infomessage")
|
||||
local Notification = require("ui/widget/notification")
|
||||
local InputContainer = require("ui/widget/container/inputcontainer")
|
||||
local TimeVal = require("ui/timeval")
|
||||
local Translator = require("ui/translator")
|
||||
@@ -843,6 +844,29 @@ function ReaderHighlight:onHoldRelease()
|
||||
return true
|
||||
end
|
||||
|
||||
function ReaderHighlight:onCycleHighlightAction()
|
||||
local next_actions = {
|
||||
highlight = "translate",
|
||||
translate = "wikipedia",
|
||||
wikipedia = nil
|
||||
}
|
||||
local current_action = G_reader_settings:readSetting("default_highlight_action")
|
||||
if not current_action then
|
||||
G_reader_settings:saveSetting("default_highlight_action", "highlight")
|
||||
UIManager:show(Notification:new{
|
||||
text = _("Default highlight action changed to 'highlight'."),
|
||||
timeout = 1,
|
||||
})
|
||||
else
|
||||
local next_action = next_actions[current_action]
|
||||
G_reader_settings:saveSetting("default_highlight_action", next_action)
|
||||
UIManager:show(Notification:new{
|
||||
text = T(_("Default highlight action changed to '%1'."), (next_action or "default")),
|
||||
timeout = 1,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
function ReaderHighlight:highlightFromHoldPos()
|
||||
if self.hold_pos then
|
||||
if not self.selected_text then
|
||||
|
||||
Reference in New Issue
Block a user