Fix: set custom screen DPI (#5165)

Settings -> Screen -> Screen DPI
When custom DPI is not set we see ugly information with %1:
pull/5175/head
Robert 5 years ago committed by Frans de Jonge
parent 825a3c4b52
commit d3e02d05c6

@ -20,6 +20,27 @@ local function setDPI(_dpi)
Device:setScreenDPI(_dpi)
end
local function spinWidgetSetDPI(touchmenu_instance)
local SpinWidget = require("ui/widget/spinwidget")
local UIManager = require("ui/uimanager")
local items = SpinWidget:new{
width = Screen:getWidth() * 0.6,
value = custom() or dpi(),
value_min = 90,
value_max = 900,
value_step = 10,
value_hold_step = 50,
ok_text = _("Set DPI"),
title_text = _("Set custom screen DPI"),
callback = function(spin)
G_reader_settings:saveSetting("custom_screen_dpi", spin.value)
setDPI(spin.value)
touchmenu_instance:updateItems()
end
}
UIManager:show(items)
end
local dpi_auto = Screen.device.screen_dpi
local dpi_small = 120
local dpi_medium = 160
@ -93,27 +114,28 @@ return {
},
{
text_func = function()
return T(_("Custom DPI: %1 (hold to set)"), custom() or dpi_auto)
local custom_dpi = custom() or dpi_auto
if custom_dpi then
return T(_("Custom DPI: %1 (hold to set)"), custom() or dpi_auto)
else
return _("Custom DPI")
end
end,
checked_func = function()
if isAutoDPI() then return false end
local _dpi, _custom = dpi(), custom()
return _custom and _dpi == _custom
end,
callback = function() setDPI(custom() or dpi_auto) end,
hold_input = {
title = _("Enter custom screen DPI"),
type = "number",
hint = "(90 - 900)",
callback = function(input)
local _dpi = tonumber(input)
_dpi = _dpi < 90 and 90 or _dpi
_dpi = _dpi > 900 and 900 or _dpi
G_reader_settings:saveSetting("custom_screen_dpi", _dpi)
setDPI(_dpi)
end,
ok_text = _("Set custom DPI"),
},
callback = function(touchmenu_instance)
if custom() then
setDPI(custom() or dpi_auto)
else
spinWidgetSetDPI(touchmenu_instance)
end
end,
hold_callback = function(touchmenu_instance)
spinWidgetSetDPI(touchmenu_instance)
end,
},
}
}

Loading…
Cancel
Save