coverbrowser: make showing some metadata fields optional

reviewable/pr10967/r1
Benoit Pierre 8 months ago committed by Frans de Jonge
parent e8bc28db33
commit 08555ad68b

@ -423,35 +423,39 @@ function ListMenuItem:update()
local fontsize_info = _fontSize(14, 18)
local wfileinfo = TextWidget:new{
text = fileinfo_str,
face = Font:getFace("cfont", fontsize_info),
fgcolor = self.file_deleted and Blitbuffer.COLOR_DARK_GRAY or nil,
}
local wpageinfo = TextWidget:new{
text = pages_str,
face = Font:getFace("cfont", fontsize_info),
fgcolor = self.file_deleted and Blitbuffer.COLOR_DARK_GRAY or nil,
}
local wright_items = {align = "right"}
local wright_right_padding = 0
local wright_width = 0
local wright
local wright_width = math.max(wfileinfo:getSize().w, wpageinfo:getSize().w)
local wright_right_padding = Screen:scaleBySize(10)
if not BookInfoManager:getSetting("hide_file_info") then
local wfileinfo = TextWidget:new{
text = fileinfo_str,
face = Font:getFace("cfont", fontsize_info),
fgcolor = self.file_deleted and Blitbuffer.COLOR_DARK_GRAY or nil,
}
table.insert(wright_items, wfileinfo)
end
-- We just built two string to be put one on top of the other, and we want
-- the combo centered. Given the nature of our strings (numbers,
-- uppercase MB/KB on top text, number and lowercase "page" on bottom text),
-- we get the annoying feeling it's not centered but shifted towards top.
-- Let's add a small VerticalSpan at top to give a better visual
-- feeling of centering.
local wright = CenterContainer:new{
dimen = Geom:new{ w = wright_width, h = dimen.h },
VerticalGroup:new{
align = "right",
VerticalSpan:new{ width = Screen:scaleBySize(2) },
wfileinfo,
wpageinfo,
if not BookInfoManager:getSetting("hide_page_info") then
local wpageinfo = TextWidget:new{
text = pages_str,
face = Font:getFace("cfont", fontsize_info),
fgcolor = self.file_deleted and Blitbuffer.COLOR_DARK_GRAY or nil,
}
}
table.insert(wright_items, wpageinfo)
end
if #wright_items > 0 then
for i, w in ipairs(wright_items) do
wright_width = math.max(wright_width, w:getSize().w)
end
wright = CenterContainer:new{
dimen = Geom:new{ w = wright_width, h = dimen.h },
VerticalGroup:new(wright_items),
}
wright_right_padding = Screen:scaleBySize(10)
end
-- Create or replace corner_mark if needed
local mark_size = math.floor(dimen.h * (1/6))
@ -678,13 +682,15 @@ function ListMenuItem:update()
wmain
})
-- add right widget
table.insert(widget, RightContainer:new{
if wright then
table.insert(widget, RightContainer:new{
dimen = dimen,
HorizontalGroup:new{
wright,
HorizontalSpan:new{ width = wright_right_padding },
},
})
end
else -- bookinfo not found
if self.init_done then

@ -190,6 +190,46 @@ function CoverBrowser:addToMainMenu(menu_items)
UIManager:show(items)
end,
},
{
text = _("Progress"),
sub_item_table = {
{
text = _("Show progress"),
checked_func = function() return
not BookInfoManager:getSetting("hide_page_info")
end,
callback = function()
BookInfoManager:toggleSetting("hide_page_info")
self:refreshFileManagerInstance()
end,
},
{
text = _("Show progress % in mosaic mode"),
checked_func = function() return BookInfoManager:getSetting("show_progress_in_mosaic") end,
callback = function()
BookInfoManager:toggleSetting("show_progress_in_mosaic")
self:refreshFileManagerInstance()
end,
},
{
text = _("Show number of pages read instead of progress %"),
checked_func = function() return BookInfoManager:getSetting("show_pages_read_as_progress") end,
callback = function()
BookInfoManager:toggleSetting("show_pages_read_as_progress")
self:refreshFileManagerInstance()
end,
},
{
text = _("Show number of pages left to read"),
checked_func = function() return BookInfoManager:getSetting("show_pages_left_in_progress") end,
callback = function()
BookInfoManager:toggleSetting("show_pages_left_in_progress")
self:refreshFileManagerInstance()
end,
separator = true,
},
},
},
{
text = _("Display hints"),
sub_item_table = {
@ -265,29 +305,14 @@ function CoverBrowser:addToMainMenu(menu_items)
separator = true
},
{
text = _("Show progress % in mosaic mode"),
checked_func = function() return BookInfoManager:getSetting("show_progress_in_mosaic") end,
callback = function()
BookInfoManager:toggleSetting("show_progress_in_mosaic")
self:refreshFileManagerInstance()
end,
},
{
text = _("Show number of pages read instead of progress %"),
checked_func = function() return BookInfoManager:getSetting("show_pages_read_as_progress") end,
callback = function()
BookInfoManager:toggleSetting("show_pages_read_as_progress")
self:refreshFileManagerInstance()
text = _("Show file properties"),
checked_func = function()
return not BookInfoManager:getSetting("hide_file_info")
end,
},
{
text = _("Show number of pages left to read"),
checked_func = function() return BookInfoManager:getSetting("show_pages_left_in_progress") end,
callback = function()
BookInfoManager:toggleSetting("show_pages_left_in_progress")
BookInfoManager:toggleSetting("hide_file_info")
self:refreshFileManagerInstance()
end,
separator = true,
},
{
text = _("Book info cache management"),

Loading…
Cancel
Save