コード例 #1
0
 def _set(self, value, settings=None):
     utils.unused(settings)
     setter = getattr(QWebEngineProfile.defaultProfile(), self._setter)
     setter(
         QWebEngineProfile.AllowPersistentCookies if value else
         QWebEngineProfile.NoPersistentCookies
     )
コード例 #2
0
    def set_perc(self, x, y):
        """Setter to be used as a Qt slot.

        Args:
            x: The x percentage (int), currently ignored.
            y: The y percentage (int)
        """
        utils.unused(x)
        self._set_text(self._strings.get(y, '[???]'))
コード例 #3
0
ファイル: configtypes.py プロジェクト: swalladge/qutebrowser
    def to_doc(self, value, indent=0):
        """Get a string with the given value for the documentation.

        This currently uses asciidoc syntax.
        """
        utils.unused(indent)  # only needed for Dict/List
        if not value:
            return 'empty'
        return '+pass:[{}]+'.format(html.escape(self.to_str(value)))
コード例 #4
0
    def to_doc(self, value, indent=0):
        """Get a string with the given value for the documentation.

        This currently uses asciidoc syntax.
        """
        utils.unused(indent)  # only needed for Dict/List
        str_value = self.to_str(value)
        if not str_value:
            return 'empty'
        return '+pass:[{}]+'.format(html.escape(str_value))
コード例 #5
0
def session(*, info=None):
    """A CompletionModel filled with session names."""
    from qutebrowser.misc import sessions
    utils.unused(info)
    model = completionmodel.CompletionModel()
    try:
        sess = ((name, ) for name in sessions.session_manager.list_sessions()
                if not name.startswith('_'))
        model.add_category(listcategory.ListCategory("Sessions", sess))
    except OSError:
        log.completion.exception("Failed to list sessions!")
    return model
コード例 #6
0
ファイル: miscmodels.py プロジェクト: mkonig/qutebrowser
def quickmark(*, info=None):
    """A CompletionModel filled with all quickmarks."""
    def delete(data: Sequence[str]) -> None:
        """Delete a quickmark from the completion menu."""
        name = data[0]
        quickmark_manager = objreg.get('quickmark-manager')
        log.completion.debug('Deleting quickmark {}'.format(name))
        quickmark_manager.delete(name)

    utils.unused(info)
    model = completionmodel.CompletionModel(column_widths=(30, 70, 0))
    marks = objreg.get('quickmark-manager').marks.items()
    model.add_category(listcategory.ListCategory('Quickmarks', marks,
                                                 delete_func=delete,
                                                 sort=False))
    return model
コード例 #7
0
ファイル: notification.py プロジェクト: ebell451/qutebrowser
    def present(
        self,
        qt_notification: "QWebEngineNotification",
        *,
        replaces_id: Optional[int],
    ) -> int:
        utils.unused(replaces_id)  # QSystemTray can only show one message
        self.close_id.emit(self.NOTIFICATION_ID)
        self._systray.show()

        icon = self._convert_icon(qt_notification.icon())
        msg = self._format_message(qt_notification.message(), qt_notification.origin())

        self._systray.showMessage(qt_notification.title(), msg, icon)

        return self.NOTIFICATION_ID
コード例 #8
0
def bookmark(*, info=None):
    """A CompletionModel filled with all bookmarks."""
    def delete(data: typing.Sequence[str]) -> None:
        """Delete a bookmark from the completion menu."""
        urlstr = data[0]
        log.completion.debug('Deleting bookmark {}'.format(urlstr))
        bookmark_manager = objreg.get('bookmark-manager')
        bookmark_manager.delete(urlstr)

    utils.unused(info)
    model = completionmodel.CompletionModel(column_widths=(30, 70, 0))
    marks = objreg.get('bookmark-manager').marks.items()
    model.add_category(listcategory.ListCategory('Bookmarks', marks,
                                                 delete_func=delete,
                                                 sort=False))
    return model
