2
0
mirror of https://github.com/koreader/koreader synced 2024-10-31 21:20:20 +00:00
koreader/frontend/apps/reader/modules/readerscreenshot.lua

46 lines
1.3 KiB
Lua
Raw Normal View History

2013-10-18 20:38:07 +00:00
local InputContainer = require("ui/widget/container/inputcontainer")
2014-01-16 05:43:45 +00:00
local Device = require("ui/device")
2013-10-18 20:38:07 +00:00
local Screen = require("ui/screen")
local GestureRange = require("ui/gesturerange")
local UIManager = require("ui/uimanager")
local InfoMessage = require("ui/widget/infomessage")
local _ = require("gettext")
local DEBUG = require("dbg")
2013-10-18 20:38:07 +00:00
local ReaderScreenshot = InputContainer:new{}
function ReaderScreenshot:init()
2014-03-13 13:52:43 +00:00
local diagonal = math.sqrt(
math.pow(Screen:getWidth(), 2) +
math.pow(Screen:getHeight(), 2)
)
self.ges_events = {
Screenshot = {
GestureRange:new{
ges = "two_finger_tap",
scale = {diagonal - Screen:scaleByDPI(100), diagonal},
rate = 1.0,
}
},
}
end
function ReaderScreenshot:onScreenshot()
2014-03-13 13:52:43 +00:00
if Device:getModel() ~= 'Kobo_phoenix' then
os.execute("screenshot")
else Screen.bb:invert()
local screenshot_name = os.date("screenshots/Screenshot_%Y-%B-%d_%Hh%M.pam")
UIManager:show(InfoMessage:new{
text = _("Writing screen to ")..screenshot_name,
timeout = 2,
})
Screen.bb:writePAM(screenshot_name)
DEBUG(screenshot_name)
Screen.bb:invert()
end
UIManager.full_refresh = true
return true
end
2013-10-18 20:38:07 +00:00
return ReaderScreenshot