How to use the qutebrowser.config.config.val function in qutebrowser

To help you get started, we’ve selected a few qutebrowser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github qutebrowser / qutebrowser / qutebrowser / browser / hints.py View on Github external
def click(self, elem: webelem.AbstractWebElement,
              context: HintContext) -> None:
        """Click an element."""
        target_mapping = {
            Target.normal: usertypes.ClickTarget.normal,
            Target.current: usertypes.ClickTarget.normal,
            Target.tab_fg: usertypes.ClickTarget.tab,
            Target.tab_bg: usertypes.ClickTarget.tab_bg,
            Target.window: usertypes.ClickTarget.window,
        }
        if config.val.tabs.background:
            target_mapping[Target.tab] = usertypes.ClickTarget.tab_bg
        else:
            target_mapping[Target.tab] = usertypes.ClickTarget.tab

        if context.target in [Target.normal, Target.current]:
            # Set the pre-jump mark ', so we can jump back here after following
            context.tab.scroller.before_jump_requested.emit()

        try:
            if context.target == Target.hover:
                elem.hover()
            elif context.target == Target.right_click:
                elem.right_click()
            elif context.target == Target.current:
                elem.remove_blank_target()
                elem.click(target_mapping[context.target])
github qutebrowser / qutebrowser / qutebrowser / browser / webkit / cookies.py View on Github external
def _on_cookies_store_changed(self):
        """Delete stored cookies if cookies.store changed."""
        if not config.val.content.cookies.store:
            self._lineparser.data = []
            self._lineparser.save()
            self.changed.emit()
github qutebrowser / qutebrowser / qutebrowser / mainwindow / tabbedbrowser.py View on Github external
def undo(self):
        """Undo removing of a tab or tabs."""
        # Remove unused tab which may be created after the last tab is closed
        last_close = config.val.tabs.last_close
        use_current_tab = False
        if last_close in ['blank', 'startpage', 'default-page']:
            only_one_tab_open = self.widget.count() == 1
            no_history = len(self.widget.widget(0).history) == 1
            urls = {
                'blank': QUrl('about:blank'),
                'startpage': config.val.url.start_pages[0],
                'default-page': config.val.url.default_page,
            }
            first_tab_url = self.widget.widget(0).url()
            last_close_urlstr = urls[last_close].toString().rstrip('/')
            first_tab_urlstr = first_tab_url.toString().rstrip('/')
            last_close_url_used = first_tab_urlstr == last_close_urlstr
            use_current_tab = (only_one_tab_open and no_history and
                               last_close_url_used)
github qutebrowser / qutebrowser / qutebrowser / misc / editor.py View on Github external
def _create_tempfile(self, text, prefix):
        # Close while the external process is running, as otherwise systems
        # with exclusive write access (e.g. Windows) may fail to update
        # the file from the external editor, see
        # https://github.com/qutebrowser/qutebrowser/issues/1767
        with tempfile.NamedTemporaryFile(
                mode='w', prefix=prefix,
                encoding=config.val.editor.encoding,
                delete=False) as fobj:
            if text:
                fobj.write(text)
            return fobj.name
github qutebrowser / qutebrowser / qutebrowser / browser / browsertab.py View on Github external
def should_show_icon(self) -> bool:
        return (config.val.tabs.favicons.show == 'always' or
                config.val.tabs.favicons.show == 'pinned' and self.pinned)
github qutebrowser / qutebrowser / qutebrowser / mainwindow / tabwidget.py View on Github external
def _set_font(self):
        """Set the tab bar font."""
        self.setFont(config.val.fonts.tabs)
        self._set_icon_size()
        # clear tab size cache
        self._minimum_tab_size_hint_helper.cache_clear()
        self._minimum_tab_height.cache_clear()
github qutebrowser / qutebrowser / qutebrowser / browser / shared.py View on Github external
def get_user_stylesheet(searching=False):
    """Get the combined user-stylesheet."""
    css = ''
    stylesheets = config.val.content.user_stylesheets

    for filename in stylesheets:
        with open(filename, 'r', encoding='utf-8') as f:
            css += f.read()

    if (config.val.scrolling.bar == 'never' or
            config.val.scrolling.bar == 'when-searching' and not searching):
        css += '\nhtml > ::-webkit-scrollbar { width: 0px; height: 0px; }'

    return css
github qutebrowser / qutebrowser / qutebrowser / browser / browsertab.py View on Github external
def should_show_icon(self) -> bool:
        return (config.val.tabs.favicons.show == 'always' or
                config.val.tabs.favicons.show == 'pinned' and self.pinned)
github qutebrowser / qutebrowser / qutebrowser / mainwindow / tabbedbrowser.py View on Github external
def _get_new_tab_idx(self, related):
        """Get the index of a tab to insert.

        Args:
            related: Whether the tab was opened from another tab (as a "child")

        Return:
            The index of the new tab.
        """
        if related:
            pos = config.val.tabs.new_position.related
        else:
            pos = config.val.tabs.new_position.unrelated
        if pos == 'prev':
            idx = self._tab_insert_idx_left
            # On first sight, we'd think we have to decrement
            # self._tab_insert_idx_left here, as we want the next tab to be
            # *before* the one we just opened. However, since we opened a tab
            # *before* the currently focused tab, indices will shift by
            # 1 automatically.
        elif pos == 'next':
            idx = self._tab_insert_idx_right
            self._tab_insert_idx_right += 1
        elif pos == 'first':
            idx = 0
        elif pos == 'last':
            idx = -1
github qutebrowser / qutebrowser / qutebrowser / browser / webkit / webview.py View on Github external
def mousePressEvent(self, e):
        """Set the tabdata ClickTarget on a mousepress.

        This is implemented here as we don't need it for QtWebEngine.
        """
        if e.button() == Qt.MidButton or e.modifiers() & Qt.ControlModifier:
            background = config.val.tabs.background
            if e.modifiers() & Qt.ShiftModifier:
                background = not background
            if background:
                target = usertypes.ClickTarget.tab_bg
            else:
                target = usertypes.ClickTarget.tab
            self.page().open_target = target
            log.mouse.debug("Ctrl/Middle click, setting target: {}".format(
                target))
        else:
            self.page().open_target = usertypes.ClickTarget.normal
            log.mouse.debug("Normal click, setting normal target")
        super().mousePressEvent(e)