mirror of
https://github.com/koreader/koreader.git
synced 2025-12-13 20:36:53 +01:00
Book Shortcuts: allow recursively searching folders
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user