Book Shortcuts: allow recursively searching folders

reviewable/pr9416/r2^2
yparitcher 2 years ago
parent c3065f9a84
commit c9bfb74d2a

@ -198,11 +198,12 @@ function ReadHistory:getPreviousFile(current_file)
end end
end end
function ReadHistory:getFileByDirectory(directory) function ReadHistory:getFileByDirectory(directory, recursive)
assert(self ~= nil) assert(self ~= nil)
local real_path = realpath(directory) local real_path = realpath(directory)
for i=1, #self.hist do 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 return self.hist[i].file
end end
end end

@ -48,7 +48,7 @@ function BookShortcuts:onBookShortcut(path)
end end
end end
else else
file = ReadHistory:getFileByDirectory(path) file = ReadHistory:getFileByDirectory(path, G_reader_settings:isTrue("BookShortcuts_recursive_directory"))
end end
else else
file = path file = path
@ -121,6 +121,13 @@ function BookShortcuts:getSubMenuItems()
callback = function() G_reader_settings:saveSetting("BookShortcuts_directory_action", "FM") end, 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, separator = true,
} }
} }

Loading…
Cancel
Save