fix: auto dpi menu checkbox display (#4771)

pull/4772/head
Qingping Hou 5 years ago committed by Frans de Jonge
parent 658f513512
commit fc69257660

@ -13,6 +13,7 @@ local Device = {
model = nil,
powerd = nil,
screen = nil,
screen_dpi_override = nil,
input = nil,
-- For Kobo, wait at least 15 seconds before calling suspend script. Otherwise, suspend might
-- fail and the battery will be drained while we are in screensaver mode
@ -146,6 +147,7 @@ end
function Device:setScreenDPI(dpi_override)
self.screen:setDPI(dpi_override)
self.input.gesture_detector:init()
self.screen_dpi_override = dpi_override
end
function Device:getPowerDevice()

@ -1,7 +1,10 @@
local _ = require("gettext")
local Screen = require("device").screen
local Device = require("device")
local Screen = Device.screen
local T = require("ffi/util").template
local function isAutoDPI() return Device.screen_dpi_override == nil end
local function dpi() return Screen:getDPI() end
local function custom() return G_reader_settings:readSetting("custom_screen_dpi") end
@ -14,7 +17,7 @@ local function setDPI(_dpi)
or _("DPI set to auto. This will take effect after restarting."),
})
G_reader_settings:saveSetting("screen_dpi", _dpi)
Screen:setDPI(_dpi)
Device:setScreenDPI(_dpi)
end
local dpi_auto = Screen.device.screen_dpi
@ -31,14 +34,13 @@ return {
{
text = dpi_auto and T(_("Auto DPI (%1)"), dpi_auto) or _("Auto DPI"),
help_text = _("The DPI of your screen is automatically detected so items can be drawn with the right amount of pixels. This will usually display at (roughly) the same size on different devices, while remaining sharp. Increasing the DPI setting will result in larger text and icons, while a lower DPI setting will look smaller on the screen."),
checked_func = function()
return dpi() == nil
end,
checked_func = isAutoDPI,
callback = function() setDPI() end
},
{
text = T(_("Small (%1)"), dpi_small),
checked_func = function()
if isAutoDPI() then return false end
local _dpi, _custom = dpi(), custom()
return _dpi and _dpi <= 140 and _dpi ~= _custom
end,
@ -47,6 +49,7 @@ return {
{
text = T(_("Medium (%1)"), dpi_medium),
checked_func = function()
if isAutoDPI() then return false end
local _dpi, _custom = dpi(), custom()
return _dpi and _dpi > 140 and _dpi <= 200 and _dpi ~= _custom
end,
@ -55,6 +58,7 @@ return {
{
text = T(_("Large (%1)"), dpi_large),
checked_func = function()
if isAutoDPI() then return false end
local _dpi, _custom = dpi(), custom()
return _dpi and _dpi > 200 and _dpi <= 280 and _dpi ~= _custom
end,
@ -63,6 +67,7 @@ return {
{
text = T(_("Extra large (%1)"), dpi_xlarge),
checked_func = function()
if isAutoDPI() then return false end
local _dpi, _custom = dpi(), custom()
return _dpi and _dpi > 280 and _dpi <= 400 and _dpi ~= _custom
end,
@ -71,6 +76,7 @@ return {
{
text = T(_("Extra-Extra Large (%1)"), dpi_xxlarge),
checked_func = function()
if isAutoDPI() then return false end
local _dpi, _custom = dpi(), custom()
return _dpi and _dpi > 400 and _dpi <= 560 and _dpi ~= _custom
end,
@ -79,6 +85,7 @@ return {
{
text = T(_("Extra-Extra-Extra Large (%1)"), dpi_xxxlarge),
checked_func = function()
if isAutoDPI() then return false end
local _dpi, _custom = dpi(), custom()
return _dpi and _dpi > 560 and _dpi ~= _custom
end,
@ -89,6 +96,7 @@ return {
return T(_("Custom DPI: %1 (hold to set)"), custom() or dpi_auto)
end,
checked_func = function()
if isAutoDPI() then return false end
local _dpi, _custom = dpi(), custom()
return _custom and _dpi == _custom
end,

Loading…
Cancel
Save