Ejemplo n.º 1
0
def showContextMenu(self):
    opts = [
        [_("Mark Note"), "*", self.onMark],
        [_("Bury Note"), "-", self.onBuryNote],
        [_("Suspend Card"), "@", self.onSuspendCard],
        [_("Suspend Note"), "!", self.onSuspend],
        [_("Delete Note"), "Delete", self.onDelete],
        [_("Options"), "O", self.onOptions],
        None,
        [_("Replay Audio"), "R", self.replayAudio],
        [_("Record Own Voice"), "Shift+V", self.onRecordVoice],
        [_("Replay Own Voice"), "V", self.onReplayRecorded],
    ]
    m = QMenu(self.mw)
    for row in opts:
        if not row:
            m.addSeparator()
            continue
        label, scut, func = row
        a = m.addAction(label)
        a.setShortcut(QKeySequence(scut))
        a.connect(a, SIGNAL("triggered()"), func)
        #Only change is the following statement
    runHook("Reviewer.contextMenuEvent", self, m)
    m.exec_(QCursor.pos())
Ejemplo n.º 2
0
    def onAdvanced(self):
        m = QMenu(self.mw)
        a = m.addAction(_("MathJax inline"))
        a.triggered.connect(self.insertMathjaxInline)
        a.setShortcut(QKeySequence("Ctrl+M, M"))
        a = m.addAction(_("MathJax block"))
        a.triggered.connect(self.insertMathjaxBlock)
        a.setShortcut(QKeySequence("Ctrl+M, E"))
        a = m.addAction(_("MathJax chemistry"))
        a.triggered.connect(self.insertMathjaxChemistry)
        a.setShortcut(QKeySequence("Ctrl+M, C"))
        a = m.addAction(_("LaTeX"))
        a.triggered.connect(self.insertLatex)
        a.setShortcut(QKeySequence("Ctrl+T, T"))
        a = m.addAction(_("LaTeX equation"))
        a.triggered.connect(self.insertLatexEqn)
        a.setShortcut(QKeySequence("Ctrl+T, E"))
        a = m.addAction(_("LaTeX math env."))
        a.triggered.connect(self.insertLatexMathEnv)
        a.setShortcut(QKeySequence("Ctrl+T, M"))
        a = m.addAction(_("Edit HTML"))
        a.triggered.connect(self.onHtmlEdit)
        a.setShortcut(QKeySequence("Ctrl+Shift+X"))

        qtMenuShortcutWorkaround(m)

        m.exec_(QCursor.pos())
Ejemplo n.º 3
0
    def onMore(self):
        m = QMenu(self)

        if not self._isCloze():
            a = m.addAction(_("Add Card Type..."))
            a.triggered.connect(self.onAddCard)

            a = m.addAction(_("Remove Card Type..."))
            a.triggered.connect(self.onRemove)

            a = m.addAction(_("Rename Card Type..."))
            a.triggered.connect(self.onRename)

            a = m.addAction(_("Reposition Card Type..."))
            a.triggered.connect(self.onReorder)

            m.addSeparator()

            t = self.card.template()
            if t['did']:
                s = _(" (on)")
            else:
                s = _(" (off)")
            a = m.addAction(_("Deck Override...") + s)
            a.triggered.connect(self.onTargetDeck)

        a = m.addAction(_("Browser Appearance..."))
        a.triggered.connect(self.onBrowserDisplay)

        m.exec_(self.topAreaForm.templateOptions.mapToGlobal(QPoint(0,0)))
Ejemplo n.º 4
0
def showContextMenu(self):
    opts = [
        [_("Mark Note"), "*", self.onMark],
        [_("Bury Note"), "-", self.onBuryNote],
        [_("Suspend Card"), "@", self.onSuspendCard],
        [_("Suspend Note"), "!", self.onSuspend],
        [_("Delete Note"), "Delete", self.onDelete],
        [_("Options"), "O", self.onOptions],
        None,
        [_("Replay Audio"), "R", self.replayAudio],
        [_("Record Own Voice"), "Shift+V", self.onRecordVoice],
        [_("Replay Own Voice"), "V", self.onReplayRecorded],
    ]
    m = QMenu(self.mw)
    for row in opts:
        if not row:
            m.addSeparator()
            continue
        label, scut, func = row
        a = m.addAction(label)
        a.setShortcut(QKeySequence(scut))
        a.connect(a, SIGNAL("triggered()"), func)
        #Only change is the following statement
    runHook("Reviewer.contextMenuEvent", self, m)
    m.exec_(QCursor.pos())
