EInk: Add a setting to toggle flashing on pages with images (#10049)

With minor code cleanups along the way ;).
reviewable/pr10071/r1
Sargun Vohra 1 year ago committed by GitHub
parent 1faf0a1786
commit 15fb73384f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -250,7 +250,7 @@ function ReaderView:paintTo(bb, x, y)
if img_count and img_count > 0 and img_coverage and img_coverage >= 0.075 then
self.dialog.dithered = true
-- Request a flashing update while we're at it, but only if it's the first time we're painting it
if self.state.drawn == false then
if self.state.drawn == false and G_reader_settings:nilOrTrue("refresh_on_pages_with_images") then
UIManager:setDirty(nil, "full")
end
end

@ -10,18 +10,6 @@ local T = require("ffi/util").template
local DeviceListener = EventListener:extend{}
local function _setSetting(name)
G_reader_settings:makeTrue(name)
end
local function _unsetSetting(name)
G_reader_settings:delSetting(name)
end
local function _toggleSetting(name)
G_reader_settings:flipNilOrFalse(name)
end
function DeviceListener:onToggleNightMode()
local night_mode = G_reader_settings:isTrue("night_mode")
Screen:toggleNightMode()
@ -216,7 +204,7 @@ end
if Device:hasGSensor() then
function DeviceListener:onToggleGSensor()
_toggleSetting("input_ignore_gsensor")
G_reader_settings:flipNilOrFalse("input_ignore_gsensor")
Device:toggleGSensor(not G_reader_settings:isTrue("input_ignore_gsensor"))
local new_text
if G_reader_settings:isTrue("input_ignore_gsensor") then
@ -284,30 +272,42 @@ end
function DeviceListener:onSetFlashOnChapterBoundaries(toggle)
if toggle == true then
_setSetting("refresh_on_chapter_boundaries")
G_reader_settings:makeTrue("refresh_on_chapter_boundaries")
else
_unsetSetting("refresh_on_chapter_boundaries")
G_reader_settings:delSetting("refresh_on_chapter_boundaries")
end
end
function DeviceListener:onToggleFlashOnChapterBoundaries()
_toggleSetting("refresh_on_chapter_boundaries")
G_reader_settings:flipNilOrFalse("refresh_on_chapter_boundaries")
end
function DeviceListener:onSetNoFlashOnSecondChapterPage(toggle)
if toggle == true then
_setSetting("no_refresh_on_second_chapter_page")
G_reader_settings:makeTrue("no_refresh_on_second_chapter_page")
else
_unsetSetting("no_refresh_on_second_chapter_page")
G_reader_settings:delSetting("no_refresh_on_second_chapter_page")
end
end
function DeviceListener:onToggleNoFlashOnSecondChapterPage()
_toggleSetting("no_refresh_on_second_chapter_page")
G_reader_settings:flipNilOrFalse("no_refresh_on_second_chapter_page")
end
function DeviceListener:onSetFlashOnPagesWithImages(toggle)
if toggle == true then
G_reader_settings:delSetting("refresh_on_pages_with_images")
else
G_reader_settings:makeFalse("refresh_on_pages_with_images")
end
end
function DeviceListener:onToggleFlashOnPagesWithImages()
G_reader_settings:flipNilOrTrue("refresh_on_pages_with_images")
end
function DeviceListener:onSwapPageTurnButtons()
_toggleSetting("input_invert_page_turn_keys")
G_reader_settings:flipNilOrFalse("input_invert_page_turn_keys")
Device:invertButtons()
end

@ -66,6 +66,8 @@ local settingsList = {
toggle_flash_on_chapter_boundaries = {category="none", event="ToggleFlashOnChapterBoundaries", title=_("Toggle flashing on chapter boundaries"), screen=true, condition=Device:hasEinkScreen()},
set_no_flash_on_second_chapter_page = {category="string", event="SetNoFlashOnSecondChapterPage", title=_("Never flash on chapter's 2nd page"), screen=true, condition=Device:hasEinkScreen(), args={true, false}, toggle={_("on"), _("off")}},
toggle_no_flash_on_second_chapter_page = {category="none", event="ToggleNoFlashOnSecondChapterPage", title=_("Toggle flashing on chapter's 2nd page"), screen=true, condition=Device:hasEinkScreen(), separator=true},
set_flash_on_pages_with_images = {category="string", event="SetFlashOnPagesWithImages", title=_("Always flash on pages with images"), screen=true, condition=Device:hasEinkScreen(), args={true, false}, toggle={_("on"), _("off")}},
toggle_flash_on_pages_with_images = {category="none", event="ToggleFlashOnPagesWithImages", title=_("Toggle flashing on pages with images"), screen=true, condition=Device:hasEinkScreen()},
-- Device settings
toggle_gsensor = {category="none", event="ToggleGSensor", title=_("Toggle accelerometer"), device=true, condition=Device:hasGSensor()},
@ -274,6 +276,8 @@ local dispatcher_menu_order = {
"toggle_flash_on_chapter_boundaries",
"set_no_flash_on_second_chapter_page",
"toggle_no_flash_on_second_chapter_page",
"set_flash_on_pages_with_images",
"toggle_flash_on_pages_with_images",
-- filemanager
"folder_up",

@ -116,5 +116,10 @@ return {
checked_func = function() return G_reader_settings:isTrue("no_refresh_on_second_chapter_page") end,
callback = function() UIManager:broadcastEvent(Event:new("ToggleNoFlashOnSecondChapterPage")) end,
},
{
text = _("Always flash on pages with images"),
checked_func = function() return G_reader_settings:nilOrTrue("refresh_on_pages_with_images") end,
callback = function() UIManager:broadcastEvent(Event:new("ToggleFlashOnPagesWithImages")) end,
},
}
}

Loading…
Cancel
Save