From 750e34259a005ec01e730c450c316e11386f11d5 Mon Sep 17 00:00:00 2001 From: Charles Haley Date: Sun, 20 Apr 2025 16:56:53 +0100 Subject: [PATCH] Slight cleanup of the cleanup --- src/calibre/gui2/book_details.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/calibre/gui2/book_details.py b/src/calibre/gui2/book_details.py index 5253a82bf2..45c5d9b0a4 100644 --- a/src/calibre/gui2/book_details.py +++ b/src/calibre/gui2/book_details.py @@ -682,7 +682,7 @@ def details_context_menu_event(view, ev, book_info, add_popup_action=False, edit # position. Theory: on high-resolution displays, the outer right edge # can be a few real pixels to the right of the bounding box for the # anchor. As a result, Qt's chosen point isn't in the box. Compensate - # for that by moving the position 3 pixels to the right and see if an + # for that by moving the position slightly to the left and see if an # anchor is found and, if so, use it. When back-tabbing into an anchor, # Qt uses the left hand side of the bounding box, which isn't affected # by high density. Note that this compensation could cause Qt to find @@ -692,13 +692,14 @@ def details_context_menu_event(view, ev, book_info, add_popup_action=False, edit p = ev.pos() p += QPoint(-dpr, 0) url = view.anchorAt(p) - def pnt_to_str(p): - return f'{p.x()}, {p.y()}' - def rect_to_str(p): - return f'{p.x()}, {p.y()}, {p.width()}, {p.height()}' if DEBUG: - print(f'BD context menu pos. ev.pos: ({pnt_to_str(ev.pos())}), ' - f'new pos: ({pnt_to_str(p)}), cursor rect: ({rect_to_str(view.cursorRect())})') + def pnt_to_str(p): + return f'{p.x()}, {p.y()}' + def rect_to_str(p): + return f'{p.x()}, {p.y()}, {p.width()}, {p.height()}' + print(f'BD ctxt menu pos. ev.pos: ({pnt_to_str(ev.pos())}), ' + f'npos: ({pnt_to_str(p)}), cursor rect: ({rect_to_str(view.cursorRect())}), ' + f'has url: {bool(url)}') menu = QMenu(view) copy_menu = menu.addMenu(QIcon.ic('edit-copy.png'), _('Copy')) copy_menu.addAction(QIcon.ic('edit-copy.png'), _('All book details'), partial(copy_all, view))