Пример #1
0
 def __init__(self, *, win_id, mode_manager, private, parent=None):
     super().__init__(win_id=win_id,
                      mode_manager=mode_manager,
                      private=private,
                      parent=parent)
     widget = webview.WebView(win_id=win_id,
                              tab_id=self.tab_id,
                              private=private,
                              tab=self)
     if private:
         self._make_private(widget)
     self.history = WebKitHistory(self)
     self.scroller = WebKitScroller(self, parent=self)
     self.caret = WebKitCaret(mode_manager=mode_manager,
                              tab=self,
                              parent=self)
     self.zoom = WebKitZoom(tab=self, parent=self)
     self.search = WebKitSearch(parent=self)
     self.printing = WebKitPrinting(tab=self)
     self.elements = WebKitElements(tab=self)
     self.action = WebKitAction(tab=self)
     self.audio = WebKitAudio(parent=self)
     # We're assigning settings in _set_widget
     self.settings = webkitsettings.WebKitSettings(settings=None)
     self._set_widget(widget)
     self._connect_signals()
     self.backend = usertypes.Backend.QtWebKit
Пример #2
0
 def __init__(self, win_id, mode_manager, parent=None):
     super().__init__(win_id=win_id, mode_manager=mode_manager,
                      parent=parent)
     widget = webview.WebView(win_id, self.tab_id, tab=self)
     self.history = WebKitHistory(self)
     self.scroller = WebKitScroller(self, parent=self)
     self.caret = WebKitCaret(win_id=win_id, mode_manager=mode_manager,
                              tab=self, parent=self)
     self.zoom = WebKitZoom(win_id=win_id, parent=self)
     self.search = WebKitSearch(parent=self)
     self.printing = WebKitPrinting()
     self.elements = WebKitElements(self)
     self._set_widget(widget)
     self._connect_signals()
     self.zoom.set_default()
     self.backend = usertypes.Backend.QtWebKit
Пример #3
0
    def tabopen(self, url=None, background=None, explicit=False):
        """Open a new tab with a given URL.

        Inner logic for open-tab and open-tab-bg.
        Also connect all the signals we need to _filter_signals.

        Args:
            url: The URL to open as QUrl or None for an empty tab.
            background: Whether to open the tab in the background.
                        if None, the background-tabs setting decides.
            explicit: Whether the tab was opened explicitly.
                      If this is set, the new position might be different. With
                      the default settings we handle it like Chromium does:
                          - Tabs from clicked links etc. are to the right of
                            the current.
                          - Explicitly opened tabs are at the very right.

        Return:
            The opened WebView instance.
        """
        if url is not None:
            qtutils.ensure_valid(url)
        log.webview.debug("Creating new tab with URL {}".format(url))
        if config.get('tabs', 'tabs-are-windows') and self.count() > 0:
            from qutebrowser.mainwindow import mainwindow
            window = mainwindow.MainWindow()
            window.show()
            tabbed_browser = objreg.get('tabbed-browser',
                                        scope='window',
                                        window=window.win_id)
            return tabbed_browser.tabopen(url, background, explicit)
        tab = webview.WebView(self._win_id, self)
        self._connect_tab_signals(tab)
        idx = self._get_new_tab_idx(explicit)
        self.insertTab(idx, tab, "")
        if url is not None:
            tab.openurl(url)
        if background is None:
            background = config.get('tabs', 'background-tabs')
        if background:
            self.tab_index_changed.emit(self.currentIndex(), self.count())
        else:
            self.setCurrentWidget(tab)
        tab.show()
        self.new_tab.emit(tab, idx)
        return tab