[Non-touch] Add a menu item to toggle a bookmark on the current page (#4262)

pull/4273/head
onde2rock 6 years ago committed by poire-z
parent 846f8bfa18
commit 53e7a0b6c9

@ -55,6 +55,14 @@ function ReaderBookmark:addToMainMenu(menu_items)
self:onShowBookmark()
end,
}
if not Device:isTouchDevice() then
menu_items.toggle_bookmark = {
text_func = function() return self:isCurrentPageBookmarked() and _("Remove bookmark for current page") or _("Bookmark current page") end,
callback = function()
self:onToggleBookmark()
end,
}
end
if self.ui.document.info.has_pages then
menu_items.bookmark_browsing_mode = {
text = self.bbm_menu_title,
@ -158,6 +166,16 @@ function ReaderBookmark:onSaveSettings()
self.ui.doc_settings:saveSetting("highlights_imported", true)
end
function ReaderBookmark:isCurrentPageBookmarked()
local pn_or_xp
if self.ui.document.info.has_pages then
pn_or_xp = self.view.state.page
else
pn_or_xp = self.ui.document:getXPointer()
end
return self:getDogearBookmarkIndex(pn_or_xp) and true or false
end
function ReaderBookmark:onToggleBookmark()
local pn_or_xp
if self.ui.document.info.has_pages then

@ -11,6 +11,7 @@ local order = {
navi = {
"table_of_contents",
"bookmarks",
"toggle_bookmark",
"bookmark_browsing_mode",
"----------------------------",
"go_to",

Loading…
Cancel
Save