Skip to content

Commit

Permalink
[Gesture manager] Add toggle default highlight action
Browse files Browse the repository at this point in the history
  • Loading branch information
galunid committed Mar 14, 2019
1 parent 766b199 commit b8eb22d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
6 changes: 4 additions & 2 deletions frontend/apps/reader/modules/readergesture.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
}

Expand Down Expand Up @@ -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 = {}
Expand Down Expand Up @@ -786,6 +786,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("ToggleHighlightAction"))
end
return true
end
Expand Down
23 changes: 23 additions & 0 deletions frontend/apps/reader/modules/readerhighlight.lua
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,29 @@ function ReaderHighlight:onHoldRelease()
return true
end

function ReaderHighlight:onToggleHighlightAction()
local 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(InfoMessage:new{
text = _("Default highlight action changed to highlight"),
timeout = 1,
})
else
local next_action = actions[current_action]
G_reader_settings:saveSetting("default_highlight_action", next_action)
UIManager:show(InfoMessage:new{
text = _("Default highlight action changed to " .. (next_action or "default")),
timeout = 1,
})
end
end

function ReaderHighlight:highlightFromHoldPos()
if self.hold_pos then
if not self.selected_text then
Expand Down
1 change: 1 addition & 0 deletions plugins/coverbrowser.koplugin/bookinfomanager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,7 @@ Do you want to prune cache of removed books?]]
},
text_widget
})
info.movable[1][1]._size = nil -- reset HorizontalGroup size
info.movable:setMovedOffset(orig_moved_offset)
info:paintTo(Screen.bb, 0,0)
local d = info.movable[1].dimen
Expand Down
9 changes: 7 additions & 2 deletions plugins/coverbrowser.koplugin/covermenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,13 @@ function CoverMenu:updateItems(select_number)
self:_updateItemsBuildUI()

-- Set the local variables with the things we know
current_path = self.path
current_cover_specs = self.cover_specs
-- These are used only by extractBooksInDirectory(), which should
-- use the cover_specs set for FileBrowser, and not those from History.
-- Hopefully, we get self.path=nil when called fro History
if self.path then
current_path = self.path
current_cover_specs = self.cover_specs
end

-- As done in Menu:updateItems()
self:updatePageInfo(select_number)
Expand Down

0 comments on commit b8eb22d

Please sign in to comment.