mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
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:
@@ -45,6 +45,7 @@ function TextEditor:loadSettings()
|
||||
return
|
||||
end
|
||||
self.settings = LuaSettings:open(self.settings_file)
|
||||
-- NOTE: addToHistory assigns a new object
|
||||
self.history = self.settings:readSetting("history") or {}
|
||||
self.last_view_pos = self.settings:readSetting("last_view_pos") or {}
|
||||
self.last_path = self.settings:readSetting("last_path") or ffiutil.realpath(DataStorage:getDataDir())
|
||||
@@ -56,10 +57,10 @@ function TextEditor:loadSettings()
|
||||
--
|
||||
-- Allow users to set their prefered font manually in text_editor.lua
|
||||
-- (sadly, not via TextEditor itself, as they would be overriden on close)
|
||||
if self.settings:readSetting("normal_font") then
|
||||
if self.settings:has("normal_font") then
|
||||
self.normal_font = self.settings:readSetting("normal_font")
|
||||
end
|
||||
if self.settings:readSetting("monospace_font") then
|
||||
if self.settings:has("monospace_font") then
|
||||
self.monospace_font = self.settings:readSetting("monospace_font")
|
||||
end
|
||||
self.auto_para_direction = self.settings:nilOrTrue("auto_para_direction")
|
||||
@@ -254,7 +255,7 @@ function TextEditor:execWhenDoneFunc()
|
||||
end
|
||||
|
||||
function TextEditor:removeFromHistory(file_path)
|
||||
for i=#self.history, 1, -1 do
|
||||
for i = #self.history, 1, -1 do
|
||||
if self.history[i] == file_path then
|
||||
table.remove(self.history, i)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user