mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
[Non-touch] Add a menu item to toggle a bookmark on the current page (#4262)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user