File list: new display options (#12954)
Some checks are pending
macos / macOS ${{ matrix.image }} ${{ matrix.platform }} 🔨${{ matrix.xcode_version }} 🎯${{ matrix.deployment_target }} (10.15, 13, x86-64, 15.2) (push) Waiting to run
macos / macOS ${{ matrix.image }} ${{ matrix.platform }} 🔨${{ matrix.xcode_version }} 🎯${{ matrix.deployment_target }} (11.0, 14, ARM64, 15.4) (push) Waiting to run

This commit is contained in:
hius07
2025-01-05 18:59:28 +02:00
committed by GitHub
parent cbe211190f
commit f0a3e1c63a
5 changed files with 105 additions and 122 deletions

View File

@@ -240,7 +240,7 @@ function FileManagerMenu:setUpdateItemTable()
end,
callback = function()
G_reader_settings:flipNilOrFalse("items_multilines_show_more_text")
self.ui:onRefresh()
FileChooser:refreshPath()
end,
separator = true,
},
@@ -255,7 +255,7 @@ function FileManagerMenu:setUpdateItemTable()
else
G_reader_settings:saveSetting("show_file_in_bold", "opened")
end
self.ui:onRefresh()
FileChooser:refreshPath()
end,
},
{
@@ -269,7 +269,7 @@ function FileManagerMenu:setUpdateItemTable()
else
G_reader_settings:delSetting("show_file_in_bold")
end
self.ui:onRefresh()
FileChooser:refreshPath()
end,
},
},
@@ -375,12 +375,22 @@ To:
end,
callback = function()
G_reader_settings:flipNilOrFalse("lock_home_folder")
self.ui:onRefresh()
FileChooser:refreshPath()
end,
},
},
separator = true,
},
{
text = _("Show collection mark"),
checked_func = function()
return G_reader_settings:hasNot("collection_show_mark")
end,
callback = function()
G_reader_settings:flipNilOrTrue("collection_show_mark")
FileChooser:refreshPath()
end,
},
{
text_func = function()
local default_value = KeyValuePage.getDefaultItemsPerPage()

View File

@@ -88,11 +88,13 @@ function ReadCollection:isFileInCollection(file, collection_name)
return self.coll[collection_name][file] and true or false
end
function ReadCollection:isFileInCollections(file)
file = ffiUtil.realpath(file) or file
for _, coll in pairs(self.coll) do
if coll[file] then
return true
function ReadCollection:isFileInCollections(file, ignore_show_mark_setting)
if ignore_show_mark_setting or G_reader_settings:nilOrTrue("collection_show_mark") then
file = ffiUtil.realpath(file) or file
for _, coll in pairs(self.coll) do
if coll[file] then
return true
end
end
end
return false

View File

@@ -483,7 +483,8 @@ function ListMenuItem:update()
local fontsize_title = _fontSize(20, 24)
local fontsize_authors = _fontSize(18, 22)
local wtitle, wauthors
local title, authors
local title, authors, reduce_font_size
local fixed_font_size = BookInfoManager:getSetting("fixed_item_font_size")
local series_mode = BookInfoManager:getSetting("series_mode")
-- whether to use or not title and authors
@@ -493,11 +494,9 @@ function ListMenuItem:update()
-- if concatenated.)
if self.do_filename_only or bookinfo.ignore_meta then
title = filename_without_suffix -- made out above
title = BD.auto(title)
authors = nil
else
title = bookinfo.title and bookinfo.title or filename_without_suffix
title = BD.auto(title)
title = bookinfo.title or filename_without_suffix
authors = bookinfo.authors
-- If multiple authors (crengine separates them with \n), we
-- can display them on multiple lines, but limit to 2, and
@@ -514,41 +513,35 @@ function ListMenuItem:update()
end
authors = table.concat(authors, "\n")
-- as we'll fit 3 lines instead of 2, we can avoid some loops by starting from a lower font size
fontsize_title = _fontSize(17, 21)
fontsize_authors = _fontSize(15, 19)
reduce_font_size = true
elseif authors then
authors = BD.auto(authors)
end
end
title = BD.auto(title)
-- add Series metadata if requested
if bookinfo.series then
if bookinfo.series_index then
bookinfo.series = BD.auto(bookinfo.series .. " #" .. bookinfo.series_index)
else
bookinfo.series = BD.auto(bookinfo.series)
end
if series_mode and bookinfo.series then
local series = bookinfo.series_index and bookinfo.series .. " #" .. bookinfo.series_index
or bookinfo.series
series = BD.auto(series)
if series_mode == "append_series_to_title" then
if title then
title = title .. " - " .. bookinfo.series
else
title = bookinfo.series
end
end
if not authors then
if series_mode == "append_series_to_authors" or series_mode == "series_in_separate_line" then
authors = bookinfo.series
end
else
if series_mode == "append_series_to_authors" then
authors = authors .. " - " .. bookinfo.series
elseif series_mode == "series_in_separate_line" then
authors = bookinfo.series .. "\n" .. authors
title = title .. " - " .. series
elseif series_mode == "append_series_to_authors" then
authors = authors and authors .. " - " .. series or series
else -- "series_in_separate_line"
if authors then
authors = series .. "\n" .. authors
-- as we'll fit 3 lines instead of 2, we can avoid some loops by starting from a lower font size
fontsize_title = _fontSize(17, 21)
fontsize_authors = _fontSize(15, 19)
reduce_font_size = true
else
authors = series
end
end
end
if reduce_font_size and not fixed_font_size then
fontsize_title = _fontSize(17, 21)
fontsize_authors = _fontSize(15, 19)
end
if bookinfo.unsupported then
-- Let's show this fact in place of the anyway empty authors slot
authors = T(_("(no book information: %1)"), _(bookinfo.unsupported))
@@ -606,7 +599,7 @@ function ListMenuItem:update()
break
end
-- Don't go too low, and get out of this loop.
if fontsize_title <= 12 or fontsize_authors <= 10 then
if fixed_font_size or fontsize_title <= 12 or fontsize_authors <= 10 then
local title_height = wtitle:getSize().h
local title_line_height = wtitle:getLineHeight()
local title_min_height = 2 * title_line_height -- unscaled_size_check: ignore

