Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: set custom screen DPI #5165

Merged
merged 4 commits into from Aug 3, 2019

Conversation

@robert00s
Copy link
Contributor

commented Aug 2, 2019

Settings -> Screen -> Screen DPI
When custom DPI is not set we see ugly information with %1:

obraz
This PR should fix it and replace input widget with spin widget.

Before:
obraz

After:

obraz

obraz

obraz

@Frenzie Frenzie added this to the 2019.08 milestone Aug 2, 2019

@Frenzie

This comment has been minimized.

Copy link
Member

commented Aug 2, 2019

I forget, but does the spin widget allow to hold for custom input? The higher the (physical) DPI the less it matters, but the scaling factor may cause multiple (slightly) distinct renderings in steps smaller than 10.

G_reader_settings:saveSetting("custom_screen_dpi", spin.value)
setDPI(spin.value)
local Event = require("ui/event")
UIManager:broadcastEvent(Event:new("UpdateTouchMenu"))

This comment has been minimized.

Copy link
@poire-z

poire-z Aug 2, 2019

Contributor

May be you don't need to add this onUpdateTouchMenu and use a broadcast.
A callback called from a menu item gets passed the touchmenu_instance, and you can call updateItems on it.
For example (even if it's a bit different from your situation):

callback = function(touchmenu_instance)
local SpinWidget = require("ui/widget/spinwidget")
UIManager:show(SpinWidget:new{
width = Screen:getWidth() * 0.75,
value = G_reader_settings:readSetting("copt_overlap_lines") or 1,
value_min = 1,
value_max = 10,
precision = "%d",
ok_text = _("Set"),
title_text = _("Set overlapped lines"),
text = overlap_lines_help_text,
callback = function(spin)
G_reader_settings:saveSetting("copt_overlap_lines", spin.value)
touchmenu_instance:updateItems()
end,
})

This comment has been minimized.

Copy link
@robert00s

robert00s Aug 2, 2019

Author Contributor

I didn't know about that trick :)
Thanks, it works :)

@robert00s

This comment has been minimized.

Copy link
Contributor Author

commented Aug 2, 2019

@Frenzie You can tap on numbers (between up and down buttons) and you can enter manual value (for example 152).

@Frenzie

This comment has been minimized.

Copy link
Member

commented Aug 2, 2019

@robert00s Alright, cool. I have no real comments at a glance.

@Frenzie

Frenzie approved these changes Aug 2, 2019

@Frenzie Frenzie merged commit d3e02d0 into koreader:master Aug 3, 2019

1 check passed

ci/circleci Your tests passed on CircleCI!
Details

@robert00s robert00s deleted the robert00s:custom_dpi branch Aug 16, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.