Book Shortcuts: allow recursively searching folders

This commit is contained in:
yparitcher
2022-03-23 18:05:18 -04:00
parent c3065f9a84
commit c9bfb74d2a
2 changed files with 11 additions and 3 deletions

View File

@@ -198,11 +198,12 @@ function ReadHistory:getPreviousFile(current_file)
end
end
function ReadHistory:getFileByDirectory(directory)
function ReadHistory:getFileByDirectory(directory, recursive)
assert(self ~= nil)
local real_path = realpath(directory)
for i=1, #self.hist do
if realpath(ffiutil.dirname(self.hist[i].file)) == real_path then
local ipath = realpath(ffiutil.dirname(self.hist[i].file))
if ipath == real_path or (recursive and util.stringStartsWith(ipath, real_path)) then
return self.hist[i].file
end
end

View File

@@ -48,7 +48,7 @@ function BookShortcuts:onBookShortcut(path)
end
end
else
file = ReadHistory:getFileByDirectory(path)
file = ReadHistory:getFileByDirectory(path, G_reader_settings:isTrue("BookShortcuts_recursive_directory"))
end
else
file = path
@@ -121,6 +121,13 @@ function BookShortcuts:getSubMenuItems()
callback = function() G_reader_settings:saveSetting("BookShortcuts_directory_action", "FM") end,
},
},
},
{
text = _("Recursively search folders"),
keep_menu_open = true,
checked_func = function() return G_reader_settings:isTrue("BookShortcuts_recursive_directory") end,
enabled_func = function() return G_reader_settings:readSetting("BookShortcuts_directory_action") == "Last" end,
callback = function() G_reader_settings:flipNilOrFalse("BookShortcuts_recursive_directory") end,
separator = true,
}
}