From 493ff006099542802efffac522e82048acb19d4f Mon Sep 17 00:00:00 2001 From: Hzj_jie Date: Mon, 4 Jul 2016 17:38:04 -0700 Subject: [PATCH 1/2] Add path in file manager --- frontend/apps/filemanager/filemanager.lua | 9 +++++++++ frontend/ui/widget/filechooser.lua | 8 ++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/frontend/apps/filemanager/filemanager.lua b/frontend/apps/filemanager/filemanager.lua index 9c1be469a..f71b6a119 100644 --- a/frontend/apps/filemanager/filemanager.lua +++ b/frontend/apps/filemanager/filemanager.lua @@ -63,6 +63,10 @@ function FileManager:init() face = Font:getFace("tfont", 24), text = self.title, }, + TextWidget:new{ + face = Font:getFace("infofont", 18), + text = self.root_path, + }, VerticalSpan:new{ width = Screen:scaleBySize(10) } } @@ -88,6 +92,11 @@ function FileManager:init() } self.file_chooser = file_chooser + function file_chooser:onPathChanged(path) -- luacheck: ignore + FileManager.instance.banner[2].text = path + return true + end + function file_chooser:onFileSelect(file) -- luacheck: ignore FileManager.instance:onClose() local ReaderUI = require("apps/reader/readerui") diff --git a/frontend/ui/widget/filechooser.lua b/frontend/ui/widget/filechooser.lua index 9d6cb0c32..c5ae74794 100644 --- a/frontend/ui/widget/filechooser.lua +++ b/frontend/ui/widget/filechooser.lua @@ -20,7 +20,6 @@ local FileChooser = Menu:extend{ path = lfs.currentdir(), parent = nil, show_hidden = nil, - filter = function(filename) return true end, exclude_dirs = {"%.sdr$"}, strcoll = strcoll, collate = "strcoll", -- or collate = "access", @@ -33,7 +32,7 @@ function FileChooser:init() -- common dir filter self.dir_filter = function(dirname) for _, pattern in ipairs(self.exclude_dirs) do - if dirname:match(pattern) then return end + if dirname:match(pattern) then return false end end return true end @@ -161,6 +160,7 @@ function FileChooser:changeToPath(path) path = util.realpath(path) self.path = path self:refreshPath() + self:onPathChanged(path) end function FileChooser:toggleHiddenFiles() @@ -203,4 +203,8 @@ function FileChooser:onFileHold(file) return true end +function FileChooser:onPathChanged(path) + return true +end + return FileChooser From 400e63a4637129dc167c85db93ccd0a5e62a8ea7 Mon Sep 17 00:00:00 2001 From: Hzj_jie Date: Mon, 4 Jul 2016 23:14:53 -0700 Subject: [PATCH 2/2] Resolve review comments --- frontend/apps/filemanager/filemanager.lua | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/frontend/apps/filemanager/filemanager.lua b/frontend/apps/filemanager/filemanager.lua index f71b6a119..60f16ffcc 100644 --- a/frontend/apps/filemanager/filemanager.lua +++ b/frontend/apps/filemanager/filemanager.lua @@ -1,6 +1,7 @@ local FileManagerHistory = require("apps/filemanager/filemanagerhistory") local InputContainer = require("ui/widget/container/inputcontainer") local FrameContainer = require("ui/widget/container/framecontainer") +local CenterContainer = require("ui/widget/container/centercontainer") local FileManagerMenu = require("apps/filemanager/filemanagermenu") local DocumentRegistry = require("document/documentregistry") local VerticalGroup = require("ui/widget/verticalgroup") @@ -58,14 +59,19 @@ local FileManager = InputContainer:extend{ function FileManager:init() self.show_parent = self.show_parent or self + self.path_text = TextWidget:new{ + face = Font:getFace("infofont", 18), + text = self.root_path, + } + self.banner = VerticalGroup:new{ TextWidget:new{ face = Font:getFace("tfont", 24), text = self.title, }, - TextWidget:new{ - face = Font:getFace("infofont", 18), - text = self.root_path, + CenterContainer:new{ + dimen = { w = Screen:getWidth(), h = nil }, + self.path_text, }, VerticalSpan:new{ width = Screen:scaleBySize(10) } } @@ -93,7 +99,7 @@ function FileManager:init() self.file_chooser = file_chooser function file_chooser:onPathChanged(path) -- luacheck: ignore - FileManager.instance.banner[2].text = path + FileManager.instance.path_text:setText(path) return true end