mirror of
https://github.com/koreader/koreader
synced 2024-10-31 21:20:20 +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:
parent
930731d67c
commit
f637555d93
@ -76,7 +76,7 @@ local action_strings = {
|
||||
|
||||
folder_up = _("Folder up"),
|
||||
folder_shortcuts = _("Folder shortcuts"),
|
||||
|
||||
toggle_highlight_action = _("Toggle highlight action"),
|
||||
wallabag_download = _("Wallabag retrieval"),
|
||||
}
|
||||
|
||||
@ -358,7 +358,7 @@ function ReaderGesture:buildMenu(ges, default)
|
||||
{"zoom_column", not self.is_docless},
|
||||
{"zoom_content", not self.is_docless},
|
||||
{"zoom_page", not self.is_docless, true},
|
||||
|
||||
{"toggle_highlight_action", not self.is_docless},
|
||||
{"wallabag_download", self.ui.wallabag ~= nil},
|
||||
}
|
||||
local return_menu = {}
|
||||
@ -796,6 +796,8 @@ function ReaderGesture:gestureAction(action, ges)
|
||||
self.ui:handleEvent(Event:new("SetZoomMode", "page"))
|
||||
elseif action == "wallabag_download" then
|
||||
self.ui:handleEvent(Event:new("SynchronizeWallabag"))
|
||||
elseif action == "toggle_highlight_action" then
|
||||
self.ui:handleEvent(Event:new("CycleHighlightAction"))
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user