2
0
mirror of https://github.com/koreader/koreader synced 2024-11-10 01:10:34 +00:00

FilemanagerShortcuts: call from PathChooser

This commit is contained in:
hius07 2022-02-07 18:12:48 +02:00 committed by Frans de Jonge
parent c7666221ec
commit a9a75f503f

View File

@ -15,7 +15,7 @@ local FileManagerShortcuts = InputContainer:extend{
folder_shortcuts = G_reader_settings:readSetting("folder_shortcuts", {}),
}
function FileManagerShortcuts:updateItemTable()
function FileManagerShortcuts:updateItemTable(select_callback)
local item_table = {}
for _, item in ipairs(self.folder_shortcuts) do
table.insert(item_table, {
@ -29,6 +29,9 @@ function FileManagerShortcuts:updateItemTable()
local folder = item.folder
if folder ~= nil and lfs.attributes(folder, "mode") == "directory" then
if select_callback then
select_callback(folder)
else
if self.ui.file_chooser then
self.ui.file_chooser:changeToPath(folder)
else -- called from Reader
@ -42,6 +45,7 @@ function FileManagerShortcuts:updateItemTable()
end
end
end
end
end,
})
end
@ -221,7 +225,7 @@ function FileManagerShortcuts:MenuSetRotationModeHandler(rotation)
return true
end
function FileManagerShortcuts:onShowFolderShortcutsDialog()
function FileManagerShortcuts:onShowFolderShortcutsDialog(select_callback)
self.fm_bookmark = Menu:new{
title = _("Folder shortcuts"),
show_parent = self.ui,
@ -233,14 +237,14 @@ function FileManagerShortcuts:onShowFolderShortcutsDialog()
is_popout = false,
is_borderless = true,
curr_path = self.ui.file_chooser and self.ui.file_chooser.path or self.ui:getLastDirFile(),
onMenuHold = self.onMenuHold,
onMenuHold = not select_callback and self.onMenuHold or nil,
onSetRotationMode = self.MenuSetRotationModeHandler,
title_bar_left_icon = "plus",
title_bar_left_icon = not select_callback and "plus" or nil,
onLeftButtonTap = function() self:addNewFolder() end,
_manager = self,
}
self:updateItemTable()
self:updateItemTable(select_callback)
UIManager:show(self.fm_bookmark)
end