2021-11-21 18:01:43 +00:00
|
|
|
local Device = require("device")
|
|
|
|
local Event = require("ui/event")
|
|
|
|
local UIManager = require("ui/uimanager")
|
|
|
|
local _ = require("gettext")
|
|
|
|
|
|
|
|
local exit_settings = {}
|
|
|
|
|
|
|
|
exit_settings.exit_menu = {
|
2021-11-21 18:33:09 +00:00
|
|
|
text = _("Exit"),
|
|
|
|
-- submenu entries will be appended by xyz_menu_order_lua
|
2021-11-21 18:01:43 +00:00
|
|
|
}
|
|
|
|
exit_settings.exit = {
|
2021-11-21 18:33:09 +00:00
|
|
|
text = _("Exit"),
|
|
|
|
callback = function()
|
|
|
|
UIManager:broadcastEvent(Event:new("Exit"))
|
|
|
|
end,
|
2021-11-21 18:01:43 +00:00
|
|
|
}
|
|
|
|
exit_settings.restart_koreader = {
|
2021-11-21 18:33:09 +00:00
|
|
|
text = _("Restart KOReader"),
|
|
|
|
callback = function()
|
|
|
|
UIManager:broadcastEvent(Event:new("Restart"))
|
|
|
|
end,
|
2021-11-21 18:01:43 +00:00
|
|
|
}
|
|
|
|
if not Device:canRestart() then
|
2021-11-21 18:33:09 +00:00
|
|
|
exit_settings.exit_menu = exit_settings.exit
|
|
|
|
exit_settings.exit = nil
|
|
|
|
exit_settings.restart_koreader = nil
|
2021-11-21 18:01:43 +00:00
|
|
|
end
|
|
|
|
if Device:canSuspend() then
|
2021-11-21 18:33:09 +00:00
|
|
|
exit_settings.sleep = {
|
|
|
|
text = _("Sleep"),
|
|
|
|
callback = function()
|
|
|
|
UIManager:suspend()
|
|
|
|
end,
|
|
|
|
}
|
2021-11-21 18:01:43 +00:00
|
|
|
end
|
|
|
|
if Device:canReboot() then
|
2021-11-21 18:33:09 +00:00
|
|
|
exit_settings.reboot = {
|
|
|
|
text = _("Reboot the device"),
|
|
|
|
keep_menu_open = true,
|
|
|
|
callback = function()
|
|
|
|
UIManager:broadcastEvent(Event:new("Reboot"))
|
|
|
|
end
|
|
|
|
}
|
2021-11-21 18:01:43 +00:00
|
|
|
end
|
|
|
|
if Device:canPowerOff() then
|
2021-11-21 18:33:09 +00:00
|
|
|
exit_settings.poweroff = {
|
|
|
|
text = _("Power off"),
|
|
|
|
keep_menu_open = true,
|
|
|
|
callback = function()
|
|
|
|
UIManager:broadcastEvent(Event:new("PowerOff"))
|
|
|
|
end
|
|
|
|
}
|
2021-11-21 18:01:43 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return exit_settings
|