From 3f677a7fdd8f4da947473b370050ac415004db34 Mon Sep 17 00:00:00 2001 From: hius07 <62179190+hius07@users.noreply.github.com> Date: Wed, 13 Sep 2023 07:49:57 +0300 Subject: [PATCH] copt/kopt options: deduplicate some defaults (#10893) --- frontend/apps/reader/modules/readerview.lua | 8 +++++--- frontend/configurable.lua | 3 --- frontend/ui/data/creoptions.lua | 13 ++----------- frontend/ui/data/koptoptions.lua | 2 +- 4 files changed, 8 insertions(+), 18 deletions(-) diff --git a/frontend/apps/reader/modules/readerview.lua b/frontend/apps/reader/modules/readerview.lua index 392cb5fbb..3c0c5273b 100644 --- a/frontend/apps/reader/modules/readerview.lua +++ b/frontend/apps/reader/modules/readerview.lua @@ -48,7 +48,7 @@ local ReaderView = OverlapGroup:extend{ -- properties of the gap drawn between each page in scroll mode: page_gap = nil, -- table -- DjVu page rendering mode (used in djvu.c:drawPage()) - render_mode = G_defaults:readSetting("DRENDER_MODE"), -- default to COLOR + render_mode = nil, -- default to COLOR, will be set in onReadSettings() -- Crengine view mode view_mode = G_defaults:readSetting("DCREREADER_VIEW_MODE"), -- default to page mode hinting = true, @@ -861,7 +861,7 @@ end function ReaderView:onReadSettings(config) if self.ui.paging then self.document:setTileCacheValidity(config:readSetting("tile_cache_validity_ts")) - self.render_mode = config:readSetting("render_mode") or 0 + self.render_mode = config:readSetting("render_mode") or G_defaults:readSetting("DRENDER_MODE") if config:has("gamma") then -- old doc contrast setting config:saveSetting("kopt_contrast", config:readSetting("gamma")) config:delSetting("gamma") @@ -1067,7 +1067,9 @@ function ReaderView:onSaveSettings() self.document:resetTileCacheValidity() end self.ui.doc_settings:saveSetting("tile_cache_validity_ts", self.document:getTileCacheValidity()) - self.ui.doc_settings:saveSetting("render_mode", self.render_mode) + if self.document.is_djvu then + self.ui.doc_settings:saveSetting("render_mode", self.render_mode) + end end -- Don't etch the current rotation in stone when sticky rotation is enabled if G_reader_settings:nilOrFalse("lock_rotation") then diff --git a/frontend/configurable.lua b/frontend/configurable.lua index a99086ac4..23943d36a 100644 --- a/frontend/configurable.lua +++ b/frontend/configurable.lua @@ -38,9 +38,6 @@ function Configurable:loadDefaults(config_options) local settings_key = prefix..key local default = G_reader_settings:readSetting(settings_key) self[key] = default or options[j].default_value - if not self[key] then - self[key] = options[j].default_arg - end end end end diff --git a/frontend/ui/data/creoptions.lua b/frontend/ui/data/creoptions.lua index 2eb81157f..636b71078 100644 --- a/frontend/ui/data/creoptions.lua +++ b/frontend/ui/data/creoptions.lua @@ -93,8 +93,8 @@ local CreOptions = { labels = {C_("Rotation", "⤹ 90°"), C_("Rotation", "↑ 0°"), C_("Rotation", "⤸ 90°"), C_("Rotation", "↓ 180°")}, alternate = false, values = {Screen.DEVICE_ROTATED_COUNTER_CLOCKWISE, Screen.DEVICE_ROTATED_UPRIGHT, Screen.DEVICE_ROTATED_CLOCKWISE, Screen.DEVICE_ROTATED_UPSIDE_DOWN}, + default_value = Screen.DEVICE_ROTATED_UPRIGHT, args = {Screen.DEVICE_ROTATED_COUNTER_CLOCKWISE, Screen.DEVICE_ROTATED_UPRIGHT, Screen.DEVICE_ROTATED_CLOCKWISE, Screen.DEVICE_ROTATED_UPSIDE_DOWN}, - default_arg = 0, current_func = function() return Screen:getRotationMode() end, event = "SetRotationMode", name_text_hold_callback = optionsutil.showValues, @@ -106,7 +106,6 @@ local CreOptions = { values = {1, 2}, default_value = 1, args = {1, 2}, - default_arg = 1, event = "SetVisiblePages", --[[ Commented out, to have it also available in portrait mode current_func = function() @@ -184,7 +183,6 @@ This is disabled in scroll mode. Switching from page mode with two columns to sc default_value = 0, event = "SyncPageTopBottomMargins", args = {false, true}, - default_arg = false, hide_on_apply = true, name_text_hold_callback = optionsutil.showValues, help_text = _([[Keep top and bottom margins synchronized. @@ -310,9 +308,8 @@ In the top menu → Settings → Status bar, you can choose whether the bottom m name_text = _("View Mode"), toggle = {_("page"), _("continuous")}, values = {0, 1}, - default_value = 0, + default_value = G_defaults:readSetting("DCREREADER_VIEW_MODE") == "page" and 0 or 1, args = {"page", "scroll"}, - default_arg = "page", event = "SetViewMode", name_text_hold_callback = optionsutil.showValues, help_text = _([[- 'page' mode splits the text into pages, at the most acceptable places (page numbers and the number of pages may change when you change fonts, margins, styles, etc.). @@ -325,7 +322,6 @@ In the top menu → Settings → Status bar, you can choose whether the bottom m values = {0, 1, 2, 3}, default_value = 2, args = {0, 1, 2, 3}, - default_arg = 2, event = "SetBlockRenderingMode", name_text_hold_callback = optionsutil.showValues, help_text = _([[ @@ -676,7 +672,6 @@ If a font variation is not available, as well as for fractional adjustments, it values = {1, 0}, -- Note that 0 means crengine header status line enabled, and 1 means disabled default_value = 1, args = {1, 0}, - default_arg = 1, event = "SetStatusLine", name_text_hold_callback = optionsutil.showValues, help_text = _([[Enable or disable the rendering engine alternative status bar at the top of the screen. The items displayed can be customized via the main menu. @@ -690,7 +685,6 @@ Whether enabled or disabled, KOReader's own status bar at the bottom of the scre values = {0, 1}, default_value = 1, args = {false, true}, - default_arg = nil, event = "ToggleEmbeddedStyleSheet", name_text_hold_callback = optionsutil.showValues, help_text = _([[Enable or disable publisher stylesheets embedded in the book. @@ -703,7 +697,6 @@ Whether enabled or disabled, KOReader's own status bar at the bottom of the scre values = {0, 1}, default_value = 1, args = {false, true}, - default_arg = nil, event = "ToggleEmbeddedFonts", enabled_func = function(configurable, document) return optionsutil.enableIfEquals(configurable, "embedded_css", 1) @@ -731,7 +724,6 @@ Whether enabled or disabled, KOReader's own status bar at the bottom of the scre values = {0, 1}, default_value = 0, args = {false, true}, - default_arg = nil, event = "ToggleImageScaling", name_text_hold_callback = optionsutil.showValues, help_text = _([[- 'fast' uses a fast but inaccurate scaling algorithm when scaling images. @@ -744,7 +736,6 @@ Whether enabled or disabled, KOReader's own status bar at the bottom of the scre values = {1, 0}, default_value = 1, args = {true, false}, - default_arg = nil, event = "ToggleNightmodeImages", show_func = function() return Screen.night_mode end, name_text_hold_callback = optionsutil.showValues, diff --git a/frontend/ui/data/koptoptions.lua b/frontend/ui/data/koptoptions.lua index da3ebe7f0..801dff66d 100644 --- a/frontend/ui/data/koptoptions.lua +++ b/frontend/ui/data/koptoptions.lua @@ -67,8 +67,8 @@ local KoptOptions = { labels = {C_("Rotation", "⤹ 90°"), C_("Rotation", "↑ 0°"), C_("Rotation", "⤸ 90°"), C_("Rotation", "↓ 180°")}, alternate = false, values = {Screen.DEVICE_ROTATED_COUNTER_CLOCKWISE, Screen.DEVICE_ROTATED_UPRIGHT, Screen.DEVICE_ROTATED_CLOCKWISE, Screen.DEVICE_ROTATED_UPSIDE_DOWN}, + default_value = Screen.DEVICE_ROTATED_UPRIGHT, args = {Screen.DEVICE_ROTATED_COUNTER_CLOCKWISE, Screen.DEVICE_ROTATED_UPRIGHT, Screen.DEVICE_ROTATED_CLOCKWISE, Screen.DEVICE_ROTATED_UPSIDE_DOWN}, - default_arg = 0, current_func = function() return Screen:getRotationMode() end, event = "SetRotationMode", name_text_hold_callback = optionsutil.showValues,