mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Kopt/Creoptions: change to using an event to update configurable. Abstract implimentation out of ConfigDialog
This commit is contained in:
committed by
Martín Fernández
parent
0577f57617
commit
002b4d4be9
@@ -63,6 +63,12 @@ function ReaderCoptListener:onReadSettings(config)
|
||||
self:rescheduleHeaderRefreshIfNeeded() -- schedule (or not) first refresh
|
||||
end
|
||||
|
||||
function ReaderCoptListener:onConfigChange(option_name, option_value)
|
||||
self.document.configurable[option_name] = option_value
|
||||
self.ui:handleEvent(Event:new("StartActivityIndicator"))
|
||||
return true
|
||||
end
|
||||
|
||||
function ReaderCoptListener:onSetFontSize(font_size)
|
||||
self.document.configurable.font_size = font_size
|
||||
end
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
local EventListener = require("ui/widget/eventlistener")
|
||||
local Event = require("ui/event")
|
||||
local ReaderZooming = require("apps/reader/modules/readerzooming")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local util = require("util")
|
||||
|
||||
local ReaderKoptListener = EventListener:new{}
|
||||
@@ -72,4 +73,11 @@ function ReaderKoptListener:onDocLangUpdate(lang)
|
||||
end
|
||||
end
|
||||
|
||||
function ReaderKoptListener:onConfigChange(option_name, option_value)
|
||||
self.document.configurable[option_name] = option_value
|
||||
self.ui:handleEvent(Event:new("StartActivityIndicator"))
|
||||
UIManager:setDirty("all", "partial")
|
||||
return true
|
||||
end
|
||||
|
||||
return ReaderKoptListener
|
||||
|
||||
@@ -651,7 +651,7 @@ function Dispatcher:execute(ui, settings, gesture)
|
||||
if v == r then value = settingsList[k].configurable.values[i] break end
|
||||
end
|
||||
end
|
||||
ui.document.configurable[settingsList[k].configurable.name] = value
|
||||
ui:handleEvent(Event:new("ConfigChange", settingsList[k].configurable.name, value))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -22,7 +22,6 @@ end
|
||||
|
||||
local KoptOptions = {
|
||||
prefix = "kopt",
|
||||
needs_redraw_on_change = true,
|
||||
{
|
||||
icon = "appbar.rotation",
|
||||
options = {
|
||||
|
||||
@@ -959,8 +959,7 @@ function ConfigDialog:onShowConfigPanel(index)
|
||||
end
|
||||
|
||||
function ConfigDialog:onConfigChoice(option_name, option_value)
|
||||
self.configurable[option_name] = option_value
|
||||
self.ui:handleEvent(Event:new("StartActivityIndicator"))
|
||||
self.ui:handleEvent(Event:new("ConfigChange", option_name, option_value))
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -982,18 +981,9 @@ function ConfigDialog:onConfigChoose(values, name, event, args, events, position
|
||||
-- Repainting may be delayed depending on options
|
||||
local refresh_dialog_func = function()
|
||||
self.skip_paint = nil
|
||||
if self.config_options.needs_redraw_on_change then
|
||||
-- Some Kopt document event handlers just save their setting,
|
||||
-- and need a full repaint for kopt to load these settings,
|
||||
-- notice the change, and redraw the document
|
||||
UIManager:setDirty("all", "partial")
|
||||
else
|
||||
-- CreDocument event handlers do their own refresh:
|
||||
-- we can just redraw our frame
|
||||
UIManager:setDirty(self, function()
|
||||
return "ui", self.dialog_frame.dimen
|
||||
end)
|
||||
end
|
||||
UIManager:setDirty(self, function()
|
||||
return "ui", self.dialog_frame.dimen
|
||||
end)
|
||||
end
|
||||
local when_applied_callback = nil
|
||||
if type(hide_on_apply) == "number" then -- timeout
|
||||
@@ -1033,18 +1023,9 @@ function ConfigDialog:onConfigFineTuneChoose(values, name, event, args, events,
|
||||
-- Repainting may be delayed depending on options
|
||||
local refresh_dialog_func = function()
|
||||
self.skip_paint = nil
|
||||
if self.config_options.needs_redraw_on_change then
|
||||
-- Some Kopt document event handlers just save their setting,
|
||||
-- and need a full repaint for kopt to load these settings,
|
||||
-- notice the change, and redraw the document
|
||||
UIManager:setDirty("all", "partial")
|
||||
else
|
||||
-- CreDocument event handlers do their own refresh:
|
||||
-- we can just redraw our frame
|
||||
UIManager:setDirty(self, function()
|
||||
return "ui", self.dialog_frame.dimen
|
||||
end)
|
||||
end
|
||||
UIManager:setDirty(self, function()
|
||||
return "ui", self.dialog_frame.dimen
|
||||
end)
|
||||
end
|
||||
local when_applied_callback = nil
|
||||
if type(hide_on_apply) == "number" then -- timeout
|
||||
@@ -1139,24 +1120,15 @@ function ConfigDialog:onConfigMoreChoose(values, name, event, args, name_text, m
|
||||
if self.skip_paint and not keep_skip_paint then
|
||||
self.skip_paint = nil
|
||||
end
|
||||
if self.config_options.needs_redraw_on_change then
|
||||
-- Some Kopt document event handlers just save their setting,
|
||||
-- and need a full repaint for kopt to load these settings,
|
||||
-- notice the change, and redraw the document
|
||||
UIManager:setDirty("all", "partial")
|
||||
if self.skip_paint then
|
||||
-- Redraw anything below the now hidden ConfigDialog
|
||||
UIManager:setDirty("all", function()
|
||||
return "partial", self.dialog_frame.dimen
|
||||
end)
|
||||
else
|
||||
-- CreDocument event handlers do their own refresh:
|
||||
-- we can just redraw our frame
|
||||
if self.skip_paint then
|
||||
-- Redraw anything below the now hidden ConfigDialog
|
||||
UIManager:setDirty("all", function()
|
||||
return "partial", self.dialog_frame.dimen
|
||||
end)
|
||||
else
|
||||
UIManager:setDirty(self, function()
|
||||
return "ui", self.dialog_frame.dimen
|
||||
end)
|
||||
end
|
||||
UIManager:setDirty(self, function()
|
||||
return "ui", self.dialog_frame.dimen
|
||||
end)
|
||||
end
|
||||
end
|
||||
local hide_on_picker_show = more_options_param.hide_on_picker_show
|
||||
|
||||
Reference in New Issue
Block a user