From f51eb40d707e51a556122bc4c05c5e7317fbec39 Mon Sep 17 00:00:00 2001 From: hius07 <62179190+hius07@users.noreply.github.com> Date: Sat, 16 May 2026 13:08:18 +0300 Subject: [PATCH] Perception expander: minor fixes (#15364) --- frontend/pluginloader.lua | 6 +++- plugins/perceptionexpander.koplugin/main.lua | 29 +++++++++++--------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/frontend/pluginloader.lua b/frontend/pluginloader.lua index 6d43a332a..7390c7533 100644 --- a/frontend/pluginloader.lua +++ b/frontend/pluginloader.lua @@ -460,8 +460,12 @@ function PluginLoader:showPluginDialog(plugin, touchmenu_instance) }}) end end + local title = plugin.fullname .. "\n\n" .. plugin.description .. "\n" + if plugin.enable and not plugin_instance then + title = title .. "\n" .. _("This plugin is used in the reader only.\nOpen this dialog while reading a document to view additional options.") + end plugin_dialog = ButtonDialog:new{ - title = plugin.fullname .. "\n\n" .. plugin.description .. "\n", + title = title, title_align = "center", buttons = buttons, } diff --git a/plugins/perceptionexpander.koplugin/main.lua b/plugins/perceptionexpander.koplugin/main.lua index 8bc081b30..1f165ccba 100644 --- a/plugins/perceptionexpander.koplugin/main.lua +++ b/plugins/perceptionexpander.koplugin/main.lua @@ -14,8 +14,10 @@ local DataStorage = require("datastorage") local Blitbuffer = require("ffi/blitbuffer") local PerceptionExpander = Widget:extend{ - is_enabled = nil, name = "perceptionexpander", + is_doc_only = true, + settings_file = DataStorage:getSettingsDir() .. "/perception_expander.lua", + is_enabled = nil, page_counter = 0, shift_each_pages = 100, margin = 0.1, @@ -24,21 +26,15 @@ local PerceptionExpander = Widget:extend{ margin_shift = 0.03, settings = nil, ALMOST_CENTER_OF_THE_SCREEN = 0.37, - last_screen_mode = nil + last_screen_mode = nil, } function PerceptionExpander:init() - if not self.settings then self:readSettingsFile() end - - self.is_enabled = self.settings:isTrue("is_enabled") - if not self.is_enabled then - return + self.settings = LuaSettings:open(self.settings_file) + if self.settings:isTrue("is_enabled") then + self.is_enabled = true + self:createUI(true) end - self:createUI(true) -end - -function PerceptionExpander:readSettingsFile() - self.settings = LuaSettings:open(DataStorage:getSettingsDir() .. "/perception_expander.lua") end function PerceptionExpander:createUI(readSettings) @@ -230,7 +226,7 @@ function PerceptionExpander:saveSettings(fields) self.settings:saveSetting("line_color_intensity", self.line_color_intensity) self.settings:saveSetting("shift_each_pages", self.shift_each_pages) self.settings:saveSetting("is_enabled", self.is_enabled) - self.settings:flush() + self.updated = true self:createUI() end @@ -241,4 +237,11 @@ function PerceptionExpander:paintTo(bb, x, y) end end +function PerceptionExpander:onFlushSettings() + if self.updated then + self.settings:flush() + self.updated = nil + end +end + return PerceptionExpander