コード例 #9
0
    def rect_on_view(self,
                     *,
                     elem_geometry: QRect = None,
                     no_js: bool = False) -> QRect:
        """Get the geometry of the element relative to the webview.

        Skipping of small rectangles is due to <a> elements containing other
        elements with "display:block" style, see
        https://github.com/qutebrowser/qutebrowser/issues/1298

        Args:
            elem_geometry: The geometry of the element, or None.
                           Ignored with QtWebEngine.
            no_js: Fall back to the Python implementation.
                   Ignored with QtWebEngine.
        """
        utils.unused(elem_geometry)
        utils.unused(no_js)
        rects = self._js_dict['rects']
        for rect in rects:
            # FIXME:qtwebengine
            # width = rect.get("width", 0)
            # height = rect.get("height", 0)
            width = rect['width']
            height = rect['height']
            left = rect['left']
            top = rect['top']
            if width > 1 and height > 1:
                # Fix coordinates according to zoom level
                # We're not checking for zoom.text_only here as that doesn't
                # exist for QtWebEngine.
                zoom = self._tab.zoom.factor()
                rect = QRect(int(left * zoom), int(top * zoom),
                             int(width * zoom), int(height * zoom))
                # FIXME:qtwebengine
                # frame = self._elem.webFrame()
                # while frame is not None:
                #     # Translate to parent frames' position (scroll position
                #     # is taken care of inside getClientRects)
                #     rect.translate(frame.geometry().topLeft())
                #     frame = frame.parentFrame()
                return rect
        log.webelem.debug("Couldn't find rectangle for {!r} ({})".format(
            self, rects))
        return QRect()
コード例 #10
0
def init(args: argparse.Namespace) -> None:
    """Initialize all QWeb(Engine)Settings."""
    utils.unused(args)
    if objects.backend == usertypes.Backend.QtWebEngine:
        from qutebrowser.browser.webengine import webenginesettings
        webenginesettings.init()
    elif objects.backend == usertypes.Backend.QtWebKit:
        from qutebrowser.browser.webkit import webkitsettings
        webkitsettings.init()
    else:
        raise utils.Unreachable(objects.backend)

    # Make sure special URLs always get JS support
    for pattern in ['chrome://*/*', 'qute://*/*']:
        config.instance.set_obj('content.javascript.enabled',
                                True,
                                pattern=urlmatch.UrlPattern(pattern),
                                hide_userconfig=True)
コード例 #11
0
ファイル: webkittab.py プロジェクト: fiete201/qutebrowser
    def find_css(self, selector, callback, error_cb, *, only_visible=False):
        utils.unused(error_cb)
        mainframe = self._widget.page().mainFrame()
        if mainframe is None:
            raise browsertab.WebTabError("No frame focused!")

        elems = []
        frames = webkitelem.get_child_frames(mainframe)
        for f in frames:
            for elem in f.findAllElements(selector):
                elems.append(webkitelem.WebKitElement(elem, tab=self._tab))

        if only_visible:
            # pylint: disable=protected-access
            elems = [e for e in elems if e._is_visible(mainframe)]
            # pylint: enable=protected-access

        callback(elems)
コード例 #12
0
ファイル: webkittab.py プロジェクト: xaverdh/qutebrowser
    def find_css(self, selector, callback, error_cb, *, only_visible=False):
        utils.unused(error_cb)
        mainframe = self._widget.page().mainFrame()
        if mainframe is None:
            raise browsertab.WebTabError("No frame focused!")

        elems = []
        frames = webkitelem.get_child_frames(mainframe)
        for f in frames:
            for elem in f.findAllElements(selector):
                elems.append(webkitelem.WebKitElement(elem, tab=self._tab))

        if only_visible:
            # pylint: disable=protected-access
            elems = [e for e in elems if e._is_visible(mainframe)]
            # pylint: enable=protected-access

        callback(elems)
コード例 #13
0
ファイル: miscmodels.py プロジェクト: AlexBocken/qutebrowser
def process(*, info):
    """A CompletionModel filled with processes."""
    utils.unused(info)
    from qutebrowser.misc import guiprocess
    model = completionmodel.CompletionModel(column_widths=(10, 10, 80))
    for what, processes in itertools.groupby(
        (p for p in guiprocess.all_processes.values() if p is not None),
            lambda proc: proc.what):

        # put successful processes last
        sorted_processes = sorted(
            processes,
            key=lambda proc: proc.outcome.state_str() == 'successful',
        )

        entries = [(str(proc.pid), proc.outcome.state_str(), str(proc))
                   for proc in sorted_processes]
        cat = listcategory.ListCategory(what.capitalize(), entries, sort=False)
        model.add_category(cat)
    return model
