diff --git a/frontend/apps/reader/modules/readerdevicestatus.lua b/frontend/apps/reader/modules/readerdevicestatus.lua index e9deadbd8..930b88d8a 100644 --- a/frontend/apps/reader/modules/readerdevicestatus.lua +++ b/frontend/apps/reader/modules/readerdevicestatus.lua @@ -200,7 +200,6 @@ High level threshold is checked when the device is charging.]]), right_max = 100, right_default = 100, right_hold_step = 5, - default_values = true, unit = "%", callback = function(left_value, right_value) self.battery_threshold = left_value diff --git a/frontend/apps/reader/modules/readertypography.lua b/frontend/apps/reader/modules/readertypography.lua index 7ad3f5472..c49b62bd5 100644 --- a/frontend/apps/reader/modules/readertypography.lua +++ b/frontend/apps/reader/modules/readertypography.lua @@ -380,7 +380,6 @@ When the book's language tag is not among our presets, no specific features will -- let room on the widget sides so we can see -- the hyphenation changes happening width_factor = 0.6, - default_values = true, default_text = T(_("Language defaults: %1 / %2"), alg_left_hyphen_min, alg_right_hyphen_min), title_text = _("Hyphenation limits"), info_text = _([[ diff --git a/frontend/ui/widget/configdialog.lua b/frontend/ui/widget/configdialog.lua index 976349cc3..7a650d612 100644 --- a/frontend/ui/widget/configdialog.lua +++ b/frontend/ui/widget/configdialog.lua @@ -577,7 +577,15 @@ function ConfigOption:init() self.options[c].more_options_param.show_true_value_func = self.options[c].show_true_value_func end Notification:setNotifySource(Notification.SOURCE_BOTTOM_MENU_MORE) - self.config:onConfigMoreChoose(self.options[c].values, self.options[c].name, + local default_value_original + if self.options[c].more_options_param.names then + local option1 = self.config:findOptionByName(self.options[c].more_options_param.names[1]) + local option2 = self.config:findOptionByName(self.options[c].more_options_param.names[2]) + default_value_original = { option1.default_value, option2.default_value } + else + default_value_original = self.options[c].default_value + end + self.config:onConfigMoreChoose(self.options[c].values, default_value_original, self.options[c].name, self.options[c].event, arg, name_text, self.options[c].more_options_param) UIManager:tickAfterNext(function() Notification:resetNotifySource() @@ -615,10 +623,18 @@ function ConfigOption:init() self.options[c].fine_tune_param) elseif arg == "⋮" then Notification:setNotifySource(Notification.SOURCE_BOTTOM_MENU_MORE) - self.config:onConfigMoreChoose(self.options[c].values, self.options[c].name, + local default_value_original + if self.options[c].more_options_param.names then + local option1 = self.config:findOptionByName(self.options[c].more_options_param.names[1]) + local option2 = self.config:findOptionByName(self.options[c].more_options_param.names[2]) + default_value_original = { option1.default_value, option2.default_value } + else + default_value_original = self.options[c].default_value + end + self.config:onConfigMoreChoose(self.options[c].values, default_value_original, self.options[c].name, self.options[c].event, arg, name_text, self.options[c].more_options_param) else - Notification:setNotifySource(Notification.SOURCE_BOTTOM_MENU_PROGRESS) + Notification:setNotifySource(Notification.SOURCE_BOTTOM_MENU_PROGRESS) self.config:onConfigChoose(self.options[c].values, self.options[c].name, self.options[c].event, self.options[c].args, arg, self.options[c].hide_on_apply) end @@ -1100,7 +1116,7 @@ end -- Tweaked variant used with the more options variant of buttonprogress and fine tune with numpicker -- events are not supported -function ConfigDialog:onConfigMoreChoose(values, name, event, args, name_text, more_options_param) +function ConfigDialog:onConfigMoreChoose(values, default_value_orig, name, event, args, name_text, more_options_param) if not more_options_param then more_options_param = {} end @@ -1150,15 +1166,20 @@ 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, default_values + local curr_values, left_default, right_default 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]) } + left_default = G_reader_settings:readSetting(self.config_options.prefix.."_"..more_options_param.names[1]) + or default_value_orig[1] + right_default = G_reader_settings:readSetting(self.config_options.prefix.."_"..more_options_param.names[2]) + or default_value_orig[2] else curr_values = self.configurable[name] - default_values = G_reader_settings:readSetting(self.config_options.prefix.."_"..name) + local default_values = G_reader_settings:readSetting(self.config_options.prefix.."_"..name) + or default_value_orig + left_default = default_values[1] + right_default = default_values[2] end widget = DoubleSpinWidget:new{ width_factor = more_options_param.widget_width_factor, @@ -1176,9 +1197,8 @@ 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], + left_default = left_default, + right_default = right_default, keep_shown_on_apply = true, unit = more_options_param.unit, precision = more_options_param.precision, @@ -1256,6 +1276,7 @@ function ConfigDialog:onConfigMoreChoose(values, name, event, args, name_text, m local curr_items = self.configurable[name] local value_index local default_value = G_reader_settings:readSetting(self.config_options.prefix.."_"..name) + or default_value_orig if more_options_param.value_table then local table_shift = more_options_param.value_table_shift or 0 value_index = curr_items + table_shift @@ -1341,7 +1362,16 @@ function ConfigDialog:onConfigMoreChoose(values, name, event, args, name_text, m when_applied_callback = nil -- prevent bottom menu from being shown (before being hidden again) widget:onClose() local option = self:findOptionByName(more_options_param.other_button.other_option) - self:onConfigMoreChoose(option.values, option.name, option.event, nil, option.name_text, option.more_options_param) + local default_value_original + if option.more_options_param.names then + local option1 = self:findOptionByName(option.more_options_param.names[1]) + local option2 = self:findOptionByName(option.more_options_param.names[2]) + default_value_original = { option1.default_value, option2.default_value } + else + default_value_original = option.default_value + end + self:onConfigMoreChoose(option.values, default_value_original, option.name, + option.event, nil, option.name_text, option.more_options_param) end, } end diff --git a/frontend/ui/widget/doublespinwidget.lua b/frontend/ui/widget/doublespinwidget.lua index fac918dee..0dc10412a 100644 --- a/frontend/ui/widget/doublespinwidget.lua +++ b/frontend/ui/widget/doublespinwidget.lua @@ -31,14 +31,12 @@ local DoubleSpinWidget = FocusManager:new{ left_min = 1, left_max = 20, left_value = 1, - left_default = nil, left_precision = nil, -- default "%02d" in NumberPickerWidget left_wrap = false, right_text = _("Right"), right_min = 1, right_max = 20, right_value = 1, - right_default = nil, right_precision = nil, right_wrap = false, cancel_text = _("Close"), @@ -48,8 +46,9 @@ local DoubleSpinWidget = FocusManager:new{ callback = nil, close_callback = nil, keep_shown_on_apply = false, - -- Set this to add upper default button that applies default values with callback(left_default, right_default) - default_values = false, + -- Set both left and right defaults to add upper button that sets spin values to default values + left_default = nil, + right_default = nil, default_text = nil, -- Optional extra button above ok/cancel buttons row extra_text = nil, @@ -197,7 +196,7 @@ function DoubleSpinWidget:update(numberpicker_left_value, numberpicker_right_val } local buttons = {} - if self.default_values then + if self.left_default and self.right_default then local separator = self.is_range and "–" or "/" local unit = "" if self.unit then diff --git a/plugins/statistics.koplugin/main.lua b/plugins/statistics.koplugin/main.lua index bc10c16b7..1815a1363 100644 --- a/plugins/statistics.koplugin/main.lua +++ b/plugins/statistics.koplugin/main.lua @@ -957,7 +957,6 @@ function ReaderStatistics:addToMainMenu(menu_items) right_max = 7200, right_step = 10, right_hold_step = 60, - default_values = true, is_range = true, -- @translators This is the time unit for seconds. unit = C_("Time", "s"),