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

[feat] GestureManager: Implement action to change highlight style using gesture manager (#4936)

This commit is contained in:
Galunid 2019-04-18 06:12:38 -04:00 committed by Frans de Jonge
parent c053e48526
commit 9759ffa381
2 changed files with 20 additions and 0 deletions

View File

@ -84,6 +84,7 @@ local action_strings = {
show_plus_menu = _("Show plus menu"), show_plus_menu = _("Show plus menu"),
folder_shortcuts = _("Folder shortcuts"), folder_shortcuts = _("Folder shortcuts"),
cycle_highlight_action = _("Cycle highlight action"), cycle_highlight_action = _("Cycle highlight action"),
cycle_highlight_style = _("Cycle highlight style"),
wallabag_download = _("Wallabag retrieval"), wallabag_download = _("Wallabag retrieval"),
} }
@ -488,6 +489,7 @@ function ReaderGesture:buildMenu(ges, default)
{"zoom_content", not self.is_docless}, {"zoom_content", not self.is_docless},
{"zoom_page", not self.is_docless, true}, {"zoom_page", not self.is_docless, true},
{"cycle_highlight_action", not self.is_docless}, {"cycle_highlight_action", not self.is_docless},
{"cycle_highlight_style", not self.is_docless},
{"wallabag_download", self.ui.wallabag ~= nil}, {"wallabag_download", self.ui.wallabag ~= nil},
} }
local return_menu = {} local return_menu = {}
@ -1049,6 +1051,8 @@ function ReaderGesture:gestureAction(action, ges)
self.ui:handleEvent(Event:new("SynchronizeWallabag")) self.ui:handleEvent(Event:new("SynchronizeWallabag"))
elseif action == "cycle_highlight_action" then elseif action == "cycle_highlight_action" then
self.ui:handleEvent(Event:new("CycleHighlightAction")) self.ui:handleEvent(Event:new("CycleHighlightAction"))
elseif action == "cycle_highlight_style" then
self.ui:handleEvent(Event:new("CycleHighlightStyle"))
end end
return true return true
end end

View File

@ -870,6 +870,22 @@ function ReaderHighlight:onCycleHighlightAction()
timeout = 1, timeout = 1,
}) })
end end
return true
end
function ReaderHighlight:onCycleHighlightStyle()
local next_actions = {
lighten = "underscore",
underscore = "invert",
invert = "lighten"
}
self.view.highlight.saved_drawer = next_actions[self.view.highlight.saved_drawer]
self.ui.doc_settings:saveSetting("highlight_drawer", self.view.highlight.saved_drawer)
UIManager:show(Notification:new{
text = T(_("Default highlight style changed to '%1'."), self.view.highlight.saved_drawer),
timeout = 1,
})
return true
end end
function ReaderHighlight:highlightFromHoldPos() function ReaderHighlight:highlightFromHoldPos()