Fix focus not returning to popup book details window after show notes

This commit is contained in:
Kovid Goyal 2023-10-27 20:14:10 +05:30
parent e1acdb6237
commit 1bbd823c32
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 11 additions and 6 deletions

View File

@ -66,7 +66,7 @@ class ShowBookDetailsAction(InterfaceAction):
self.dialogs[dn] = None
try:
d = BookInfo(self.gui, self.gui.library_view, index,
self.gui.book_details.handle_click, dialog_number=dn,
self.gui.book_details.handle_click_from_popup, dialog_number=dn,
library_id=library_id, library_path=library_path, book_id=book_id)
except ValueError as e:
error_dialog(self.gui, _('Book not found'), str(e)).exec()

View File

@ -1314,7 +1314,8 @@ class BookDetails(DetailsLayout): # {{{
url = url_for_author_search(data.where, author=data.author)
safe_open_url(url)
def handle_click(self, link):
def handle_click_from_popup(self, link, parent=None):
parent = parent or self
typ, val = link.partition(':')[::2]
from calibre.gui2.ui import get_gui
db = get_gui().current_db.new_api
@ -1370,14 +1371,17 @@ class BookDetails(DetailsLayout): # {{{
if field and db.field_supports_notes(field):
item_id = data['item_id']
if item_id is not None and db.notes_for(field, item_id):
return self.show_notes(field, item_id)
return self.show_notes(field, item_id, parent)
else:
browse(link)
def show_notes(self, field, item_id):
def handle_click(self, link):
self.handle_click_from_popup(link)
def show_notes(self, field, item_id, parent=None):
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()
ShowNoteDialog(field, item_id, get_gui().current_db.new_api, parent=parent or self).show()
def mouseDoubleClickEvent(self, ev):
ev.accept()

View File

@ -303,7 +303,7 @@ class BookInfo(QDialog):
def on_link_clicked(self, qurl):
link = str(qurl.toString(NO_URL_FORMATTING))
self.link_delegate(link)
self.link_delegate(link, self)
def done(self, r):
self.save_geometry(gprefs, self.geometry_string('book_info_dialog_geometry'))

View File

@ -129,6 +129,7 @@ class ShowNoteDialog(Dialog):
if gui is not None:
gui.do_field_item_value_changed()
self.refresh()
self.setFocus(Qt.FocusReason.OtherFocusReason)
def find_books(self):
q = self.item_val.replace('"', r'\"')