|
|
|
@ -1148,12 +1148,15 @@ function ConfigDialog:onConfigMoreChoose(values, name, event, args, name_text, m
|
|
|
|
|
if more_options_param.left_min then -- DoubleSpinWidget
|
|
|
|
|
local DoubleSpinWidget = require("ui/widget/doublespinwidget")
|
|
|
|
|
-- (No support for value_table - add it if needed)
|
|
|
|
|
local curr_values
|
|
|
|
|
local curr_values, default_values
|
|
|
|
|
if more_options_param.names then -- allows managing 2 different settings
|
|
|
|
|
curr_values = { self.configurable[more_options_param.names[1]],
|
|
|
|
|
self.configurable[more_options_param.names[2]] }
|
|
|
|
|
default_values = { G_reader_settings:readSetting(self.config_options.prefix.."_"..more_options_param.names[1]),
|
|
|
|
|
G_reader_settings:readSetting(self.config_options.prefix.."_"..more_options_param.names[2]) }
|
|
|
|
|
else
|
|
|
|
|
curr_values = self.configurable[name]
|
|
|
|
|
default_values = G_reader_settings:readSetting(self.config_options.prefix.."_"..name)
|
|
|
|
|
end
|
|
|
|
|
widget = DoubleSpinWidget:new{
|
|
|
|
|
width_factor = more_options_param.widget_width_factor,
|
|
|
|
@ -1171,6 +1174,9 @@ function ConfigDialog:onConfigMoreChoose(values, name, event, args, name_text, m
|
|
|
|
|
right_max = more_options_param.right_max,
|
|
|
|
|
right_step = more_options_param.right_step,
|
|
|
|
|
right_hold_step = more_options_param.right_hold_step,
|
|
|
|
|
default_values = true,
|
|
|
|
|
left_default = default_values[1],
|
|
|
|
|
right_default = default_values[2],
|
|
|
|
|
keep_shown_on_apply = true,
|
|
|
|
|
unit = more_options_param.unit,
|
|
|
|
|
precision = more_options_param.precision,
|
|
|
|
@ -1226,6 +1232,9 @@ function ConfigDialog:onConfigMoreChoose(values, name, event, args, name_text, m
|
|
|
|
|
setting_name = self.config_options.prefix.."_"..name
|
|
|
|
|
G_reader_settings:saveSetting(setting_name, value_tables)
|
|
|
|
|
end
|
|
|
|
|
widget.left_default = left_value
|
|
|
|
|
widget.right_default = right_value
|
|
|
|
|
widget:update()
|
|
|
|
|
self:update()
|
|
|
|
|
UIManager:setDirty(self, function()
|
|
|
|
|
return "ui", self.dialog_frame.dimen
|
|
|
|
@ -1243,18 +1252,12 @@ function ConfigDialog:onConfigMoreChoose(values, name, event, args, name_text, m
|
|
|
|
|
value_hold_step = values[2] - values[1]
|
|
|
|
|
end
|
|
|
|
|
local curr_items = self.configurable[name]
|
|
|
|
|
local value_index = nil
|
|
|
|
|
local value_index
|
|
|
|
|
local default_value = G_reader_settings:readSetting(self.config_options.prefix.."_"..name)
|
|
|
|
|
if more_options_param.value_table then
|
|
|
|
|
if more_options_param.args_table then
|
|
|
|
|
for k,v in pairs(more_options_param.args_table) do
|
|
|
|
|
if v == curr_items then
|
|
|
|
|
value_index = k
|
|
|
|
|
break
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
value_index = curr_items
|
|
|
|
|
end
|
|
|
|
|
local table_shift = more_options_param.value_table_shift or 0
|
|
|
|
|
value_index = curr_items + table_shift
|
|
|
|
|
default_value = default_value + table_shift
|
|
|
|
|
end
|
|
|
|
|
widget = SpinWidget:new{
|
|
|
|
|
width_factor = more_options_param.widget_width_factor,
|
|
|
|
@ -1269,6 +1272,7 @@ function ConfigDialog:onConfigMoreChoose(values, name, event, args, name_text, m
|
|
|
|
|
value_max = more_options_param.value_max or values[#values],
|
|
|
|
|
unit = more_options_param.unit,
|
|
|
|
|
precision = more_options_param.precision,
|
|
|
|
|
default_value = default_value,
|
|
|
|
|
keep_shown_on_apply = true,
|
|
|
|
|
close_callback = function()
|
|
|
|
|
if when_applied_callback then
|
|
|
|
@ -1277,15 +1281,14 @@ function ConfigDialog:onConfigMoreChoose(values, name, event, args, name_text, m
|
|
|
|
|
end
|
|
|
|
|
end,
|
|
|
|
|
callback = function(spin)
|
|
|
|
|
local spin_value
|
|
|
|
|
if more_options_param.value_table then
|
|
|
|
|
if more_options_param.args_table then
|
|
|
|
|
self:onConfigChoice(name, more_options_param.args_table[spin.value_index])
|
|
|
|
|
else
|
|
|
|
|
self:onConfigChoice(name, spin.value_index)
|
|
|
|
|
end
|
|
|
|
|
local table_shift = more_options_param.value_table_shift or 0
|
|
|
|
|
spin_value = spin.value_index - table_shift
|
|
|
|
|
else
|
|
|
|
|
self:onConfigChoice(name, spin.value)
|
|
|
|
|
spin_value = spin.value
|
|
|
|
|
end
|
|
|
|
|
self:onConfigChoice(name, spin_value)
|
|
|
|
|
if event then
|
|
|
|
|
-- Repainting (with when_applied_callback) if hide_on_picker_show
|
|
|
|
|
-- is done in close_callback, but we want onConfigEvent to
|
|
|
|
@ -1294,15 +1297,7 @@ function ConfigDialog:onConfigMoreChoose(values, name, event, args, name_text, m
|
|
|
|
|
local dummy_callback = when_applied_callback and function() end
|
|
|
|
|
args = args or {}
|
|
|
|
|
Notification:setNotifySource(Notification.SOURCE_BOTTOM_MENU_MORE)
|
|
|
|
|
if more_options_param.value_table then
|
|
|
|
|
if more_options_param.args_table then
|
|
|
|
|
self:onConfigEvent(event, more_options_param.args_table[spin.value_index], dummy_callback)
|
|
|
|
|
else
|
|
|
|
|
self:onConfigEvent(event, spin.value_index, dummy_callback)
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
self:onConfigEvent(event, spin.value, dummy_callback)
|
|
|
|
|
end
|
|
|
|
|
self:onConfigEvent(event, spin_value, dummy_callback)
|
|
|
|
|
UIManager:tickAfterNext(function()
|
|
|
|
|
Notification:resetNotifySource()
|
|
|
|
|
end)
|
|
|
|
@ -1321,16 +1316,17 @@ function ConfigDialog:onConfigMoreChoose(values, name, event, args, name_text, m
|
|
|
|
|
text = T(_("Set default %1 to %2?"), (name_text or ""), value_string),
|
|
|
|
|
ok_text = T(_("Set as default")),
|
|
|
|
|
ok_callback = function()
|
|
|
|
|
local setting_name = self.config_options.prefix.."_"..name
|
|
|
|
|
local spin_value
|
|
|
|
|
if more_options_param.value_table then
|
|
|
|
|
if more_options_param.args_table then
|
|
|
|
|
G_reader_settings:saveSetting(setting_name, more_options_param.args_table[spin.value_index])
|
|
|
|
|
else
|
|
|
|
|
G_reader_settings:saveSetting(setting_name, spin.value_index)
|
|
|
|
|
end
|
|
|
|
|
local table_shift = more_options_param.value_table_shift or 0
|
|
|
|
|
spin_value = spin.value_index - table_shift
|
|
|
|
|
widget.default_value = spin.value_index
|
|
|
|
|
else
|
|
|
|
|
G_reader_settings:saveSetting(setting_name, spin.value)
|
|
|
|
|
spin_value = spin.value
|
|
|
|
|
widget.default_value = spin.value
|
|
|
|
|
end
|
|
|
|
|
G_reader_settings:saveSetting(self.config_options.prefix.."_"..name, spin_value)
|
|
|
|
|
widget:update()
|
|
|
|
|
self:update()
|
|
|
|
|
UIManager:setDirty(self, function()
|
|
|
|
|
return "ui", self.dialog_frame.dimen
|
|
|
|
|