File browser settings: reorganize into Settings submenu (#7259)

Move classic file browser settings from CoverBrowser plugin
into FileManagerMenu, so they are available when this
plugin is disabled (as they also apply to everything
based on Menu).
pull/7265/head
poire-z 3 years ago committed by GitHub
parent 8e1721173e
commit 6059958ab6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -142,19 +142,20 @@ function FileManagerMenu:setUpdateItemTable()
end
-- setting tab
self.menu_items.show_hidden_files = {
text = _("Show hidden files"),
checked_func = function() return self.ui.file_chooser.show_hidden end,
callback = function() self.ui:toggleHiddenFiles() end
}
self.menu_items.show_unsupported_files = {
text = _("Show unsupported files"),
checked_func = function() return self.ui.file_chooser.show_unsupported end,
callback = function() self.ui:toggleUnsupportedFiles() end
}
self.menu_items.items = {
text = _("Items"),
self.menu_items.filebrowser_settings = {
text = _("Settings"),
sub_item_table = {
{
text = _("Show hidden files"),
checked_func = function() return self.ui.file_chooser.show_hidden end,
callback = function() self.ui:toggleHiddenFiles() end,
},
{
text = _("Show unsupported files"),
checked_func = function() return self.ui.file_chooser.show_unsupported end,
callback = function() self.ui:toggleUnsupportedFiles() end,
separator = true,
},
{
text = _("Items per page"),
help_text = _([[This sets the number of items per page in:
@ -182,10 +183,10 @@ function FileManagerMenu:setUpdateItemTable()
end
}
UIManager:show(items)
end
end,
},
{
text = _("Font size"),
text = _("Item font size"),
keep_menu_open = true,
callback = function()
local Menu = require("ui/widget/menu")
@ -200,7 +201,7 @@ function FileManagerMenu:setUpdateItemTable()
value_max = 72,
default_value = default_font_size,
keep_shown_on_apply = true,
title_text = _("Maximum font size for item"),
title_text = _("Item font size"),
callback = function(spin)
if spin.value == default_font_size then
-- We can't know if the user has set a size or hit "Use default", but
@ -214,10 +215,10 @@ function FileManagerMenu:setUpdateItemTable()
end
}
UIManager:show(items_font)
end
end,
},
{
text = _("Reduce font size to show more text"),
text = _("Shrink item font size to fit more text"),
keep_menu_open = true,
checked_func = function()
return G_reader_settings:isTrue("items_multilines_show_more_text")
@ -225,8 +226,72 @@ function FileManagerMenu:setUpdateItemTable()
callback = function()
G_reader_settings:flipNilOrFalse("items_multilines_show_more_text")
self.ui:onRefresh()
end
}
end,
},
{
text_func = function()
local current_state = _("Show new files in bold")
if G_reader_settings:readSetting("show_file_in_bold") == "opened" then
current_state = _("Show opened files in bold")
elseif G_reader_settings:readSetting("show_file_in_bold") == false then
current_state = _("Show files in bold") -- with checkmark unchecked
end
-- Inform that this settings applies only to classic file chooser
current_state = T(_("(Classic file browser) %1"), current_state)
return current_state
end,
checked_func = function() return G_reader_settings:readSetting("show_file_in_bold") ~= false end,
sub_item_table = {
{
text = _("Don't show files in bold"),
checked_func = function() return G_reader_settings:readSetting("show_file_in_bold") == false end,
callback = function()
G_reader_settings:saveSetting("show_file_in_bold", false)
self.ui:onRefresh()
end,
},
{
text = _("Show opened files in bold"),
checked_func = function() return G_reader_settings:readSetting("show_file_in_bold") == "opened" end,
callback = function()
G_reader_settings:saveSetting("show_file_in_bold", "opened")
self.ui:onRefresh()
end,
},
{
text = _("Show new (not yet opened) files in bold"),
checked_func = function()
return G_reader_settings:readSetting("show_file_in_bold") ~= false and G_reader_settings:readSetting("show_file_in_bold") ~= "opened"
end,
callback = function()
G_reader_settings:delSetting("show_file_in_bold")
self.ui:onRefresh()
end,
},
},
separator = true,
},
{
text = _("Shorten home directory"),
checked_func = function()
return G_reader_settings:nilOrTrue("shorten_home_dir")
end,
callback = function()
G_reader_settings:flipNilOrTrue("shorten_home_dir")
local FileManager = require("apps/filemanager/filemanager")
if FileManager.instance then FileManager.instance:reinit() end
end,
},
{
text = _("Show filename in Open last/previous menu items"),
checked_func = function() return G_reader_settings:readSetting("open_last_menu_show_filename") end,
callback = function() G_reader_settings:flipNilOrFalse("open_last_menu_show_filename") end,
},
{
text = _("Auto-remove deleted or purged items from history"),
checked_func = function() return G_reader_settings:readSetting("autoremove_deleted_items_from_history") end,
callback = function() G_reader_settings:flipNilOrFalse("autoremove_deleted_items_from_history") end,
},
}
}
self.menu_items.sort_by = self.ui:getSortingMenuTable()

@ -11,9 +11,7 @@ local order = {
},
filemanager_settings = {
"filemanager_display_mode",
"show_hidden_files",
"show_unsupported_files",
"items",
"filebrowser_settings",
"----------------------------",
"sort_by",
"reverse_sorting",

@ -4,7 +4,6 @@ local logger = require("logger")
local _ = require("gettext")
local BookInfoManager = require("bookinfomanager")
local Screen = require("device").screen
local T = require("ffi/util").template
--[[
This plugin provides additional display modes to file browsers (File Manager
@ -52,16 +51,8 @@ local CoverBrowser = InputContainer:new{
}
function CoverBrowser:init()
self.full_featured = true
-- (Could be set to false for some platforms to provide a fallback
-- option with only a menu for managing a few core settings)
self.ui.menu:registerToMainMenu(self)
if not self.full_featured then -- nothing else than menu registration
return
end
if init_done then -- things already patched according to current modes
return
end
@ -93,87 +84,6 @@ function CoverBrowser:addToMainMenu(menu_items)
return
end
-- Items available even if not full_featured
-- (settings used by core, that fit in this menu)
local generic_items = {
{
text_func = function()
local current_state = _("Show new files in bold")
if G_reader_settings:readSetting("show_file_in_bold") == "opened" then
current_state = _("Show opened files in bold")
elseif G_reader_settings:readSetting("show_file_in_bold") == false then
current_state = _("Show files in bold") -- with checkmark unchecked
end
if self.full_featured then
-- Inform that this settings applies only to classic file chooser
current_state = T(_("(Classic mode) %1"), current_state)
end
return current_state
end,
checked_func = function() return G_reader_settings:readSetting("show_file_in_bold") ~= false end,
sub_item_table = {
{
text = _("Don't show files in bold"),
checked_func = function() return G_reader_settings:readSetting("show_file_in_bold") == false end,
callback = function()
G_reader_settings:saveSetting("show_file_in_bold", false)
self:refreshFileManagerInstance()
end,
},
{
text = _("Show opened files in bold"),
checked_func = function() return G_reader_settings:readSetting("show_file_in_bold") == "opened" end,
callback = function()
G_reader_settings:saveSetting("show_file_in_bold", "opened")
self:refreshFileManagerInstance()
end,
},
{
text = _("Show new (not yet opened) files in bold"),
checked_func = function()
return G_reader_settings:readSetting("show_file_in_bold") ~= false and G_reader_settings:readSetting("show_file_in_bold") ~= "opened"
end,
callback = function()
G_reader_settings:delSetting("show_file_in_bold")
self:refreshFileManagerInstance()
end,
},
},
separator = true,
},
{
text = _("Shorten home directory"),
checked_func = function()
return G_reader_settings:nilOrTrue("shorten_home_dir")
end,
callback = function()
G_reader_settings:flipNilOrTrue("shorten_home_dir")
if FileManager.instance then FileManager.instance:reinit() end
end,
},
{
text = _("Auto-remove deleted or purged items from history"),
checked_func = function() return G_reader_settings:readSetting("autoremove_deleted_items_from_history") end,
callback = function() G_reader_settings:flipNilOrFalse("autoremove_deleted_items_from_history") end,
},
{
text = _("Show filename in Open last/previous menu items"),
checked_func = function() return G_reader_settings:readSetting("open_last_menu_show_filename") end,
callback = function() G_reader_settings:flipNilOrFalse("open_last_menu_show_filename") end,
},
}
if not self.full_featured then
-- Make the generic items directly as 1st level items,
-- and use alternate name for main menu, not mentionning
-- "display mode" that are not available
menu_items.filemanager_display_mode = {
text = _("File browser settings"),
sub_item_table = generic_items
}
return
end
menu_items.filemanager_display_mode = {
text = _("Display mode"),
sub_item_table = {
@ -323,7 +233,7 @@ function CoverBrowser:addToMainMenu(menu_items)
},
-- Misc settings
{
text = _("Other settings"),
text = _("Mosaic and detailed list settings"),
sub_item_table = {
{
text = _("Display hints"),
@ -461,7 +371,6 @@ function CoverBrowser:addToMainMenu(menu_items)
end,
separator = true
},
-- generic_items will be inserted here
},
},
{
@ -539,12 +448,6 @@ function CoverBrowser:addToMainMenu(menu_items)
},
},
}
-- Finally, insert the generic items at end of "Other settings" submenu
local sub_item_table = menu_items.filemanager_display_mode.sub_item_table
local generic_items_target = sub_item_table[#sub_item_table-1].sub_item_table -- second to last
for _, item in pairs(generic_items) do
table.insert(generic_items_target, item)
end
end
function CoverBrowser:refreshFileManagerInstance(cleanup, post_init)

Loading…
Cancel
Save