2017-12-17 17:27:24 +00:00
|
|
|
local Screensaver = require("ui/screensaver")
|
|
|
|
local _ = require("gettext")
|
|
|
|
|
2021-03-06 21:44:18 +00:00
|
|
|
local function hasLastFile()
|
|
|
|
if G_reader_settings:hasNot("lastfile") then
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
2017-12-17 17:27:24 +00:00
|
|
|
local lfs = require("libs/libkoreader-lfs")
|
|
|
|
local last_file = G_reader_settings:readSetting("lastfile")
|
2021-03-06 21:44:18 +00:00
|
|
|
return last_file and lfs.attributes(last_file, "mode") == "file"
|
2017-12-17 17:27:24 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return {
|
|
|
|
{
|
|
|
|
text = _("Use last book's cover as screensaver"),
|
2021-03-06 21:44:18 +00:00
|
|
|
enabled_func = hasLastFile,
|
2017-12-17 17:27:24 +00:00
|
|
|
checked_func = function()
|
2021-03-06 21:44:18 +00:00
|
|
|
return G_reader_settings:readSetting("screensaver_type") == "cover"
|
2017-12-17 17:27:24 +00:00
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("screensaver_type", "cover")
|
|
|
|
end
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Use book status as screensaver"),
|
2021-03-06 21:44:18 +00:00
|
|
|
enabled_func = hasLastFile,
|
2017-12-17 17:27:24 +00:00
|
|
|
checked_func = function()
|
2021-03-06 21:44:18 +00:00
|
|
|
return G_reader_settings:readSetting("screensaver_type") == "bookstatus"
|
2017-12-17 17:27:24 +00:00
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("screensaver_type", "bookstatus")
|
|
|
|
end
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Use random image from folder as screensaver"),
|
|
|
|
checked_func = function()
|
2021-03-06 21:44:18 +00:00
|
|
|
return G_reader_settings:readSetting("screensaver_type") == "random_image"
|
2017-12-17 17:27:24 +00:00
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("screensaver_type", "random_image")
|
|
|
|
end
|
|
|
|
},
|
2019-09-16 13:27:49 +00:00
|
|
|
{
|
|
|
|
text = _("Use document cover as screensaver"),
|
|
|
|
checked_func = function()
|
2021-03-06 21:44:18 +00:00
|
|
|
return G_reader_settings:readSetting("screensaver_type") == "document_cover"
|
2019-09-16 13:27:49 +00:00
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("screensaver_type", "document_cover")
|
|
|
|
end
|
|
|
|
},
|
2018-07-23 08:37:24 +00:00
|
|
|
{
|
|
|
|
text = _("Use image as screensaver"),
|
|
|
|
checked_func = function()
|
2021-03-06 21:44:18 +00:00
|
|
|
return G_reader_settings:readSetting("screensaver_type") == "image_file"
|
2018-07-23 08:37:24 +00:00
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("screensaver_type", "image_file")
|
|
|
|
end
|
|
|
|
},
|
2017-12-17 17:27:24 +00:00
|
|
|
{
|
|
|
|
text = _("Use reading progress as screensaver"),
|
2021-04-04 01:28:45 +00:00
|
|
|
enabled_func = function()
|
|
|
|
return Screensaver.getReaderProgress ~= nil and hasLastFile()
|
|
|
|
end,
|
2017-12-17 17:27:24 +00:00
|
|
|
checked_func = function()
|
2021-03-06 21:44:18 +00:00
|
|
|
return G_reader_settings:readSetting("screensaver_type") == "readingprogress"
|
2017-12-17 17:27:24 +00:00
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("screensaver_type", "readingprogress")
|
|
|
|
end
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Leave screen as it is"),
|
|
|
|
checked_func = function()
|
2021-04-04 01:28:45 +00:00
|
|
|
return G_reader_settings:readSetting("screensaver_type") == "disable"
|
2017-12-17 17:27:24 +00:00
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("screensaver_type", "disable")
|
2020-06-06 17:23:16 +00:00
|
|
|
end,
|
|
|
|
separator = true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Add message to screensaver"),
|
2021-03-06 21:44:18 +00:00
|
|
|
checked_func = function()
|
2021-04-04 01:28:45 +00:00
|
|
|
return G_reader_settings:isTrue("screensaver_show_message")
|
2021-03-06 21:44:18 +00:00
|
|
|
end,
|
2020-06-06 17:23:16 +00:00
|
|
|
callback = function()
|
2021-03-06 21:44:18 +00:00
|
|
|
G_reader_settings:toggle("screensaver_show_message")
|
2020-06-06 17:23:16 +00:00
|
|
|
end,
|
|
|
|
separator = true,
|
2017-12-17 17:27:24 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Settings"),
|
|
|
|
sub_item_table = {
|
|
|
|
{
|
|
|
|
text = _("Screensaver folder"),
|
2018-09-04 21:55:58 +00:00
|
|
|
keep_menu_open = true,
|
2017-12-17 17:27:24 +00:00
|
|
|
callback = function()
|
|
|
|
Screensaver:chooseFolder()
|
|
|
|
end,
|
|
|
|
},
|
2018-07-23 08:37:24 +00:00
|
|
|
{
|
|
|
|
text = _("Screensaver image"),
|
2018-09-04 21:55:58 +00:00
|
|
|
keep_menu_open = true,
|
2018-07-23 08:37:24 +00:00
|
|
|
callback = function()
|
|
|
|
Screensaver:chooseFile()
|
|
|
|
end,
|
|
|
|
},
|
2019-09-16 13:27:49 +00:00
|
|
|
{
|
|
|
|
text = _("Document cover"),
|
|
|
|
keep_menu_open = true,
|
|
|
|
callback = function()
|
|
|
|
Screensaver:chooseFile(true)
|
|
|
|
end,
|
|
|
|
},
|
2017-12-17 17:27:24 +00:00
|
|
|
{
|
|
|
|
text = _("Screensaver message"),
|
2018-09-04 21:55:58 +00:00
|
|
|
keep_menu_open = true,
|
2017-12-17 17:27:24 +00:00
|
|
|
callback = function()
|
|
|
|
Screensaver:setMessage()
|
|
|
|
end,
|
|
|
|
},
|
2021-03-06 21:44:18 +00:00
|
|
|
{
|
2021-04-04 01:28:45 +00:00
|
|
|
text = _("Covers and images settings"),
|
|
|
|
sub_item_table = {
|
|
|
|
{
|
2022-01-02 22:13:19 +00:00
|
|
|
text = _("Black background"),
|
2021-04-04 01:28:45 +00:00
|
|
|
checked_func = function()
|
|
|
|
return G_reader_settings:readSetting("screensaver_img_background") == "black"
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("screensaver_img_background", "black")
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
{
|
2022-01-02 22:13:19 +00:00
|
|
|
text = _("White background"),
|
2021-04-04 01:28:45 +00:00
|
|
|
checked_func = function()
|
|
|
|
return G_reader_settings:readSetting("screensaver_img_background") == "white"
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("screensaver_img_background", "white")
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
{
|
2022-01-02 22:13:19 +00:00
|
|
|
text = _("Leave background as-is"),
|
2021-04-04 01:28:45 +00:00
|
|
|
checked_func = function()
|
|
|
|
return G_reader_settings:readSetting("screensaver_img_background") == "none"
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("screensaver_img_background", "none")
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
{
|
2022-01-02 22:13:19 +00:00
|
|
|
text_func = function()
|
|
|
|
if G_reader_settings:nilOrFalse("screensaver_stretch_images") then
|
|
|
|
return _("Stretch to fit screen")
|
|
|
|
elseif G_reader_settings:readSetting("screensaver_stretch_limit_percentage") then
|
|
|
|
return _("Stretch to fit screen (with limit)")
|
|
|
|
else
|
|
|
|
return _("Stretch to fit screen")
|
|
|
|
end
|
|
|
|
end,
|
2021-04-04 01:28:45 +00:00
|
|
|
checked_func = function()
|
|
|
|
return G_reader_settings:isTrue("screensaver_stretch_images")
|
|
|
|
end,
|
2022-01-02 22:13:19 +00:00
|
|
|
callback = function(touchmenu_instance)
|
|
|
|
Screensaver:setStretchLimit(touchmenu_instance)
|
2021-04-04 01:28:45 +00:00
|
|
|
end,
|
|
|
|
separator = true,
|
|
|
|
},
|
|
|
|
},
|
2017-12-17 17:27:24 +00:00
|
|
|
},
|
2020-02-22 08:07:28 +00:00
|
|
|
{
|
2021-04-04 01:28:45 +00:00
|
|
|
text = _("Message settings"),
|
2020-02-22 08:07:28 +00:00
|
|
|
sub_item_table = {
|
|
|
|
{
|
2021-04-04 01:28:45 +00:00
|
|
|
text = _("Black background behind message"),
|
2020-02-22 08:07:28 +00:00
|
|
|
checked_func = function()
|
2021-04-04 01:28:45 +00:00
|
|
|
return G_reader_settings:readSetting("screensaver_msg_background") == "black"
|
2020-02-22 08:07:28 +00:00
|
|
|
end,
|
|
|
|
callback = function()
|
2021-04-04 01:28:45 +00:00
|
|
|
G_reader_settings:saveSetting("screensaver_msg_background", "black")
|
|
|
|
end,
|
2020-02-22 08:07:28 +00:00
|
|
|
},
|
|
|
|
{
|
2021-04-04 01:28:45 +00:00
|
|
|
text = _("White background behind message"),
|
2020-02-22 08:07:28 +00:00
|
|
|
checked_func = function()
|
2021-04-04 01:28:45 +00:00
|
|
|
return G_reader_settings:readSetting("screensaver_msg_background") == "white"
|
2020-02-22 08:07:28 +00:00
|
|
|
end,
|
|
|
|
callback = function()
|
2021-04-04 01:28:45 +00:00
|
|
|
G_reader_settings:saveSetting("screensaver_msg_background", "white")
|
|
|
|
end,
|
2020-02-22 08:07:28 +00:00
|
|
|
},
|
|
|
|
{
|
2021-04-04 01:28:45 +00:00
|
|
|
text = _("Leave background as-is behind message"),
|
2020-02-22 08:07:28 +00:00
|
|
|
checked_func = function()
|
2021-04-04 01:28:45 +00:00
|
|
|
return G_reader_settings:readSetting("screensaver_msg_background") == "none"
|
2020-02-22 08:07:28 +00:00
|
|
|
end,
|
|
|
|
callback = function()
|
2021-04-04 01:28:45 +00:00
|
|
|
G_reader_settings:saveSetting("screensaver_msg_background", "none")
|
|
|
|
end,
|
|
|
|
},
|
2021-04-19 00:20:46 +00:00
|
|
|
{
|
|
|
|
text = _("Hide reboot/poweroff message"),
|
|
|
|
checked_func = function()
|
|
|
|
return G_reader_settings:isTrue("screensaver_hide_fallback_msg")
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:toggle("screensaver_hide_fallback_msg")
|
|
|
|
end,
|
|
|
|
},
|
2021-04-04 01:28:45 +00:00
|
|
|
{
|
|
|
|
text = _("Message position"),
|
|
|
|
sub_item_table = {
|
|
|
|
{
|
|
|
|
text = _("Top"),
|
|
|
|
checked_func = function()
|
|
|
|
return G_reader_settings:readSetting("screensaver_message_position") == "top"
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("screensaver_message_position", "top")
|
|
|
|
end
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Middle"),
|
|
|
|
checked_func = function()
|
|
|
|
return G_reader_settings:readSetting("screensaver_message_position") == "middle"
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("screensaver_message_position", "middle")
|
|
|
|
end
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Bottom"),
|
|
|
|
checked_func = function()
|
|
|
|
return G_reader_settings:readSetting("screensaver_message_position") == "bottom"
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("screensaver_message_position", "bottom")
|
|
|
|
end
|
|
|
|
},
|
|
|
|
},
|
2020-02-22 08:07:28 +00:00
|
|
|
},
|
2021-04-04 01:28:45 +00:00
|
|
|
},
|
2020-02-22 08:07:28 +00:00
|
|
|
},
|
2017-12-17 17:27:24 +00:00
|
|
|
{
|
2021-02-23 23:36:05 +00:00
|
|
|
text = _("Keep the screensaver on screen after wakeup"),
|
2017-12-17 17:27:24 +00:00
|
|
|
sub_item_table = {
|
|
|
|
{
|
|
|
|
text = _("Disable"),
|
|
|
|
checked_func = function()
|
2021-04-04 01:28:45 +00:00
|
|
|
return G_reader_settings:readSetting("screensaver_delay") == "disable"
|
2017-12-17 17:27:24 +00:00
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("screensaver_delay", "disable")
|
|
|
|
end
|
|
|
|
},
|
|
|
|
{
|
2021-02-23 23:36:05 +00:00
|
|
|
text = _("For 1 second"),
|
2017-12-17 17:27:24 +00:00
|
|
|
checked_func = function()
|
2021-03-06 21:44:18 +00:00
|
|
|
return G_reader_settings:readSetting("screensaver_delay") == "1"
|
2017-12-17 17:27:24 +00:00
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("screensaver_delay", "1")
|
|
|
|
end
|
|
|
|
},
|
|
|
|
{
|
2021-02-23 23:36:05 +00:00
|
|
|
text = _("For 3 seconds"),
|
2017-12-17 17:27:24 +00:00
|
|
|
checked_func = function()
|
2021-03-06 21:44:18 +00:00
|
|
|
return G_reader_settings:readSetting("screensaver_delay") == "3"
|
2017-12-17 17:27:24 +00:00
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("screensaver_delay", "3")
|
|
|
|
end
|
|
|
|
},
|
|
|
|
{
|
2021-02-23 23:36:05 +00:00
|
|
|
text = _("For 5 seconds"),
|
2017-12-17 17:27:24 +00:00
|
|
|
checked_func = function()
|
2021-03-06 21:44:18 +00:00
|
|
|
return G_reader_settings:readSetting("screensaver_delay") == "5"
|
2017-12-17 17:27:24 +00:00
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("screensaver_delay", "5")
|
|
|
|
end
|
|
|
|
},
|
|
|
|
{
|
2021-02-23 23:36:05 +00:00
|
|
|
text = _("Until a tap"),
|
2017-12-17 17:27:24 +00:00
|
|
|
checked_func = function()
|
2021-03-06 21:44:18 +00:00
|
|
|
return G_reader_settings:readSetting("screensaver_delay") == "tap"
|
2017-12-17 17:27:24 +00:00
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("screensaver_delay", "tap")
|
|
|
|
end
|
|
|
|
},
|
2021-04-04 01:28:45 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2017-12-17 17:27:24 +00:00
|
|
|
}
|