Keep some menus open when Tap or Hold (#4189)

TouchMenu: added options to menu items with the following defaults:
    keep_menu_open = false
    hold_keep_menu_open = true
So, default for Tap callback is to close menu, and for Hold callback
to keep menu open.
In both cases, provide the TouchMenu instance as the 1st argument to
the callback functions (instead of a refresh_menu_func I added in #3941)
so the callback can do more things, like closing, refreshing,
changing menu items text and re-ordering...

ReaderZooming: show symbol for default (like it was done for
ReaderFont, ReaderHyphenation...)
TextEditor plugin: update the previously opened files list in real
time, so the menu can be kept open and used as the TextEditor main
interface.
SSH plugin: keep menu open and update the Start/Stop state in real time
ReadTimer plugin: tried to do what feels right (but I don't use it)

Also remove forgotten cp in the move/paste file code
This commit is contained in:
poire-z
2018-09-04 23:55:58 +02:00
committed by GitHub
parent 4320359b25
commit 850be52177
33 changed files with 214 additions and 99 deletions

View File

@@ -68,9 +68,8 @@ function ReaderFont:init()
callback = function()
self:setFont(v)
end,
hold_may_update_menu = true,
hold_callback = function(refresh_menu_func)
self:makeDefault(v, refresh_menu_func)
hold_callback = function(touchmenu_instance)
self:makeDefault(v, touchmenu_instance)
end,
checked_func = function()
return v == self.font_face
@@ -310,14 +309,14 @@ function ReaderFont:setFont(face)
end
end
function ReaderFont:makeDefault(face, refresh_menu_func)
function ReaderFont:makeDefault(face, touchmenu_instance)
if face then
UIManager:show(MultiConfirmBox:new{
text = T( _("Would you like %1 to be used as the default font (★), or the fallback font (<28>)?\n\nCharacters not found in the active font are shown in the fallback font instead."), face),
choice1_text = _("Default"),
choice1_callback = function()
G_reader_settings:saveSetting("cre_font", face)
if refresh_menu_func then refresh_menu_func() end
if touchmenu_instance then touchmenu_instance:updateItems() end
end,
choice2_text = _("Fallback"),
choice2_callback = function()
@@ -325,7 +324,7 @@ function ReaderFont:makeDefault(face, refresh_menu_func)
G_reader_settings:saveSetting("fallback_font", face)
self.ui:handleEvent(Event:new("UpdatePos"))
end
if refresh_menu_func then refresh_menu_func() end
if touchmenu_instance then touchmenu_instance:updateItems() end
end,
})
end