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

Set font size for menu items #5146

Merged
merged 3 commits into from
Jul 28, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 50 additions & 19 deletions frontend/apps/filemanager/filemanagermenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -126,31 +126,62 @@ function FileManagerMenu:setUpdateItemTable()
checked_func = function() return self.ui.file_chooser.show_unsupported end,
callback = function() self.ui:toggleUnsupportedFiles() end
}
self.menu_items.items_per_page = {
text = _("Items per page"),
help_text = _([[This sets the number of items per page in:
self.menu_items.items = {
text = _("Items"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe something like View? But that's just a synonym for Display, already used above when CoverBrowser is enabled. Without CoverBrowser you don't get access to settings like home abbreviation? It might be necessary to give that some attention, even if not necessarily as part of this PR. Also pinging @poire-z

sub_item_table = {
{
text = _("Items per page"),
help_text = _([[This sets the number of items per page in:
- File browser and history in 'classic' display mode
- File and directory selection
- Table of contents
- Bookmarks list]]),
keep_menu_open = true,
callback = function()
local SpinWidget = require("ui/widget/spinwidget")
local curr_items = G_reader_settings:readSetting("items_per_page") or 14
local items = SpinWidget:new{
width = Screen:getWidth() * 0.6,
value = curr_items,
value_min = 6,
value_max = 24,
ok_text = _("Set items"),
title_text = _("Items per page"),
callback = function(spin)
G_reader_settings:saveSetting("items_per_page", spin.value)
self.ui:onRefresh()
keep_menu_open = true,
callback = function()
local SpinWidget = require("ui/widget/spinwidget")
local curr_items = G_reader_settings:readSetting("items_per_page") or 14
local items = SpinWidget:new{
width = Screen:getWidth() * 0.6,
value = curr_items,
value_min = 6,
value_max = 24,
ok_text = _("Set items"),
title_text = _("Items per page"),
callback = function(spin)
G_reader_settings:saveSetting("items_per_page", spin.value)
--after changing items per page we reset the font size of item and set it as default
G_reader_settings:saveSetting("items_font_size", math.floor(24 - ((spin.value - 6)/ 18) * 10 ))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After changing items per page should I change font size for default or keep settings from maximum font size for item? Now I reset font size to default.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems somewhat unexpected to change that when you're just changing one setting.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I removed it.

self.ui:onRefresh()
end
}
UIManager:show(items)
end
},
{
text = _("Font size"),
keep_menu_open = true,
callback = function()
local SpinWidget = require("ui/widget/spinwidget")
local curr_items = G_reader_settings:readSetting("items_per_page") or 14
local default_font_size = math.floor(24 - ((curr_items - 6)/ 18) * 10 )
local curr_font_size = G_reader_settings:readSetting("items_font_size") or default_font_size
local items_font = SpinWidget:new{
width = Screen:getWidth() * 0.6,
value = curr_font_size,
value_min = 10,
value_max = 72,
default_value = default_font_size,
ok_text = _("Set size"),
title_text = _("Max font size for item"),
robert00s marked this conversation as resolved.
Show resolved Hide resolved
callback = function(spin)
G_reader_settings:saveSetting("items_font_size", spin.value)
self.ui:onRefresh()
end
}
UIManager:show(items_font)
end
}
UIManager:show(items)
end
}
}
self.menu_items.sort_by = self.ui:getSortingMenuTable()
self.menu_items.reverse_sorting = {
Expand Down
2 changes: 1 addition & 1 deletion frontend/ui/elements/filemanager_menu_order.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ local order = {
"filemanager_display_mode",
"show_hidden_files",
"show_unsupported_files",
"items_per_page",
"items",
"----------------------------",
"sort_by",
"reverse_sorting",
Expand Down
4 changes: 2 additions & 2 deletions frontend/ui/widget/menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -929,8 +929,8 @@ function Menu:updateItems(select_number)
end
--font size between 12 and 18 for better matching
local infont_size = math.floor(18 - (self.perpage - 6) / 3)
--font size between 14 and 24 for better matching
local font_size = math.floor(24 - ((self.perpage - 6)/ 18) * 10 )
--default font size between 14 and 24 for better matching
local font_size = G_reader_settings:readSetting("items_font_size") or math.floor(24 - ((self.perpage - 6)/ 18) * 10 )

for c = 1, math.min(self.perpage, #self.item_table) do
-- calculate index in item_table
Expand Down