Пример #1
0
 def __init__(self, win_id, parent=None):
     super().__init__(parent)
     if sys.platform == 'darwin' and qtutils.version_check('5.4'):
         # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-42948
         # See https://github.com/The-Compiler/qutebrowser/issues/462
         self.setStyle(QStyleFactory.create('Fusion'))
     self._win_id = win_id
     self.load_status = LoadStatus.none
     self._check_insertmode = False
     self.inspector = None
     self.scroll_pos = (-1, -1)
     self.statusbar_message = ''
     self._old_scroll_pos = (-1, -1)
     self.open_target = usertypes.ClickTarget.normal
     self._force_open_target = None
     self._zoom = None
     self._has_ssl_errors = False
     self.keep_icon = False
     self.init_neighborlist()
     cfg = objreg.get('config')
     cfg.changed.connect(self.init_neighborlist)
     # For some reason, this signal doesn't get disconnected automatically
     # when the WebView is destroyed on older PyQt versions.
     # See https://github.com/The-Compiler/qutebrowser/issues/390
     self.destroyed.connect(
         functools.partial(cfg.changed.disconnect, self.init_neighborlist))
     self._cur_url = None
     self.cur_url = QUrl()
     self.progress = 0
     self.registry = objreg.ObjectRegistry()
     self.tab_id = next(tab_id_gen)
     tab_registry = objreg.get('tab-registry',
                               scope='window',
                               window=win_id)
     tab_registry[self.tab_id] = self
     objreg.register('webview', self, registry=self.registry)
     page = webpage.BrowserPage(win_id, self.tab_id, self)
     self.setPage(page)
     hintmanager = hints.HintManager(win_id, self.tab_id, self)
     hintmanager.mouse_event.connect(self.on_mouse_event)
     hintmanager.set_open_target.connect(self.set_force_open_target)
     objreg.register('hintmanager', hintmanager, registry=self.registry)
     mode_manager = objreg.get('mode-manager',
                               scope='window',
                               window=win_id)
     mode_manager.entered.connect(self.on_mode_entered)
     mode_manager.left.connect(self.on_mode_left)
     page.linkHovered.connect(self.linkHovered)
     page.mainFrame().loadStarted.connect(self.on_load_started)
     self.urlChanged.connect(self.on_url_changed)
     page.mainFrame().loadFinished.connect(self.on_load_finished)
     self.loadProgress.connect(lambda p: setattr(self, 'progress', p))
     self.page().statusBarMessage.connect(
         lambda msg: setattr(self, 'statusbar_message', msg))
     self.page().networkAccessManager().sslErrors.connect(
         lambda *args: setattr(self, '_has_ssl_errors', True))
     self.viewing_source = False
     self.setZoomFactor(float(config.get('ui', 'default-zoom')) / 100)
     self._default_zoom_changed = False
     objreg.get('config').changed.connect(self.on_config_changed)
Пример #2
0
 def _init_page(self):
     """Initialize the QWebPage used by this view."""
     page = webpage.BrowserPage(self.win_id, self.tab_id, self)
     self.setPage(page)
     page.linkHovered.connect(self.linkHovered)
     page.mainFrame().loadStarted.connect(self.on_load_started)
     page.mainFrame().loadFinished.connect(self.on_load_finished)
     page.statusBarMessage.connect(
         lambda msg: setattr(self, 'statusbar_message', msg))
     page.networkAccessManager().sslErrors.connect(
         lambda *args: setattr(self, '_has_ssl_errors', True))
     return page
Пример #3
0
 def __init__(self, win_id, parent=None):
     super().__init__(parent)
     self._win_id = win_id
     self.load_status = LoadStatus.none
     self._check_insertmode = False
     self.inspector = None
     self.scroll_pos = (-1, -1)
     self.statusbar_message = ''
     self._old_scroll_pos = (-1, -1)
     self.open_target = usertypes.ClickTarget.normal
     self._force_open_target = None
     self._zoom = None
     self._has_ssl_errors = False
     self.init_neighborlist()
     objreg.get('config').changed.connect(self.init_neighborlist)
     self._cur_url = None
     self.cur_url = QUrl()
     self.progress = 0
     self.registry = objreg.ObjectRegistry()
     self.tab_id = next(tab_id_gen)
     tab_registry = objreg.get('tab-registry',
                               scope='window',
                               window=win_id)
     tab_registry[self.tab_id] = self
     objreg.register('webview', self, registry=self.registry)
     page = webpage.BrowserPage(win_id, self)
     self.setPage(page)
     hintmanager = hints.HintManager(win_id, self.tab_id, self)
     hintmanager.mouse_event.connect(self.on_mouse_event)
     hintmanager.set_open_target.connect(self.set_force_open_target)
     objreg.register('hintmanager', hintmanager, registry=self.registry)
     page.linkHovered.connect(self.linkHovered)
     page.mainFrame().loadStarted.connect(self.on_load_started)
     self.urlChanged.connect(self.on_url_changed)
     page.mainFrame().loadFinished.connect(self.on_load_finished)
     page.scrollRequested.connect(self.on_scroll_requested)
     # Calculate scroll position once
     self.on_scroll_requested()
     self.loadProgress.connect(lambda p: setattr(self, 'progress', p))
     self.page().statusBarMessage.connect(
         lambda msg: setattr(self, 'statusbar_message', msg))
     self.page().networkAccessManager().sslErrors.connect(
         lambda *args: setattr(self, '_has_ssl_errors', True))
     self.viewing_source = False
     self.setZoomFactor(float(config.get('ui', 'default-zoom')) / 100)