mirror of
https://github.com/koreader/koreader.git
synced 2025-12-13 20:36:53 +01:00
add filemanager icon in reader menu
now we can access the filemanager in all launcher configurations
This commit is contained in:
@@ -20,8 +20,6 @@ local util = require("ffi/util")
|
||||
|
||||
local FileManager = InputContainer:extend{
|
||||
title = _("FileManager"),
|
||||
width = Screen:getWidth(),
|
||||
height = Screen:getHeight(),
|
||||
root_path = lfs.currentdir(),
|
||||
-- our own size
|
||||
dimen = Geom:new{ w = 400, h = 600 },
|
||||
|
||||
@@ -38,13 +38,22 @@ function ReaderMenu:init()
|
||||
plugins = {
|
||||
icon = "resources/icons/appbar.tools.png",
|
||||
},
|
||||
filemanager = {
|
||||
icon = "resources/icons/appbar.cabinet.files.png",
|
||||
callback = function()
|
||||
self.ui:onClose()
|
||||
UIManager:quit()
|
||||
local lastdir = G_reader_settings:readSetting("lastdir")
|
||||
showHomePage(lastdir)
|
||||
end,
|
||||
},
|
||||
home = {
|
||||
icon = "resources/icons/appbar.home.png",
|
||||
callback = function()
|
||||
self.ui:handleEvent(Event:new("RestoreScreenMode",
|
||||
G_reader_settings:readSetting("screen_mode") or "portrait"))
|
||||
UIManager:close(self.menu_container)
|
||||
self.ui:onClose()
|
||||
UIManager:quit()
|
||||
end,
|
||||
},
|
||||
}
|
||||
@@ -150,6 +159,7 @@ function ReaderMenu:onShowReaderMenu()
|
||||
self.tab_item_table.setting,
|
||||
self.tab_item_table.info,
|
||||
self.tab_item_table.plugins,
|
||||
self.tab_item_table.filemanager,
|
||||
self.tab_item_table.home,
|
||||
},
|
||||
show_parent = menu_container,
|
||||
|
||||
@@ -133,6 +133,7 @@ end
|
||||
|
||||
-- register & show a widget
|
||||
function UIManager:show(widget, x, y)
|
||||
self._running = true
|
||||
-- put widget on top of stack
|
||||
table.insert(self._window_stack, {x = x or 0, y = y or 0, widget = widget})
|
||||
-- and schedule it to be painted
|
||||
@@ -226,6 +227,12 @@ end
|
||||
-- signal to quit
|
||||
function UIManager:quit()
|
||||
self._running = false
|
||||
for i = #self._window_stack, 1, -1 do
|
||||
table.remove(self._window_stack, i)
|
||||
end
|
||||
for i = #self._execution_stack, 1, -1 do
|
||||
table.remove(self._execution_stack, i)
|
||||
end
|
||||
for i = #self._zeromqs, 1, -1 do
|
||||
self._zeromqs[i]:stop()
|
||||
table.remove(self._zeromqs, i)
|
||||
|
||||
@@ -591,7 +591,7 @@ function Menu:swithItemTable(new_title, new_item_table, itemnumber)
|
||||
if itemnumber then
|
||||
self.page = math.ceil(itemnumber / self.perpage)
|
||||
else
|
||||
self.page = 1
|
||||
self.page = 1
|
||||
end
|
||||
|
||||
self.item_table = new_item_table
|
||||
|
||||
14
reader.lua
14
reader.lua
@@ -69,8 +69,8 @@ function exitReader()
|
||||
os.exit(0)
|
||||
end
|
||||
|
||||
function showReaderUI(file, pass)
|
||||
DEBUG("opening file", file)
|
||||
function showReaderUI(file)
|
||||
DEBUG("show reader ui")
|
||||
if lfs.attributes(file, "mode") ~= "file" then
|
||||
UIManager:show(InfoMessage:new{
|
||||
text = _("File ") .. file .. _(" does not exist")
|
||||
@@ -81,10 +81,11 @@ function showReaderUI(file, pass)
|
||||
text = _("Opening file ") .. file,
|
||||
timeout = 1,
|
||||
})
|
||||
UIManager:scheduleIn(0.1, function() doShowReaderUI(file, pass) end)
|
||||
UIManager:scheduleIn(0.1, function() doShowReaderUI(file) end)
|
||||
end
|
||||
|
||||
function doShowReaderUI(file, pass)
|
||||
function doShowReaderUI(file)
|
||||
DEBUG("opening file", file)
|
||||
local document = DocumentRegistry:openDocument(file)
|
||||
if not document then
|
||||
UIManager:show(InfoMessage:new{
|
||||
@@ -95,15 +96,14 @@ function doShowReaderUI(file, pass)
|
||||
|
||||
G_reader_settings:saveSetting("lastfile", file)
|
||||
local reader = ReaderUI:new{
|
||||
dialog = readerwindow,
|
||||
dimen = Screen:getSize(),
|
||||
document = document,
|
||||
password = pass
|
||||
}
|
||||
UIManager:show(reader)
|
||||
end
|
||||
|
||||
function showHomePage(path)
|
||||
DEBUG("show home page")
|
||||
G_reader_settings:saveSetting("lastdir", path)
|
||||
UIManager:show(FileManager:new{
|
||||
dimen = Screen:getSize(),
|
||||
@@ -199,8 +199,6 @@ if ARGV[argidx] and ARGV[argidx] ~= "" then
|
||||
showReaderUI(ARGV[argidx])
|
||||
elseif open_last and last_file then
|
||||
showReaderUI(last_file)
|
||||
UIManager:run()
|
||||
showHomePage(ARGV[argidx])
|
||||
else
|
||||
showHomePage(ARGV[argidx])
|
||||
end
|
||||
|
||||
BIN
resources/icons/appbar.cabinet.files.png
Normal file
BIN
resources/icons/appbar.cabinet.files.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 700 B |
Reference in New Issue
Block a user