Add a setting to disable save document (#2138)

* Add a setting to disable save document
* Add UI elements to control save-document settings
This commit is contained in:
Hzj_jie
2016-07-14 10:38:00 -07:00
committed by Qingping Hou
parent 483963cd71
commit d4c31d683f
2 changed files with 55 additions and 12 deletions

View File

@@ -465,18 +465,26 @@ end
function ReaderUI:notifyCloseDocument()
self:handleEvent(Event:new("CloseDocument"))
if self.document:isEdited() then
UIManager:show(ConfirmBox:new{
text = _("Do you want to save this document?"),
ok_text = _("Yes"),
cancel_text = _("No"),
ok_callback = function()
self:closeDocument()
end,
cancel_callback = function()
self.document:discardChange()
self:closeDocument()
end,
})
local setting = G_reader_settings:readSetting("save_document")
if setting == "always" then
self:closeDocument()
elseif setting == "disable" then
self.document:discardChange()
self:closeDocument()
else
UIManager:show(ConfirmBox:new{
text = _("Do you want to save this document?"),
ok_text = _("Yes"),
cancel_text = _("No"),
ok_callback = function()
self:closeDocument()
end,
cancel_callback = function()
self.document:discardChange()
self:closeDocument()
end,
})
end
else
self:closeDocument()
end