コード例 #14
0
    def __init__(self,
                 *,
                 win_id: int,
                 mode_manager: modeman.ModeManager,
                 private: bool,
                 parent: QWidget = None) -> None:
        utils.unused(mode_manager)  # needed for mypy
        self.is_private = private
        self.win_id = win_id
        self.tab_id = next(tab_id_gen)
        super().__init__(parent)

        self.registry = objreg.ObjectRegistry()
        tab_registry = objreg.get('tab-registry',
                                  scope='window',
                                  window=win_id)
        tab_registry[self.tab_id] = self
        objreg.register('tab', self, registry=self.registry)

        self.data = TabData()
        self._layout = miscwidgets.WrapperLayout(self)
        self._widget = cast(QWidget, None)
        self._progress = 0
        self._load_status = usertypes.LoadStatus.none
        self._tab_event_filter = eventfilter.TabEventFilter(self, parent=self)
        self.backend: Optional[usertypes.Backend] = None

        self._last_history_url: Optional[QUrl] = None
        self._last_history_atime: Optional[int] = None
        self._last_history_title: Optional[str] = None
        self._last_history_requested_url: Optional[QUrl] = None

        # If true, this tab has been requested to be removed (or is removed).
        self.pending_removal = False
        self.shutting_down.connect(
            functools.partial(setattr, self, 'pending_removal', True))

        self.before_load_started.connect(self._on_before_load_started)
コード例 #15
0
 def download_open(self, cmdline, pdfjs):
     """Open the download directly if this is a download prompt."""
     utils.unused(cmdline)
     utils.unused(pdfjs)
     raise UnsupportedOperationError
コード例 #16
0
 def get(self, settings=None):
     utils.unused(settings)
     return config.get('content', 'cookies-store')
コード例 #17
0
 def get(self, settings=None):
     utils.unused(settings)
     return config.get('content', 'cookies-store')
コード例 #18
0
 def _set(self, value, settings=None):
     utils.unused(settings)
     setter = getattr(default_profile, self._setter)
     setter(value)
コード例 #19
0
 def get(self, settings=None):
     utils.unused(settings)
     getter = getattr(default_profile, self._getter)
     return getter()
コード例 #20
0
 def _set(self, value, settings=None):
     utils.unused(settings)
     setter = getattr(QWebEngineProfile.defaultProfile(), self._setter)
     setter(value)
コード例 #21
0
 def get(self, settings=None):
     utils.unused(settings)
     return self._getter()
コード例 #22
0
 def _set(self, value, settings=None):
     utils.unused(settings)
     self._setter(value)
コード例 #23
0
 def get(self, settings=None):
     utils.unused(settings)
     getter = getattr(QWebEngineProfile.defaultProfile(), self._getter)
     return getter()
コード例 #24
0
 def _set(self, value, settings=None):
     utils.unused(settings)
     self._setter(QWebEngineProfile.AllowPersistentCookies
                  if value else QWebEngineProfile.NoPersistentCookies)
コード例 #25
0
ファイル: webengineelem.py プロジェクト: ususdei/qutebrowser
 def __delitem__(self, key: str) -> None:
     utils.unused(key)
     log.stub()
コード例 #26
0
 def get(self, settings=None):
     utils.unused(settings)
     getter = getattr(default_profile, self._getter)
     return getter()
コード例 #27
0
 def _set(self, value, settings=None):
     utils.unused(settings)
     setter = getattr(default_profile, self._setter)
     setter(value)
コード例 #28
0
 def columnCount(self, parent=QModelIndex()):
     """Override QAbstractItemModel::columnCount."""
     utils.unused(parent)
     return len(self.column_widths)
コード例 #29
0
ファイル: prompt.py プロジェクト: fiete201/qutebrowser
 def download_open(self, cmdline, pdfjs):
     """Open the download directly if this is a download prompt."""
     utils.unused(cmdline)
     utils.unused(pdfjs)
     raise UnsupportedOperationError