View File

@@ -155,6 +155,23 @@ function CoverBrowser:addToMainMenu(menu_items)
-- next to Classic mode settings
if menu_items.filebrowser_settings == nil then return end
local fc = self.ui.file_chooser
local function genSeriesSubMenuItem(item_text, item_series_mode)
return {
text = item_text,
radio = true,
checked_func = function()
return series_mode == item_series_mode
end,
callback = function()
if series_mode ~= item_series_mode then
series_mode = item_series_mode
BookInfoManager:saveSetting("series_mode", series_mode)
fc:updateItems(1, true)
end
end,
}
end
table.insert (menu_items.filebrowser_settings.sub_item_table, 5, {
text = _("Mosaic and detailed list settings"),
separator = true,
@@ -255,6 +272,7 @@ function CoverBrowser:addToMainMenu(menu_items)
}
UIManager:show(widget)
end,
separator = true,
},
{
text_func = function()
@@ -292,6 +310,26 @@ function CoverBrowser:addToMainMenu(menu_items)
}
UIManager:show(widget)
end,
},
{
text = _("Shrink item font size to fit more text"),
checked_func = function()
return not BookInfoManager:getSetting("fixed_item_font_size")
end,
callback = function()
BookInfoManager:toggleSetting("fixed_item_font_size")
fc:updateItems(1, true)
end,
},
{
text = _("Show file properties"),
checked_func = function()
return not BookInfoManager:getSetting("hide_file_info")
end,
callback = function()
BookInfoManager:toggleSetting("hide_file_info")
fc:updateItems(1, true)
end,
separator = true,
},
{
@@ -344,6 +382,7 @@ function CoverBrowser:addToMainMenu(menu_items)
BookInfoManager:toggleSetting("no_hint_description")
fc:updateItems(1, true)
end,
separator = true,
},
{
text = _("Show hint for book status in history"),
@@ -360,62 +399,17 @@ function CoverBrowser:addToMainMenu(menu_items)
BookInfoManager:toggleSetting("collections_hint_opened")
fc:updateItems(1, true)
end,
}
}
},
{
text = _("Series"),
sub_item_table = {
{
text = _("Append series metadata to authors"),
checked_func = function() return series_mode == "append_series_to_authors" end,
callback = function()
if series_mode == "append_series_to_authors" then
series_mode = nil
else
series_mode = "append_series_to_authors"
end
BookInfoManager:saveSetting("series_mode", series_mode)
fc:updateItems(1, true)
end,
},
{
text = _("Append series metadata to title"),
checked_func = function() return series_mode == "append_series_to_title" end,
callback = function()
if series_mode == "append_series_to_title" then
series_mode = nil
else
series_mode = "append_series_to_title"
end
BookInfoManager:saveSetting("series_mode", series_mode)
fc:updateItems(1, true)
end,
},
{
text = _("Show series metadata in separate line"),
checked_func = function() return series_mode == "series_in_separate_line" end,
callback = function()
if series_mode == "series_in_separate_line" then
series_mode = nil
else
series_mode = "series_in_separate_line"
end
BookInfoManager:saveSetting("series_mode", series_mode)
fc:updateItems(1, true)
end,
},
},
},
{
text = _("Show file properties"),
checked_func = function()
return not BookInfoManager:getSetting("hide_file_info")
end,
callback = function()
BookInfoManager:toggleSetting("hide_file_info")
fc:updateItems(1, true)
end,
text = _("Series"),
sub_item_table = {
genSeriesSubMenuItem(_("Do not show series metadata"), nil),
genSeriesSubMenuItem(_("Show series metadata in separate line"), "series_in_separate_line"),
genSeriesSubMenuItem(_("Append series metadata to title"), "append_series_to_title"),
genSeriesSubMenuItem(_("Append series metadata to authors"), "append_series_to_authors"),
},
separator = true,
},
{
@@ -434,7 +428,6 @@ function CoverBrowser:addToMainMenu(menu_items)
keep_menu_open = true,
callback = function()
local ConfirmBox = require("ui/widget/confirmbox")
UIManager:close(self.file_dialog)
UIManager:show(ConfirmBox:new{
-- Checking file existences is quite fast, but deleting entries is slow.
text = _("Are you sure that you want to prune cache of removed books?\n(This may take a while.)"),
@@ -446,9 +439,9 @@ function CoverBrowser:addToMainMenu(menu_items)
UIManager:nextTick(function()
local summary = BookInfoManager:removeNonExistantEntries()
UIManager:close(msg)
UIManager:show( InfoMessage:new{ text = summary } )
UIManager:show(InfoMessage:new{ text = summary })
end)
end
end,
})
end,
},
@@ -457,7 +450,6 @@ function CoverBrowser:addToMainMenu(menu_items)
keep_menu_open = true,
callback = function()
local ConfirmBox = require("ui/widget/confirmbox")
UIManager:close(self.file_dialog)
UIManager:show(ConfirmBox:new{
text = _("Are you sure that you want to compact cache database?\n(This may take a while.)"),
ok_text = _("Compact database"),
@@ -468,9 +460,9 @@ function CoverBrowser:addToMainMenu(menu_items)
UIManager:nextTick(function()
local summary = BookInfoManager:compactDb()
UIManager:close(msg)
UIManager:show( InfoMessage:new{ text = summary } )
UIManager:show(InfoMessage:new{ text = summary })
end)
end
end,
})
end,
},
@@ -479,13 +471,12 @@ function CoverBrowser:addToMainMenu(menu_items)
keep_menu_open = true,
callback = function()
local ConfirmBox = require("ui/widget/confirmbox")
UIManager:close(self.file_dialog)
UIManager:show(ConfirmBox:new{
text = _("Are you sure that you want to delete cover and metadata cache?\n(This will also reset your display mode settings.)"),
ok_text = _("Purge"),
ok_callback = function()
BookInfoManager:deleteDb()
end
end,
})
end,
},

