QuickMenu: keep open on apply (#11135)

reviewable/pr11165/r1^2
hius07 5 months ago committed by GitHub
parent 82e7ebd6df
commit f6fb35fd98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -945,6 +945,7 @@ function Dispatcher:addSubMenu(caller, menu, location, settings)
{"rolling", _("Reflowable documents (epub, fb2, txt…)")},
{"paging", _("Fixed layout documents (pdf, djvu, pics…)")},
}
menu.max_per_page = 1 + #section_list -- settings in page 2
for _, section in ipairs(section_list) do
local submenu = {}
Dispatcher:_addItem(caller, submenu, location, settings, section[1])
@ -1020,6 +1021,31 @@ function Dispatcher:addSubMenu(caller, menu, location, settings)
end
end,
})
table.insert(menu, {
text = _("Keep QuickMenu open"),
checked_func = function()
return location[settings] ~= nil
and location[settings].settings ~= nil
and location[settings].settings.keep_open_on_apply
end,
callback = function()
if location[settings] then
if location[settings].settings then
if location[settings].settings.keep_open_on_apply then
location[settings].settings.keep_open_on_apply = nil
if next(location[settings].settings) == nil then
location[settings].settings = nil
end
else
location[settings].settings.keep_open_on_apply = true
end
else
location[settings].settings = {["keep_open_on_apply"] = true}
end
caller.updated = true
end
end,
})
end
function Dispatcher:isActionEnabled(action)
@ -1039,6 +1065,8 @@ function Dispatcher:isActionEnabled(action)
end
function Dispatcher:_showAsMenu(settings, exec_props)
local title = settings.settings.name or _("QuickMenu")
local keep_open_on_apply = settings.settings.keep_open_on_apply
local display_list = Dispatcher:getDisplayList(settings)
local quickmenu
local buttons = {}
@ -1065,6 +1093,10 @@ function Dispatcher:_showAsMenu(settings, exec_props)
callback = function()
UIManager:close(quickmenu)
Dispatcher:execute({[v.key] = settings[v.key]})
if keep_open_on_apply and not util.stringStartsWith(v.key, "touch_input") then
quickmenu:setTitle(title)
UIManager:show(quickmenu)
end
end,
hold_callback = function()
if v.key:sub(1, 13) == "profile_exec_" then
@ -1076,7 +1108,7 @@ function Dispatcher:_showAsMenu(settings, exec_props)
end
local ButtonDialog = require("ui/widget/buttondialog")
quickmenu = ButtonDialog:new{
title = settings.settings.name or _("QuickMenu"),
title = title,
title_align = "center",
shrink_unneeded_width = true,
shrink_min_width = math.floor(0.6 * Screen:getWidth()),

@ -244,6 +244,7 @@ function Gestures:genMenu(ges)
end,
})
Dispatcher:addSubMenu(self, sub_items, self.gestures, ges)
sub_items.max_per_page = nil -- restore default, settings in page 2
table.insert(sub_items, {
text = _("Anchor QuickMenu to gesture position"),
checked_func = function()

Loading…
Cancel
Save