Move AutoSuspend menu to the Plugin itself

pull/4852/head
NiLuJe 5 years ago
parent 1eba95d87f
commit fe3fc78171

@ -106,38 +106,6 @@ if Device:setDateTime() then
}
end
if Device:isCervantes() or Device:isKobo() or Device:isSDL() or Device:isSonyPRSTUX() then
common_settings.autosuspend = {
text = _("Autosuspend timeout"),
enabled_func = function()
-- NOTE: Pilfered from frontend/pluginloader.lua
local plugins_disabled = G_reader_settings:readSetting("plugins_disabled") or {}
return plugins_disabled["autosuspend"] ~= true
end,
callback = function()
local SpinWidget = require("ui/widget/spinwidget")
local curr_items = G_reader_settings:readSetting("auto_suspend_timeout_seconds") or 60*60
local autosuspend_spin = SpinWidget:new {
width = Screen:getWidth() * 0.6,
value = curr_items / 60,
value_min = 5,
value_max = 240,
value_hold_step = 15,
ok_text = _("Set timeout"),
title_text = _("Timeout in minutes"),
callback = function(autosuspend_spin)
G_reader_settings:saveSetting("auto_suspend_timeout_seconds", autosuspend_spin.value * 60)
-- NOTE: Will only take effect after a restart, as we don't have a method to set this live...
UIManager:show(InfoMessage:new{
text = _("This will take effect on next restart."),
})
end
}
UIManager:show(autosuspend_spin)
end
}
end
if Device:isKobo() then
common_settings.sleepcover = {
text = _("Ignore sleepcover events"),

@ -116,6 +116,49 @@ local AutoSuspendWidget = WidgetContainer:new{
name = "autosuspend",
}
function AutoSuspendWidget:addToMainMenu(menu_items)
menu_items.autosuspend = {
text = _("Autosuspend timeout"),
-- This won't ever be registered if the plugin is disabled ;).
--[[
enabled_func = function()
-- NOTE: Pilfered from frontend/pluginloader.lua
local plugins_disabled = G_reader_settings:readSetting("plugins_disabled") or {}
return plugins_disabled["autosuspend"] ~= true
end,
--]]
callback = function()
local InfoMessage = require("ui/widget/infomessage")
local Screen = Device.screen
local SpinWidget = require("ui/widget/spinwidget")
local curr_items = G_reader_settings:readSetting("auto_suspend_timeout_seconds") or 60*60
local autosuspend_spin = SpinWidget:new {
width = Screen:getWidth() * 0.6,
value = curr_items / 60,
value_min = 5,
value_max = 240,
value_hold_step = 15,
ok_text = _("Set timeout"),
title_text = _("Timeout in minutes"),
callback = function(autosuspend_spin)
G_reader_settings:saveSetting("auto_suspend_timeout_seconds", autosuspend_spin.value * 60)
-- NOTE: Will only take effect after a restart, as we don't have a method to set this live...
UIManager:show(InfoMessage:new{
text = _("This will take effect on next restart."),
})
end
}
UIManager:show(autosuspend_spin)
end,
}
end
function AutoSuspendWidget:init()
-- self.ui is nil in the testsuite
if not self.ui or not self.ui.menu then return end
self.ui.menu:registerToMainMenu(self)
end
function AutoSuspendWidget:onInputEvent()
AutoSuspend:onInputEvent()
end

Loading…
Cancel
Save