mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
Add a find books button to search the calibre library for books with the category item
This commit is contained in:
parent
abe3deb186
commit
d22845828c
@ -13,6 +13,7 @@ from calibre.ebooks.metadata.book.render import render_author_link
|
|||||||
from calibre.gui2 import Application, default_author_link, safe_open_url
|
from calibre.gui2 import Application, default_author_link, safe_open_url
|
||||||
from calibre.gui2.book_details import resolved_css
|
from calibre.gui2.book_details import resolved_css
|
||||||
from calibre.gui2.dialogs.edit_category_notes import EditNoteDialog
|
from calibre.gui2.dialogs.edit_category_notes import EditNoteDialog
|
||||||
|
from calibre.gui2.ui import get_gui
|
||||||
from calibre.gui2.widgets2 import Dialog, HTMLDisplay
|
from calibre.gui2.widgets2 import Dialog, HTMLDisplay
|
||||||
|
|
||||||
|
|
||||||
@ -76,8 +77,16 @@ class ShowNoteDialog(Dialog):
|
|||||||
self.bb.clear()
|
self.bb.clear()
|
||||||
self.bb.addButton(QDialogButtonBox.StandardButton.Close)
|
self.bb.addButton(QDialogButtonBox.StandardButton.Close)
|
||||||
b = self.bb.addButton(_('&Edit'), QDialogButtonBox.ButtonRole.ActionRole)
|
b = self.bb.addButton(_('&Edit'), QDialogButtonBox.ButtonRole.ActionRole)
|
||||||
|
b.setIcon(QIcon.ic('edit_input.png'))
|
||||||
b.clicked.connect(self.edit)
|
b.clicked.connect(self.edit)
|
||||||
b.setToolTip(_('Edit this note'))
|
b.setToolTip(_('Edit this note'))
|
||||||
|
b = self.bb.addButton(_('Find &books'), QDialogButtonBox.ButtonRole.ActionRole)
|
||||||
|
b.setIcon(QIcon.ic('search.png'))
|
||||||
|
b.clicked.connect(self.find_books)
|
||||||
|
if self.field == 'authors':
|
||||||
|
b.setToolTip(_('Search the calibre library for books by: {}').format(self.item_val))
|
||||||
|
else:
|
||||||
|
b.setToolTip(_('Search the calibre library for books with: {}').format(self.item_val))
|
||||||
l.addWidget(self.bb)
|
l.addWidget(self.bb)
|
||||||
|
|
||||||
def sizeHint(self):
|
def sizeHint(self):
|
||||||
@ -91,6 +100,14 @@ class ShowNoteDialog(Dialog):
|
|||||||
if d.exec() == QDialog.DialogCode.Accepted:
|
if d.exec() == QDialog.DialogCode.Accepted:
|
||||||
self.refresh()
|
self.refresh()
|
||||||
|
|
||||||
|
def find_books(self):
|
||||||
|
q = self.item_val.replace('"', r'\"')
|
||||||
|
search_string = f'{self.field}:"={q}"'
|
||||||
|
gui = get_gui()
|
||||||
|
if gui is not None:
|
||||||
|
gui.apply_virtual_library()
|
||||||
|
gui.search.set_search_string(search_string)
|
||||||
|
|
||||||
|
|
||||||
def develop_show_note():
|
def develop_show_note():
|
||||||
from calibre.library import db as dbc
|
from calibre.library import db as dbc
|
||||||
|
Loading…
x
Reference in New Issue
Block a user