Slight cleanup of the cleanup

This commit is contained in:
Charles Haley 2025-04-20 16:56:53 +01:00
parent 804ec31459
commit 750e34259a

View File

@ -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))