diff --git a/frontend/apps/cloudstorage/cloudstorage.lua b/frontend/apps/cloudstorage/cloudstorage.lua index 4e28dbbb2..cb7f6444f 100644 --- a/frontend/apps/cloudstorage/cloudstorage.lua +++ b/frontend/apps/cloudstorage/cloudstorage.lua @@ -604,7 +604,6 @@ function CloudStorage:uploadFile(url) local path_chooser path_chooser = PathChooser:new{ select_directory = false, - detailed_file_info = true, path = self.last_path, onConfirm = function(file_path) self.last_path = file_path:match("(.*)/") diff --git a/frontend/ui/screensaver.lua b/frontend/ui/screensaver.lua index 3012e3c62..775e2cf73 100644 --- a/frontend/ui/screensaver.lua +++ b/frontend/ui/screensaver.lua @@ -286,7 +286,6 @@ function Screensaver:chooseFile(document_cover) local PathChooser = require("ui/widget/pathchooser") local path_chooser = PathChooser:new{ select_directory = false, - select_file = true, file_filter = function(filename) local suffix = util.getFileNameSuffix(filename) if document_cover and DocumentRegistry:hasProvider(filename) then @@ -295,7 +294,6 @@ function Screensaver:chooseFile(document_cover) return true end end, - detailed_file_info = true, path = self.root_path, onConfirm = function(file_path) if document_cover then diff --git a/frontend/ui/widget/pathchooser.lua b/frontend/ui/widget/pathchooser.lua index 6fd45c4ae..b1fe6197c 100644 --- a/frontend/ui/widget/pathchooser.lua +++ b/frontend/ui/widget/pathchooser.lua @@ -1,4 +1,5 @@ local BD = require("ui/bidi") +local ButtonDialog = require("ui/widget/buttondialog") local ButtonDialogTitle = require("ui/widget/buttondialogtitle") local Device = require("device") local Event = require("ui/event") @@ -20,9 +21,9 @@ local PathChooser = FileChooser:extend{ is_borderless = true, select_directory = true, -- allow selecting directories select_file = true, -- allow selecting files - show_files = true, -- show files, even if select_files=false + show_files = true, -- show files, even if select_file=false -- (directories are always shown, to allow navigation) - detailed_file_info = false, -- show size and last mod time in Select message + detailed_file_info = true, -- show size and last mod time in Select message (if select_file=true only) } function PathChooser:init() @@ -48,7 +49,7 @@ function PathChooser:init() self:goHome() end self.onLeftButtonHold = function() - UIManager:broadcastEvent(Event:new("ShowFolderShortcutsDialog", function(path) self:changeToPath(path) end)) + self:showPlusMenu() end FileChooser.init(self) end @@ -153,4 +154,34 @@ function PathChooser:onMenuHold(item) return true end +function PathChooser:showPlusMenu() + local button_dialog + button_dialog = ButtonDialog:new{ + buttons = { + { + { + text = _("Folder shortcuts"), + callback = function() + UIManager:close(button_dialog) + UIManager:broadcastEvent(Event:new("ShowFolderShortcutsDialog", + function(path) self:changeToPath(path) end)) + end, + }, + }, + { + { + text = _("New folder"), + callback = function() + UIManager:close(button_dialog) + local FileManager = require("apps/filemanager/filemanager") + FileManager.file_chooser = self + FileManager:createFolder() + end, + }, + }, + }, + } + UIManager:show(button_dialog) +end + return PathChooser diff --git a/plugins/bookshortcuts.koplugin/main.lua b/plugins/bookshortcuts.koplugin/main.lua index 5466b9a1a..6445f1468 100644 --- a/plugins/bookshortcuts.koplugin/main.lua +++ b/plugins/bookshortcuts.koplugin/main.lua @@ -92,9 +92,6 @@ function BookShortcuts:getSubMenuItems() keep_menu_open = true, callback = function(touchmenu_instance) local path_chooser = PathChooser:new{ - select_file = true, - select_directory = true, - detailed_file_info = true, path = G_reader_settings:readSetting("home_dir"), onConfirm = function(path) self:addShortcut(path) diff --git a/plugins/texteditor.koplugin/main.lua b/plugins/texteditor.koplugin/main.lua index 55edc36ed..247dd59e2 100644 --- a/plugins/texteditor.koplugin/main.lua +++ b/plugins/texteditor.koplugin/main.lua @@ -339,7 +339,6 @@ Do you want to proceed?]]), cancel_text = _("No"), ok_callback = function() local path_chooser = PathChooser:new{ - select_directory = true, select_file = false, path = self.last_path, onConfirm = function(dir_path) @@ -380,9 +379,7 @@ end function TextEditor:chooseFile() self:loadSettings() local path_chooser = PathChooser:new{ - select_file = true, select_directory = false, - detailed_file_info = true, path = self.last_path, onConfirm = function(file_path) -- Remember last_path only when we select a file from it