2017-12-17 17:27:24 +00:00
|
|
|
local Screensaver = require("ui/screensaver")
|
2023-09-23 07:21:44 +00:00
|
|
|
local lfs = require("libs/libkoreader-lfs")
|
2017-12-17 17:27:24 +00:00
|
|
|
local _ = require("gettext")
|
2022-05-23 22:25:50 +00:00
|
|
|
local T = require("ffi/util").template
|
2017-12-17 17:27:24 +00:00
|
|
|
|
2021-03-06 21:44:18 +00:00
|
|
|
local function hasLastFile()
|
2017-12-17 17:27:24 +00:00
|
|
|
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
|
|
|
|
|
2023-09-23 07:21:44 +00:00
|
|
|
local function isReaderProgressEnabled()
|
|
|
|
return Screensaver.getReaderProgress ~= nil and hasLastFile()
|
|
|
|
end
|
|
|
|
|
|
|
|
local function genMenuItem(text, setting, value, enabled_func, separator)
|
|
|
|
return {
|
|
|
|
text = text,
|
|
|
|
enabled_func = enabled_func,
|
2017-12-17 17:27:24 +00:00
|
|
|
checked_func = function()
|
2023-09-23 07:21:44 +00:00
|
|
|
return G_reader_settings:readSetting(setting) == value
|
2017-12-17 17:27:24 +00:00
|
|
|
end,
|
|
|
|
callback = function()
|
2023-09-23 07:21:44 +00:00
|
|
|
G_reader_settings:saveSetting(setting, value)
|
2020-06-06 17:23:16 +00:00
|
|
|
end,
|
2023-09-23 07:21:44 +00:00
|
|
|
radio = true,
|
|
|
|
separator = separator,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
return {
|
2020-06-06 17:23:16 +00:00
|
|
|
{
|
2024-04-08 20:47:17 +00:00
|
|
|
text = _("Wallpaper"),
|
2017-12-17 17:27:24 +00:00
|
|
|
sub_item_table = {
|
2024-04-08 20:47:17 +00:00
|
|
|
genMenuItem(_("Show book cover on sleep screen"), "screensaver_type", "cover", hasLastFile),
|
|
|
|
genMenuItem(_("Show custom image or cover on sleep screen"), "screensaver_type", "document_cover"),
|
|
|
|
genMenuItem(_("Show random image from folder on sleep screen"), "screensaver_type", "random_image"),
|
|
|
|
genMenuItem(_("Show reading progress on sleep screen"), "screensaver_type", "readingprogress", isReaderProgressEnabled),
|
|
|
|
genMenuItem(_("Show book status on sleep screen"), "screensaver_type", "bookstatus", hasLastFile),
|
|
|
|
genMenuItem(_("Leave screen as-is"), "screensaver_type", "disable", nil, true),
|
|
|
|
separator = true,
|
2017-12-17 17:27:24 +00:00
|
|
|
{
|
2024-04-08 20:47:17 +00:00
|
|
|
text = _("Border fill"),
|
|
|
|
enabled_func = function()
|
|
|
|
return G_reader_settings:readSetting("screensaver_type") == "cover"
|
|
|
|
or G_reader_settings:readSetting("screensaver_type") == "document_cover"
|
|
|
|
or G_reader_settings:readSetting("screensaver_type") == "random_image"
|
2018-07-23 08:37:24 +00:00
|
|
|
end,
|
2021-04-04 01:28:45 +00:00
|
|
|
sub_item_table = {
|
2024-04-08 20:47:17 +00:00
|
|
|
genMenuItem(_("Black fill"), "screensaver_img_background", "black"),
|
|
|
|
genMenuItem(_("White fill"), "screensaver_img_background", "white"),
|
2024-04-09 10:53:30 +00:00
|
|
|
genMenuItem(_("No fill"), "screensaver_img_background", "none", nil, true),
|
2023-09-23 07:21:44 +00:00
|
|
|
-- separator
|
2021-04-04 01:28:45 +00:00
|
|
|
{
|
2022-01-02 22:13:19 +00:00
|
|
|
text_func = function()
|
2023-09-23 07:21:44 +00:00
|
|
|
local percentage = G_reader_settings:readSetting("screensaver_stretch_limit_percentage")
|
|
|
|
if G_reader_settings:isTrue("screensaver_stretch_images") and percentage then
|
|
|
|
return T(_("Stretch to fit screen (with limit: %1 %)"), percentage)
|
2022-01-02 22:13:19 +00:00
|
|
|
end
|
2024-04-08 20:47:17 +00:00
|
|
|
return _("Stretch cover to fit screen")
|
2022-01-02 22:13:19 +00:00
|
|
|
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,
|
|
|
|
},
|
|
|
|
},
|
2017-12-17 17:27:24 +00:00
|
|
|
},
|
2020-02-22 08:07:28 +00:00
|
|
|
{
|
2024-04-09 10:53:30 +00:00
|
|
|
text = _("Postpone screen update after wake-up"),
|
2024-04-08 20:47:17 +00:00
|
|
|
sub_item_table = {
|
2024-06-05 20:23:00 +00:00
|
|
|
genMenuItem(_("Never"), "screensaver_delay", "disable"),
|
2024-04-08 20:47:17 +00:00
|
|
|
genMenuItem(_("1 second"), "screensaver_delay", "1"),
|
|
|
|
genMenuItem(_("3 seconds"), "screensaver_delay", "3"),
|
|
|
|
genMenuItem(_("5 seconds"), "screensaver_delay", "5"),
|
|
|
|
genMenuItem(_("Until a tap"), "screensaver_delay", "tap"),
|
|
|
|
genMenuItem(_("Until 'exit sleep screen' gesture"), "screensaver_delay", "gesture"),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Custom images"),
|
|
|
|
enabled_func = function()
|
|
|
|
return G_reader_settings:readSetting("screensaver_type") == "random_image"
|
|
|
|
or G_reader_settings:readSetting("screensaver_type") == "document_cover"
|
|
|
|
end,
|
2020-02-22 08:07:28 +00:00
|
|
|
sub_item_table = {
|
2021-04-19 00:20:46 +00:00
|
|
|
{
|
2024-06-10 12:47:06 +00:00
|
|
|
text = _("Choose image or document cover"),
|
2024-04-08 20:47:17 +00:00
|
|
|
enabled_func = function()
|
|
|
|
return G_reader_settings:readSetting("screensaver_type") == "document_cover"
|
2021-04-19 00:20:46 +00:00
|
|
|
end,
|
2024-04-08 20:47:17 +00:00
|
|
|
keep_menu_open = true,
|
2021-04-19 00:20:46 +00:00
|
|
|
callback = function()
|
2024-04-08 20:47:17 +00:00
|
|
|
Screensaver:chooseFile()
|
2021-04-19 00:20:46 +00:00
|
|
|
end,
|
|
|
|
},
|
2024-04-08 20:47:17 +00:00
|
|
|
{
|
2024-06-10 12:47:06 +00:00
|
|
|
text = _("Choose random image folder"),
|
2024-04-08 20:47:17 +00:00
|
|
|
enabled_func = function()
|
|
|
|
return G_reader_settings:readSetting("screensaver_type") == "random_image"
|
|
|
|
end,
|
|
|
|
keep_menu_open = true,
|
|
|
|
callback = function()
|
|
|
|
Screensaver:chooseFolder()
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Sleep screen message"),
|
|
|
|
sub_item_table = {
|
|
|
|
{
|
|
|
|
text = _("Add custom message to sleep screen"),
|
|
|
|
checked_func = function()
|
|
|
|
return G_reader_settings:isTrue("screensaver_show_message")
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:toggle("screensaver_show_message")
|
|
|
|
end,
|
|
|
|
separator = true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Edit sleep screen message"),
|
|
|
|
enabled_func = function()
|
|
|
|
return G_reader_settings:isTrue("screensaver_show_message")
|
|
|
|
end,
|
|
|
|
keep_menu_open = true,
|
|
|
|
callback = function()
|
|
|
|
Screensaver:setMessage()
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Background fill"),
|
2024-04-09 10:53:30 +00:00
|
|
|
help_text = _("This option will only become available, if you have selected 'Leave screen as-is' as wallpaper and have 'Sleep screen message' on."),
|
2024-04-08 20:47:17 +00:00
|
|
|
enabled_func = function()
|
|
|
|
return G_reader_settings:readSetting("screensaver_type") == "disable" and G_reader_settings:isTrue("screensaver_show_message")
|
|
|
|
end,
|
|
|
|
sub_item_table = {
|
|
|
|
genMenuItem(_("Black fill"), "screensaver_msg_background", "black"),
|
|
|
|
genMenuItem(_("White fill"), "screensaver_msg_background", "white"),
|
2024-04-09 10:53:30 +00:00
|
|
|
genMenuItem(_("No fill"), "screensaver_msg_background", "none", nil, true),
|
2021-04-04 01:28:45 +00:00
|
|
|
},
|
2020-02-22 08:07:28 +00:00
|
|
|
},
|
2017-12-17 17:27:24 +00:00
|
|
|
{
|
2024-04-08 20:47:17 +00:00
|
|
|
text = _("Message position"),
|
|
|
|
enabled_func = function()
|
|
|
|
return G_reader_settings:isTrue("screensaver_show_message")
|
|
|
|
end,
|
2017-12-17 17:27:24 +00:00
|
|
|
sub_item_table = {
|
2024-04-08 20:47:17 +00:00
|
|
|
genMenuItem(_("Top"), "screensaver_message_position", "top"),
|
|
|
|
genMenuItem(_("Middle"), "screensaver_message_position", "middle"),
|
|
|
|
genMenuItem(_("Bottom"), "screensaver_message_position", "bottom", nil, true),
|
2021-04-04 01:28:45 +00:00
|
|
|
},
|
|
|
|
},
|
2024-04-08 20:47:17 +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
|
|
|
},
|
|
|
|
},
|
2017-12-17 17:27:24 +00:00
|
|
|
}
|