|
|
@ -2,6 +2,7 @@ local UIManager = require("ui/uimanager")
|
|
|
|
local WidgetContainer = require("ui/widget/container/widgetcontainer")
|
|
|
|
local WidgetContainer = require("ui/widget/container/widgetcontainer")
|
|
|
|
local logger = require("logger")
|
|
|
|
local logger = require("logger")
|
|
|
|
local _ = require("gettext")
|
|
|
|
local _ = require("gettext")
|
|
|
|
|
|
|
|
local T = require("ffi/util").template
|
|
|
|
local BookInfoManager = require("bookinfomanager")
|
|
|
|
local BookInfoManager = require("bookinfomanager")
|
|
|
|
|
|
|
|
|
|
|
|
--[[
|
|
|
|
--[[
|
|
|
@ -50,7 +51,9 @@ local CoverBrowser = WidgetContainer:extend{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function CoverBrowser:init()
|
|
|
|
function CoverBrowser:init()
|
|
|
|
|
|
|
|
if self.ui.file_chooser then -- FileManager menu only
|
|
|
|
self.ui.menu:registerToMainMenu(self)
|
|
|
|
self.ui.menu:registerToMainMenu(self)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
if init_done then -- things already patched according to current modes
|
|
|
|
if init_done then -- things already patched according to current modes
|
|
|
|
return
|
|
|
|
return
|
|
|
@ -64,6 +67,7 @@ function CoverBrowser:init()
|
|
|
|
logger.info("CoverBrowser: setting default display modes")
|
|
|
|
logger.info("CoverBrowser: setting default display modes")
|
|
|
|
BookInfoManager:saveSetting("filemanager_display_mode", "list_image_meta")
|
|
|
|
BookInfoManager:saveSetting("filemanager_display_mode", "list_image_meta")
|
|
|
|
BookInfoManager:saveSetting("history_display_mode", "mosaic_image")
|
|
|
|
BookInfoManager:saveSetting("history_display_mode", "mosaic_image")
|
|
|
|
|
|
|
|
BookInfoManager:saveSetting("collection_display_mode", "mosaic_image")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
G_reader_settings:makeTrue("coverbrowser_initial_default_setup_done")
|
|
|
|
G_reader_settings:makeTrue("coverbrowser_initial_default_setup_done")
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -72,17 +76,11 @@ function CoverBrowser:init()
|
|
|
|
self:setupHistoryDisplayMode(BookInfoManager:getSetting("history_display_mode"))
|
|
|
|
self:setupHistoryDisplayMode(BookInfoManager:getSetting("history_display_mode"))
|
|
|
|
self:setupCollectionDisplayMode(BookInfoManager:getSetting("collection_display_mode"))
|
|
|
|
self:setupCollectionDisplayMode(BookInfoManager:getSetting("collection_display_mode"))
|
|
|
|
series_mode = BookInfoManager:getSetting("series_mode")
|
|
|
|
series_mode = BookInfoManager:getSetting("series_mode")
|
|
|
|
|
|
|
|
|
|
|
|
init_done = true
|
|
|
|
init_done = true
|
|
|
|
BookInfoManager:closeDbConnection() -- will be re-opened if needed
|
|
|
|
BookInfoManager:closeDbConnection() -- will be re-opened if needed
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function CoverBrowser:addToMainMenu(menu_items)
|
|
|
|
function CoverBrowser:addToMainMenu(menu_items)
|
|
|
|
-- We add it only to FileManager menu
|
|
|
|
|
|
|
|
if self.ui.view then -- Reader
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local modes = {
|
|
|
|
local modes = {
|
|
|
|
{ _("Classic (filename only)") },
|
|
|
|
{ _("Classic (filename only)") },
|
|
|
|
{ _("Mosaic with cover images"), "mosaic_image" },
|
|
|
|
{ _("Mosaic with cover images"), "mosaic_image" },
|
|
|
@ -94,7 +92,7 @@ function CoverBrowser:addToMainMenu(menu_items)
|
|
|
|
local sub_item_table, history_sub_item_table, collection_sub_item_table = {}, {}, {}
|
|
|
|
local sub_item_table, history_sub_item_table, collection_sub_item_table = {}, {}, {}
|
|
|
|
for i, v in ipairs(modes) do
|
|
|
|
for i, v in ipairs(modes) do
|
|
|
|
local text, mode = unpack(v)
|
|
|
|
local text, mode = unpack(v)
|
|
|
|
table.insert(sub_item_table, {
|
|
|
|
sub_item_table[i] = {
|
|
|
|
text = text,
|
|
|
|
text = text,
|
|
|
|
checked_func = function()
|
|
|
|
checked_func = function()
|
|
|
|
return mode == filemanager_display_mode
|
|
|
|
return mode == filemanager_display_mode
|
|
|
@ -106,8 +104,8 @@ function CoverBrowser:addToMainMenu(menu_items)
|
|
|
|
self:setupCollectionDisplayMode(mode)
|
|
|
|
self:setupCollectionDisplayMode(mode)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
table.insert(history_sub_item_table, {
|
|
|
|
history_sub_item_table[i] = {
|
|
|
|
text = text,
|
|
|
|
text = text,
|
|
|
|
checked_func = function()
|
|
|
|
checked_func = function()
|
|
|
|
return mode == history_display_mode
|
|
|
|
return mode == history_display_mode
|
|
|
@ -115,8 +113,8 @@ function CoverBrowser:addToMainMenu(menu_items)
|
|
|
|
callback = function()
|
|
|
|
callback = function()
|
|
|
|
self:setupHistoryDisplayMode(mode)
|
|
|
|
self:setupHistoryDisplayMode(mode)
|
|
|
|
end,
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
table.insert(collection_sub_item_table, {
|
|
|
|
collection_sub_item_table[i] = {
|
|
|
|
text = text,
|
|
|
|
text = text,
|
|
|
|
checked_func = function()
|
|
|
|
checked_func = function()
|
|
|
|
return mode == collection_display_mode
|
|
|
|
return mode == collection_display_mode
|
|
|
@ -124,7 +122,7 @@ function CoverBrowser:addToMainMenu(menu_items)
|
|
|
|
callback = function()
|
|
|
|
callback = function()
|
|
|
|
self:setupCollectionDisplayMode(mode)
|
|
|
|
self:setupCollectionDisplayMode(mode)
|
|
|
|
end,
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
sub_item_table[#modes].separator = true
|
|
|
|
sub_item_table[#modes].separator = true
|
|
|
|
table.insert(sub_item_table, {
|
|
|
|
table.insert(sub_item_table, {
|
|
|
@ -161,58 +159,174 @@ function CoverBrowser:addToMainMenu(menu_items)
|
|
|
|
-- add Mosaic / Detailed list mode settings to File browser Settings submenu
|
|
|
|
-- add Mosaic / Detailed list mode settings to File browser Settings submenu
|
|
|
|
-- next to Classic mode settings
|
|
|
|
-- next to Classic mode settings
|
|
|
|
if menu_items.filebrowser_settings == nil then return end
|
|
|
|
if menu_items.filebrowser_settings == nil then return end
|
|
|
|
table.insert (menu_items.filebrowser_settings.sub_item_table, 4, {
|
|
|
|
table.insert (menu_items.filebrowser_settings.sub_item_table, 5, {
|
|
|
|
text = _("Mosaic and detailed list settings"),
|
|
|
|
text = _("Mosaic and detailed list settings"),
|
|
|
|
separator = true,
|
|
|
|
separator = true,
|
|
|
|
sub_item_table = {
|
|
|
|
sub_item_table = {
|
|
|
|
{
|
|
|
|
{
|
|
|
|
text = _("Items per page"),
|
|
|
|
text_func = function()
|
|
|
|
help_text = _([[This sets the number of files and folders per page in display modes other than classic.]]),
|
|
|
|
local fc = self.ui.file_chooser
|
|
|
|
|
|
|
|
return T(_("Items per page in portrait mosaic mode: %1 × %2"), fc.nb_cols_portrait, fc.nb_rows_portrait)
|
|
|
|
|
|
|
|
end,
|
|
|
|
-- Best to not "keep_menu_open = true", to see how this apply on the full view
|
|
|
|
-- Best to not "keep_menu_open = true", to see how this apply on the full view
|
|
|
|
callback = function()
|
|
|
|
callback = function()
|
|
|
|
|
|
|
|
local fc = self.ui.file_chooser
|
|
|
|
|
|
|
|
local nb_cols = fc.nb_cols_portrait
|
|
|
|
|
|
|
|
local nb_rows = fc.nb_rows_portrait
|
|
|
|
|
|
|
|
local DoubleSpinWidget = require("/ui/widget/doublespinwidget")
|
|
|
|
|
|
|
|
local widget = DoubleSpinWidget:new{
|
|
|
|
|
|
|
|
title_text = _("Portrait mosaic mode"),
|
|
|
|
|
|
|
|
width_factor = 0.6,
|
|
|
|
|
|
|
|
left_text = _("Columns"),
|
|
|
|
|
|
|
|
left_value = nb_cols,
|
|
|
|
|
|
|
|
left_min = 2,
|
|
|
|
|
|
|
|
left_max = 8,
|
|
|
|
|
|
|
|
left_default = 3,
|
|
|
|
|
|
|
|
left_precision = "%01d",
|
|
|
|
|
|
|
|
right_text = _("Rows"),
|
|
|
|
|
|
|
|
right_value = nb_rows,
|
|
|
|
|
|
|
|
right_min = 2,
|
|
|
|
|
|
|
|
right_max = 8,
|
|
|
|
|
|
|
|
right_default = 3,
|
|
|
|
|
|
|
|
right_precision = "%01d",
|
|
|
|
|
|
|
|
keep_shown_on_apply = true,
|
|
|
|
|
|
|
|
callback = function(left_value, right_value)
|
|
|
|
|
|
|
|
fc.nb_cols_portrait = left_value
|
|
|
|
|
|
|
|
fc.nb_rows_portrait = right_value
|
|
|
|
|
|
|
|
if fc.display_mode_type == "mosaic" and fc.portrait_mode then
|
|
|
|
|
|
|
|
fc.no_refresh_covers = true
|
|
|
|
|
|
|
|
fc:updateItems()
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end,
|
|
|
|
|
|
|
|
close_callback = function()
|
|
|
|
|
|
|
|
if fc.nb_cols_portrait ~= nb_cols or fc.nb_rows_portrait ~= nb_rows then
|
|
|
|
|
|
|
|
BookInfoManager:saveSetting("nb_cols_portrait", fc.nb_cols_portrait)
|
|
|
|
|
|
|
|
BookInfoManager:saveSetting("nb_rows_portrait", fc.nb_rows_portrait)
|
|
|
|
|
|
|
|
FileChooser.nb_cols_portrait = fc.nb_cols_portrait
|
|
|
|
|
|
|
|
FileChooser.nb_rows_portrait = fc.nb_rows_portrait
|
|
|
|
|
|
|
|
if fc.display_mode_type == "mosaic" and fc.portrait_mode then
|
|
|
|
|
|
|
|
fc.no_refresh_covers = nil
|
|
|
|
|
|
|
|
fc:updateItems()
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
UIManager:show(widget)
|
|
|
|
|
|
|
|
end,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
text_func = function()
|
|
|
|
|
|
|
|
local fc = self.ui.file_chooser
|
|
|
|
|
|
|
|
return T(_("Items per page in landscape mosaic mode: %1 × %2"), fc.nb_cols_landscape, fc.nb_rows_landscape)
|
|
|
|
|
|
|
|
end,
|
|
|
|
|
|
|
|
callback = function()
|
|
|
|
|
|
|
|
local fc = self.ui.file_chooser
|
|
|
|
|
|
|
|
local nb_cols = fc.nb_cols_landscape
|
|
|
|
|
|
|
|
local nb_rows = fc.nb_rows_landscape
|
|
|
|
|
|
|
|
local DoubleSpinWidget = require("/ui/widget/doublespinwidget")
|
|
|
|
|
|
|
|
local widget = DoubleSpinWidget:new{
|
|
|
|
|
|
|
|
title_text = _("Landscape mosaic mode"),
|
|
|
|
|
|
|
|
width_factor = 0.6,
|
|
|
|
|
|
|
|
left_text = _("Columns"),
|
|
|
|
|
|
|
|
left_value = nb_cols,
|
|
|
|
|
|
|
|
left_min = 2,
|
|
|
|
|
|
|
|
left_max = 8,
|
|
|
|
|
|
|
|
left_default = 4,
|
|
|
|
|
|
|
|
left_precision = "%01d",
|
|
|
|
|
|
|
|
right_text = _("Rows"),
|
|
|
|
|
|
|
|
right_value = nb_rows,
|
|
|
|
|
|
|
|
right_min = 2,
|
|
|
|
|
|
|
|
right_max = 8,
|
|
|
|
|
|
|
|
right_default = 2,
|
|
|
|
|
|
|
|
right_precision = "%01d",
|
|
|
|
|
|
|
|
keep_shown_on_apply = true,
|
|
|
|
|
|
|
|
callback = function(left_value, right_value)
|
|
|
|
|
|
|
|
fc.nb_cols_landscape = left_value
|
|
|
|
|
|
|
|
fc.nb_rows_landscape = right_value
|
|
|
|
|
|
|
|
if fc.display_mode_type == "mosaic" and not fc.portrait_mode then
|
|
|
|
|
|
|
|
fc.no_refresh_covers = true
|
|
|
|
|
|
|
|
fc:updateItems()
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end,
|
|
|
|
|
|
|
|
close_callback = function()
|
|
|
|
|
|
|
|
if fc.nb_cols_landscape ~= nb_cols or fc.nb_rows_landscape ~= nb_rows then
|
|
|
|
|
|
|
|
BookInfoManager:saveSetting("nb_cols_landscape", fc.nb_cols_landscape)
|
|
|
|
|
|
|
|
BookInfoManager:saveSetting("nb_rows_landscape", fc.nb_rows_landscape)
|
|
|
|
|
|
|
|
FileChooser.nb_cols_landscape = fc.nb_cols_landscape
|
|
|
|
|
|
|
|
FileChooser.nb_rows_landscape = fc.nb_rows_landscape
|
|
|
|
|
|
|
|
if fc.display_mode_type == "mosaic" and not fc.portrait_mode then
|
|
|
|
|
|
|
|
fc.no_refresh_covers = nil
|
|
|
|
|
|
|
|
fc:updateItems()
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
UIManager:show(widget)
|
|
|
|
|
|
|
|
end,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
text_func = function()
|
|
|
|
|
|
|
|
local fc = self.ui.file_chooser
|
|
|
|
|
|
|
|
-- default files_per_page should be calculated by ListMenu on the first drawing,
|
|
|
|
|
|
|
|
-- use 10 if ListMenu has not been drawn yet
|
|
|
|
|
|
|
|
return T(_("Items per page in portrait list mode: %1"), fc.files_per_page or 10)
|
|
|
|
|
|
|
|
end,
|
|
|
|
|
|
|
|
callback = function()
|
|
|
|
|
|
|
|
local fc = self.ui.file_chooser
|
|
|
|
|
|
|
|
local files_per_page = fc.files_per_page or 10
|
|
|
|
local SpinWidget = require("ui/widget/spinwidget")
|
|
|
|
local SpinWidget = require("ui/widget/spinwidget")
|
|
|
|
-- "files_per_page" should have been saved with an adequate value
|
|
|
|
local widget = SpinWidget:new{
|
|
|
|
-- the first time Detailed list was shown. Fallback to a start
|
|
|
|
title_text = _("Portrait list mode"),
|
|
|
|
-- value of 10 if it hasn't.
|
|
|
|
value = files_per_page,
|
|
|
|
local curr_items = BookInfoManager:getSetting("files_per_page") or 10
|
|
|
|
|
|
|
|
local items = SpinWidget:new{
|
|
|
|
|
|
|
|
value = curr_items,
|
|
|
|
|
|
|
|
value_min = 4,
|
|
|
|
value_min = 4,
|
|
|
|
value_max = 20,
|
|
|
|
value_max = 20,
|
|
|
|
default_value = 10,
|
|
|
|
default_value = 10,
|
|
|
|
keep_shown_on_apply = true,
|
|
|
|
keep_shown_on_apply = true,
|
|
|
|
title_text = _("Items per page"),
|
|
|
|
|
|
|
|
callback = function(spin)
|
|
|
|
callback = function(spin)
|
|
|
|
BookInfoManager:saveSetting("files_per_page", spin.value)
|
|
|
|
fc.files_per_page = spin.value
|
|
|
|
self.ui:onRefresh()
|
|
|
|
if fc.display_mode_type == "list" then
|
|
|
|
|
|
|
|
fc.no_refresh_covers = true
|
|
|
|
|
|
|
|
fc:updateItems()
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end,
|
|
|
|
|
|
|
|
close_callback = function()
|
|
|
|
|
|
|
|
if fc.files_per_page ~= files_per_page then
|
|
|
|
|
|
|
|
BookInfoManager:saveSetting("files_per_page", fc.files_per_page)
|
|
|
|
|
|
|
|
FileChooser.files_per_page = fc.files_per_page
|
|
|
|
|
|
|
|
if fc.display_mode_type == "list" then
|
|
|
|
|
|
|
|
fc.no_refresh_covers = nil
|
|
|
|
|
|
|
|
fc:updateItems()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
UIManager:show(items)
|
|
|
|
UIManager:show(widget)
|
|
|
|
end,
|
|
|
|
end,
|
|
|
|
|
|
|
|
separator = true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
text = _("Progress"),
|
|
|
|
text = _("Progress"),
|
|
|
|
sub_item_table = {
|
|
|
|
sub_item_table = {
|
|
|
|
{
|
|
|
|
{
|
|
|
|
text = _("Show progress"),
|
|
|
|
text = _("Show progress in mosaic mode"),
|
|
|
|
checked_func = function() return
|
|
|
|
checked_func = function() return BookInfoManager:getSetting("show_progress_in_mosaic") end,
|
|
|
|
not BookInfoManager:getSetting("hide_page_info")
|
|
|
|
|
|
|
|
end,
|
|
|
|
|
|
|
|
callback = function()
|
|
|
|
callback = function()
|
|
|
|
BookInfoManager:toggleSetting("hide_page_info")
|
|
|
|
BookInfoManager:toggleSetting("show_progress_in_mosaic")
|
|
|
|
self:refreshFileManagerInstance()
|
|
|
|
self:refreshFileManagerInstance()
|
|
|
|
end,
|
|
|
|
end,
|
|
|
|
|
|
|
|
separator = true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
text = _("Show progress % in mosaic mode"),
|
|
|
|
text = _("Show progress in detailed list mode"),
|
|
|
|
checked_func = function() return BookInfoManager:getSetting("show_progress_in_mosaic") end,
|
|
|
|
checked_func = function() return not BookInfoManager:getSetting("hide_page_info") end,
|
|
|
|
callback = function()
|
|
|
|
callback = function()
|
|
|
|
BookInfoManager:toggleSetting("show_progress_in_mosaic")
|
|
|
|
BookInfoManager:toggleSetting("hide_page_info")
|
|
|
|
self:refreshFileManagerInstance()
|
|
|
|
self:refreshFileManagerInstance()
|
|
|
|
end,
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
text = _("Show number of pages read instead of progress %"),
|
|
|
|
text = _("Show number of pages read instead of progress %"),
|
|
|
|
|
|
|
|
enabled_func = function() return not BookInfoManager:getSetting("hide_page_info") end,
|
|
|
|
checked_func = function() return BookInfoManager:getSetting("show_pages_read_as_progress") end,
|
|
|
|
checked_func = function() return BookInfoManager:getSetting("show_pages_read_as_progress") end,
|
|
|
|
callback = function()
|
|
|
|
callback = function()
|
|
|
|
BookInfoManager:toggleSetting("show_pages_read_as_progress")
|
|
|
|
BookInfoManager:toggleSetting("show_pages_read_as_progress")
|
|
|
@ -221,12 +335,12 @@ function CoverBrowser:addToMainMenu(menu_items)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
text = _("Show number of pages left to read"),
|
|
|
|
text = _("Show number of pages left to read"),
|
|
|
|
|
|
|
|
enabled_func = function() return not BookInfoManager:getSetting("hide_page_info") end,
|
|
|
|
checked_func = function() return BookInfoManager:getSetting("show_pages_left_in_progress") end,
|
|
|
|
checked_func = function() return BookInfoManager:getSetting("show_pages_left_in_progress") end,
|
|
|
|
callback = function()
|
|
|
|
callback = function()
|
|
|
|
BookInfoManager:toggleSetting("show_pages_left_in_progress")
|
|
|
|
BookInfoManager:toggleSetting("show_pages_left_in_progress")
|
|
|
|
self:refreshFileManagerInstance()
|
|
|
|
self:refreshFileManagerInstance()
|
|
|
|
end,
|
|
|
|
end,
|
|
|
|
separator = true,
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -302,7 +416,6 @@ function CoverBrowser:addToMainMenu(menu_items)
|
|
|
|
end,
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
separator = true
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
text = _("Show file properties"),
|
|
|
|
text = _("Show file properties"),
|
|
|
@ -313,6 +426,7 @@ function CoverBrowser:addToMainMenu(menu_items)
|
|
|
|
BookInfoManager:toggleSetting("hide_file_info")
|
|
|
|
BookInfoManager:toggleSetting("hide_file_info")
|
|
|
|
self:refreshFileManagerInstance()
|
|
|
|
self:refreshFileManagerInstance()
|
|
|
|
end,
|
|
|
|
end,
|
|
|
|
|
|
|
|
separator = true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
text = _("Book info cache management"),
|
|
|
|
text = _("Book info cache management"),
|
|
|
@ -391,6 +505,19 @@ function CoverBrowser:addToMainMenu(menu_items)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function CoverBrowser.initGrid(menu, display_mode)
|
|
|
|
|
|
|
|
if menu == nil then return end
|
|
|
|
|
|
|
|
if menu.nb_cols_portrait == nil then
|
|
|
|
|
|
|
|
menu.nb_cols_portrait = BookInfoManager:getSetting("nb_cols_portrait") or 3
|
|
|
|
|
|
|
|
menu.nb_rows_portrait = BookInfoManager:getSetting("nb_rows_portrait") or 3
|
|
|
|
|
|
|
|
menu.nb_cols_landscape = BookInfoManager:getSetting("nb_cols_landscape") or 4
|
|
|
|
|
|
|
|
menu.nb_rows_landscape = BookInfoManager:getSetting("nb_rows_landscape") or 2
|
|
|
|
|
|
|
|
-- initial List mode files_per_page will be calculated and saved by ListMenu on the first drawing
|
|
|
|
|
|
|
|
menu.files_per_page = BookInfoManager:getSetting("files_per_page")
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
menu.display_mode_type = display_mode and display_mode:gsub("_.*", "") -- "mosaic" or "list"
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function CoverBrowser:refreshFileManagerInstance(cleanup, post_init)
|
|
|
|
function CoverBrowser:refreshFileManagerInstance(cleanup, post_init)
|
|
|
|
local fm = FileManager.instance
|
|
|
|
local fm = FileManager.instance
|
|
|
|
if fm then
|
|
|
|
if fm then
|
|
|
@ -433,6 +560,9 @@ function CoverBrowser:setupFileManagerDisplayMode(display_mode)
|
|
|
|
filemanager_display_mode = display_mode
|
|
|
|
filemanager_display_mode = display_mode
|
|
|
|
logger.dbg("CoverBrowser: setting FileManager display mode to:", display_mode or "classic")
|
|
|
|
logger.dbg("CoverBrowser: setting FileManager display mode to:", display_mode or "classic")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- init Mosaic and List grid dimensions (in Classic mode used in the settings menu)
|
|
|
|
|
|
|
|
CoverBrowser.initGrid(FileChooser, display_mode)
|
|
|
|
|
|
|
|
|
|
|
|
if not init_done and not display_mode then
|
|
|
|
if not init_done and not display_mode then
|
|
|
|
return -- starting in classic mode, nothing to patch
|
|
|
|
return -- starting in classic mode, nothing to patch
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -459,8 +589,7 @@ function CoverBrowser:setupFileManagerDisplayMode(display_mode)
|
|
|
|
FileChooser.updateCache = CoverMenu.updateCache
|
|
|
|
FileChooser.updateCache = CoverMenu.updateCache
|
|
|
|
FileChooser.updateItems = CoverMenu.updateItems
|
|
|
|
FileChooser.updateItems = CoverMenu.updateItems
|
|
|
|
FileChooser.onCloseWidget = CoverMenu.onCloseWidget
|
|
|
|
FileChooser.onCloseWidget = CoverMenu.onCloseWidget
|
|
|
|
|
|
|
|
if FileChooser.display_mode_type == "mosaic" then
|
|
|
|
if display_mode == "mosaic_image" or display_mode == "mosaic_text" then -- mosaic mode
|
|
|
|
|
|
|
|
-- Replace some other original methods with those from our MosaicMenu
|
|
|
|
-- Replace some other original methods with those from our MosaicMenu
|
|
|
|
local MosaicMenu = require("mosaicmenu")
|
|
|
|
local MosaicMenu = require("mosaicmenu")
|
|
|
|
FileChooser._recalculateDimen = MosaicMenu._recalculateDimen
|
|
|
|
FileChooser._recalculateDimen = MosaicMenu._recalculateDimen
|
|
|
@ -470,14 +599,7 @@ function CoverBrowser:setupFileManagerDisplayMode(display_mode)
|
|
|
|
FileChooser._do_hint_opened = true -- dogear at bottom
|
|
|
|
FileChooser._do_hint_opened = true -- dogear at bottom
|
|
|
|
-- Don't have "../" centered in empty directories
|
|
|
|
-- Don't have "../" centered in empty directories
|
|
|
|
FileChooser._do_center_partial_rows = false
|
|
|
|
FileChooser._do_center_partial_rows = false
|
|
|
|
-- One could override default 3x3 grid here (put that as settings ?)
|
|
|
|
elseif FileChooser.display_mode_type == "list" then
|
|
|
|
-- FileChooser.nb_cols_portrait = 4
|
|
|
|
|
|
|
|
-- FileChooser.nb_rows_portrait = 4
|
|
|
|
|
|
|
|
-- FileChooser.nb_cols_landscape = 6
|
|
|
|
|
|
|
|
-- FileChooser.nb_rows_landscape = 3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elseif display_mode == "list_image_meta" or display_mode == "list_only_meta" or
|
|
|
|
|
|
|
|
display_mode == "list_image_filename" then -- list modes
|
|
|
|
|
|
|
|
-- Replace some other original methods with those from our ListMenu
|
|
|
|
-- Replace some other original methods with those from our ListMenu
|
|
|
|
local ListMenu = require("listmenu")
|
|
|
|
local ListMenu = require("listmenu")
|
|
|
|
FileChooser._recalculateDimen = ListMenu._recalculateDimen
|
|
|
|
FileChooser._recalculateDimen = ListMenu._recalculateDimen
|
|
|
@ -488,7 +610,6 @@ function CoverBrowser:setupFileManagerDisplayMode(display_mode)
|
|
|
|
FileChooser._do_hint_opened = true -- dogear at bottom
|
|
|
|
FileChooser._do_hint_opened = true -- dogear at bottom
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Replace this FileManager method with the one from CoverMenu
|
|
|
|
-- Replace this FileManager method with the one from CoverMenu
|
|
|
|
-- (but first, make the original method saved here as local available
|
|
|
|
-- (but first, make the original method saved here as local available
|
|
|
|
-- to CoverMenu)
|
|
|
|
-- to CoverMenu)
|
|
|
@ -505,7 +626,6 @@ function CoverBrowser:setupFileManagerDisplayMode(display_mode)
|
|
|
|
self:refreshFileManagerInstance(false, true)
|
|
|
|
self:refreshFileManagerInstance(false, true)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local function _FileManagerHistory_updateItemTable(self)
|
|
|
|
local function _FileManagerHistory_updateItemTable(self)
|
|
|
@ -529,7 +649,8 @@ local function _FileManagerHistory_updateItemTable(self)
|
|
|
|
hist_menu.onMenuHold_orig = hist_menu.onMenuHold
|
|
|
|
hist_menu.onMenuHold_orig = hist_menu.onMenuHold
|
|
|
|
hist_menu.onMenuHold = CoverMenu.onHistoryMenuHold
|
|
|
|
hist_menu.onMenuHold = CoverMenu.onHistoryMenuHold
|
|
|
|
|
|
|
|
|
|
|
|
if display_mode == "mosaic_image" or display_mode == "mosaic_text" then -- mosaic mode
|
|
|
|
CoverBrowser.initGrid(hist_menu, display_mode)
|
|
|
|
|
|
|
|
if hist_menu.display_mode_type == "mosaic" then
|
|
|
|
-- Replace some other original methods with those from our MosaicMenu
|
|
|
|
-- Replace some other original methods with those from our MosaicMenu
|
|
|
|
local MosaicMenu = require("mosaicmenu")
|
|
|
|
local MosaicMenu = require("mosaicmenu")
|
|
|
|
hist_menu._recalculateDimen = MosaicMenu._recalculateDimen
|
|
|
|
hist_menu._recalculateDimen = MosaicMenu._recalculateDimen
|
|
|
@ -538,8 +659,7 @@ local function _FileManagerHistory_updateItemTable(self)
|
|
|
|
hist_menu._do_cover_images = display_mode ~= "mosaic_text"
|
|
|
|
hist_menu._do_cover_images = display_mode ~= "mosaic_text"
|
|
|
|
hist_menu._do_center_partial_rows = true -- nicer looking when few elements
|
|
|
|
hist_menu._do_center_partial_rows = true -- nicer looking when few elements
|
|
|
|
|
|
|
|
|
|
|
|
elseif display_mode == "list_image_meta" or display_mode == "list_only_meta" or
|
|
|
|
elseif hist_menu.display_mode_type == "list" then
|
|
|
|
display_mode == "list_image_filename" then -- list modes
|
|
|
|
|
|
|
|
-- Replace some other original methods with those from our ListMenu
|
|
|
|
-- Replace some other original methods with those from our ListMenu
|
|
|
|
local ListMenu = require("listmenu")
|
|
|
|
local ListMenu = require("listmenu")
|
|
|
|
hist_menu._recalculateDimen = ListMenu._recalculateDimen
|
|
|
|
hist_menu._recalculateDimen = ListMenu._recalculateDimen
|
|
|
@ -608,7 +728,8 @@ local function _FileManagerCollections_updateItemTable(self)
|
|
|
|
coll_menu.onMenuHold_orig = coll_menu.onMenuHold
|
|
|
|
coll_menu.onMenuHold_orig = coll_menu.onMenuHold
|
|
|
|
coll_menu.onMenuHold = CoverMenu.onCollectionsMenuHold
|
|
|
|
coll_menu.onMenuHold = CoverMenu.onCollectionsMenuHold
|
|
|
|
|
|
|
|
|
|
|
|
if display_mode == "mosaic_image" or display_mode == "mosaic_text" then -- mosaic mode
|
|
|
|
CoverBrowser.initGrid(coll_menu, display_mode)
|
|
|
|
|
|
|
|
if coll_menu.display_mode_type == "mosaic" then
|
|
|
|
-- Replace some other original methods with those from our MosaicMenu
|
|
|
|
-- Replace some other original methods with those from our MosaicMenu
|
|
|
|
local MosaicMenu = require("mosaicmenu")
|
|
|
|
local MosaicMenu = require("mosaicmenu")
|
|
|
|
coll_menu._recalculateDimen = MosaicMenu._recalculateDimen
|
|
|
|
coll_menu._recalculateDimen = MosaicMenu._recalculateDimen
|
|
|
@ -617,8 +738,7 @@ local function _FileManagerCollections_updateItemTable(self)
|
|
|
|
coll_menu._do_cover_images = display_mode ~= "mosaic_text"
|
|
|
|
coll_menu._do_cover_images = display_mode ~= "mosaic_text"
|
|
|
|
coll_menu._do_center_partial_rows = true -- nicer looking when few elements
|
|
|
|
coll_menu._do_center_partial_rows = true -- nicer looking when few elements
|
|
|
|
|
|
|
|
|
|
|
|
elseif display_mode == "list_image_meta" or display_mode == "list_only_meta" or
|
|
|
|
elseif coll_menu.display_mode_type == "list" then
|
|
|
|
display_mode == "list_image_filename" then -- list modes
|
|
|
|
|
|
|
|
-- Replace some other original methods with those from our ListMenu
|
|
|
|
-- Replace some other original methods with those from our ListMenu
|
|
|
|
local ListMenu = require("listmenu")
|
|
|
|
local ListMenu = require("listmenu")
|
|
|
|
coll_menu._recalculateDimen = ListMenu._recalculateDimen
|
|
|
|
coll_menu._recalculateDimen = ListMenu._recalculateDimen
|
|
|
|