mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
Show notes when clicking on category items in the book details panel
This commit is contained in:
parent
b5b4162ff3
commit
d78bd8971d
@ -1246,6 +1246,8 @@ class BookDetails(DetailsLayout): # {{{
|
||||
|
||||
def handle_click(self, link):
|
||||
typ, val = link.partition(':')[::2]
|
||||
from calibre.gui2.ui import get_gui
|
||||
db = get_gui().current_db.new_api
|
||||
|
||||
def search_term(field, val):
|
||||
append = ''
|
||||
@ -1270,9 +1272,17 @@ class BookDetails(DetailsLayout): # {{{
|
||||
data = json_loads(from_hex_bytes(val))
|
||||
dt = data['type']
|
||||
if dt == 'search':
|
||||
field = data.get('field')
|
||||
if field and db.field_supports_notes(field):
|
||||
item_id = db.get_item_id(field, data['value'])
|
||||
if item_id is not None and db.notes_for(field, item_id):
|
||||
return self.show_notes(field, item_id)
|
||||
search_term(data['term'], data['value'])
|
||||
elif dt == 'author':
|
||||
url = data['url']
|
||||
item_id = db.get_item_id('authors', data['name'])
|
||||
if item_id is not None and db.notes_for('authors', item_id):
|
||||
return self.show_notes('authors', item_id)
|
||||
if url == 'calibre':
|
||||
search_term('authors', data['name'])
|
||||
else:
|
||||
@ -1292,6 +1302,11 @@ class BookDetails(DetailsLayout): # {{{
|
||||
else:
|
||||
browse(link)
|
||||
|
||||
def show_notes(self, field, item_id):
|
||||
from calibre.gui2.dialogs.show_category_note import ShowNoteDialog
|
||||
from calibre.gui2.ui import get_gui
|
||||
ShowNoteDialog(field, item_id, get_gui().current_db.new_api, parent=self).show()
|
||||
|
||||
def mouseDoubleClickEvent(self, ev):
|
||||
ev.accept()
|
||||
self.show_book_info.emit()
|
||||
|
@ -61,7 +61,7 @@ class ShowNoteDialog(Dialog):
|
||||
x = prepare_string_for_xml
|
||||
src = x(self.item_val)
|
||||
if self.item_link:
|
||||
src = f'<a href="{x(self.item_link, True)}">{src}</a>'
|
||||
src = f'<a href="{x(self.item_link, True)}" style="text-decoration: none">{src}</a>'
|
||||
if self.extra_link:
|
||||
link_markup = '<img valign="bottom" src="calibre-icon:///external-link.png" width=24 height=24>'
|
||||
src += f' <a style="text-decoration: none" href="{x(self.extra_link, True)}" title="{x(self.extra_link_tooltip, True)}">{link_markup}</a>'
|
||||
|
Loading…
x
Reference in New Issue
Block a user