From 72f2cef4725f3c65a102ac6e6a92365a720f7f8f Mon Sep 17 00:00:00 2001 From: poire-z Date: Fri, 28 Feb 2020 23:06:58 +0100 Subject: [PATCH] Style tweaks: enable EPUB/FB2 in-page footnotes by default (#5908) Set these 2 tweaks as default global tweaks for new users (and existing users that have not set any global defaults). One can disable them by long-press on each of them. Only per-specs EPUB and FB2 footnotes (other in-page footnotes tweaks may trigger on non-footnote content on some books, so let enabling them be a user decision). --- frontend/apps/reader/modules/readerstyletweak.lua | 6 ++++-- frontend/ui/data/css_tweaks.lua | 7 +++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/frontend/apps/reader/modules/readerstyletweak.lua b/frontend/apps/reader/modules/readerstyletweak.lua index da3c2cd21..e3b2a18a3 100644 --- a/frontend/apps/reader/modules/readerstyletweak.lua +++ b/frontend/apps/reader/modules/readerstyletweak.lua @@ -312,7 +312,9 @@ end function ReaderStyleTweak:onReadSettings(config) self.enabled = not (config:readSetting("style_tweaks_enabled") == false) self.doc_tweaks = config:readSetting("style_tweaks") or {} - self.global_tweaks = G_reader_settings:readSetting("style_tweaks") or {} + -- Default globally enabled style tweaks (for new installations) + -- are defined in css_tweaks.lua + self.global_tweaks = G_reader_settings:readSetting("style_tweaks") or CssTweaks.DEFAULT_GLOBAL_STYLE_TWEAKS self:updateCssText() end @@ -323,7 +325,7 @@ function ReaderStyleTweak:onSaveSettings() self.ui.doc_settings:saveSetting("style_tweaks_enabled", false) 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", util.tableSize(self.global_tweaks) > 0 and self.global_tweaks or nil) + G_reader_settings:saveSetting("style_tweaks", self.global_tweaks) end function ReaderStyleTweak:init() diff --git a/frontend/ui/data/css_tweaks.lua b/frontend/ui/data/css_tweaks.lua index b04542a8d..2ecbb574b 100644 --- a/frontend/ui/data/css_tweaks.lua +++ b/frontend/ui/data/css_tweaks.lua @@ -12,7 +12,14 @@ They may have the following optional attributes: local _ = require("gettext") local C_ = _.pgettext +-- Default globally enabled style tweaks, for new installations +local DEFAULT_GLOBAL_STYLE_TWEAKS = {} +-- Display in-page per-specs footnotes for EPUB and FB2: +DEFAULT_GLOBAL_STYLE_TWEAKS["footnote-inpage_epub_smaller"] = true +DEFAULT_GLOBAL_STYLE_TWEAKS["footnote-inpage_fb2"] = true + local CssTweaks = { + DEFAULT_GLOBAL_STYLE_TWEAKS = DEFAULT_GLOBAL_STYLE_TWEAKS, { title = C_("Style tweaks category", "Pages"), {