mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Minor changes to PageBrowser/BookMap/ReaderHandmade (#13691)
ReaderHandmade new features: Long-press to bypass input dialog for adding custom TOC chapters via highlight dialog in Reader. Custom TOC input dialog initial cursor position in front of text (for new chapter entries and 'Use selected text' option): facilitating input of chapter number. Book map new features: Separate 'Page browser on tap' setting for overview mode. Larger page-slot width adjustment via long-press on -/+. Page browser new features: Adjust 2 lines/columns at once via long-press on -/+. Add unnamed Custom TOC chapters bypassing input dialog via long-press on 'Start TOC chapter here'. readerthumbnail.lua: Fix reader menu staying open on Book map (overview) launch.
This commit is contained in:
@@ -404,6 +404,11 @@ function ReaderHandMade:updateHighlightDialog()
|
||||
this:onClose()
|
||||
self:addOrEditPageTocItem(nil, nil, selected_text)
|
||||
end,
|
||||
hold_callback = function() -- no dialog: directly creates new TOC item with selection (if none existing)
|
||||
local selected_text = this.selected_text
|
||||
this:onClose()
|
||||
self:addOrEditPageTocItem(nil, nil, selected_text, true)
|
||||
end,
|
||||
}
|
||||
end)
|
||||
else
|
||||
@@ -454,7 +459,7 @@ function ReaderHandMade:hasPageTocItem(pageno, xpointer)
|
||||
return is_match
|
||||
end
|
||||
|
||||
function ReaderHandMade:addOrEditPageTocItem(pageno, when_updated_callback, selected_text)
|
||||
function ReaderHandMade:addOrEditPageTocItem(pageno, when_updated_callback, selected_text, no_dialog)
|
||||
local xpointer, title
|
||||
if selected_text then
|
||||
-- If we get selected_text, it's from the highlight dialog after text selection
|
||||
@@ -484,12 +489,29 @@ function ReaderHandMade:addOrEditPageTocItem(pageno, when_updated_callback, sele
|
||||
depth = 1, -- we only support 1-level chapters to keep the UX simple
|
||||
}
|
||||
end
|
||||
if no_dialog then
|
||||
if item_found then return true end -- no changes if existing TOC entry
|
||||
if selected_text then -- via highlight dialog
|
||||
item.title = selected_text.text
|
||||
table.insert(self.toc, idx, item)
|
||||
self.ui:handleEvent(Event:new("UpdateToc"))
|
||||
else -- via Page browser
|
||||
item.title = ""
|
||||
table.insert(self.toc, idx, item)
|
||||
self.ui:handleEvent(Event:new("UpdateToc"))
|
||||
if when_updated_callback then
|
||||
when_updated_callback()
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
local dialog
|
||||
dialog = InputDialog:new{
|
||||
title = item_found and _("Edit custom TOC chapter") or _("Create new custom ToC chapter"),
|
||||
input = item.title,
|
||||
input_hint = _("TOC chapter title"),
|
||||
description = T(_([[On page %1.]]), pageno),
|
||||
cursor_at_end = item_found and true or false, -- cursor at start for new entries for easy manual addition of chapter number
|
||||
buttons = {
|
||||
{
|
||||
{
|
||||
@@ -532,7 +554,7 @@ function ReaderHandMade:addOrEditPageTocItem(pageno, when_updated_callback, sele
|
||||
text = _("Use selected text"),
|
||||
callback = function()
|
||||
-- Just replace the text without saving, to allow editing/fixing it
|
||||
dialog:setInputText(selected_text.text, nil, false)
|
||||
dialog:setInputText(selected_text.text, nil, true)
|
||||
end,
|
||||
} or nil,
|
||||
} or nil,
|
||||
|
||||
Reference in New Issue
Block a user