Hide right click copy option in deck list (#3363)

* hide copy if nothing selected

* Update CONTRIBUTORS

* type hint

* Update CONTRIBUTORS
This commit is contained in:
bpnguyen107 2024-08-16 23:18:46 -07:00 committed by GitHub
parent c99b50c82f
commit f2adf5d9ad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -379,11 +379,15 @@ class AnkiWebView(QWebEngineView):
def contextMenuEvent(self, evt: QContextMenuEvent) -> None:
m = QMenu(self)
a = m.addAction(tr.actions_copy())
qconnect(a.triggered, self.onCopy)
self._maybe_add_copy_action(m)
gui_hooks.webview_will_show_context_menu(self, m)
m.popup(QCursor.pos())
def _maybe_add_copy_action(self, menu: QMenu) -> None:
if self.hasSelection():
a = menu.addAction(tr.actions_copy())
qconnect(a.triggered, self.onCopy)
def dropEvent(self, evt: QDropEvent) -> None:
if self.allow_drops:
super().dropEvent(evt)