LuaSettings: Add a method to initialize a setting properly (#7371)

* LuaSettings/DocSettings: Updated readSetting API to allow proper initialization to default.
Use it to initialize tables, e.g., fixing corner-cases in readerFooter that could prevent settings from being saved.
(Fixes an issue reported on Gitter).
* LuaSettings/DocSettings: Add simpler API than the the flip* ones to toggle boolean settings.
* Update LuaSettings/DocSettigns usage throughout the codebase to use the dedicated boolean methods wher appropriate, and clean up some of the more mind-bending uses.
* FileChooser: Implement an extended default exclusion list (fix #2360)
* ScreenSaver: Refactor to avoid the pile of kludges this was threatening to become. Code should be easier to follow and use, and fallbacks now behave as expected (fix #4418).
This commit is contained in:
NiLuJe
2021-03-06 22:44:18 +01:00
committed by GitHub
parent 15ef1a3a1b
commit bf6c0cdd6c
78 changed files with 1424 additions and 1218 deletions

View File

@@ -71,8 +71,9 @@ function ReaderMenu:init()
end
end
end
self.activation_menu = G_reader_settings:readSetting("activate_menu")
if self.activation_menu == nil then
if G_reader_settings:has("activate_menu") then
self.activation_menu = G_reader_settings:readSetting("activate_menu")
else
self.activation_menu = "swipe_tap"
end
end
@@ -190,16 +191,16 @@ function ReaderMenu:setUpdateItemTable()
text = _("Exclude this book's cover from screensaver"),
enabled_func = function()
return not (self.ui == nil or self.ui.document == nil)
and G_reader_settings:readSetting('screensaver_type') == "cover"
and G_reader_settings:readSetting("screensaver_type") == "cover"
end,
checked_func = function()
return self.ui and self.ui.doc_settings and self.ui.doc_settings:readSetting("exclude_screensaver") == true
return self.ui and self.ui.doc_settings and self.ui.doc_settings:isTrue("exclude_screensaver")
end,
callback = function()
if Screensaver:excluded() then
self.ui.doc_settings:saveSetting("exclude_screensaver", false)
if Screensaver:isExcluded() then
self.ui.doc_settings:makeFalse("exclude_screensaver")
else
self.ui.doc_settings:saveSetting("exclude_screensaver", true)
self.ui.doc_settings:makeTrue("exclude_screensaver")
end
self.ui:saveSettings()
end,