Ejemplo n.º 5
0
def clean_html_menu(editor):
    m = QMenu(editor.mw)
    if getUserOption("shortcut_editor_menu_wider_fields"):
        m.setStyleSheet(basic_stylesheet)
    for userconfig, text, func in template:
        cut = getUserOption(userconfig)
        if cut:
            text += f"({cut})"
        a = m.addAction(text)
        a.triggered.connect(lambda _, e=editor, f=func: f(e))
    m.exec_(QCursor.pos())
Ejemplo n.º 6
0
 def _showOptions(self, did):
     m = QMenu(self.mw)
     a = m.addAction(_("Rename"))
     a.triggered.connect(lambda b, did=did: self._rename(did))
     a = m.addAction(_("Options"))
     a.triggered.connect(lambda b, did=did: self._options(did))
     a = m.addAction(_("Export"))
     a.triggered.connect(lambda b, did=did: self._export(did))
     a = m.addAction(_("Delete"))
     a.triggered.connect(lambda b, did=did: self._delete(did))
     runHook("showDeckOptions", m, did)
     m.exec_(QCursor.pos())
def additional_menu_styled(editor):
    # mod of onAdvanced from editor.py
    config = getconfig()
    # QMenu(editor.mw) conflict with persistent editor, 1686259334 I get
    # RuntimeError: super-class __init__() of type AnkiQt was never called
    m = QMenu()
    a = m.addAction("Clear more formatting (Classes, etc.)")
    a.triggered.connect(lambda _: classes_addon_rangy_remove_all(editor))
    m.addSeparator()
    for e in config['v3']:
        if e.get('Show_in_menu', False):
            m.addAction(editor.create_menu_entry(e, m))
    m.exec_(QCursor.pos())
Ejemplo n.º 8
0
 def confOpts(self):
     m = QMenu(self.mw)
     a = m.addAction(_("Add"))
     a.triggered.connect(self.addGroup)
     a = m.addAction(_("Delete"))
     a.triggered.connect(self.remGroup)
     a = m.addAction(_("Rename"))
     a.triggered.connect(self.renameGroup)
     a = m.addAction(_("Set for all subdecks"))
     a.triggered.connect(self.setChildren)
     if not self.childDids:
         a.setEnabled(False)
     m.exec_(QCursor.pos())
Ejemplo n.º 9
0
 def onHistory(self):
     m = QMenu(self)
     for nid in self.history:
         if self.mw.col.findNotes("nid:%s" % nid):
             fields = self.mw.col.getNote(nid).fields
             txt = htmlToTextLine(", ".join(fields))
             if len(txt) > 30:
                 txt = txt[:30] + "..."
             a = m.addAction(_("Edit \"%s\"") % txt)
             a.triggered.connect(lambda b, nid=nid: self.editHistory(nid))
         else:
             a = m.addAction(_("(Note deleted)"))
             a.setEnabled(False)
     runHook("AddCards.onHistory", self, m)
     m.exec_(self.historyButton.mapToGlobal(QPoint(0, 0)))
def additional_menu_basic(editor):
    config = getconfig()
    # mod of onAdvanced from editor.py
    m = QMenu(editor.mw)
    # m.setStyleSheet(basic_stylesheet)
    m.setFont(QFont('Courier New', 11))
    a = m.addAction("Clear more formatting (Classes, etc.)")
    a.triggered.connect(lambda _: classes_addon_rangy_remove_all(editor))
    m.addSeparator()
    for e in config['v3']:
        if e.get('Show_in_menu', False):
            text = editor.my_label_text(e, False)
            a = m.addAction(text)
            cat = e["Category"]
            se = e.get("Setting", e.get("Category", False))
            a.triggered.connect(
                lambda _, a=cat, b=se: my_highlight_helper(editor, a, b))
    m.exec_(QCursor.pos())
Ejemplo n.º 11
0
 def popupOver(self, widget):
     qmenu = QMenu()
     self.renderTo(qmenu)
     qmenu.exec_(widget.mapToGlobal(QPoint(0,0)))