Exemplo n.º 1
0
def toggle_search_highlights(browser: Browser, checked: bool):
    """Toggle search highlights on or off"""
    browser._highlight_results = checked
    if not checked:
        clear_highlights(browser.editor.web)
    else:
        on_browser_did_change_row(browser)
Exemplo n.º 2
0
def on_browser_menus_did_init(browser: Browser):
    """Setup menu entries and hotkeys"""
    browser._highlight_results = config["local"]["highlight_by_default"]

    try:
        # used by multiple add-ons, so we check for its existence first
        menu = browser.menuView
    except AttributeError:
        browser.menuView = QMenu("&View")
        browser.menuBar().insertMenu(browser.mw.form.menuTools.menuAction(),
                                     browser.menuView)
        menu = browser.menuView

    menu.addSeparator()

    a = menu.addAction("Highlight Search Results")
    a.setCheckable(True)
    a.setChecked(browser._highlight_results)
    a.setShortcut(QKeySequence(config["local"]["hotkey_toggle_highlights"]))
    a.toggled.connect(
        lambda toggled: toggle_search_highlights(browser, toggled))