mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
E-book viewer: When suggesting a default bookmark title, use the name of the current chapter. Fixes #1851908 [Suggest a name for the bookmark](https://bugs.launchpad.net/calibre/+bug/1851908)
This commit is contained in:
parent
281ff268f8
commit
5f927e2ea0
@ -92,6 +92,7 @@ class BookmarkManager(QWidget):
|
||||
self.l = l = QGridLayout(self)
|
||||
l.setContentsMargins(0, 0, 0, 0)
|
||||
self.setLayout(l)
|
||||
self.toc = parent.toc
|
||||
|
||||
self.bookmarks_list = bl = BookmarksList(self)
|
||||
bl.itemChanged.connect(self.item_changed)
|
||||
@ -340,7 +341,7 @@ class BookmarkManager(QWidget):
|
||||
import_current_bookmarks(imported)
|
||||
|
||||
def create_new_bookmark(self, pos_data):
|
||||
base_default_title = _('Bookmark')
|
||||
base_default_title = self.toc.model().title_for_current_node or _('Bookmark')
|
||||
all_titles = {bm['title'] for bm in self.get_bookmarks()}
|
||||
c = 0
|
||||
while True:
|
||||
|
@ -227,7 +227,6 @@ class TOC(QStandardItemModel):
|
||||
for t in toc['children']:
|
||||
self.appendRow(TOCItem(t, 0, depth_first, normal_font, emphasis_font))
|
||||
self.node_id_map = {x.node_id: x for x in self.all_items}
|
||||
self.currently_viewed_entry = None
|
||||
|
||||
def find_items(self, query):
|
||||
for item in self.all_items:
|
||||
@ -284,6 +283,12 @@ class TOC(QStandardItemModel):
|
||||
def viewed_nodes(self):
|
||||
return tuple(node for node in self.all_items if node.is_being_viewed)
|
||||
|
||||
@property
|
||||
def title_for_current_node(self):
|
||||
for node in reversed(self.all_items):
|
||||
if node.is_being_viewed:
|
||||
return node.title
|
||||
|
||||
@property
|
||||
def as_plain_text(self):
|
||||
lines = []
|
||||
|
Loading…
x
Reference in New Issue
Block a user