Plugins: adds PluginMenuInserter helper (#7419)

Allows user-plugins to register themselves
into "More tools" menu.
reviewable/pr7649/r1
Hzj_jie 3 years ago committed by GitHub
parent d082f795e6
commit 1a08f2cb69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,21 @@
local reader_order = require("ui/elements/reader_menu_order")
local filemanager_order = require("ui/elements/filemanager_menu_order")
-- A "hacky" way to update plugin menu items on-the-fly.
-- Use: require("plugins/insert_menu").add("my_plugin_menu_name")
-- This piece of logic / table is singleton in the KOReader process.
-- It provides a way to add a plugin into the "More Plugins" and is useful to
-- work with contrib/plugins which are not in the core logic of KOReader.
-- To avoid duplicating the menu item, caller is expected to call the add once
-- in the KOReader process, usually it's achieveable to rely on the "require"
-- function in lua.
local PluginMenuInserter = {}
function PluginMenuInserter.add(name)
table.insert(reader_order.more_tools, name)
table.insert(filemanager_order.more_tools, name)
end
return PluginMenuInserter
Loading…
Cancel
Save