mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Add Set Frontlight/Set Frontlight Warmth to dispatcher (#6440)
Add Set Frontlight/Set Frontlight warmth events to dispatcher. This allows users to set day/night profiles with different fl/warmth values as requested in #6444
This commit is contained in:
@@ -114,12 +114,18 @@ if Device:hasFrontlight() then
|
||||
|
||||
if new_intensity == nil then return true end
|
||||
-- when new_intensity <=0, toggle light off
|
||||
self:onSetFlIntensity(new_intensity)
|
||||
self:onShowIntensity()
|
||||
return true
|
||||
end
|
||||
|
||||
function DeviceListener:onSetFlIntensity(new_intensity)
|
||||
local powerd = Device:getPowerDevice()
|
||||
if new_intensity <= 0 then
|
||||
powerd:turnOffFrontlight()
|
||||
else
|
||||
powerd:setIntensity(new_intensity)
|
||||
end
|
||||
self:onShowIntensity()
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -202,13 +208,19 @@ if Device:hasFrontlight() then
|
||||
direction = 1
|
||||
end
|
||||
local warmth = powerd.fl_warmth + direction * delta_int
|
||||
self:onSetFlWarmth(warmth)
|
||||
self:onShowWarmth()
|
||||
return true
|
||||
end
|
||||
|
||||
function DeviceListener:onSetFlWarmth(warmth)
|
||||
local powerd = Device:getPowerDevice()
|
||||
if warmth > 100 then
|
||||
warmth = 100
|
||||
elseif warmth < 0 then
|
||||
warmth = 0
|
||||
end
|
||||
powerd:setWarmth(warmth)
|
||||
self:onShowWarmth()
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
@@ -33,8 +33,10 @@ local settingsList = {
|
||||
-- Device settings
|
||||
show_frontlight_dialog = { category="none", event="ShowFlDialog", title=_("Show frontlight dialog"), device=true, condition=Device:hasFrontlight(),},
|
||||
toggle_frontlight = { category="none", event="ToggleFrontlight", title=_("Toggle frontlight"), device=true, condition=Device:hasFrontlight(),},
|
||||
set_frontlight = { category="absolutenumber", event="SetFlIntensity", min=0, max=Device:getPowerDevice().fl_max, title=_("Set frontlight brightness"), device=true, condition=Device:hasFrontlight(),},
|
||||
increase_frontlight = { category="incrementalnumber", event="IncreaseFlIntensity", min=1, max=Device:getPowerDevice().fl_max, title=_("Increase frontlight brightness"), device=true, condition=Device:hasFrontlight(),},
|
||||
decrease_frontlight = { category="incrementalnumber", event="DecreaseFlIntensity", min=1, max=Device:getPowerDevice().fl_max, title=_("Decrease frontlight brightness"), device=true, condition=Device:hasFrontlight(),},
|
||||
set_frontlight_warmth = { category="absolutenumber", event="SetFlWarmth", min=0, max=100, title=_("Set frontlight warmth"), device=true, condition=Device:hasNaturalLight(),},
|
||||
increase_frontlight_warmth = { category="incrementalnumber", event="IncreaseFlWarmth", min=1, max=Device:getPowerDevice().fl_warmth_max, title=_("Increase frontlight warmth"), device=true, condition=Device:hasNaturalLight(),},
|
||||
decrease_frontlight_warmth = { category="incrementalnumber", event="DecreaseFlWarmth", min=1, max=Device:getPowerDevice().fl_warmth_max, title=_("Decrease frontlight warmth"), device=true, condition=Device:hasNaturalLight(),},
|
||||
toggle_gsensor = { category="none", event="ToggleGSensor", title=_("Toggle accelerometer"), device=true, condition=Device:canToggleGSensor(),},
|
||||
@@ -164,8 +166,10 @@ local dispatcher_menu_order = {
|
||||
"show_config_menu",
|
||||
"show_frontlight_dialog",
|
||||
"toggle_frontlight",
|
||||
"set_frontlight",
|
||||
"increase_frontlight",
|
||||
"decrease_frontlight",
|
||||
"set_frontlight_warmth",
|
||||
"increase_frontlight_warmth",
|
||||
"decrease_frontlight_warmth",
|
||||
|
||||
|
||||
Reference in New Issue
Block a user