[SDL] Add quit through regular window manager actions (#3206)

* [SDL] Add quit through regular window manager actions

Depends on https://github.com/koreader/koreader-base/pull/506

* proper exit and fix bug in restart function as a bonus
This commit is contained in:
Frans de Jonge
2017-09-11 21:37:00 +02:00
committed by GitHub
parent 85e2140ced
commit a39db783c0
4 changed files with 66 additions and 19 deletions

View File

@@ -218,11 +218,31 @@ dbg:guard(ReaderMenu, 'setUpdateItemTable',
end)
function ReaderMenu:exitOrRestart(callback)
self:onTapCloseMenu()
if self.menu_container then self:onTapCloseMenu() end
UIManager:nextTick(function()
self.ui:onClose()
if callback ~= nil then
callback()
-- show an empty widget so that the callback always happens
local Widget = require("ui/widget/widget")
local widget = Widget:new{
width = Screen:getWidth(),
height = Screen:getHeight(),
}
UIManager:show(widget)
local waiting = function(waiting)
-- if we don't do this you can get a situation where either the
-- program won't exit due to remaining widgets until they're
-- dismissed or if the callback forces all widgets to close,
-- that the save document ConfirmBox is also closed
if self.ui and self.ui.document and self.ui.document:isEdited() then
logger.dbg("waiting for save settings")
UIManager:scheduleIn(1, function() waiting(waiting) end)
else
callback()
UIManager:close(widget)
end
end
UIManager:scheduleIn(1, function() waiting(waiting) end)
end
end)
local FileManager = require("apps/filemanager/filemanager")