diff --git a/frontend/ui/reader/readermenu.lua b/frontend/ui/reader/readermenu.lua index 787af9163..48bc18940 100644 --- a/frontend/ui/reader/readermenu.lua +++ b/frontend/ui/reader/readermenu.lua @@ -55,7 +55,7 @@ function ReaderMenu:setUpdateItemTable() end table.insert(self.item_table, { - text = "Return to file browser", + text = "Return to file manager", callback = function() UIManager:close(self.menu_container) self.ui:onClose() diff --git a/reader.lua b/reader.lua index cad1a7d1f..90acbbeac 100755 --- a/reader.lua +++ b/reader.lua @@ -5,8 +5,62 @@ require "ui/ui" require "ui/readerui" require "ui/filechooser" require "ui/infomessage" +require "ui/button" require "document/document" + + +HomeMenu = InputContainer:new{ + item_table = {}, + ges_events = { + TapShowMenu = { + GestureRange:new{ + ges = "tap", + range = Geom:new{ + x = 0, y = 0, + w = Screen:getWidth(), + h = 25, + } + } + }, + }, +} + +function HomeMenu:setUpdateItemTable() + table.insert(self.item_table, { + text = "Exit", + callback = function() + os.exit(0) + end + }) +end + +function HomeMenu:onTapShowMenu() + if #self.item_table == 0 then + self:setUpdateItemTable() + end + + local home_menu = Menu:new{ + title = "Home menu", + item_table = self.item_table, + width = Screen:getWidth() - 100, + } + + local menu_container = CenterContainer:new{ + ignore = "height", + dimen = Screen:getSize(), + home_menu, + } + home_menu.close_callback = function () + UIManager:close(menu_container) + end + + UIManager:show(menu_container) + + return true +end + + function showReader(file, pass) local document = DocumentRegistry:openDocument(file) if not document then @@ -23,11 +77,14 @@ function showReader(file, pass) UIManager:show(reader) end -function showFileManager(path) +function showHomePage(path) local FileManager = FileChooser:new{ + title = "FileManager", path = path, - dimen = Screen:getSize(), + width = Screen:getWidth(), + height = Screen:getHeight(), is_borderless = true, + has_close_button = false, filter = function(filename) if DocumentRegistry:getProvider(filename) then return true @@ -35,17 +92,22 @@ function showFileManager(path) end } + local HomePage = InputContainer:new{ + FileManager, + HomeMenu, + } + function FileManager:onFileSelect(file) showReader(file) return true end function FileManager:onClose() - UIManager:quit() + --UIManager:quit() return true end - UIManager:show(FileManager) + UIManager:show(HomePage) end @@ -106,7 +168,7 @@ Screen.native_rotation_mode = Screen.cur_rotation_mode if ARGV[argidx] then if lfs.attributes(ARGV[argidx], "mode") == "directory" then - showFileManager(ARGV[argidx]) + showHomePage(ARGV[argidx]) elseif lfs.attributes(ARGV[argidx], "mode") == "file" then showReader(ARGV[argidx]) end