2
0
mirror of https://github.com/koreader/koreader synced 2024-10-31 21:20:20 +00:00

final changes to readerfooter

This commit is contained in:
SomeGuy 2024-04-14 00:36:59 +01:00 committed by GitHub
parent 5e3013c26c
commit 6a49707659
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1187,87 +1187,12 @@ function ReaderFooter:addToMainMenu(menu_items)
}, },
}, },
}, },
{
text = _("Show initial-position marker"),
checked_func = function()
return self.settings.initial_marker == true
end,
callback = function()
self.settings.initial_marker = not self.settings.initial_marker
self.progress_bar.initial_pos_marker = self.settings.initial_marker
self:refreshFooter(true)
end
},
{
text = _("Show chapter markers"),
checked_func = function()
return self.settings.toc_markers == true and not self.settings.chapter_progress_bar
end,
enabled_func = function()
return not self.settings.progress_style_thin and not self.settings.chapter_progress_bar
end,
callback = function()
self.settings.toc_markers = not self.settings.toc_markers
self:setTocMarkers()
self:refreshFooter(true)
end
},
{
text_func = function()
local markers_width_text = _("thick")
if self.settings.toc_markers_width == 1 then
markers_width_text = _("thin")
elseif self.settings.toc_markers_width == 2 then
markers_width_text = _("medium")
end
return T(_("Chapter marker width (%1)"), markers_width_text)
end,
enabled_func = function()
return not self.settings.progress_style_thin and not self.settings.chapter_progress_bar
and self.settings.toc_markers
end,
sub_item_table = {
{
text = _("Thin"),
checked_func = function()
return self.settings.toc_markers_width == 1
end,
callback = function()
self.settings.toc_markers_width = 1 -- unscaled_size_check: ignore
self:setTocMarkers()
self:refreshFooter(true)
end,
},
{
text = _("Medium"),
checked_func = function()
return self.settings.toc_markers_width == 2
end,
callback = function()
self.settings.toc_markers_width = 2 -- unscaled_size_check: ignore
self:setTocMarkers()
self:refreshFooter(true)
end,
},
{
text = _("Thick"),
checked_func = function()
return self.settings.toc_markers_width == 3
end,
callback = function()
self.settings.toc_markers_width = 3 -- unscaled_size_check: ignore
self:setTocMarkers()
self:refreshFooter(true)
end
},
},
},
{ {
text_func = function() text_func = function()
if self.settings.progress_style_thin then if self.settings.progress_style_thin then
return _("Style: thin") return _("Thickness and height: (thin)")
else else
return _("Style: thick") return _("Thickness and height: (thick)")
end end
end, end,
enabled_func = function() enabled_func = function()
@ -1298,6 +1223,7 @@ function ReaderFooter:addToMainMenu(menu_items)
self.progress_bar:updateStyle(false, bar_height) self.progress_bar:updateStyle(false, bar_height)
self:refreshFooter(true, true) self:refreshFooter(true, true)
end, end,
separator = true,
}, },
{ {
text = _("Set height"), text = _("Set height"),
@ -1447,13 +1373,92 @@ function ReaderFooter:addToMainMenu(menu_items)
end, end,
keep_menu_open = true, keep_menu_open = true,
separator = true, separator = true,
} },
{
text = _("Show initial-position marker"),
checked_func = function()
return self.settings.initial_marker == true
end,
enabled_func = function()
return not self.settings.disable_progress_bar
end,
callback = function()
self.settings.initial_marker = not self.settings.initial_marker
self.progress_bar.initial_pos_marker = self.settings.initial_marker
self:refreshFooter(true)
end
},
{
text = _("Show chapter markers"),
checked_func = function()
return self.settings.toc_markers == true and not self.settings.chapter_progress_bar
end,
enabled_func = function()
return not self.settings.progress_style_thin and not self.settings.chapter_progress_bar
and not self.settings.disable_progress_bar
end,
callback = function()
self.settings.toc_markers = not self.settings.toc_markers
self:setTocMarkers()
self:refreshFooter(true)
end
},
{
text_func = function()
local markers_width_text = _("thick")
if self.settings.toc_markers_width == 1 then
markers_width_text = _("thin")
elseif self.settings.toc_markers_width == 2 then
markers_width_text = _("medium")
end
return T(_("Chapter marker width (%1)"), markers_width_text)
end,
enabled_func = function()
return not self.settings.progress_style_thin and not self.settings.chapter_progress_bar
and self.settings.toc_markers and not self.settings.disable_progress_bar
end,
sub_item_table = {
{
text = _("Thin"),
checked_func = function()
return self.settings.toc_markers_width == 1
end,
callback = function()
self.settings.toc_markers_width = 1 -- unscaled_size_check: ignore
self:setTocMarkers()
self:refreshFooter(true)
end,
},
{
text = _("Medium"),
checked_func = function()
return self.settings.toc_markers_width == 2
end,
callback = function()
self.settings.toc_markers_width = 2 -- unscaled_size_check: ignore
self:setTocMarkers()
self:refreshFooter(true)
end,
},
{
text = _("Thick"),
checked_func = function()
return self.settings.toc_markers_width == 3
end,
callback = function()
self.settings.toc_markers_width = 3 -- unscaled_size_check: ignore
self:setTocMarkers()
self:refreshFooter(true)
end
},
},
},
} }
}) })
----------- COMPLICATIONS ----------- COMPLICATIONS (FOOTER_ITEMS)
local about_text = _([[A complication is any feature that offers additional information beyond the content of your book. Examples of local about_text = _("A complication is any feature that provides additional information beyond the content of your book. Examples of "..
common complications include time, percentage read, pages left, and the battery indicator. You can choose which complications to display "common complications include time, percentage read, pages left, and the battery indicator. You can choose which complications to "..
on the status bar from this page.]]) "display on the status bar from this page.")
local complication_subitems = {} local complication_subitems = {}
table.insert(sub_items, { table.insert(sub_items, {
text = _("Complications"), text = _("Complications"),
@ -1495,7 +1500,7 @@ on the status bar from this page.]])
table.insert(complication_subitems, getMinibarOption("book_title")) table.insert(complication_subitems, getMinibarOption("book_title"))
table.insert(complication_subitems, getMinibarOption("book_chapter")) table.insert(complication_subitems, getMinibarOption("book_chapter"))
table.insert(complication_subitems, getMinibarOption("custom_text")) table.insert(complication_subitems, getMinibarOption("custom_text"))
-------- CONFIGURE COMPLICATIONS -------- CONFIGURE COMPLICATIONS (FOOTER_ITEMS)
table.insert(sub_items, { table.insert(sub_items, {
separator = true, separator = true,
text = _("Configure complications"), text = _("Configure complications"),
@ -1527,6 +1532,18 @@ on the status bar from this page.]])
end, end,
}, },
getMinibarOption("all_at_once", self.updateFooterTextGenerator), getMinibarOption("all_at_once", self.updateFooterTextGenerator),
{
text = _("Auto refresh complications"),
help_text = _("This option allows certain complications to update without needing a full-page update. For example, the time"..
" complication will update every minute regardless of user input."),
checked_func = function()
return self.settings.auto_refresh_time == true
end,
callback = function()
self.settings.auto_refresh_time = not self.settings.auto_refresh_time
self:rescheduleFooterAutoRefreshIfNeeded()
end
},
{ {
text = _("Hide empty complications"), text = _("Hide empty complications"),
help_text = _([[This option will hide values like 0 or off.]]), help_text = _([[This option will hide values like 0 or off.]]),
@ -1541,6 +1558,22 @@ on the status bar from this page.]])
self:refreshFooter(true, true) self:refreshFooter(true, true)
end, end,
}, },
{
text = _("Count current page in pages left"),
help_text = _("By default, KOReader does not include the current page when calculating pages left. For example, in a book "..
"or chapter with n pages the 'pages left' complication will range from 'n-1' to 0 (last page). With this feature activated, "..
"the current page is factored in, resulting in the count going from n to 1 instead."),
enabled_func = function()
return self.settings.pages_left or self.settings.pages_left_book
end,
checked_func = function()
return self.settings.pages_left_includes_current_page == true
end,
callback = function()
self.settings.pages_left_includes_current_page = not self.settings.pages_left_includes_current_page
self:refreshFooter(true)
end,
},
{ {
text_func = function() text_func = function()
return T(_("Progress percentage format: %1"), return T(_("Progress percentage format: %1"),
@ -1586,33 +1619,110 @@ on the status bar from this page.]])
}, },
}, },
{ {
text = _("Count current page in pages left"), text = _("Maximum lenght for text complications"),
help_text = _([[ separator = true,
By default, KOReader does not include the current page when calculating pages left. For example, in a book or chapter with n pages the "pages sub_item_table = {
left" complication will range from 'n-1' to 0 (last page). With this feature activated, the current page is factored in, resulting in the count {
going from n to 1 instead.]]), text_func = function()
enabled_func = function() return T(_("Lenght of book-title complication: %1".. "%"), self.settings.book_title_max_width_pct)
return self.settings.pages_left or self.settings.pages_left_book end,
end, callback = function(touchmenu_instance)
checked_func = function() local SpinWidget = require("ui/widget/spinwidget")
return self.settings.pages_left_includes_current_page == true local items = SpinWidget:new{
end, value = self.settings.book_title_max_width_pct,
callback = function() value_min = 10,
self.settings.pages_left_includes_current_page = not self.settings.pages_left_includes_current_page value_step = 5,
self:refreshFooter(true) value_hold_step = 20,
end, value_max = 100,
unit = "%",
title_text = _("Max lenght of book-title complication"),
info_text = _("Maximum percentage of screen width used for book-title complication"),
keep_shown_on_apply = true,
callback = function(spin)
self.settings.book_title_max_width_pct = spin.value
self:refreshFooter(true, true)
if touchmenu_instance then touchmenu_instance:updateItems() end
end
}
UIManager:show(items)
end,
keep_menu_open = true,
},
{
text_func = function()
return T(_("Lenght of chapter-title complication: %1".. "%"), self.settings.book_chapter_max_width_pct)
end,
callback = function(touchmenu_instance)
local SpinWidget = require("ui/widget/spinwidget")
local items = SpinWidget:new{
value = self.settings.book_chapter_max_width_pct,
value_min = 10,
value_step = 5,
value_hold_step = 20,
value_max = 100,
unit = "%",
title_text = _("Max lenght of chapter-title complication"),
info_text = _("Maximum percentage of screen width used for chapter-title complication"),
keep_shown_on_apply = true,
callback = function(spin)
self.settings.book_chapter_max_width_pct = spin.value
self:refreshFooter(true, true)
if touchmenu_instance then touchmenu_instance:updateItems() end
end
}
UIManager:show(items)
end,
keep_menu_open = true,
}
},
}, },
{ {
text = _("Auto refresh complications"), text_func = function()
help_text = _([[This option allows certain complications to update without needing a full-page update. For example, the time local align_text
complication will update every minute regardless of user input.]]), if self.settings.align == "left" then
checked_func = function() align_text = _("Left")
return self.settings.auto_refresh_time == true elseif self.settings.align == "right" then
align_text = _("Right")
else
align_text = _("Center")
end
return T(_("Alignment: %1"), align_text)
end, end,
callback = function() enabled_func = function()
self.settings.auto_refresh_time = not self.settings.auto_refresh_time return self.settings.disable_progress_bar or self.settings.progress_bar_position ~= "alongside"
self:rescheduleFooterAutoRefreshIfNeeded() end,
end sub_item_table = {
{
text = _("Left"),
checked_func = function()
return self.settings.align == "left"
end,
callback = function()
self.settings.align = "left"
self:refreshFooter(true)
end,
},
{
text = _("Center"),
checked_func = function()
return self.settings.align == "center"
end,
callback = function()
self.settings.align = "center"
self:refreshFooter(true)
end,
},
{
text = _("Right"),
checked_func = function()
return self.settings.align == "right"
end,
callback = function()
self.settings.align = "right"
self:refreshFooter(true)
end,
},
}
}, },
{ {
text_func = function() text_func = function()
@ -1728,112 +1838,6 @@ going from n to 1 instead.]]),
end, end,
keep_menu_open = true, keep_menu_open = true,
}, },
{
text = _("Maximum lenght for text complications"),
sub_item_table = {
{
text_func = function()
return T(_("Book title: %1 %"), self.settings.book_title_max_width_pct)
end,
callback = function(touchmenu_instance)
local SpinWidget = require("ui/widget/spinwidget")
local items = SpinWidget:new{
value = self.settings.book_title_max_width_pct,
value_min = 10,
value_step = 5,
value_hold_step = 20,
value_max = 100,
unit = "%",
title_text = _("Maximum lenght of book-title complication"),
info_text = _("Maximum percentage of screen width used for book-title complication"),
keep_shown_on_apply = true,
callback = function(spin)
self.settings.book_title_max_width_pct = spin.value
self:refreshFooter(true, true)
if touchmenu_instance then touchmenu_instance:updateItems() end
end
}
UIManager:show(items)
end,
keep_menu_open = true,
},
{
text_func = function()
return T(_("Current chapter: %1 %"), self.settings.book_chapter_max_width_pct)
end,
callback = function(touchmenu_instance)
local SpinWidget = require("ui/widget/spinwidget")
local items = SpinWidget:new{
value = self.settings.book_chapter_max_width_pct,
value_min = 10,
value_step = 5,
value_hold_step = 20,
value_max = 100,
unit = "%",
title_text = _("Maximum lenght of chapter-title complication"),
info_text = _("Maximum percentage of screen width used for chapter-title complication"),
keep_shown_on_apply = true,
callback = function(spin)
self.settings.book_chapter_max_width_pct = spin.value
self:refreshFooter(true, true)
if touchmenu_instance then touchmenu_instance:updateItems() end
end
}
UIManager:show(items)
end,
keep_menu_open = true,
}
},
},
{
text_func = function()
local align_text
if self.settings.align == "left" then
align_text = _("Left")
elseif self.settings.align == "right" then
align_text = _("Right")
else
align_text = _("Center")
end
return T(_("Alignment: %1"), align_text)
end,
separator = true,
enabled_func = function()
return self.settings.disable_progress_bar or self.settings.progress_bar_position ~= "alongside"
end,
sub_item_table = {
{
text = _("Center"),
checked_func = function()
return self.settings.align == "center"
end,
callback = function()
self.settings.align = "center"
self:refreshFooter(true)
end,
},
{
text = _("Left"),
checked_func = function()
return self.settings.align == "left"
end,
callback = function()
self.settings.align = "left"
self:refreshFooter(true)
end,
},
{
text = _("Right"),
checked_func = function()
return self.settings.align == "right"
end,
callback = function()
self.settings.align = "right"
self:refreshFooter(true)
end,
},
}
},
{ {
text_func = function() text_func = function()
local prefix_text = "" local prefix_text = ""
@ -1950,10 +1954,10 @@ going from n to 1 instead.]]),
}) })
local configure_complications_sub_table = sub_items[#sub_items].sub_item_table -- will pick the last item of sub_items local configure_complications_sub_table = sub_items[#sub_items].sub_item_table -- will pick the last item of sub_items
if Device:hasBattery() then if Device:hasBattery() then
table.insert(configure_complications_sub_table , 4, { table.insert(configure_complications_sub_table , 5, {
text_func = function() text_func = function()
if self.settings.battery_hide_threshold <= (Device:hasAuxBattery() and 200 or 100) then if self.settings.battery_hide_threshold <= (Device:hasAuxBattery() and 200 or 100) then
return T(_("Hide battery complication when higher than: %1 %"), self.settings.battery_hide_threshold) return T(_("Hide battery complication when higher than: %1".. "%"), self.settings.battery_hide_threshold)
else else
return _("Hide battery complication at custom threshold") return _("Hide battery complication at custom threshold")
end end
@ -2005,7 +2009,7 @@ going from n to 1 instead.]]),
self:refreshFooter(true, true) self:refreshFooter(true, true)
end, end,
}) })
-- these next settings are useless on non-touch devices so we take them off -- the next couple of settings are useless on non-touch devices so we take them off there
if Device:isTouchDevice() then if Device:isTouchDevice() then
table.insert(sub_items, { table.insert(sub_items, {
text = _("Lock status bar"), text = _("Lock status bar"),