2
0
mirror of https://github.com/koreader/koreader synced 2024-11-18 03:25:46 +00:00
koreader/frontend/apps/reader/modules/readerstatus.lua

60 lines
1.5 KiB
Lua
Raw Normal View History

2016-02-02 17:38:14 +00:00
local InputContainer = require("ui/widget/container/inputcontainer")
local BookStatusWidget = require("ui/widget/bookstatuswidget")
2016-02-02 17:38:14 +00:00
local UIManager = require("ui/uimanager")
local _ = require("gettext")
local ReaderStatus = InputContainer:new {
document = nil,
summary = {
rating = 0,
note = nil,
status = "",
modified = "",
},
enabled = true,
2016-02-09 12:51:55 +00:00
total_pages = 0
2016-02-02 17:38:14 +00:00
}
function ReaderStatus:init()
if self.ui.document.is_pic then
2016-02-02 17:38:14 +00:00
self.enabled = false
return
else
self.total_pages = self.document:getPageCount()
self.ui.menu:registerToMainMenu(self)
-- register event listener if enabled
if G_reader_settings:nilOrTrue("auto_book_status") then
self.onEndOfBook = function()
self:showStatus()
end
end
end
2016-02-02 17:38:14 +00:00
end
function ReaderStatus:addToMainMenu(tab_item_table)
table.insert(tab_item_table.info, {
text = _("Book status"),
2016-02-02 17:38:14 +00:00
callback = function()
self:showStatus()
end,
})
end
function ReaderStatus:showStatus()
local status_page = BookStatusWidget:new {
2016-02-02 17:38:14 +00:00
thumbnail = self.document:getCoverPageImage(),
props = self.document:getProps(),
document = self.document,
settings = self.settings,
view = self.view,
2016-02-02 17:38:14 +00:00
}
2016-02-15 07:52:34 +00:00
UIManager:show(status_page)
2016-02-02 17:38:14 +00:00
end
function ReaderStatus:onReadSettings(config)
self.settings = config
end
return ReaderStatus