ReaderToc: Add an option to display a separator between entries (#7551)

pull/7553/head
hius07 3 years ago committed by GitHub
parent 7092df7f4e
commit d879062eeb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,4 +1,5 @@
local BD = require("ui/bidi")
local Blitbuffer = require("ffi/blitbuffer")
local Button = require("ui/widget/button")
local CenterContainer = require("ui/widget/container/centercontainer")
local ConfirmBox = require("ui/widget/confirmbox")
@ -641,6 +642,7 @@ function ReaderToc:onShowToc()
local items_per_page = G_reader_settings:readSetting("toc_items_per_page") or self.toc_items_per_page_default
local items_font_size = G_reader_settings:readSetting("toc_items_font_size") or Menu.getItemFontSize(items_per_page)
local items_show_separator = G_reader_settings:isTrue("toc_items_show_separator")
-- Estimate expand/collapse icon size
-- *2/5 to acount for Menu top title and bottom icons, and add some air between consecutive icons
local icon_size = math.floor(Screen:getHeight() / items_per_page * 2/5)
@ -698,7 +700,7 @@ function ReaderToc:onShowToc()
align_baselines = true,
items_per_page = items_per_page,
items_font_size = items_font_size,
line_color = require("ffi/blitbuffer").COLOR_WHITE,
line_color = items_show_separator and Blitbuffer.COLOR_DARK_GRAY or Blitbuffer.COLOR_WHITE,
on_close_ges = {
GestureRange:new{
ges = "two_finger_swipe",
@ -1051,6 +1053,16 @@ Enabling this option will restrict display to the chapter titles of progress bar
UIManager:show(items_font)
end,
}
menu_items.toc_items_show_separator = {
text = _("Add a separator between ToC entries"),
keep_menu_open = true,
checked_func = function()
return G_reader_settings:isTrue("toc_items_show_separator")
end,
callback = function()
G_reader_settings:flipNilOrFalse("toc_items_show_separator")
end
}
end
return ReaderToc

@ -33,6 +33,7 @@ local order = {
"----------------------------",
"toc_items_per_page",
"toc_items_font_size",
"toc_items_show_separator",
"----------------------------",
"bookmarks_items_per_page",
"bookmarks_items_font_size",

Loading…
Cancel
Save