def addContextMenu(ev: QCloseEvent, name: str, dc_instance) -> None:
    ev.accept()
    frm = mw.debug_diag_form
    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)

        ## ADDITION
        hist_window = menu.addAction("Open History Window")
        cut = gc("debug console: shortcut open history window", "ctrl+i")
        if cut:
            hist_window.setShortcuts(QKeySequence(cut))  # doesn't work
        qconnect(hist_window.triggered,
                 lambda _, d=dc_instance: history_helper(d))

        save = menu.addAction("Save Current")
        cut = gc("debug console: shortcut save", "ctrl+s")
        if cut:
            save.setShortcuts(QKeySequence(cut))  # doesn't work
        qconnect(save.triggered, lambda _, d=dc_instance: save_current(d))
    menu.exec(QCursor.pos())
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())
    def _on_app_focus_changed(self, old_widget: Optional[QWidget],
                              new_widget: Optional[QWidget]):
        focus_behavior = self._settings.focus_behavior
        focus_exceptions = self._settings.focus_behavior_exceptions
        parent_window = self.parent().window()
        old_window = old_widget.window() if old_widget else None
        new_window = new_widget.window() if new_widget else None

        if focus_exceptions and any(
                isinstance(old_window, wtype) for wtype in focus_exceptions):
            # switching back from an excluded window should not cause notif closing
            pass
        elif new_window is None and QApplication.widgetAt(
                QCursor.pos()) == self:
            # clicking on self should not dismiss notification when not configured as
            # such (Windows bug)
            pass
        elif new_window is None:
            # switched focus away from application
            self.close()
        elif new_window != parent_window and (not focus_exceptions or (all(
                not isinstance(new_window, wtype)
                for wtype in focus_exceptions))):
            # switched to other window within same application that's not excluded
            if focus_behavior == FocusBehavior.close_on_window_focus_lost:
                self.close()
            elif focus_behavior == FocusBehavior.lower_on_window_focus_lost:
                self.setWindowFlag(Qt.WindowType.ToolTip, on=False)
        elif (new_window == parent_window
              and focus_behavior == FocusBehavior.lower_on_window_focus_lost):
            self.setWindowFlag(Qt.WindowType.ToolTip, on=True)
            self.show()
Beispiel #4
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())
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())
Beispiel #6
0
 def test_executable(self) -> None:
     "Check to see if the TiddlyWiki executable provided can be called from Anki."
     # pylint: disable=no-member
     QApplication.setOverrideCursor(QCursor(Qt.CursorShape.WaitCursor))
     try:
         args = [self.form.tiddlywikiBinary_.text(), "--version"]
         proc = subprocess.run(args,
                               check=True,
                               stderr=subprocess.STDOUT,
                               stdout=subprocess.PIPE,
                               startupinfo=nowin_startupinfo())
     except FileNotFoundError:
         QApplication.restoreOverrideCursor()
         showCritical(
             "It doesn't look like that file exists on your computer. "
             "Try using the full path to 'tiddlywiki'.")
     except subprocess.CalledProcessError as e:
         QApplication.restoreOverrideCursor()
         showCritical(
             f"It's not quite working yet. Try seeing if you can run TiddlyWiki "
             f"from the command line and copy your command in here.\n\n"
             f"{e.output}")
     except Exception:
         QApplication.restoreOverrideCursor()
         raise
     else:
         QApplication.restoreOverrideCursor()
         showInfo(
             f"Successfully called TiddlyWiki {proc.stdout.decode().strip()}! "
             f"You're all set.")
Beispiel #7
0
 def contextMenuEvent(self, evt):
     m = QMenu(self)
     a = m.addAction(_("Cut"))
     a.triggered.connect(self.onCut)
     a = m.addAction(_("Copy"))
     a.triggered.connect(self.onCopy)
     a = m.addAction(_("Paste"))
     a.triggered.connect(self.onPaste)
     runHook("EditorWebView.contextMenuEvent", self, m)
     m.popup(QCursor.pos())
Beispiel #8
0
def _on_transcription_button(self):
    """
    Executed when the button on the right top of the editor is pressed.
    Creates popup menu with different phonetics symbols to print.
    """
    m = QMenu(self.mw)
    symbols = "æɑɒɔəɜɪʊʌθðŋɹɫʃʒʍʔ"
    for s in symbols:
        a = m.addAction(_(s))
        a.triggered.connect(lambda ign, _s=s: self.doPaste(_s, True))
    m.popup(QCursor.pos())
Beispiel #9
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())
 def make_new_context_menu(self, location):
     if self.tform.front_button.isChecked():
         boxname = "front"
     elif self.tform.back_button.isChecked():
         boxname = "back"
     else:
         boxname = "css"
     tedit = self.tform.edit_area
     menu = tedit.createStandardContextMenu()
     menu = options_to_contextmenu(self, tedit, boxname, menu)
     menu.exec_(QCursor.pos())
Beispiel #11
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 make_new_context_menu(self, location):
     if self.tform.front_button.isChecked():
         boxname = "front"
     elif self.tform.back_button.isChecked():
         boxname = "back"
     else:
         boxname = "css"
     tedit = self.tform.edit_area
     menu = tedit.createStandardContextMenu()
     c = menu.addAction("edit in external text editor")
     c.triggered.connect(lambda _, s=self: editExternal(s, boxname, tedit))
     menu.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())
Beispiel #14
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())
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())
Beispiel #16
0
def mystart(*args: Any, **kwargs: Any) -> Optional[ProgressDialog]:
    global myprogress
    _old = kwargs.pop("_old")
    if "parent" in kwargs:
        parent = kwargs["parent"]
    elif len(args) > 4:
        parent = args[4]  # Position of 'parent' parameter.
    else:
        parent = None

    if parent == "EFDRCsemiedit":
        # Don't show progress window when pasting images while in review.
        myprogress = True
        mw.app.setOverrideCursor(QCursor(Qt.WaitCursor))
        return None
    else:
        myprogress = False
        return _old(*args, **kwargs)
Beispiel #17
0
 def contextMenuEvent(self, evt):
     m = QMenu(self)
     a = m.addAction(_("Copy"))
     a.triggered.connect(self.onCopy)
     runHook("AnkiWebView.contextMenuEvent", self, m)
     m.popup(QCursor.pos())
 def make_context_menu_back(self, location):
     menu = self.common_context_menu(self.tform.back, "back")
     menu.exec_(QCursor.pos())
 def make_context_menu_css(self, location):
     menu = self.common_context_menu(self.tform.css, "css")
     menu.exec_(QCursor.pos())
 def make_context_menu_front(self, location):
     menu = self.common_context_menu(self.tform.front, "front")
     menu.exec_(QCursor.pos())
Beispiel #21
0
 def _setBusy(self):
     self.mw.app.setOverrideCursor(QCursor(Qt.WaitCursor))