From 0c1093cba684d918b868dc13650d4dfa35df2915 Mon Sep 17 00:00:00 2001 From: Saterz_ Date: Mon, 27 Apr 2026 16:49:10 +0100 Subject: [PATCH] Feature: Add a two different submenus for built-in and user plugins (#15245) Closes #15242. --- frontend/pluginloader.lua | 65 +++++++++++++++++++++++++++++++-- spec/unit/pluginloader_spec.lua | 8 ++-- 2 files changed, 65 insertions(+), 8 deletions(-) diff --git a/frontend/pluginloader.lua b/frontend/pluginloader.lua index 08191b789..810458af3 100644 --- a/frontend/pluginloader.lua +++ b/frontend/pluginloader.lua @@ -21,6 +21,46 @@ local T = ffiUtil.template local DEFAULT_PLUGIN_PATH = "plugins" +local BUILTIN_PLUGINS = { + ["archiveviewer"] = true, + ["autodim"] = true, + ["autostandby"] = true, + ["autosuspend"] = true, + ["autoturn"] = true, + ["autowarmth"] = true, + ["batterystat"] = true, + ["bookshortcuts"] = true, + ["calibre"] = true, + ["cloudstorage"] = true, + ["coverbrowser"] = true, + ["coverimage"] = true, + ["docsettingtweak"] = true, + ["exporter"] = true, + ["externalkeyboard"] = true, + ["gestures"] = true, + ["hello"] = true, + ["hotkeys"] = true, + ["httpinspector"] = true, + ["japanese"] = true, + ["keepalive"] = true, + ["kosync"] = true, + ["movetoarchive"] = true, + ["newsdownloader"] = true, + ["opds"] = true, + ["perceptionexpander"] = true, + ["profiles"] = true, + ["qrclipboard"] = true, + ["readtimer"] = true, + ["SSH"] = true, + ["statistics"] = true, + ["systemstat"] = true, + ["terminal"] = true, + ["texteditor"] = true, + ["timesync"] = true, + ["vocabbuilder"] = true, + ["wallabag"] = true, +} + local DEPRECATION_MESSAGES = { remove = _("This plugin is unmaintained and will be removed soon."), feature = _("The following features are unmaintained and will be removed soon:"), @@ -274,9 +314,10 @@ function PluginLoader:genPluginManagerSubItem() table.sort(self.all_plugins, function(v1, v2) return v1.fullname < v2.fullname end) end - local plugin_table = {} + local builtin_plugin_items = {} + local user_plugin_items = {} for __, plugin in ipairs(self.all_plugins) do - table.insert(plugin_table, { + local item = { text = plugin.fullname, checked_func = function() return plugin.enable @@ -339,9 +380,25 @@ function PluginLoader:genPluginManagerSubItem() confirmbox:addWidget(delete_plugin_settings_checkbox) UIManager:show(confirmbox) end, - }) + } + if BUILTIN_PLUGINS[plugin.name] == true then + table.insert(builtin_plugin_items, item) + else + table.insert(user_plugin_items, item) + end end - return plugin_table + return { + { + text = _("Built-in plugins"), + enabled_func = function() return #builtin_plugin_items > 0 end, + sub_item_table = builtin_plugin_items, + }, + { + text = _("User plugins"), + enabled_func = function() return #user_plugin_items > 0 end, + sub_item_table = user_plugin_items, + }, + } end function PluginLoader:createPluginInstance(plugin, attr) diff --git a/spec/unit/pluginloader_spec.lua b/spec/unit/pluginloader_spec.lua index dad113998..4526be202 100644 --- a/spec/unit/pluginloader_spec.lua +++ b/spec/unit/pluginloader_spec.lua @@ -152,7 +152,7 @@ describe("PluginLoader module", function() stub(UIManager, "askForRestart") local plugin_items = PluginLoader:genPluginManagerSubItem() - plugin_items[1].callback() + plugin_items[2].sub_item_table[1].callback() local plugins_disabled = G_reader_settings:readSetting("plugins_disabled") assert.is_true(plugins_disabled.test) @@ -197,7 +197,7 @@ describe("PluginLoader module", function() }) local plugin_items = PluginLoader:genPluginManagerSubItem() - plugin_items[1].hold_callback() + plugin_items[2].sub_item_table[1].hold_callback() shown_widget._added_widgets[1].checked = true shown_widget._added_widgets[1].callback() shown_widget.ok_callback() @@ -237,7 +237,7 @@ describe("PluginLoader module", function() end) local plugin_items = PluginLoader:genPluginManagerSubItem() - plugin_items[1].hold_callback() + plugin_items[2].sub_item_table[1].hold_callback() assert.is_not_nil(shown_widget._added_widgets) assert.is_false(shown_widget._added_widgets[1].enabled) @@ -267,4 +267,4 @@ describe("PluginLoader module", function() PluginLoader.getPluginInstance:revert() end) -end) \ No newline at end of file +end)