mirror of
https://github.com/koreader/koreader.git
synced 2025-12-18 12:02:09 +01:00
CRE: allow both Top/Bottom margins fine tuning (#7104)
By having the same DoubleSpinWidget launched when hitting "..." on any of Top margin or Bottom margin progress bars. DoubleSpinWidget: remove blank space when no info_text.
This commit is contained in:
@@ -94,6 +94,7 @@ Note that this may not be ensured under some conditions: in scroll mode, when a
|
||||
name_text_hold_callback = optionsutil.showValuesHMargins,
|
||||
more_options = true,
|
||||
more_options_param = {
|
||||
name_text = _("Left/Right Margins"),
|
||||
left_min = 0,
|
||||
left_max = 140,
|
||||
left_step = 1,
|
||||
@@ -154,10 +155,23 @@ In the top menu → Settings → Status bar, you can choose whether the bottom m
|
||||
name_text_hold_callback = optionsutil.showValues,
|
||||
more_options = true,
|
||||
more_options_param = {
|
||||
value_min = 0,
|
||||
value_max = 140,
|
||||
value_step = 1,
|
||||
value_hold_step = 5,
|
||||
-- Allow this to tune both top and bottom margins,
|
||||
-- handling 2 setting names and sending 2 events
|
||||
-- (we'll get the exact same DoubleSpinWidget in
|
||||
-- the b_page_margin setting just below)
|
||||
name_text = _("Top/Bottom Margins"),
|
||||
names = { "t_page_margin", "b_page_margin" },
|
||||
events = { "SetPageTopMargin", "SetPageBottomMargin" },
|
||||
left_text = _("Top"),
|
||||
left_min = 0,
|
||||
left_max = 140,
|
||||
left_step = 1,
|
||||
left_hold_step = 5,
|
||||
right_text = _("Bottom"),
|
||||
right_min = 0,
|
||||
right_max = 140,
|
||||
right_step = 1,
|
||||
right_hold_step = 5,
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -194,10 +208,20 @@ In the top menu → Settings → Status bar, you can choose whether the bottom m
|
||||
help_text = _([[In the top menu → Settings → Status bar, you can choose whether the bottom margin applies from the bottom of the screen, or from above the status bar.]]),
|
||||
more_options = true,
|
||||
more_options_param = {
|
||||
value_min = 0,
|
||||
value_max = 140,
|
||||
value_step = 1,
|
||||
value_hold_step = 5,
|
||||
-- Similar as for t_page_margin above
|
||||
name_text = _("Top/Bottom Margins"),
|
||||
names = { "t_page_margin", "b_page_margin" },
|
||||
events = { "SetPageTopMargin", "SetPageBottomMargin" },
|
||||
left_text = _("Top"),
|
||||
left_min = 0,
|
||||
left_max = 140,
|
||||
left_step = 1,
|
||||
left_hold_step = 5,
|
||||
right_text = _("Bottom"),
|
||||
right_min = 0,
|
||||
right_max = 140,
|
||||
right_step = 1,
|
||||
right_hold_step = 5,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1126,7 +1126,13 @@ function ConfigDialog:onConfigMoreChoose(values, name, event, args, name_text, d
|
||||
if more_options_param.left_min then -- DoubleSpingWidget
|
||||
local DoubleSpinWidget = require("ui/widget/doublespinwidget")
|
||||
-- (No support for value_table - add it if needed)
|
||||
local curr_values = self.configurable[name]
|
||||
local curr_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]] }
|
||||
else
|
||||
curr_values = self.configurable[name]
|
||||
end
|
||||
widget = DoubleSpinWidget:new{
|
||||
width = math.floor(Screen:getWidth() * 0.6),
|
||||
left_text = more_options_param.left_text,
|
||||
@@ -1152,8 +1158,17 @@ function ConfigDialog:onConfigMoreChoose(values, name, event, args, name_text, d
|
||||
self:closeDialog()
|
||||
end
|
||||
local value_tables = { left_value, right_value }
|
||||
self:onConfigChoice(name, value_tables)
|
||||
if event then
|
||||
if more_options_param.names then
|
||||
self:onConfigChoice(more_options_param.names[1], left_value)
|
||||
self:onConfigChoice(more_options_param.names[2], right_value)
|
||||
else
|
||||
self:onConfigChoice(name, value_tables)
|
||||
end
|
||||
if more_options_param.events then
|
||||
self:onConfigEvent(more_options_param.events[1], left_value, nil)
|
||||
self:onConfigEvent(more_options_param.events[2], right_value, refresh_callback)
|
||||
self:update()
|
||||
elseif event then
|
||||
args = args or {}
|
||||
self:onConfigEvent(event, value_tables, refresh_callback)
|
||||
self:update()
|
||||
@@ -1172,8 +1187,15 @@ function ConfigDialog:onConfigMoreChoose(values, name, event, args, name_text, d
|
||||
text = T(_("Set default %1 to %2?"), (name_text or ""), values_string),
|
||||
ok_text = T(_("Set as default")),
|
||||
ok_callback = function()
|
||||
name = self.config_options.prefix.."_"..name
|
||||
G_reader_settings:saveSetting(name, value_tables)
|
||||
if more_options_param.names then
|
||||
name = self.config_options.prefix.."_"..more_options_param.names[1]
|
||||
G_reader_settings:saveSetting(name, left_value)
|
||||
name = self.config_options.prefix.."_"..more_options_param.names[2]
|
||||
G_reader_settings:saveSetting(name, right_value)
|
||||
else
|
||||
name = self.config_options.prefix.."_"..name
|
||||
G_reader_settings:saveSetting(name, value_tables)
|
||||
end
|
||||
self:update()
|
||||
UIManager:setDirty(self, function()
|
||||
return "ui", self.dialog_frame.dimen
|
||||
|
||||
@@ -167,16 +167,21 @@ function DoubleSpinWidget:update()
|
||||
widget_title,
|
||||
CloseButton:new{ window = self, padding_top = Size.margin.title, },
|
||||
}
|
||||
local widget_info = FrameContainer:new{
|
||||
padding = Size.padding.default,
|
||||
margin = Size.margin.small,
|
||||
bordersize = 0,
|
||||
TextBoxWidget:new{
|
||||
text = self.info_text or "",
|
||||
face = Font:getFace("x_smallinfofont"),
|
||||
width = math.floor(self.width * 0.9),
|
||||
local widget_info
|
||||
if self.info_text then
|
||||
widget_info = FrameContainer:new{
|
||||
padding = Size.padding.default,
|
||||
margin = Size.margin.small,
|
||||
bordersize = 0,
|
||||
TextBoxWidget:new{
|
||||
text = self.info_text,
|
||||
face = Font:getFace("x_smallinfofont"),
|
||||
width = math.floor(self.width * 0.9),
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
widget_info = VerticalSpan:new{ width = 0 }
|
||||
end
|
||||
local buttons = {
|
||||
{
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user