hidden flows removed from non-touch

reviewable/pr11690/r1
SomeGuy 4 weeks ago committed by GitHub
parent 12552f1c71
commit cbd5534259
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,4 +1,5 @@
local ConfirmBox = require("ui/widget/confirmbox") local ConfirmBox = require("ui/widget/confirmbox")
local Device = require("device")
local Event = require("ui/event") local Event = require("ui/event")
local InfoMessage = require("ui/widget/infomessage") local InfoMessage = require("ui/widget/infomessage")
local InputDialog = require("ui/widget/inputdialog") local InputDialog = require("ui/widget/inputdialog")
@ -119,186 +120,189 @@ function ReaderHandMade:onToggleHandmadeFlows()
end end
function ReaderHandMade:addToMainMenu(menu_items) function ReaderHandMade:addToMainMenu(menu_items)
menu_items.handmade_toc = { if Device:isTouchDevice() then
text = _("Custom table of contents") .. " " .. self.custom_toc_symbol, menu_items.handmade_toc = {
checked_func = function() return self.toc_enabled end, text = _("Custom table of contents") .. " " .. self.custom_toc_symbol,
callback = function() checked_func = function() return self.toc_enabled end,
self:onToggleHandmadeToc() callback = function()
end, self:onToggleHandmadeToc()
} end,
menu_items.handmade_hidden_flows = { }
text = _("Custom hidden flows"), menu_items.handmade_hidden_flows = {
checked_func = function() return self.flows_enabled end, text = _("Custom hidden flows"),
callback = function() checked_func = function() return self.flows_enabled end,
self:onToggleHandmadeFlows() callback = function()
end, self:onToggleHandmadeFlows()
} end,
--[[ Not yet implemented }
menu_items.handmade_page_numbers = { --[[ Not yet implemented
text = _("Custom page numbers"), menu_items.handmade_page_numbers = {
checked_func = function() return false end, text = _("Custom page numbers"),
callback = function() checked_func = function() return false end,
end, callback = function()
} end,
]]-- }
menu_items.handmade_settings = { ]]--
text = _("Custom layout features"), menu_items.handmade_settings = {
sub_item_table_func = function() text = _("Custom layout features"),
return { sub_item_table_func = function()
{ return {
text = _("About custom table of contents") .. " " .. self.custom_toc_symbol, {
callback = function() text = _("About custom table of contents") .. " " .. self.custom_toc_symbol,
UIManager:show(InfoMessage:new{ callback = function()
text = _([[ UIManager:show(InfoMessage:new{
If the book has no table of contents or you would like to substitute it with your own, you can create a custom TOC. The original TOC (if available) will not be altered. text = _([[
If the book has no table of contents or you would like to substitute it with your own, you can create a custom TOC. The original TOC (if available) will not be altered.
You can create, edit and remove chapters: You can create, edit and remove chapters:
- in Page browser, by long-pressing on a thumbnail; - in Page browser, by long-pressing on a thumbnail;
- on a book page, by selecting some text to be used as the chapter title. - on a book page, by selecting some text to be used as the chapter title.
(Once you're done building it and don't want to see the buttons anymore, you can disable Edit mode.) (Once you're done building it and don't want to see the buttons anymore, you can disable Edit mode.)
This custom table of contents is currently limited to a single level and can't have sub-chapters.]]) This custom table of contents is currently limited to a single level and can't have sub-chapters.]])
}) })
end, end,
keep_menu_open = true, keep_menu_open = true,
}, },
{ {
text = _("Edit mode"), text = _("Edit mode"),
enabled_func = function() enabled_func = function()
return self:isHandmadeTocEnabled() return self:isHandmadeTocEnabled()
end, end,
checked_func = function() checked_func = function()
return self:isHandmadeTocEditEnabled() return self:isHandmadeTocEditEnabled()
end, end,
callback = function() callback = function()
self.toc_edit_enabled = not self.toc_edit_enabled self.toc_edit_enabled = not self.toc_edit_enabled
self:updateHighlightDialog() self:updateHighlightDialog()
end, end,
}, },
--[[ Not yet implemented --[[ Not yet implemented
{ {
text = _("Add multiple chapter start page numbers"), text = _("Add multiple chapter start page numbers"),
}, },
]]-- ]]--
{ {
text = _("Clear custom table of contents"), text = _("Clear custom table of contents"),
enabled_func = function() enabled_func = function()
return #self.toc > 0 return #self.toc > 0
end, end,
callback = function(touchmenu_instance) callback = function(touchmenu_instance)
UIManager:show(ConfirmBox:new{ UIManager:show(ConfirmBox:new{
text = _("Are you sure you want to clear your custom table of contents?"), text = _("Are you sure you want to clear your custom table of contents?"),
ok_callback = function() ok_callback = function()
self.toc = {} self.toc = {}
self.ui:handleEvent(Event:new("UpdateToc")) self.ui:handleEvent(Event:new("UpdateToc"))
-- The footer may be visible, so have it update its chapter related items -- The footer may be visible, so have it update its chapter related items
self.view.footer:onUpdateFooter(self.view.footer_visible) self.view.footer:onUpdateFooter(self.view.footer_visible)
if touchmenu_instance then if touchmenu_instance then
touchmenu_instance:updateItems() touchmenu_instance:updateItems()
end end
end, end,
}) })
end, end,
keep_menu_open = true, keep_menu_open = true,
separator = true, separator = true,
}, },
{ {
text = _("About custom hidden flows"), text = _("About custom hidden flows"),
callback = function() callback = function()
UIManager:show(InfoMessage:new{ UIManager:show(InfoMessage:new{
text = _([[ text = _([[
Custom hidden flows can be created to exclude sections of the book from your normal reading flow: Custom hidden flows can be created to exclude sections of the book from your normal reading flow:
- hidden flows will automatically be skipped when turning pages within the regular flow; - hidden flows will automatically be skipped when turning pages within the regular flow;
- pages part of hidden flows are assigned distinct page numbers and won't be considered in the various book & chapter progress and time to read features; - pages part of hidden flows are assigned distinct page numbers and won't be considered in the various book & chapter progress and time to read features;
- following direct links to pages in hidden flows will still work, including from the TOC or Book map. - following direct links to pages in hidden flows will still work, including from the TOC or Book map.
This can be useful to exclude long footnotes or bibliography sections. This can be useful to exclude long footnotes or bibliography sections.
It can also be handy when interested in reading only a subset of a book. It can also be handy when interested in reading only a subset of a book.
In Page browser, you can long-press on a thumbnail to start a hidden flow or restart the regular flow on this page. In Page browser, you can long-press on a thumbnail to start a hidden flow or restart the regular flow on this page.
(Once you're done building it and don't want to see the button anymore, you can disable Edit mode.) (Once you're done building it and don't want to see the button anymore, you can disable Edit mode.)
Hidden flows are shown with gray or hatched background in Book map and Page browser.]]) Hidden flows are shown with gray or hatched background in Book map and Page browser.]])
}) })
end, end,
keep_menu_open = true, keep_menu_open = true,
}, },
{ {
text = _("Edit mode"), text = _("Edit mode"),
enabled_func = function() enabled_func = function()
return self:isHandmadeHiddenFlowsEnabled() return self:isHandmadeHiddenFlowsEnabled()
end, end,
checked_func = function() checked_func = function()
return self:isHandmadeHiddenFlowsEditEnabled() return self:isHandmadeHiddenFlowsEditEnabled()
end, end,
callback = function() callback = function()
self.flows_edit_enabled = not self.flows_edit_enabled self.flows_edit_enabled = not self.flows_edit_enabled
end, end,
}, },
{ {
text_func = function() text_func = function()
return T(_("Clear inactive marked pages (%1)"), #self.inactive_flow_points) return T(_("Clear inactive marked pages (%1)"), #self.inactive_flow_points)
end, end,
enabled_func = function() enabled_func = function()
return #self.inactive_flow_points > 0 return #self.inactive_flow_points > 0
end, end,
callback = function(touchmenu_instance) callback = function(touchmenu_instance)
UIManager:show(ConfirmBox:new{ UIManager:show(ConfirmBox:new{
text = _("Inactive marked pages are pages that you tagged as start hidden flow or restart regular flow, but that other marked pages made them have no effect.\nAre you sure you want to clear them?"), text = _("Inactive marked pages are pages that you tagged as start hidden flow or restart regular flow, but that other marked pages made them have no effect.\nAre you sure you want to clear them?"),
ok_callback = function() ok_callback = function()
for i=#self.inactive_flow_points, 1, -1 do for i=#self.inactive_flow_points, 1, -1 do
table.remove(self.flow_points, self.inactive_flow_points[i]) table.remove(self.flow_points, self.inactive_flow_points[i])
end end
self:updateDocFlows() self:updateDocFlows()
self.ui:handleEvent(Event:new("UpdateToc")) self.ui:handleEvent(Event:new("UpdateToc"))
self.ui:handleEvent(Event:new("InitScrollPageStates")) self.ui:handleEvent(Event:new("InitScrollPageStates"))
-- The footer may be visible, so have it update its dependant items -- The footer may be visible, so have it update its dependant items
self.view.footer:onUpdateFooter(self.view.footer_visible) self.view.footer:onUpdateFooter(self.view.footer_visible)
if touchmenu_instance then if touchmenu_instance then
touchmenu_instance:updateItems() touchmenu_instance:updateItems()
end end
end, end,
}) })
end, end,
keep_menu_open = true, keep_menu_open = true,
}, },
{ {
text = _("Clear all marked pages"), text = _("Clear all marked pages"),
enabled_func = function() enabled_func = function()
return #self.flow_points > 0 return #self.flow_points > 0
end, end,
callback = function(touchmenu_instance) callback = function(touchmenu_instance)
UIManager:show(ConfirmBox:new{ UIManager:show(ConfirmBox:new{
text = _("Are you sure you want to clear all your custom hidden flows?"), text = _("Are you sure you want to clear all your custom hidden flows?"),
ok_callback = function() ok_callback = function()
self.flow_points = {} self.flow_points = {}
self:updateDocFlows() self:updateDocFlows()
self.ui:handleEvent(Event:new("UpdateToc")) self.ui:handleEvent(Event:new("UpdateToc"))
self.ui:handleEvent(Event:new("InitScrollPageStates")) self.ui:handleEvent(Event:new("InitScrollPageStates"))
-- The footer may be visible, so have it update its dependant items -- The footer may be visible, so have it update its dependant items
self.view.footer:onUpdateFooter(self.view.footer_visible) self.view.footer:onUpdateFooter(self.view.footer_visible)
if touchmenu_instance then if touchmenu_instance then
touchmenu_instance:updateItems() touchmenu_instance:updateItems()
end end
end, end,
}) })
end, end,
keep_menu_open = true, keep_menu_open = true,
separator = true, separator = true,
}, },
--[[ Not yet implemented --[[ Not yet implemented
{ {
text = _("About custom page numbers"), text = _("About custom page numbers"),
}, },
{ {
text = _("Clear custom page numbers"), text = _("Clear custom page numbers"),
}, },
]]-- ]]--
} }
end, end,
} }
end
end end
function ReaderHandMade:updateHandmagePages() function ReaderHandMade:updateHandmagePages()
if not self.ui.rolling then if not self.ui.rolling then
return return
@ -338,8 +342,10 @@ function ReaderHandMade:onDocumentRerendered()
-- Called with CRE document when partial rerendering not enabled -- Called with CRE document when partial rerendering not enabled
self:updateHandmagePages() self:updateHandmagePages()
-- Don't have these send events their own events -- Don't have these send events their own events
self:setupFlows(true) if Device:isTouchDevice() then
self:setupToc(true) self:setupFlows(true)
self:setupToc(true)
end
-- ReaderToc will process this event just after us, and will -- ReaderToc will process this event just after us, and will
-- call its onUpdateToc: we don't need to send it. -- call its onUpdateToc: we don't need to send it.
-- (Also, no need for InitScrollPageStates with CRE.) -- (Also, no need for InitScrollPageStates with CRE.)

Loading…
Cancel
Save