2
0
mirror of https://github.com/koreader/koreader synced 2024-11-13 19:11:25 +00:00

UI: Support appending the value in pixels when formating metric/imperial dimensions

This commit is contained in:
NiLuJe 2024-09-12 21:19:24 +02:00
parent f8890a310d
commit cd0d8ca8bd
2 changed files with 21 additions and 1 deletions

View File

@ -63,7 +63,14 @@ function optionsutil.formatFlexSize(value, unit)
-- We don't so subpixel positioning ;)
fmt = "%d (%d %s)"
end
return string.format(fmt, size, convertSizeTo(size, unit), shown_unit)
if G_reader_settings:isTrue("dimension_units_append_px") and unit ~= "px" then
local px_str = C_("Pixels", "px")
return string.format(fmt .. " [%d %s]", size, convertSizeTo(size, unit), shown_unit,
convertSizeTo(size, "px"), px_str)
else
return string.format(fmt, size, convertSizeTo(size, unit), shown_unit)
end
end
function optionsutil.showValues(configurable, option, prefix, document, unit)

View File

@ -721,6 +721,19 @@ common_settings.units = {
return T(_("Dimension units: %1"), unit)
end,
sub_item_table = {
{
text = _("Also show values in pixels"),
checked_func = function()
return G_reader_settings:isTrue("dimension_units_append_px")
end,
enabled_func = function()
return G_reader_settings:readSetting("dimension_units") ~= "px"
end,
callback = function()
G_reader_settings:flipNilOrFalse("dimension_units_append_px")
end,
separator = true,
},
genGenericMenuEntry(_("Metric system"), "dimension_units", "mm", nil, true),
genGenericMenuEntry(_("Imperial system"), "dimension_units", "in", nil, true),
genGenericMenuEntry(_("Pixels"), "dimension_units", "px", nil, true),