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:
@@ -32,12 +32,12 @@ function ReaderBookmark:init()
|
||||
}
|
||||
end
|
||||
|
||||
if not G_reader_settings:readSetting("bookmarks_items_per_page") then
|
||||
if G_reader_settings:hasNot("bookmarks_items_per_page") then
|
||||
-- The Bookmarks items per page and items' font size can now be
|
||||
-- configured. Previously, the ones set for the file browser
|
||||
-- were used. Initialize them from these ones.
|
||||
local items_per_page = G_reader_settings:readSetting("items_per_page")
|
||||
or self.bookmarks_items_per_page_default
|
||||
or self.bookmarks_items_per_page_default
|
||||
G_reader_settings:saveSetting("bookmarks_items_per_page", items_per_page)
|
||||
local items_font_size = G_reader_settings:readSetting("items_font_size")
|
||||
if items_font_size and items_font_size ~= Menu.getItemFontSize(items_per_page) then
|
||||
@@ -186,7 +186,7 @@ end
|
||||
function ReaderBookmark:fixBookmarkSort(config)
|
||||
-- for backward compatibility, since previously bookmarks for credocuments
|
||||
-- are not well sorted. We need to do a whole sorting for at least once.
|
||||
if not config:readSetting("bookmarks_sorted") then
|
||||
if config:hasNot("bookmarks_sorted") then
|
||||
table.sort(self.bookmarks, function(a, b)
|
||||
return self:isBookmarkInPageOrder(a, b)
|
||||
end)
|
||||
@@ -197,7 +197,7 @@ function ReaderBookmark:importSavedHighlight(config)
|
||||
local textmarks = config:readSetting("highlight") or {}
|
||||
-- import saved highlight once, because from now on highlight are added to
|
||||
-- bookmarks when they are created.
|
||||
if not config:readSetting("highlights_imported") then
|
||||
if config:hasNot("highlights_imported") then
|
||||
for page, marks in pairs(textmarks) do
|
||||
for _, mark in ipairs(marks) do
|
||||
page = self.ui.document.info.has_pages and page or mark.pos0
|
||||
@@ -228,8 +228,8 @@ end
|
||||
|
||||
function ReaderBookmark:onSaveSettings()
|
||||
self.ui.doc_settings:saveSetting("bookmarks", self.bookmarks)
|
||||
self.ui.doc_settings:saveSetting("bookmarks_sorted", true)
|
||||
self.ui.doc_settings:saveSetting("highlights_imported", true)
|
||||
self.ui.doc_settings:makeTrue("bookmarks_sorted")
|
||||
self.ui.doc_settings:makeTrue("highlights_imported")
|
||||
end
|
||||
|
||||
function ReaderBookmark:isCurrentPageBookmarked()
|
||||
|
||||
@@ -29,8 +29,9 @@ function ReaderConfig:init()
|
||||
if Device:isTouchDevice() then
|
||||
self:initGesListener()
|
||||
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
|
||||
|
||||
@@ -11,8 +11,9 @@ local _ = require("gettext")
|
||||
local ReaderCoptListener = EventListener:new{}
|
||||
|
||||
function ReaderCoptListener:onReadSettings(config)
|
||||
local view_mode = config:readSetting("copt_view_mode") or
|
||||
G_reader_settings:readSetting("copt_view_mode") or 0 -- default to "page" mode
|
||||
local view_mode = config:readSetting("copt_view_mode")
|
||||
or G_reader_settings:readSetting("copt_view_mode")
|
||||
or 0 -- default to "page" mode
|
||||
local view_mode_name = view_mode == 0 and "page" or "scroll"
|
||||
-- Let crengine know of the view mode before rendering, as it can
|
||||
-- cause a rendering change (2-pages would become 1-page in
|
||||
|
||||
@@ -58,7 +58,6 @@ end
|
||||
local ReaderDictionary = InputContainer:new{
|
||||
data_dir = nil,
|
||||
dict_window_list = {},
|
||||
disable_lookup_history = G_reader_settings:isTrue("disable_lookup_history"),
|
||||
lookup_msg = _("Searching dictionary for:\n%1"),
|
||||
}
|
||||
|
||||
@@ -96,6 +95,10 @@ local function getDictionaryFixHtmlFunc(path)
|
||||
end
|
||||
|
||||
function ReaderDictionary:init()
|
||||
self.disable_lookup_history = G_reader_settings:isTrue("disable_lookup_history")
|
||||
self.dicts_order = G_reader_settings:readSetting("dicts_order", {})
|
||||
self.dicts_disabled = G_reader_settings:readSetting("dicts_disabled", {})
|
||||
|
||||
self.ui.menu:registerToMainMenu(self)
|
||||
self.data_dir = STARDICT_DATA_DIR or
|
||||
os.getenv("STARDICT_DATA_DIR") or
|
||||
@@ -140,19 +143,7 @@ function ReaderDictionary:init()
|
||||
end
|
||||
end
|
||||
logger.dbg("found", #available_ifos, "dictionaries")
|
||||
|
||||
if not G_reader_settings:readSetting("dicts_order") then
|
||||
G_reader_settings:saveSetting("dicts_order", {})
|
||||
end
|
||||
|
||||
self:sortAvailableIfos()
|
||||
|
||||
if not G_reader_settings:readSetting("dicts_disabled") then
|
||||
-- Create an empty dict for this setting, so that we can
|
||||
-- access and update it directly through G_reader_settings
|
||||
-- and it will automatically be saved.
|
||||
G_reader_settings:saveSetting("dicts_disabled", {})
|
||||
end
|
||||
end
|
||||
-- Prepare the -u options to give to sdcv the dictionary order and if some are disabled
|
||||
self:updateSdcvDictNamesOptions()
|
||||
@@ -163,11 +154,9 @@ function ReaderDictionary:init()
|
||||
end
|
||||
|
||||
function ReaderDictionary:sortAvailableIfos()
|
||||
local dicts_order = G_reader_settings:readSetting("dicts_order")
|
||||
|
||||
table.sort(available_ifos, function(lifo, rifo)
|
||||
local lord = dicts_order[lifo.file]
|
||||
local rord = dicts_order[rifo.file]
|
||||
local lord = self.dicts_order[lifo.file]
|
||||
local rord = self.dicts_order[rifo.file]
|
||||
|
||||
-- Both ifos without an explicit position -> lexical comparison
|
||||
if lord == rord then
|
||||
@@ -468,9 +457,8 @@ function ReaderDictionary:getNumberOfDictionaries()
|
||||
local nb_available = #available_ifos
|
||||
local nb_enabled = 0
|
||||
local nb_disabled = 0
|
||||
local dicts_disabled = G_reader_settings:readSetting("dicts_disabled")
|
||||
for _, ifo in pairs(available_ifos) do
|
||||
if dicts_disabled[ifo.file] then
|
||||
if self.dicts_disabled[ifo.file] then
|
||||
nb_disabled = nb_disabled + 1
|
||||
else
|
||||
nb_enabled = nb_enabled + 1
|
||||
@@ -526,7 +514,7 @@ end
|
||||
|
||||
function ReaderDictionary:showDictionariesMenu(changed_callback)
|
||||
-- Work on local copy, save to settings only when SortWidget is closed with the accept button
|
||||
local dicts_disabled = util.tableDeepCopy(G_reader_settings:readSetting("dicts_disabled"))
|
||||
local dicts_disabled = util.tableDeepCopy(self.dicts_disabled)
|
||||
|
||||
local sort_items = {}
|
||||
for _, ifo in pairs(available_ifos) do
|
||||
@@ -550,15 +538,17 @@ function ReaderDictionary:showDictionariesMenu(changed_callback)
|
||||
title = _("Manage installed dictionaries"),
|
||||
item_table = sort_items,
|
||||
callback = function()
|
||||
-- Save local copy of dicts_disabled
|
||||
G_reader_settings:saveSetting("dicts_disabled", dicts_disabled)
|
||||
-- Update both references to point to that new object
|
||||
self.dicts_disabled = dicts_disabled
|
||||
G_reader_settings:saveSetting("dicts_disabled", self.dicts_disabled)
|
||||
|
||||
-- Write back the sorted items to dicts_order
|
||||
local dicts_order = {}
|
||||
for i, sort_item in pairs(sort_items) do
|
||||
dicts_order[sort_item.ifo.file] = i
|
||||
end
|
||||
G_reader_settings:saveSetting("dicts_order", dicts_order)
|
||||
self.dicts_order = dicts_order
|
||||
G_reader_settings:saveSetting("dicts_order", self.dicts_order)
|
||||
|
||||
self:sortAvailableIfos()
|
||||
|
||||
@@ -1058,8 +1048,9 @@ function ReaderDictionary:onReadSettings(config)
|
||||
if #self.preferred_dictionaries > 0 then
|
||||
self:updateSdcvDictNamesOptions()
|
||||
end
|
||||
self.disable_fuzzy_search = config:readSetting("disable_fuzzy_search")
|
||||
if self.disable_fuzzy_search == nil then
|
||||
if config:has("disable_fuzzy_search") then
|
||||
self.disable_fuzzy_search = config:isTrue("disable_fuzzy_search")
|
||||
else
|
||||
self.disable_fuzzy_search = G_reader_settings:isTrue("disable_fuzzy_search")
|
||||
end
|
||||
end
|
||||
@@ -1118,13 +1109,13 @@ The current default (★) is enabled.]])
|
||||
return disable_fuzzy_search and _("Disable (★)") or _("Disable")
|
||||
end,
|
||||
choice1_callback = function()
|
||||
G_reader_settings:saveSetting("disable_fuzzy_search", true)
|
||||
G_reader_settings:makeTrue("disable_fuzzy_search")
|
||||
end,
|
||||
choice2_text_func = function()
|
||||
return disable_fuzzy_search and _("Enable") or _("Enable (★)")
|
||||
end,
|
||||
choice2_callback = function()
|
||||
G_reader_settings:saveSetting("disable_fuzzy_search", false)
|
||||
G_reader_settings:makeFalse("disable_fuzzy_search")
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
@@ -56,15 +56,15 @@ end
|
||||
function ReaderDogear:onReadSettings(config)
|
||||
if not self.ui.document.info.has_pages then
|
||||
-- Adjust to CreDocument margins (as done in ReaderTypeset)
|
||||
local h_margins = config:readSetting("copt_h_page_margins") or
|
||||
G_reader_settings:readSetting("copt_h_page_margins") or
|
||||
DCREREADER_CONFIG_H_MARGIN_SIZES_MEDIUM
|
||||
local t_margin = config:readSetting("copt_t_page_margin") or
|
||||
G_reader_settings:readSetting("copt_t_page_margin") or
|
||||
DCREREADER_CONFIG_T_MARGIN_SIZES_LARGE
|
||||
local b_margin = config:readSetting("copt_b_page_margin") or
|
||||
G_reader_settings:readSetting("copt_b_page_margin") or
|
||||
DCREREADER_CONFIG_B_MARGIN_SIZES_LARGE
|
||||
local h_margins = config:readSetting("copt_h_page_margins")
|
||||
or G_reader_settings:readSetting("copt_h_page_margins")
|
||||
or DCREREADER_CONFIG_H_MARGIN_SIZES_MEDIUM
|
||||
local t_margin = config:readSetting("copt_t_page_margin")
|
||||
or G_reader_settings:readSetting("copt_t_page_margin")
|
||||
or DCREREADER_CONFIG_T_MARGIN_SIZES_LARGE
|
||||
local b_margin = config:readSetting("copt_b_page_margin")
|
||||
or G_reader_settings:readSetting("copt_b_page_margin")
|
||||
or DCREREADER_CONFIG_B_MARGIN_SIZES_LARGE
|
||||
local margins = { h_margins[1], t_margin, h_margins[2], b_margin }
|
||||
self:onSetPageMargins(margins)
|
||||
end
|
||||
|
||||
@@ -108,48 +108,55 @@ end
|
||||
|
||||
function ReaderFont:onReadSettings(config)
|
||||
self.font_face = config:readSetting("font_face")
|
||||
or G_reader_settings:readSetting("cre_font")
|
||||
or self.ui.document.default_font
|
||||
or G_reader_settings:readSetting("cre_font")
|
||||
or self.ui.document.default_font
|
||||
self.ui.document:setFontFace(self.font_face)
|
||||
|
||||
self.header_font_face = config:readSetting("header_font_face")
|
||||
or G_reader_settings:readSetting("header_font")
|
||||
or self.ui.document.header_font
|
||||
or G_reader_settings:readSetting("header_font")
|
||||
or self.ui.document.header_font
|
||||
self.ui.document:setHeaderFont(self.header_font_face)
|
||||
|
||||
self.font_size = config:readSetting("font_size")
|
||||
or G_reader_settings:readSetting("copt_font_size")
|
||||
or DCREREADER_CONFIG_DEFAULT_FONT_SIZE or 22
|
||||
or G_reader_settings:readSetting("copt_font_size")
|
||||
or DCREREADER_CONFIG_DEFAULT_FONT_SIZE
|
||||
or 22
|
||||
self.ui.document:setFontSize(Screen:scaleBySize(self.font_size))
|
||||
|
||||
self.font_embolden = config:readSetting("font_embolden")
|
||||
or G_reader_settings:readSetting("copt_font_weight") or 0
|
||||
or G_reader_settings:readSetting("copt_font_weight")
|
||||
or 0
|
||||
self.ui.document:toggleFontBolder(self.font_embolden)
|
||||
|
||||
self.font_hinting = config:readSetting("font_hinting")
|
||||
or G_reader_settings:readSetting("copt_font_hinting") or 2 -- auto (default in cre.cpp)
|
||||
or G_reader_settings:readSetting("copt_font_hinting")
|
||||
or 2 -- auto (default in cre.cpp)
|
||||
self.ui.document:setFontHinting(self.font_hinting)
|
||||
|
||||
self.font_kerning = config:readSetting("font_kerning")
|
||||
or G_reader_settings:readSetting("copt_font_kerning") or 3 -- harfbuzz (slower, but needed for proper arabic)
|
||||
or G_reader_settings:readSetting("copt_font_kerning")
|
||||
or 3 -- harfbuzz (slower, but needed for proper arabic)
|
||||
self.ui.document:setFontKerning(self.font_kerning)
|
||||
|
||||
self.word_spacing = config:readSetting("word_spacing")
|
||||
or G_reader_settings:readSetting("copt_word_spacing") or {95, 75}
|
||||
or G_reader_settings:readSetting("copt_word_spacing")
|
||||
or {95, 75}
|
||||
self.ui.document:setWordSpacing(self.word_spacing)
|
||||
|
||||
self.word_expansion = config:readSetting("word_expansion")
|
||||
or G_reader_settings:readSetting("copt_word_expansion") or 0
|
||||
or G_reader_settings:readSetting("copt_word_expansion")
|
||||
or 0
|
||||
self.ui.document:setWordExpansion(self.word_expansion)
|
||||
|
||||
self.line_space_percent = config:readSetting("line_space_percent")
|
||||
or G_reader_settings:readSetting("copt_line_spacing")
|
||||
or DCREREADER_CONFIG_LINE_SPACE_PERCENT_MEDIUM
|
||||
or G_reader_settings:readSetting("copt_line_spacing")
|
||||
or DCREREADER_CONFIG_LINE_SPACE_PERCENT_MEDIUM
|
||||
self.ui.document:setInterlineSpacePercent(self.line_space_percent)
|
||||
|
||||
self.gamma_index = config:readSetting("gamma_index")
|
||||
or G_reader_settings:readSetting("copt_font_gamma")
|
||||
or DCREREADER_CONFIG_DEFAULT_FONT_GAMMA or 15 -- gamma = 1.0
|
||||
or G_reader_settings:readSetting("copt_font_gamma")
|
||||
or DCREREADER_CONFIG_DEFAULT_FONT_GAMMA
|
||||
or 15 -- gamma = 1.0
|
||||
self.ui.document:setGammaIndex(self.gamma_index)
|
||||
|
||||
-- Dirty hack: we have to add following call in order to set
|
||||
@@ -439,8 +446,8 @@ function ReaderFont:buildFontsTestDocument()
|
||||
f:close()
|
||||
end
|
||||
local dir = G_reader_settings:readSetting("home_dir")
|
||||
if not dir then dir = require("apps/filemanager/filemanagerutil").getDefaultDir() end
|
||||
if not dir then dir = "." end
|
||||
or require("apps/filemanager/filemanagerutil").getDefaultDir()
|
||||
or "."
|
||||
local font_test_final_path = dir .. "/" .. FONT_TEST_FINAL_FILENAME
|
||||
f = io.open(font_test_final_path, "w")
|
||||
if not f then return end
|
||||
|
||||
@@ -387,7 +387,7 @@ local ReaderFooter = WidgetContainer:extend{
|
||||
}
|
||||
|
||||
function ReaderFooter:init()
|
||||
self.settings = G_reader_settings:readSetting("footer") or {
|
||||
self.settings = G_reader_settings:readSetting("footer", {
|
||||
-- enable progress bar by default
|
||||
-- disable_progress_bar = true,
|
||||
disabled = false,
|
||||
@@ -414,7 +414,7 @@ function ReaderFooter:init()
|
||||
text_font_bold = false,
|
||||
container_height = DMINIBAR_CONTAINER_HEIGHT,
|
||||
container_bottom_padding = 1, -- unscaled_size_check: ignore
|
||||
}
|
||||
})
|
||||
|
||||
-- Remove items not supported by the current device
|
||||
if not Device:hasFastWifiStatusQuery() then
|
||||
@@ -889,7 +889,6 @@ function ReaderFooter:addToMainMenu(menu_items)
|
||||
end,
|
||||
callback = function()
|
||||
self.settings[option] = not self.settings[option]
|
||||
G_reader_settings:saveSetting("footer", self.settings)
|
||||
-- We only need to send a SetPageBottomMargin event when we truly affect the margin
|
||||
local should_signal = false
|
||||
-- only case that we don't need a UI update is enable/disable
|
||||
@@ -976,7 +975,6 @@ function ReaderFooter:addToMainMenu(menu_items)
|
||||
self.mode_index[i] = sort_item.item_table[i].label
|
||||
end
|
||||
self.settings.order = self.mode_index
|
||||
G_reader_settings:saveSetting("footer", self.settings)
|
||||
self:updateFooterTextGenerator()
|
||||
self:onUpdateFooter()
|
||||
UIManager:setDirty(nil, "ui")
|
||||
@@ -994,7 +992,6 @@ function ReaderFooter:addToMainMenu(menu_items)
|
||||
end,
|
||||
callback = function()
|
||||
self.settings.auto_refresh_time = not self.settings.auto_refresh_time
|
||||
G_reader_settings:saveSetting("footer", self.settings)
|
||||
self:rescheduleFooterAutoRefreshIfNeeded()
|
||||
end
|
||||
},
|
||||
@@ -1035,7 +1032,6 @@ function ReaderFooter:addToMainMenu(menu_items)
|
||||
end,
|
||||
callback = function()
|
||||
self.settings.skim_widget_on_hold = not self.settings.skim_widget_on_hold
|
||||
G_reader_settings:saveSetting("footer", self.settings)
|
||||
end,
|
||||
},
|
||||
{
|
||||
@@ -1857,7 +1853,7 @@ function ReaderFooter:getAvgTimePerPage()
|
||||
end
|
||||
|
||||
function ReaderFooter:getDataFromStatistics(title, pages)
|
||||
local sec = "N/A"
|
||||
local sec = _("N/A")
|
||||
local average_time_per_page = self:getAvgTimePerPage()
|
||||
if average_time_per_page then
|
||||
if self.settings.duration_format == "classic" then
|
||||
@@ -2065,9 +2061,9 @@ end
|
||||
|
||||
function ReaderFooter:onReadSettings(config)
|
||||
if not self.ui.document.info.has_pages then
|
||||
local h_margins = config:readSetting("copt_h_page_margins") or
|
||||
G_reader_settings:readSetting("copt_h_page_margins") or
|
||||
DCREREADER_CONFIG_H_MARGIN_SIZES_MEDIUM
|
||||
local h_margins = config:readSetting("copt_h_page_margins")
|
||||
or G_reader_settings:readSetting("copt_h_page_margins")
|
||||
or DCREREADER_CONFIG_H_MARGIN_SIZES_MEDIUM
|
||||
self.book_margins_footer_width = math.floor((h_margins[1] + h_margins[2])/2)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1175,13 +1175,13 @@ function ReaderHighlight:onCycleHighlightAction()
|
||||
dictionary = "search",
|
||||
search = nil,
|
||||
}
|
||||
local current_action = G_reader_settings:readSetting("default_highlight_action")
|
||||
if not current_action then
|
||||
if G_reader_settings:hasNot("default_highlight_action") then
|
||||
G_reader_settings:saveSetting("default_highlight_action", "highlight")
|
||||
UIManager:show(Notification:new{
|
||||
text = _("Default highlight action changed to 'highlight'."),
|
||||
})
|
||||
else
|
||||
local current_action = G_reader_settings:readSetting("default_highlight_action")
|
||||
local next_action = next_actions[current_action]
|
||||
G_reader_settings:saveSetting("default_highlight_action", next_action)
|
||||
UIManager:show(Notification:new{
|
||||
@@ -1446,23 +1446,25 @@ end
|
||||
|
||||
function ReaderHighlight:onReadSettings(config)
|
||||
self.view.highlight.saved_drawer = config:readSetting("highlight_drawer") or self.view.highlight.saved_drawer
|
||||
local disable_highlight = config:readSetting("highlight_disabled")
|
||||
if disable_highlight == nil then
|
||||
disable_highlight = G_reader_settings:readSetting("highlight_disabled") or false
|
||||
if config:has("highlight_disabled") then
|
||||
self.view.highlight.disabled = config:isTrue("highlight_disabled")
|
||||
else
|
||||
self.view.highlight.disabled = G_reader_settings:isTrue("highlight_disabled")
|
||||
end
|
||||
self.view.highlight.disabled = disable_highlight
|
||||
|
||||
-- panel zoom settings isn't supported in EPUB
|
||||
if self.document.info.has_pages then
|
||||
local ext = util.getFileNameSuffix(self.ui.document.file)
|
||||
G_reader_settings:initializeExtSettings("panel_zoom_enabled", {cbz = true, cbt = true})
|
||||
G_reader_settings:initializeExtSettings("panel_zoom_fallback_to_text_selection", {pdf = true})
|
||||
self.panel_zoom_enabled = config:readSetting("panel_zoom_enabled")
|
||||
if self.panel_zoom_enabled == nil then
|
||||
if config:has("panel_zoom_enabled") then
|
||||
self.panel_zoom_enabled = config:isTrue("panel_zoom_enabled")
|
||||
else
|
||||
self.panel_zoom_enabled = G_reader_settings:getSettingForExt("panel_zoom_enabled", ext) or false
|
||||
end
|
||||
self.panel_zoom_fallback_to_text_selection = config:readSetting("panel_zoom_fallback_to_text_selection")
|
||||
if self.panel_zoom_fallback_to_text_selection == nil then
|
||||
if config:has("panel_zoom_fallback_to_text_selection") then
|
||||
self.panel_zoom_fallback_to_text_selection = config:isTrue("panel_zoom_fallback_to_text_selection")
|
||||
else
|
||||
self.panel_zoom_fallback_to_text_selection = G_reader_settings:getSettingForExt("panel_zoom_fallback_to_text_selection", ext) or false
|
||||
end
|
||||
end
|
||||
@@ -1493,13 +1495,13 @@ function ReaderHighlight:toggleDefault()
|
||||
return highlight_disabled and _("Disable (★)") or _("Disable")
|
||||
end,
|
||||
choice1_callback = function()
|
||||
G_reader_settings:saveSetting("highlight_disabled", true)
|
||||
G_reader_settings:makeTrue("highlight_disabled")
|
||||
end,
|
||||
choice2_text_func = function()
|
||||
return highlight_disabled and _("Enable") or _("Enable (★)")
|
||||
end,
|
||||
choice2_callback = function()
|
||||
G_reader_settings:saveSetting("highlight_disabled", false)
|
||||
G_reader_settings:makeFalse("highlight_disabled")
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
@@ -16,15 +16,17 @@ end
|
||||
|
||||
function ReaderKoptListener:onReadSettings(config)
|
||||
-- normal zoom mode is zoom mode used in non-reflow mode.
|
||||
local normal_zoom_mode = config:readSetting("normal_zoom_mode") or
|
||||
G_reader_settings:readSetting("zoom_mode") or "page"
|
||||
local normal_zoom_mode = config:readSetting("normal_zoom_mode")
|
||||
or G_reader_settings:readSetting("zoom_mode")
|
||||
or "page"
|
||||
normal_zoom_mode = util.arrayContains(ReaderZooming.available_zoom_modes, normal_zoom_mode)
|
||||
and normal_zoom_mode
|
||||
and normal_zoom_mode
|
||||
or "page"
|
||||
self.normal_zoom_mode = normal_zoom_mode
|
||||
self:setZoomMode(normal_zoom_mode)
|
||||
self.document.configurable.contrast = config:readSetting("kopt_contrast") or
|
||||
G_reader_settings:readSetting("kopt_contrast") or 1.0
|
||||
self.document.configurable.contrast = config:readSetting("kopt_contrast")
|
||||
or G_reader_settings:readSetting("kopt_contrast")
|
||||
or 1.0
|
||||
self.ui:handleEvent(Event:new("GammaUpdate", 1/self.document.configurable.contrast))
|
||||
-- since K2pdfopt v2.21 negative value of word spacing is also used, for config
|
||||
-- compatability we should manually change previous -1 to a more reasonable -0.2
|
||||
|
||||
@@ -326,7 +326,7 @@ The recommended value is -2.]]),
|
||||
end
|
||||
return spin_widget
|
||||
end
|
||||
local show_absolute_font_size_widget = G_reader_settings:readSetting("footnote_popup_absolute_font_size") ~= nil
|
||||
local show_absolute_font_size_widget = G_reader_settings:has("footnote_popup_absolute_font_size")
|
||||
spin_widget = get_font_size_widget(show_absolute_font_size_widget)
|
||||
UIManager:show(spin_widget)
|
||||
end,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -88,18 +88,20 @@ function ReaderPageMap:resetLayout()
|
||||
end
|
||||
|
||||
function ReaderPageMap:onReadSettings(config)
|
||||
local h_margins = config:readSetting("copt_h_page_margins") or
|
||||
G_reader_settings:readSetting("copt_h_page_margins") or
|
||||
DCREREADER_CONFIG_H_MARGIN_SIZES_MEDIUM
|
||||
local h_margins = config:readSetting("copt_h_page_margins")
|
||||
or G_reader_settings:readSetting("copt_h_page_margins")
|
||||
or DCREREADER_CONFIG_H_MARGIN_SIZES_MEDIUM
|
||||
self.max_left_label_width = Screen:scaleBySize(h_margins[1])
|
||||
self.max_right_label_width = Screen:scaleBySize(h_margins[2])
|
||||
|
||||
self.show_page_labels = config:readSetting("pagemap_show_page_labels")
|
||||
if self.show_page_labels == nil then
|
||||
if config:has("pagemap_show_page_labels") then
|
||||
self.show_page_labels = config:isTrue("pagemap_show_page_labels")
|
||||
else
|
||||
self.show_page_labels = G_reader_settings:nilOrTrue("pagemap_show_page_labels")
|
||||
end
|
||||
self.use_page_labels = config:readSetting("pagemap_use_page_labels")
|
||||
if self.use_page_labels == nil then
|
||||
if config:has("pagemap_use_page_labels") then
|
||||
self.use_page_labels = config:isTrue("pagemap_use_page_labels")
|
||||
else
|
||||
self.use_page_labels = G_reader_settings:isTrue("pagemap_use_page_labels")
|
||||
end
|
||||
end
|
||||
@@ -352,14 +354,14 @@ function ReaderPageMap:addToMainMenu(menu_items)
|
||||
return use_page_labels and _("Renderer") or _("Renderer (★)")
|
||||
end,
|
||||
choice1_callback = function()
|
||||
G_reader_settings:saveSetting("pagemap_use_page_labels", false)
|
||||
G_reader_settings:makeFalse("pagemap_use_page_labels")
|
||||
if touchmenu_instance then touchmenu_instance:updateItems() end
|
||||
end,
|
||||
choice2_text_func = function()
|
||||
return use_page_labels and _("Reference (★)") or _("Reference")
|
||||
end,
|
||||
choice2_callback = function()
|
||||
G_reader_settings:saveSetting("pagemap_use_page_labels", true)
|
||||
G_reader_settings:makeTrue("pagemap_use_page_labels")
|
||||
if touchmenu_instance then touchmenu_instance:updateItems() end
|
||||
end,
|
||||
})
|
||||
@@ -385,14 +387,14 @@ function ReaderPageMap:addToMainMenu(menu_items)
|
||||
return show_page_labels and _("Hide") or _("Hide (★)")
|
||||
end,
|
||||
choice1_callback = function()
|
||||
G_reader_settings:saveSetting("pagemap_show_page_labels", false)
|
||||
G_reader_settings:makeFalse("pagemap_show_page_labels")
|
||||
if touchmenu_instance then touchmenu_instance:updateItems() end
|
||||
end,
|
||||
choice2_text_func = function()
|
||||
return show_page_labels and _("Show (★)") or _("Show")
|
||||
end,
|
||||
choice2_callback = function()
|
||||
G_reader_settings:saveSetting("pagemap_show_page_labels", true)
|
||||
G_reader_settings:makeTrue("pagemap_show_page_labels")
|
||||
if touchmenu_instance then touchmenu_instance:updateItems() end
|
||||
end,
|
||||
})
|
||||
|
||||
@@ -184,14 +184,16 @@ end
|
||||
function ReaderPaging:onReadSettings(config)
|
||||
self.page_positions = config:readSetting("page_positions") or {}
|
||||
self:_gotoPage(config:readSetting("last_page") or 1)
|
||||
self.show_overlap_enable = config:readSetting("show_overlap_enable")
|
||||
if self.show_overlap_enable == nil then
|
||||
if config:has("show_overlap_enable") then
|
||||
self.show_overlap_enable = config:isTrue("show_overlap_enable")
|
||||
else
|
||||
self.show_overlap_enable = DSHOWOVERLAP
|
||||
end
|
||||
self.flipping_zoom_mode = config:readSetting("flipping_zoom_mode") or "page"
|
||||
self.flipping_scroll_mode = config:readSetting("flipping_scroll_mode") or false
|
||||
self.inverse_reading_order = config:readSetting("inverse_reading_order")
|
||||
if self.inverse_reading_order == nil then
|
||||
self.flipping_scroll_mode = config:isTrue("flipping_scroll_mode")
|
||||
if config:has("inverse_reading_order") then
|
||||
self.inverse_reading_order = config:isTrue("inverse_reading_order")
|
||||
else
|
||||
self.inverse_reading_order = G_reader_settings:isTrue("inverse_reading_order")
|
||||
end
|
||||
for _, v in ipairs(ReaderZooming.zoom_pan_settings) do
|
||||
@@ -266,14 +268,14 @@ function ReaderPaging:addToMainMenu(menu_items)
|
||||
return inverse_reading_order and _("LTR") or _("LTR (★)")
|
||||
end,
|
||||
choice1_callback = function()
|
||||
G_reader_settings:saveSetting("inverse_reading_order", false)
|
||||
G_reader_settings:makeFalse("inverse_reading_order")
|
||||
if touchmenu_instance then touchmenu_instance:updateItems() end
|
||||
end,
|
||||
choice2_text_func = function()
|
||||
return inverse_reading_order and _("RTL (★)") or _("RTL")
|
||||
end,
|
||||
choice2_callback = function()
|
||||
G_reader_settings:saveSetting("inverse_reading_order", true)
|
||||
G_reader_settings:makeTrue("inverse_reading_order")
|
||||
if touchmenu_instance then touchmenu_instance:updateItems() end
|
||||
end,
|
||||
})
|
||||
|
||||
@@ -139,9 +139,9 @@ function ReaderRolling:onReadSettings(config)
|
||||
-- and highlights with old XPATHs.
|
||||
-- (EPUB will use the same correct DOM code no matter what DOM version
|
||||
-- we request here.)
|
||||
if not config:readSetting("cre_dom_version") then
|
||||
if config:hasNot("cre_dom_version") then
|
||||
-- Not previously set, guess which DOM version to use
|
||||
if config:readSetting("last_xpointer") then
|
||||
if config:has("last_xpointer") then
|
||||
-- We have a last_xpointer: this book was previously opened
|
||||
-- with possibly a very old version: request the oldest
|
||||
config:saveSetting("cre_dom_version", self.ui.document:getOldestDomVersion())
|
||||
@@ -166,7 +166,7 @@ function ReaderRolling:onReadSettings(config)
|
||||
self.ui.typeset:ensureSanerBlockRenderingFlags()
|
||||
-- And check if we can migrate to a newest DOM version after
|
||||
-- the book is loaded (unless the user told us not to).
|
||||
if not config:readSetting("cre_keep_old_dom_version") then
|
||||
if config:nilOrFalse("cre_keep_old_dom_version") then
|
||||
self.ui:registerPostReadyCallback(function()
|
||||
self:checkXPointersAndProposeDOMVersionUpgrade()
|
||||
end)
|
||||
@@ -209,13 +209,15 @@ function ReaderRolling:onReadSettings(config)
|
||||
end
|
||||
end
|
||||
end
|
||||
self.show_overlap_enable = config:readSetting("show_overlap_enable")
|
||||
if self.show_overlap_enable == nil then
|
||||
if config:has("show_overlap_enable") then
|
||||
self.show_overlap_enable = config:isTrue("show_overlap_enable")
|
||||
else
|
||||
self.show_overlap_enable = DSHOWOVERLAP
|
||||
end
|
||||
|
||||
self.inverse_reading_order = config:readSetting("inverse_reading_order")
|
||||
if self.inverse_reading_order == nil then
|
||||
if config:has("inverse_reading_order") then
|
||||
self.inverse_reading_order = config:isTrue("inverse_reading_order")
|
||||
else
|
||||
self.inverse_reading_order = G_reader_settings:isTrue("inverse_reading_order")
|
||||
end
|
||||
|
||||
@@ -229,8 +231,9 @@ function ReaderRolling:onReadSettings(config)
|
||||
G_reader_settings:readSetting("copt_visible_pages") or 1
|
||||
self.ui.document:setVisiblePageCount(self.visible_pages)
|
||||
|
||||
self.hide_nonlinear_flows = config:readSetting("hide_nonlinear_flows")
|
||||
if self.hide_nonlinear_flows == nil then
|
||||
if config:has("hide_nonlinear_flows") then
|
||||
self.hide_nonlinear_flows = config:isTrue("hide_nonlinear_flows")
|
||||
else
|
||||
self.hide_nonlinear_flows = G_reader_settings:isTrue("hide_nonlinear_flows")
|
||||
end
|
||||
self.ui.document:setHideNonlinearFlows(self.hide_nonlinear_flows)
|
||||
@@ -296,7 +299,7 @@ end
|
||||
|
||||
function ReaderRolling:onSaveSettings()
|
||||
-- remove last_percent config since its deprecated
|
||||
self.ui.doc_settings:saveSetting("last_percent", nil)
|
||||
self.ui.doc_settings:delSetting("last_percent")
|
||||
self.ui.doc_settings:saveSetting("last_xpointer", self.xpointer)
|
||||
-- in scrolling mode, the document may already be closed,
|
||||
-- so we have to check the condition to avoid crash function self:getLastPercent()
|
||||
@@ -395,14 +398,14 @@ function ReaderRolling:addToMainMenu(menu_items)
|
||||
return inverse_reading_order and _("LTR") or _("LTR (★)")
|
||||
end,
|
||||
choice1_callback = function()
|
||||
G_reader_settings:saveSetting("inverse_reading_order", false)
|
||||
G_reader_settings:makeFalse("inverse_reading_order")
|
||||
if touchmenu_instance then touchmenu_instance:updateItems() end
|
||||
end,
|
||||
choice2_text_func = function()
|
||||
return inverse_reading_order and _("RTL (★)") or _("RTL")
|
||||
end,
|
||||
choice2_callback = function()
|
||||
G_reader_settings:saveSetting("inverse_reading_order", true)
|
||||
G_reader_settings:makeTrue("inverse_reading_order")
|
||||
if touchmenu_instance then touchmenu_instance:updateItems() end
|
||||
end,
|
||||
})
|
||||
@@ -644,8 +647,10 @@ function ReaderRolling:onGotoXPointer(xp, marker_xp)
|
||||
-- followed_link_marker = true: maker shown and not auto removed
|
||||
-- followed_link_marker = <number>: removed after <number> seconds
|
||||
-- (no real need for a menu item, the default is the finest)
|
||||
local marker_setting = G_reader_settings:readSetting("followed_link_marker")
|
||||
if marker_setting == nil then
|
||||
local marker_setting
|
||||
if G_reader_settings:has("followed_link_marker") then
|
||||
marker_setting = G_reader_settings:readSetting("followed_link_marker")
|
||||
else
|
||||
marker_setting = 1 -- default is: shown and removed after 1 second
|
||||
end
|
||||
|
||||
@@ -1279,11 +1284,14 @@ function ReaderRolling:checkXPointersAndProposeDOMVersionUpgrade()
|
||||
-- Switch to default block rendering mode if this book has it set to "legacy",
|
||||
-- unless the user had set the global mode to be "legacy".
|
||||
-- (see ReaderTypeset:onReadSettings() for the logic of block_rendering_mode)
|
||||
local g_block_rendering_mode = G_reader_settings:readSetting("copt_block_rendering_mode")
|
||||
local g_block_rendering_mode
|
||||
if G_reader_settings:has("copt_block_rendering_mode") then
|
||||
g_block_rendering_mode = G_reader_settings:readSetting("copt_block_rendering_mode")
|
||||
else
|
||||
-- nil means: use default
|
||||
g_block_rendering_mode = 3 -- default in ReaderTypeset:onReadSettings()
|
||||
end
|
||||
if g_block_rendering_mode ~= 0 then -- default is not "legacy"
|
||||
if not g_block_rendering_mode then -- nil means: use default
|
||||
g_block_rendering_mode = 3 -- default in ReaderTypeset:onReadSettings()
|
||||
end
|
||||
-- This setting is actually saved by self.ui.document.configurable
|
||||
local block_rendering_mode = self.ui.document.configurable.block_rendering_mode
|
||||
if block_rendering_mode == 0 then
|
||||
@@ -1343,7 +1351,7 @@ Note that %1 (out of %2) xpaths from your bookmarks and highlights have been nor
|
||||
}},
|
||||
cancel_text = _("Not for this book"),
|
||||
cancel_callback = function()
|
||||
self.ui.doc_settings:saveSetting("cre_keep_old_dom_version", true)
|
||||
self.ui.doc_settings:makeTrue("cre_keep_old_dom_version")
|
||||
end,
|
||||
ok_text = _("Upgrade now"),
|
||||
ok_callback = function()
|
||||
|
||||
@@ -327,7 +327,7 @@ function ReaderStyleTweak:updateCssText(apply)
|
||||
end
|
||||
|
||||
function ReaderStyleTweak:onReadSettings(config)
|
||||
self.enabled = not (config:readSetting("style_tweaks_enabled") == false)
|
||||
self.enabled = config:nilOrTrue("style_tweaks_enabled")
|
||||
self.doc_tweaks = config:readSetting("style_tweaks") or {}
|
||||
-- Default globally enabled style tweaks (for new installations)
|
||||
-- are defined in css_tweaks.lua
|
||||
@@ -342,7 +342,7 @@ function ReaderStyleTweak:onSaveSettings()
|
||||
if self.enabled then
|
||||
self.ui.doc_settings:delSetting("style_tweaks_enabled")
|
||||
else
|
||||
self.ui.doc_settings:saveSetting("style_tweaks_enabled", false)
|
||||
self.ui.doc_settings:makeFalse("style_tweaks_enabled")
|
||||
end
|
||||
self.ui.doc_settings:saveSetting("style_tweaks", util.tableSize(self.doc_tweaks) > 0 and self.doc_tweaks or nil)
|
||||
G_reader_settings:saveSetting("style_tweaks", self.global_tweaks)
|
||||
|
||||
@@ -41,12 +41,12 @@ function ReaderToc:init()
|
||||
}
|
||||
end
|
||||
|
||||
if not G_reader_settings:readSetting("toc_items_per_page") then
|
||||
if G_reader_settings:hasNot("toc_items_per_page") then
|
||||
-- The TOC items per page and items' font size can now be
|
||||
-- configured. Previously, the ones set for the file browser
|
||||
-- were used. Initialize them from these ones.
|
||||
local items_per_page = G_reader_settings:readSetting("items_per_page")
|
||||
or self.toc_items_per_page_default
|
||||
or self.toc_items_per_page_default
|
||||
G_reader_settings:saveSetting("toc_items_per_page", items_per_page)
|
||||
local items_font_size = G_reader_settings:readSetting("items_font_size")
|
||||
if items_font_size and items_font_size ~= Menu.getItemFontSize(items_per_page) then
|
||||
@@ -137,7 +137,7 @@ end
|
||||
function ReaderToc:fillToc()
|
||||
if self.toc then return end
|
||||
if self.ui.document:canHaveAlternativeToc() then
|
||||
if self.ui.doc_settings:readSetting("alternative_toc") then
|
||||
if self.ui.doc_settings:isTrue("alternative_toc") then
|
||||
-- (if the document has a cache, the previously built alternative
|
||||
-- TOC was saved and has been reloaded, and this will be avoided)
|
||||
if not self.ui.document:isTocAlternativeToc() then
|
||||
@@ -900,7 +900,7 @@ See Style tweaks → Miscellaneous → Alternative ToC hints.]]),
|
||||
self:resetToc()
|
||||
self.toc_ticks_ignored_levels = {} -- reset this
|
||||
self.ui.document:buildAlternativeToc()
|
||||
self.ui.doc_settings:saveSetting("alternative_toc", true)
|
||||
self.ui.doc_settings:makeTrue("alternative_toc")
|
||||
self:onShowToc()
|
||||
self.view.footer:setTocMarkers(true)
|
||||
self.view.footer:onUpdateFooter()
|
||||
|
||||
@@ -22,13 +22,15 @@ function ReaderTypeset:init()
|
||||
end
|
||||
|
||||
function ReaderTypeset:onReadSettings(config)
|
||||
self.css = config:readSetting("css") or G_reader_settings:readSetting("copt_css")
|
||||
or self.ui.document.default_css
|
||||
self.css = config:readSetting("css")
|
||||
or G_reader_settings:readSetting("copt_css")
|
||||
or self.ui.document.default_css
|
||||
local tweaks_css = self.ui.styletweak:getCssText()
|
||||
self.ui.document:setStyleSheet(self.css, tweaks_css)
|
||||
|
||||
self.embedded_fonts = config:readSetting("embedded_fonts")
|
||||
if self.embedded_fonts == nil then
|
||||
if config:has("embedded_fonts") then
|
||||
self.embedded_fonts = config:isTrue("embedded_fonts")
|
||||
else
|
||||
-- default to enable embedded fonts
|
||||
-- note that it's a bit confusing here:
|
||||
-- global settins store 0/1, while document settings store false/true
|
||||
@@ -42,11 +44,12 @@ function ReaderTypeset:onReadSettings(config)
|
||||
self.ui.document:setEmbeddedFonts(0)
|
||||
end
|
||||
|
||||
self.embedded_css = config:readSetting("embedded_css")
|
||||
if self.embedded_css == nil then
|
||||
if config:has("embedded_css") then
|
||||
self.embedded_css = config:isTrue("embedded_css")
|
||||
else
|
||||
-- default to enable embedded CSS
|
||||
-- note that it's a bit confusing here:
|
||||
-- global settins store 0/1, while document settings store false/true
|
||||
-- global settings store 0/1, while document settings store false/true
|
||||
-- we leave it that way for now to maintain backwards compatibility
|
||||
local global = G_reader_settings:readSetting("copt_embedded_css")
|
||||
self.embedded_css = (global == nil or global == 1) and true or false
|
||||
@@ -56,15 +59,15 @@ function ReaderTypeset:onReadSettings(config)
|
||||
-- Block rendering mode: stay with legacy rendering for books
|
||||
-- previously opened so bookmarks and highlights stay valid.
|
||||
-- For new books, use 'web' mode below in BLOCK_RENDERING_FLAGS
|
||||
local block_rendering_default_mode = 3
|
||||
self.block_rendering_mode = config:readSetting("copt_block_rendering_mode")
|
||||
if not self.block_rendering_mode then
|
||||
if config:readSetting("last_xpointer") then
|
||||
if config:has("copt_block_rendering_mode") then
|
||||
self.block_rendering_mode = config:readSetting("copt_block_rendering_mode")
|
||||
else
|
||||
if config:has("last_xpointer") then
|
||||
-- We have a last_xpointer: this book was previously opened
|
||||
self.block_rendering_mode = 0
|
||||
else
|
||||
self.block_rendering_mode = G_reader_settings:readSetting("copt_block_rendering_mode")
|
||||
or block_rendering_default_mode
|
||||
or 3 -- default to 'web' mode
|
||||
end
|
||||
-- Let ConfigDialog know so it can update it on screen and have it saved on quit
|
||||
self.ui.document.configurable.block_rendering_mode = self.block_rendering_mode
|
||||
@@ -72,47 +75,52 @@ function ReaderTypeset:onReadSettings(config)
|
||||
self:setBlockRenderingMode(self.block_rendering_mode)
|
||||
|
||||
-- set render DPI
|
||||
self.render_dpi = config:readSetting("render_dpi") or
|
||||
G_reader_settings:readSetting("copt_render_dpi") or 96
|
||||
self.render_dpi = config:readSetting("render_dpi")
|
||||
or G_reader_settings:readSetting("copt_render_dpi")
|
||||
or 96
|
||||
self:setRenderDPI(self.render_dpi)
|
||||
|
||||
-- uncomment if we want font size to follow DPI changes
|
||||
-- self.ui.document:setRenderScaleFontWithDPI(1)
|
||||
|
||||
-- set page margins
|
||||
local h_margins = config:readSetting("copt_h_page_margins") or
|
||||
G_reader_settings:readSetting("copt_h_page_margins") or
|
||||
DCREREADER_CONFIG_H_MARGIN_SIZES_MEDIUM
|
||||
local t_margin = config:readSetting("copt_t_page_margin") or
|
||||
G_reader_settings:readSetting("copt_t_page_margin") or
|
||||
DCREREADER_CONFIG_T_MARGIN_SIZES_LARGE
|
||||
local b_margin = config:readSetting("copt_b_page_margin") or
|
||||
G_reader_settings:readSetting("copt_b_page_margin") or
|
||||
DCREREADER_CONFIG_B_MARGIN_SIZES_LARGE
|
||||
local h_margins = config:readSetting("copt_h_page_margins")
|
||||
or G_reader_settings:readSetting("copt_h_page_margins")
|
||||
or DCREREADER_CONFIG_H_MARGIN_SIZES_MEDIUM
|
||||
local t_margin = config:readSetting("copt_t_page_margin")
|
||||
or G_reader_settings:readSetting("copt_t_page_margin")
|
||||
or DCREREADER_CONFIG_T_MARGIN_SIZES_LARGE
|
||||
local b_margin = config:readSetting("copt_b_page_margin")
|
||||
or G_reader_settings:readSetting("copt_b_page_margin")
|
||||
or DCREREADER_CONFIG_B_MARGIN_SIZES_LARGE
|
||||
self.unscaled_margins = { h_margins[1], t_margin, h_margins[2], b_margin }
|
||||
self:onSetPageMargins(self.unscaled_margins)
|
||||
self.sync_t_b_page_margins = config:readSetting("copt_sync_t_b_page_margins") or
|
||||
G_reader_settings:readSetting("copt_sync_t_b_page_margins") or 0
|
||||
self.sync_t_b_page_margins = config:readSetting("copt_sync_t_b_page_margins")
|
||||
or G_reader_settings:readSetting("copt_sync_t_b_page_margins")
|
||||
or 0
|
||||
self.sync_t_b_page_margins = self.sync_t_b_page_margins == 1 and true or false
|
||||
|
||||
-- default to disable TXT formatting as it does more harm than good
|
||||
self.txt_preformatted = config:readSetting("txt_preformatted") or
|
||||
G_reader_settings:readSetting("txt_preformatted") or 1
|
||||
self.txt_preformatted = config:readSetting("txt_preformatted")
|
||||
or G_reader_settings:readSetting("txt_preformatted")
|
||||
or 1
|
||||
self:toggleTxtPreFormatted(self.txt_preformatted)
|
||||
|
||||
-- default to disable smooth scaling for now.
|
||||
self.smooth_scaling = config:readSetting("smooth_scaling")
|
||||
if self.smooth_scaling == nil then
|
||||
if config:has("smooth_scaling") then
|
||||
self.smooth_scaling = config:isTrue("smooth_scaling")
|
||||
else
|
||||
local global = G_reader_settings:readSetting("copt_smooth_scaling")
|
||||
self.smooth_scaling = (global == nil or global == 0) and 0 or 1
|
||||
self.smooth_scaling = (global == nil or global == 0) and false or true
|
||||
end
|
||||
self:toggleImageScaling(self.smooth_scaling)
|
||||
|
||||
-- default to automagic nightmode-friendly handling of images
|
||||
self.nightmode_images = config:readSetting("nightmode_images")
|
||||
if self.nightmode_images == nil then
|
||||
if config:has("nightmode_images") then
|
||||
self.nightmode_images = config:isTrue("nightmode_images")
|
||||
else
|
||||
local global = G_reader_settings:readSetting("copt_nightmode_images")
|
||||
self.nightmode_images = (global == nil or global == 1) and 1 or 0
|
||||
self.nightmode_images = (global == nil or global == 1) and true or false
|
||||
end
|
||||
self:toggleNightmodeImages(self.nightmode_images)
|
||||
end
|
||||
|
||||
@@ -126,7 +126,7 @@ function ReaderTypography:init()
|
||||
|
||||
-- Migrate old readerhyphenation settings (but keep them in case one
|
||||
-- go back to a previous version)
|
||||
if not G_reader_settings:readSetting("text_lang_default") and not G_reader_settings:readSetting("text_lang_fallback") then
|
||||
if G_reader_settings:hasNot("text_lang_default") and G_reader_settings:hasNot("text_lang_fallback") then
|
||||
local g_text_lang_set = false
|
||||
local hyph_alg_default = G_reader_settings:readSetting("hyph_alg_default")
|
||||
if hyph_alg_default then
|
||||
@@ -137,11 +137,11 @@ function ReaderTypography:init()
|
||||
-- Tweak the other settings if the default hyph algo happens
|
||||
-- to be one of these:
|
||||
if hyph_alg_default == "@none" then
|
||||
G_reader_settings:saveSetting("hyphenation", false)
|
||||
G_reader_settings:makeFalse("hyphenation")
|
||||
elseif hyph_alg_default == "@softhyphens" then
|
||||
G_reader_settings:saveSetting("hyph_soft_hyphens_only", true)
|
||||
G_reader_settings:makeTrue("hyph_soft_hyphens_only")
|
||||
elseif hyph_alg_default == "@algorithm" then
|
||||
G_reader_settings:saveSetting("hyph_force_algorithmic", true)
|
||||
G_reader_settings:makeTrue("hyph_force_algorithmic")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -328,13 +328,13 @@ When the book's language tag is not among our presets, no specific features will
|
||||
return text_lang_embedded_langs and _("Ignore") or _("Ignore (★)")
|
||||
end,
|
||||
choice1_callback = function()
|
||||
G_reader_settings:saveSetting("text_lang_embedded_langs", false)
|
||||
G_reader_settings:makeFalse("text_lang_embedded_langs")
|
||||
end,
|
||||
choice2_text_func = function()
|
||||
return text_lang_embedded_langs and _("Respect (★)") or _("Respect")
|
||||
end,
|
||||
choice2_callback = function()
|
||||
G_reader_settings:saveSetting("text_lang_embedded_langs", true)
|
||||
G_reader_settings:makeTrue("text_lang_embedded_langs")
|
||||
end,
|
||||
})
|
||||
end,
|
||||
@@ -361,13 +361,13 @@ When the book's language tag is not among our presets, no specific features will
|
||||
return hyphenation and _("Disable") or _("Disable (★)")
|
||||
end,
|
||||
choice1_callback = function()
|
||||
G_reader_settings:saveSetting("hyphenation", false)
|
||||
G_reader_settings:makeFalse("hyphenation")
|
||||
end,
|
||||
choice2_text_func = function()
|
||||
return hyphenation and _("Enable (★)") or _("Enable")
|
||||
end,
|
||||
choice2_callback = function()
|
||||
G_reader_settings:saveSetting("hyphenation", true)
|
||||
G_reader_settings:makeTrue("hyphenation")
|
||||
end,
|
||||
})
|
||||
end,
|
||||
@@ -379,8 +379,8 @@ When the book's language tag is not among our presets, no specific features will
|
||||
text_func = function()
|
||||
-- Note: with our callback, we either get hyph_left_hyphen_min and
|
||||
-- hyph_right_hyphen_min both nil, or both defined.
|
||||
if G_reader_settings:readSetting("hyph_left_hyphen_min") or
|
||||
G_reader_settings:readSetting("hyph_right_hyphen_min") then
|
||||
if G_reader_settings:has("hyph_left_hyphen_min") or
|
||||
G_reader_settings:has("hyph_right_hyphen_min") then
|
||||
-- @translators to RTL language translators: %1/left is the min length of the start of a hyphenated word, %2/right is the min length of the end of a hyphenated word (note that there is yet no support for hyphenation with RTL languages, so this will mostly apply to LTR documents)
|
||||
return T(_("Left/right minimal sizes: %1 - %2"),
|
||||
G_reader_settings:readSetting("hyph_left_hyphen_min"),
|
||||
@@ -447,13 +447,13 @@ These settings will apply to all books with any hyphenation dictionary.
|
||||
return hyph_trust_soft_hyphens and _("Disable") or _("Disable (★)")
|
||||
end,
|
||||
choice1_callback = function()
|
||||
G_reader_settings:saveSetting("hyph_trust_soft_hyphens", false)
|
||||
G_reader_settings:makeFalse("hyph_trust_soft_hyphens")
|
||||
end,
|
||||
choice2_text_func = function()
|
||||
return hyph_trust_soft_hyphens and _("Enable (★)") or _("Enable")
|
||||
end,
|
||||
choice2_callback = function()
|
||||
G_reader_settings:saveSetting("hyph_trust_soft_hyphens", true)
|
||||
G_reader_settings:makeTrue("hyph_trust_soft_hyphens")
|
||||
end,
|
||||
})
|
||||
end,
|
||||
@@ -504,13 +504,13 @@ These settings will apply to all books with any hyphenation dictionary.
|
||||
return hyph_force_algorithmic and _("Disable") or _("Disable (★)")
|
||||
end,
|
||||
choice1_callback = function()
|
||||
G_reader_settings:saveSetting("hyph_force_algorithmic", false)
|
||||
G_reader_settings:makeFalse("hyph_force_algorithmic")
|
||||
end,
|
||||
choice2_text_func = function()
|
||||
return hyph_force_algorithmic and _("Enable (★)") or _("Enable")
|
||||
end,
|
||||
choice2_callback = function()
|
||||
G_reader_settings:saveSetting("hyph_force_algorithmic", true)
|
||||
G_reader_settings:makeTrue("hyph_force_algorithmic")
|
||||
end,
|
||||
})
|
||||
end,
|
||||
@@ -541,13 +541,13 @@ These settings will apply to all books with any hyphenation dictionary.
|
||||
return hyph_soft_hyphens_only and _("Disable") or _("Disable (★)")
|
||||
end,
|
||||
choice1_callback = function()
|
||||
G_reader_settings:saveSetting("hyph_soft_hyphens_only", false)
|
||||
G_reader_settings:makeFalse("hyph_soft_hyphens_only")
|
||||
end,
|
||||
choice2_text_func = function()
|
||||
return hyph_soft_hyphens_only and _("Enable (★)") or _("Enable")
|
||||
end,
|
||||
choice2_callback = function()
|
||||
G_reader_settings:saveSetting("hyph_soft_hyphens_only", true)
|
||||
G_reader_settings:makeTrue("hyph_soft_hyphens_only")
|
||||
end,
|
||||
})
|
||||
end,
|
||||
@@ -625,13 +625,13 @@ function ReaderTypography:makeDefaultFloatingPunctuation()
|
||||
return floating_punctuation and _("Disable") or _("Disable (★)")
|
||||
end,
|
||||
choice1_callback = function()
|
||||
G_reader_settings:saveSetting("floating_punctuation", false)
|
||||
G_reader_settings:makeFalse("floating_punctuation")
|
||||
end,
|
||||
choice2_text_func = function()
|
||||
return floating_punctuation and _("Enable (★)") or _("Enable")
|
||||
end,
|
||||
choice2_callback = function()
|
||||
G_reader_settings:saveSetting("floating_punctuation", true)
|
||||
G_reader_settings:makeTrue("floating_punctuation")
|
||||
end,
|
||||
})
|
||||
end
|
||||
@@ -701,7 +701,7 @@ end
|
||||
-- in book settings, no default lang, and book has some language defined.
|
||||
function ReaderTypography:onReadSettings(config)
|
||||
-- Migrate old readerhyphenation setting, if one was set
|
||||
if not config:readSetting("text_lang") and config:readSetting("hyph_alg") then
|
||||
if config:hasNot("text_lang") and config:has("hyph_alg") then
|
||||
local hyph_alg = config:readSetting("hyph_alg")
|
||||
local dict_info = HYPH_DICT_NAME_TO_LANG_NAME_TAG[hyph_alg]
|
||||
if dict_info then
|
||||
@@ -709,46 +709,51 @@ function ReaderTypography:onReadSettings(config)
|
||||
-- Set the other settings if the default hyph algo happens
|
||||
-- to be one of these:
|
||||
if hyph_alg == "@none" then
|
||||
config:saveSetting("hyphenation", false)
|
||||
config:makeFalse("hyphenation")
|
||||
elseif hyph_alg == "@softhyphens" then
|
||||
config:saveSetting("hyph_soft_hyphens_only", true)
|
||||
config:makeTrue("hyph_soft_hyphens_only")
|
||||
elseif hyph_alg == "@algorithm" then
|
||||
config:saveSetting("hyph_force_algorithmic", true)
|
||||
config:makeTrue("hyph_force_algorithmic")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Enable text lang tags attributes by default
|
||||
self.text_lang_embedded_langs = config:readSetting("text_lang_embedded_langs")
|
||||
if self.text_lang_embedded_langs == nil then
|
||||
if config:has("text_lang_embedded_langs") then
|
||||
self.text_lang_embedded_langs = config:isTrue("text_lang_embedded_langs")
|
||||
else
|
||||
self.text_lang_embedded_langs = G_reader_settings:nilOrTrue("text_lang_embedded_langs")
|
||||
end
|
||||
self.ui.document:setTextEmbeddedLangs(self.text_lang_embedded_langs)
|
||||
|
||||
-- Enable hyphenation by default
|
||||
self.hyphenation = config:readSetting("hyphenation")
|
||||
if self.hyphenation == nil then
|
||||
if config:has("hyphenation") then
|
||||
self.hyphenation = config:isTrue("hyphenation")
|
||||
else
|
||||
self.hyphenation = G_reader_settings:nilOrTrue("hyphenation")
|
||||
end
|
||||
self.ui.document:setTextHyphenation(self.hyphenation)
|
||||
|
||||
-- Checking for soft-hyphens adds a bit of overhead, so have it disabled by default
|
||||
self.hyph_trust_soft_hyphens = config:readSetting("hyph_trust_soft_hyphens")
|
||||
if self.hyph_trust_soft_hyphens == nil then
|
||||
if config:has("hyph_trust_soft_hyphens") then
|
||||
self.hyph_trust_soft_hyphens = config:isTrue("hyph_trust_soft_hyphens")
|
||||
else
|
||||
self.hyph_trust_soft_hyphens = G_reader_settings:isTrue("hyph_trust_soft_hyphens")
|
||||
end
|
||||
self.ui.document:setTrustSoftHyphens(self.hyph_trust_soft_hyphens)
|
||||
|
||||
-- Alternative hyphenation method (available with all dicts) to use soft hyphens only
|
||||
self.hyph_soft_hyphens_only = config:readSetting("hyph_soft_hyphens_only")
|
||||
if self.hyph_soft_hyphens_only == nil then
|
||||
if config:has("hyph_soft_hyphens_only") then
|
||||
self.hyph_soft_hyphens_only = config:isTrue("hyph_soft_hyphens_only")
|
||||
else
|
||||
self.hyph_soft_hyphens_only = G_reader_settings:isTrue("hyph_soft_hyphens_only")
|
||||
end
|
||||
self.ui.document:setTextHyphenationSoftHyphensOnly(self.hyph_soft_hyphens_only)
|
||||
|
||||
-- Alternative hyphenation method (available with all dicts) to use algorithmic hyphenation
|
||||
self.hyph_force_algorithmic = config:readSetting("hyph_force_algorithmic")
|
||||
if self.hyph_force_algorithmic == nil then
|
||||
if config:has("hyph_force_algorithmic") then
|
||||
self.hyph_force_algorithmic = config:isTrue("hyph_force_algorithmic")
|
||||
else
|
||||
self.hyph_force_algorithmic = G_reader_settings:isTrue("hyph_force_algorithmic")
|
||||
end
|
||||
self.ui.document:setTextHyphenationForceAlgorithmic(self.hyph_force_algorithmic)
|
||||
@@ -760,40 +765,36 @@ function ReaderTypography:onReadSettings(config)
|
||||
-- Default to disable hanging/floating punctuation
|
||||
-- (Stored as 0/1 in docsetting for historical reasons, but as true/false
|
||||
-- in global settings.)
|
||||
self.floating_punctuation = config:readSetting("floating_punctuation")
|
||||
if self.floating_punctuation == nil then
|
||||
if config:has("floating_punctuation") then
|
||||
self.floating_punctuation = config:readSetting("floating_punctuation")
|
||||
else
|
||||
self.floating_punctuation = G_reader_settings:isTrue("floating_punctuation") and 1 or 0
|
||||
end
|
||||
self:onToggleFloatingPunctuation(self.floating_punctuation)
|
||||
|
||||
-- Decide and set the text main lang tag according to settings
|
||||
self.allow_doc_lang_tag_override = false
|
||||
-- Use the one manually set for this document
|
||||
self.text_lang_tag = config:readSetting("text_lang")
|
||||
if self.text_lang_tag then
|
||||
if config:has("text_lang") then
|
||||
self.allow_doc_lang_tag_override = false
|
||||
-- Use the one manually set for this document
|
||||
self.text_lang_tag = config:readSetting("text_lang")
|
||||
logger.dbg("Typography lang: using", self.text_lang_tag, "from doc settings")
|
||||
self.ui.document:setTextMainLang(self.text_lang_tag)
|
||||
return
|
||||
end
|
||||
-- Use the one manually set as default (with Hold)
|
||||
self.text_lang_tag = G_reader_settings:readSetting("text_lang_default")
|
||||
if self.text_lang_tag then
|
||||
elseif G_reader_settings:has("text_lang_default") then
|
||||
self.allow_doc_lang_tag_override = false
|
||||
-- Use the one manually set as default (with Hold)
|
||||
self.text_lang_tag = G_reader_settings:readSetting("text_lang_default")
|
||||
logger.dbg("Typography lang: using default ", self.text_lang_tag)
|
||||
self.ui.document:setTextMainLang(self.text_lang_tag)
|
||||
return
|
||||
end
|
||||
-- Document language will be allowed to override the one we set from now on
|
||||
self.allow_doc_lang_tag_override = true
|
||||
-- Use the one manually set as fallback (with Hold)
|
||||
self.text_lang_tag = G_reader_settings:readSetting("text_lang_fallback")
|
||||
if self.text_lang_tag then
|
||||
elseif G_reader_settings:has("text_lang_fallback") then
|
||||
-- Document language will be allowed to override the one we set from now on
|
||||
self.allow_doc_lang_tag_override = true
|
||||
-- Use the one manually set as fallback (with Hold)
|
||||
self.text_lang_tag = G_reader_settings:readSetting("text_lang_fallback")
|
||||
logger.dbg("Typography lang: using fallback ", self.text_lang_tag, ", might be overriden by doc language")
|
||||
self.ui.document:setTextMainLang(self.text_lang_tag)
|
||||
return
|
||||
else
|
||||
self.allow_doc_lang_tag_override = true
|
||||
-- None decided, use default (shouldn't be reached)
|
||||
self.text_lang_tag = DEFAULT_LANG_TAG
|
||||
logger.dbg("Typography lang: no lang set, using", self.text_lang_tag)
|
||||
end
|
||||
-- None decided, use default (shouldn't be reached)
|
||||
self.text_lang_tag = DEFAULT_LANG_TAG
|
||||
logger.dbg("Typography lang: no lang set, using", self.text_lang_tag)
|
||||
self.ui.document:setTextMainLang(self.text_lang_tag)
|
||||
end
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ local ReaderView = OverlapGroup:extend{
|
||||
offset = nil,
|
||||
bbox = nil,
|
||||
},
|
||||
outer_page_color = Blitbuffer.gray(DOUTER_PAGE_COLOR/15),
|
||||
outer_page_color = Blitbuffer.gray(DOUTER_PAGE_COLOR / 15),
|
||||
-- highlight with "lighten" or "underscore" or "invert"
|
||||
highlight = {
|
||||
lighten_factor = 0.2,
|
||||
@@ -45,12 +45,12 @@ local ReaderView = OverlapGroup:extend{
|
||||
highlight_visible = true,
|
||||
-- PDF/DjVu continuous paging
|
||||
page_scroll = nil,
|
||||
page_bgcolor = Blitbuffer.gray(DBACKGROUND_COLOR/15),
|
||||
page_bgcolor = Blitbuffer.gray(DBACKGROUND_COLOR / 15),
|
||||
page_states = {},
|
||||
-- properties of the gap drawn between each page in scroll mode:
|
||||
page_gap = {
|
||||
-- color (0 = white, 8 = gray, 15 = black)
|
||||
color = Blitbuffer.gray((G_reader_settings:readSetting("page_gap_color") or 8)/15),
|
||||
color = Blitbuffer.gray((G_reader_settings:readSetting("page_gap_color") or 8) / 15),
|
||||
},
|
||||
-- DjVu page rendering mode (used in djvu.c:drawPage())
|
||||
render_mode = DRENDER_MODE, -- default to COLOR
|
||||
@@ -758,8 +758,9 @@ function ReaderView:onReadSettings(config)
|
||||
-- Keep current rotation by doing nothing when sticky rota is enabled.
|
||||
if not locked then
|
||||
-- Honor docsettings's rotation
|
||||
rotation_mode = config:readSetting("rotation_mode") -- Doc's
|
||||
if not rotation_mode then
|
||||
if config:has("rotation_mode") then
|
||||
rotation_mode = config:readSetting("rotation_mode") -- Doc's
|
||||
else
|
||||
-- No doc specific rotation, pickup global defaults for the doc type
|
||||
if self.ui.document.info.has_pages then
|
||||
rotation_mode = G_reader_settings:readSetting("kopt_rotation_mode") or Screen.ORIENTATION_PORTRAIT
|
||||
@@ -781,8 +782,9 @@ function ReaderView:onReadSettings(config)
|
||||
self.page_scroll = page_scroll == 1 and true or false
|
||||
self.highlight.saved = config:readSetting("highlight") or {}
|
||||
self.page_overlap_style = config:readSetting("page_overlap_style") or G_reader_settings:readSetting("page_overlap_style") or "dim"
|
||||
self.page_gap.height = Screen:scaleBySize(config:readSetting("kopt_page_gap_height") or
|
||||
G_reader_settings:readSetting("kopt_page_gap_height") or 8)
|
||||
self.page_gap.height = Screen:scaleBySize(config:readSetting("kopt_page_gap_height")
|
||||
or G_reader_settings:readSetting("kopt_page_gap_height")
|
||||
or 8)
|
||||
end
|
||||
|
||||
function ReaderView:onPageUpdate(new_page_no)
|
||||
@@ -965,11 +967,12 @@ function ReaderView:checkAutoSaveSettings()
|
||||
if not self.settings_last_save_ts then -- reader not yet ready
|
||||
return
|
||||
end
|
||||
local interval = G_reader_settings:readSetting("auto_save_settings_interval_minutes")
|
||||
if not interval then -- no auto save
|
||||
if G_reader_settings:nilOrFalse("auto_save_settings_interval_minutes") then
|
||||
-- no auto save
|
||||
return
|
||||
end
|
||||
|
||||
local interval = G_reader_settings:readSetting("auto_save_settings_interval_minutes")
|
||||
local now_ts = os.time()
|
||||
if now_ts - self.settings_last_save_ts >= interval*60 then
|
||||
self.settings_last_save_ts = now_ts
|
||||
|
||||
@@ -175,8 +175,8 @@ function ReaderWikipedia:addToMainMenu(menu_items)
|
||||
local choose_directory = function()
|
||||
-- Default directory as chosen by DictQuickLookup
|
||||
local default_dir = G_reader_settings:readSetting("wikipedia_save_dir")
|
||||
if not default_dir then default_dir = G_reader_settings:readSetting("home_dir") end
|
||||
if not default_dir then default_dir = require("apps/filemanager/filemanagerutil").getDefaultDir() end
|
||||
or G_reader_settings:readSetting("home_dir")
|
||||
or require("apps/filemanager/filemanagerutil").getDefaultDir()
|
||||
local dialog
|
||||
dialog = ButtonDialogTitle:new{
|
||||
title = T(_("Current Wikipedia 'Save as EPUB' folder:\n\n%1\n"), BD.dirpath(default_dir)),
|
||||
@@ -198,9 +198,9 @@ function ReaderWikipedia:addToMainMenu(menu_items)
|
||||
-- so a user reading a wikipedia article can quickly select
|
||||
-- it to save related new articles in the same directory
|
||||
local dir = G_reader_settings:readSetting("wikipedia_save_dir")
|
||||
if not dir then dir = G_reader_settings:readSetting("home_dir") end
|
||||
if not dir then dir = require("apps/filemanager/filemanagerutil").getDefaultDir() end
|
||||
if not dir then dir = "/" end
|
||||
or G_reader_settings:readSetting("home_dir")
|
||||
or require("apps/filemanager/filemanagerutil").getDefaultDir()
|
||||
or "/"
|
||||
-- If this directory has no subdirectory, we would be displaying
|
||||
-- a single "..", so use parent directory in that case.
|
||||
local has_subdirectory = false
|
||||
|
||||
@@ -114,13 +114,13 @@ function ReaderZooming:onReadSettings(config)
|
||||
or G_reader_settings:readSetting("zoom_mode")
|
||||
or self.DEFAULT_ZOOM_MODE
|
||||
zoom_mode = util.arrayContains(self.available_zoom_modes, zoom_mode)
|
||||
and zoom_mode
|
||||
or self.DEFAULT_ZOOM_MODE
|
||||
and zoom_mode
|
||||
or self.DEFAULT_ZOOM_MODE
|
||||
self:setZoomMode(zoom_mode, true) -- avoid informative message on load
|
||||
for _, setting in ipairs(self.zoom_pan_settings) do
|
||||
self[setting] = config:readSetting(setting) or
|
||||
G_reader_settings:readSetting(setting) or
|
||||
self[setting]
|
||||
self[setting] = config:readSetting(setting)
|
||||
or G_reader_settings:readSetting(setting)
|
||||
or self[setting]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -433,8 +433,8 @@ function ReaderZooming:getZoom(pageno)
|
||||
zoom = self.zoom
|
||||
else
|
||||
local zoom_factor = self.ui.doc_settings:readSetting("zoom_factor")
|
||||
or G_reader_settings:readSetting("zoom_factor")
|
||||
or self.zoom_factor
|
||||
or G_reader_settings:readSetting("zoom_factor")
|
||||
or self.zoom_factor
|
||||
zoom = zoom_w * zoom_factor
|
||||
end
|
||||
if zoom and zoom > 10 and not Cache:willAccept(zoom * (self.dimen.w * self.dimen.h + 64)) then
|
||||
|
||||
Reference in New Issue
Block a user