2
0
mirror of https://github.com/koreader/koreader synced 2024-10-31 21:20:20 +00:00
koreader/frontend/ui/downloadmgr.lua
chrox 0a06041cd9 fix calculation of widget height of filechooser
the height of filechooser is provided when creating filechooser
widget since there may be no title as in filemanger which needs
a special title widget to contain filemanger menu.
2014-11-25 17:49:46 +08:00

39 lines
1.1 KiB
Lua

local PathChooser = require("ui/widget/pathchooser")
local UIManager = require("ui/uimanager")
local Screen = require("device").screen
local util = require("ffi/util")
local _ = require("gettext")
local DownloadMgr = {
title = _("Choose download directory"),
onConfirm = function() end,
}
function DownloadMgr:new(o)
local o = o or {}
setmetatable(o, self)
self.__index = self
return o
end
function DownloadMgr:chooseDir()
local lastdir = G_reader_settings:readSetting("lastdir")
local download_dir = G_reader_settings:readSetting("download_dir")
local path_chooser = PathChooser:new{
title = self.title,
height = Screen:getHeight(),
path = download_dir and (download_dir .. "/..") or lastdir,
show_hidden = G_reader_settings:readSetting("show_hidden"),
onConfirm = function(path)
-- hack to remove additional parent
if path:sub(-3, -1) == "/.." then
path = path:sub(1, -4)
end
self.onConfirm(util.realpath(path))
end
}
UIManager:show(path_chooser)
end
return DownloadMgr