mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Dispatcher: update document.configurable (#7116)
So ConfigDialog knows about changed settings and properly reflects their states.
This commit is contained in:
@@ -23,6 +23,7 @@ Each setting contains:
|
||||
* args: allowed values for string.
|
||||
* toggle: display name for args
|
||||
* separator: put a separator after in the menu list
|
||||
* configurable: can be parsed from cre/kopt and used to set document.configurable. Should not be set manualy
|
||||
--]]--
|
||||
|
||||
local CreOptions = require("ui/data/creoptions")
|
||||
@@ -289,6 +290,9 @@ function Dispatcher:init()
|
||||
for y=1,#base[i].options do
|
||||
local option = base[i].options[y]
|
||||
if settingsList[option.name] ~= nil then
|
||||
if option.name ~= nil and option.values ~= nil then
|
||||
settingsList[option.name].configurable = {name = option.name, values = option.values}
|
||||
end
|
||||
if settingsList[option.name].event == nil then
|
||||
settingsList[option.name].event = option.event
|
||||
end
|
||||
@@ -619,6 +623,15 @@ function Dispatcher:execute(ui, settings, gesture)
|
||||
local arg = v ~= 0 and v or gesture or 0
|
||||
ui:handleEvent(Event:new(settingsList[k].event, arg))
|
||||
end
|
||||
if settingsList[k].configurable ~= nil then
|
||||
local value = v
|
||||
if type(v) ~= "number" then
|
||||
for i, r in ipairs(settingsList[k].args) do
|
||||
if v == r then value = settingsList[k].configurable.values[i] break end
|
||||
end
|
||||
end
|
||||
ui.document.configurable[settingsList[k].configurable.name] = value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user