mirror of
https://github.com/koreader/koreader
synced 2024-10-31 21:20:20 +00:00
57 lines
1.1 KiB
Lua
57 lines
1.1 KiB
Lua
require "widget"
|
|
require "font"
|
|
|
|
InfoMessage = {
|
|
}
|
|
|
|
function InfoMessage:show(text,refresh_mode)
|
|
Debug("# InfoMessage ", text, refresh_mode)
|
|
local dialog = CenterContainer:new({
|
|
dimen = { w = G_width, h = G_height },
|
|
FrameContainer:new({
|
|
margin = 2,
|
|
background = 0,
|
|
HorizontalGroup:new({
|
|
align = "center",
|
|
ImageWidget:new({
|
|
file = "resources/info-i.png"
|
|
}),
|
|
Widget:new({
|
|
dimen = { w = 10, h = 0 }
|
|
}),
|
|
TextWidget:new({
|
|
text = text,
|
|
face = Font:getFace("infont", 30)
|
|
})
|
|
})
|
|
})
|
|
})
|
|
dialog:paintTo(fb.bb, 0, 0)
|
|
dialog:free()
|
|
if refresh_mode ~= nil then
|
|
fb:refresh(refresh_mode)
|
|
end
|
|
end
|
|
|
|
function showInfoMsgWithDelay(text, msec, refresh_mode)
|
|
if not refresh_mode then refresh_mode = 0 end
|
|
Screen:saveCurrentBB()
|
|
|
|
InfoMessage:show(text)
|
|
fb:refresh(refresh_mode)
|
|
-- util.usleep(msec*1000)
|
|
|
|
-- eat the first key release event
|
|
local ev = input.waitForEvent()
|
|
adjustKeyEvents(ev)
|
|
repeat
|
|
ok = pcall( function()
|
|
ev = input.waitForEvent(msec*1000)
|
|
adjustKeyEvents(ev)
|
|
end)
|
|
until not ok or ev.value == EVENT_VALUE_KEY_PRESS
|
|
|
|
Screen:restoreFromSavedBB()
|
|
fb:refresh(refresh_mode)
|
|
end
|