mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
add clear actions to context menu in debug console
This commit is contained in:
parent
92fbe3bfba
commit
653f5765b8
1 changed files with 17 additions and 0 deletions
|
@ -1356,6 +1356,23 @@ will be lost. Continue?"""
|
||||||
s.activated.connect(frm.log.clear)
|
s.activated.connect(frm.log.clear)
|
||||||
s = self.debugDiagShort = QShortcut(QKeySequence("ctrl+shift+l"), d)
|
s = self.debugDiagShort = QShortcut(QKeySequence("ctrl+shift+l"), d)
|
||||||
s.activated.connect(frm.text.clear)
|
s.activated.connect(frm.text.clear)
|
||||||
|
|
||||||
|
def addContextMenu(ev: QCloseEvent, name: str) -> None:
|
||||||
|
ev.accept()
|
||||||
|
menu = frm.log.createStandardContextMenu(QCursor.pos())
|
||||||
|
menu.addSeparator()
|
||||||
|
if name == "log":
|
||||||
|
a = menu.addAction(_("Clear Log"))
|
||||||
|
a.setShortcuts(QKeySequence("ctrl+l"))
|
||||||
|
qconnect(a.triggered, frm.log.clear)
|
||||||
|
elif name == "text":
|
||||||
|
a = menu.addAction(_("Clear Code"))
|
||||||
|
a.setShortcuts(QKeySequence("ctrl+shift+l"))
|
||||||
|
qconnect(a.triggered, frm.text.clear)
|
||||||
|
menu.exec(QCursor.pos())
|
||||||
|
|
||||||
|
frm.log.contextMenuEvent = lambda ev: addContextMenu(ev, "log")
|
||||||
|
frm.text.contextMenuEvent = lambda ev: addContextMenu(ev, "text")
|
||||||
gui_hooks.debug_console_will_show(d)
|
gui_hooks.debug_console_will_show(d)
|
||||||
d.show()
|
d.show()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue