From 9759ffa3812cb457bf95fbc05e78981c40c47e64 Mon Sep 17 00:00:00 2001 From: Galunid Date: Thu, 18 Apr 2019 06:12:38 -0400 Subject: [PATCH] [feat] GestureManager: Implement action to change highlight style using gesture manager (#4936) --- frontend/apps/reader/modules/readergesture.lua | 4 ++++ frontend/apps/reader/modules/readerhighlight.lua | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/frontend/apps/reader/modules/readergesture.lua b/frontend/apps/reader/modules/readergesture.lua index 356afc4dd..b62702891 100644 --- a/frontend/apps/reader/modules/readergesture.lua +++ b/frontend/apps/reader/modules/readergesture.lua @@ -84,6 +84,7 @@ local action_strings = { show_plus_menu = _("Show plus menu"), folder_shortcuts = _("Folder shortcuts"), cycle_highlight_action = _("Cycle highlight action"), + cycle_highlight_style = _("Cycle highlight style"), wallabag_download = _("Wallabag retrieval"), } @@ -488,6 +489,7 @@ function ReaderGesture:buildMenu(ges, default) {"zoom_content", not self.is_docless}, {"zoom_page", not self.is_docless, true}, {"cycle_highlight_action", not self.is_docless}, + {"cycle_highlight_style", not self.is_docless}, {"wallabag_download", self.ui.wallabag ~= nil}, } local return_menu = {} @@ -1049,6 +1051,8 @@ function ReaderGesture:gestureAction(action, ges) self.ui:handleEvent(Event:new("SynchronizeWallabag")) elseif action == "cycle_highlight_action" then self.ui:handleEvent(Event:new("CycleHighlightAction")) + elseif action == "cycle_highlight_style" then + self.ui:handleEvent(Event:new("CycleHighlightStyle")) end return true end diff --git a/frontend/apps/reader/modules/readerhighlight.lua b/frontend/apps/reader/modules/readerhighlight.lua index 0d743b340..6fd6fad5a 100644 --- a/frontend/apps/reader/modules/readerhighlight.lua +++ b/frontend/apps/reader/modules/readerhighlight.lua @@ -870,6 +870,22 @@ function ReaderHighlight:onCycleHighlightAction() timeout = 1, }) 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 function ReaderHighlight:highlightFromHoldPos()