From 405cea6a6057eb5e247aa1efe529d6b3cc8afc2f Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 14 Dec 2017 14:49:51 +1000 Subject: [PATCH] add context menu to browser --- aqt/browser.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/aqt/browser.py b/aqt/browser.py index 0bf59f6a2..6fe2dcc6d 100644 --- a/aqt/browser.py +++ b/aqt/browser.py @@ -450,6 +450,19 @@ class Browser(QMainWindow): runHook('browser.setupMenus', self) self.mw.maybeHideAccelerators(self) + # context menu + self.form.tableView.setContextMenuPolicy(Qt.CustomContextMenu) + self.form.tableView.customContextMenuRequested.connect(self.onContextMenu) + + def onContextMenu(self, _point): + m = QMenu() + for act in self.form.menu_Cards.actions(): + m.addAction(act) + m.addSeparator() + for act in self.form.menu_Notes.actions(): + m.addAction(act) + m.exec_(QCursor.pos()) + def updateFont(self): # we can't choose different line heights efficiently, so we need # to pick a line height big enough for any card template