View File

@@ -613,31 +613,18 @@ function MosaicMenuItem:update()
self._has_cover_image = true
else
-- add Series metadata if requested
local series_mode = BookInfoManager:getSetting("series_mode")
local title_add, authors_add
if bookinfo.series then
if bookinfo.series_index then
bookinfo.series = BD.auto(bookinfo.series .. " #" .. bookinfo.series_index)
else
bookinfo.series = BD.auto(bookinfo.series)
end
local series_mode = BookInfoManager:getSetting("series_mode")
if series_mode and bookinfo.series then
local series = bookinfo.series_index and bookinfo.series .. " #" .. bookinfo.series_index
or bookinfo.series
series = BD.auto(series)
if series_mode == "append_series_to_title" then
if bookinfo.title then
title_add = " - " .. bookinfo.series
else
title_add = bookinfo.series
end
end
if not bookinfo.authors then
if series_mode == "append_series_to_authors" or series_mode == "series_in_separate_line" then
authors_add = bookinfo.series
end
else
if series_mode == "append_series_to_authors" then
authors_add = " - " .. bookinfo.series
elseif series_mode == "series_in_separate_line" then
authors_add = "\n \n" .. bookinfo.series
end
title_add = bookinfo.title and " - " .. series or series
elseif series_mode == "append_series_to_authors" then
authors_add = bookinfo.authors and " - " .. series or series
else -- "series_in_separate_line"
authors_add = bookinfo.authors and "\n \n" .. series or series
end
end
local bottom_pad = Size.padding.default