mirror of
https://github.com/koreader/koreader.git
synced 2025-12-13 20:36:53 +01:00
Load plugins also in FileManager (#2426)
added is_doc_only plugin attribute
This commit is contained in:
@@ -26,6 +26,7 @@ local _ = require("gettext")
|
||||
local KeyValuePage = require("ui/widget/keyvaluepage")
|
||||
local ReaderUI = require("apps/reader/readerui")
|
||||
local InfoMessage = require("ui/widget/infomessage")
|
||||
local PluginLoader = require("pluginloader")
|
||||
|
||||
local function getDefaultDir()
|
||||
if Device:isKindle() then
|
||||
@@ -293,9 +294,18 @@ function FileManager:init()
|
||||
table.insert(self, self.menu)
|
||||
table.insert(self, FileManagerHistory:new{
|
||||
ui = self,
|
||||
menu = self.menu
|
||||
})
|
||||
|
||||
self.loaded_modules = {}
|
||||
-- koreader plugins
|
||||
for _,plugin_module in ipairs(PluginLoader:loadPlugins()) do
|
||||
DEBUG("Loaded plugin", plugin_module.name, "at", plugin_module.path)
|
||||
if not plugin_module.is_doc_only then
|
||||
-- Keep references to the modules which do not register into menu.
|
||||
table.insert(self.loaded_modules, plugin_module:new{ ui = self, })
|
||||
end
|
||||
end
|
||||
|
||||
if Device:hasKeys() then
|
||||
self.key_events.Close = { {"Home"}, doc = "Close file manager" }
|
||||
end
|
||||
|
||||
@@ -51,6 +51,9 @@ function FileManagerMenu:init()
|
||||
end,
|
||||
},
|
||||
}
|
||||
-- For backward compatibility, plugins look for plugins tab, which should be tools tab in file
|
||||
-- manager.
|
||||
self.tab_item_table.plugins = self.tab_item_table.tools
|
||||
self.registered_widgets = {}
|
||||
|
||||
if Device:hasKeys() then
|
||||
|
||||
@@ -43,7 +43,7 @@ local FileManagerHistory = require("apps/filemanager/filemanagerhistory")
|
||||
local ReaderSearch = require("apps/reader/modules/readersearch")
|
||||
local ReaderLink = require("apps/reader/modules/readerlink")
|
||||
local ReaderStatus = require("apps/reader/modules/readerstatus")
|
||||
local PluginLoader = require("apps/reader/pluginloader")
|
||||
local PluginLoader = require("pluginloader")
|
||||
|
||||
--[[
|
||||
This is an abstraction for a reader interface
|
||||
|
||||
@@ -16,6 +16,7 @@ local MyClipping = require("clip")
|
||||
|
||||
local EvernoteExporter = InputContainer:new{
|
||||
name = "evernote",
|
||||
is_doc_only = true,
|
||||
login_title = _("Login to Evernote"),
|
||||
notebook_name = _("KOReader Notes"),
|
||||
evernote_domain = nil,
|
||||
|
||||
27
plugins/hello.koplugin/main.lua
Normal file
27
plugins/hello.koplugin/main.lua
Normal file
@@ -0,0 +1,27 @@
|
||||
local InfoMessage = require("ui/widget/infomessage")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local WidgetContainer = require("ui/widget/container/widgetcontainer")
|
||||
local _ = require("gettext")
|
||||
|
||||
local Hello = WidgetContainer:new{
|
||||
name = 'Hello',
|
||||
is_doc_only = false,
|
||||
disabled = true, -- This is a debug plugin
|
||||
}
|
||||
|
||||
function Hello:init()
|
||||
self.ui.menu:registerToMainMenu(self)
|
||||
end
|
||||
|
||||
function Hello:addToMainMenu(tab_item_table)
|
||||
table.insert(tab_item_table.plugins, {
|
||||
text = _("Hello World"),
|
||||
callback_func = function()
|
||||
UIManager:show(InfoMessage:new{
|
||||
text = _("Hello, docless plugin world"),
|
||||
})
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
return Hello
|
||||
@@ -20,6 +20,7 @@ end
|
||||
|
||||
local KOSync = InputContainer:new{
|
||||
name = "kosync",
|
||||
is_doc_only = true,
|
||||
title = _("Register/login to KOReader server"),
|
||||
|
||||
page_update_times = 0,
|
||||
|
||||
@@ -21,6 +21,7 @@ local statistics_dir = DataStorage:getDataDir() .. "/statistics/"
|
||||
local page_max_time
|
||||
|
||||
local ReaderStatistics = InputContainer:new {
|
||||
is_doc_only = true,
|
||||
last_time = nil,
|
||||
page_min_read_sec = 5,
|
||||
page_max_read_sec = 90,
|
||||
|
||||
@@ -14,6 +14,7 @@ int rmdir(const char *);
|
||||
require("ffi/zeromq_h")
|
||||
local ZSync = InputContainer:new{
|
||||
name = "zsync",
|
||||
is_doc_only = true,
|
||||
}
|
||||
|
||||
function ZSync:init()
|
||||
|
||||
Reference in New Issue
Block a user