From 29076ec9ec5e62b60cd4dc032c369e6018dfa570 Mon Sep 17 00:00:00 2001 From: bluegreenmagick Date: Wed, 3 Mar 2021 12:17:56 +0900 Subject: [PATCH] add context menu to open ankiweb page --- qt/aqt/addons.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/qt/aqt/addons.py b/qt/aqt/addons.py index 9fba37947..0459df6eb 100644 --- a/qt/aqt/addons.py +++ b/qt/aqt/addons.py @@ -1152,9 +1152,11 @@ class ChooseAddonsToUpdateList(QListWidget): ) self.ignore_check_evt = False self.setup() + self.setContextMenuPolicy(Qt.CustomContextMenu) qconnect(self.itemClicked, self.on_click) qconnect(self.itemChanged, self.on_check) qconnect(self.itemDoubleClicked, self.on_double_click) + qconnect(self.customContextMenuRequested, self.on_context_menu) def setup(self) -> None: header_item = QListWidgetItem("", self) @@ -1208,6 +1210,14 @@ class ChooseAddonsToUpdateList(QListWidget): self.check_item(self.header_item, self.bool_to_check(not checked)) self.header_checked(self.bool_to_check(not checked)) + def on_context_menu(self, point: QPoint) -> None: + item = self.itemAt(point) + addon_id = item.data(self.ADDON_ID_ROLE) + m = QMenu() + a = m.addAction(tr(TR.ADDONS_VIEW_ADDON_PAGE)) + qconnect(a.triggered, lambda _: openLink(f"{aqt.appShared}info/{addon_id}")) + m.exec_(QCursor.pos()) + def check_item(self, item: QListWidgetItem, check: Qt.CheckState) -> None: "call item.setCheckState without triggering on_check" self.ignore_check_evt = True