Beispiel #1
0
    def __init__(self, *args):
        QWebView.__init__(self, *args)
        self.gui = None
        self.tags = ''
        self.create_browser = None

        self._page = NPWebPage()
        self.setPage(self._page)
        self.cookie_jar = QNetworkCookieJar()
        self.page().networkAccessManager().setCookieJar(self.cookie_jar)

        http_proxy = get_proxies().get('http', None)
        if http_proxy:
            proxy_parts = urlparse(http_proxy)
            proxy = QNetworkProxy()
            proxy.setType(QNetworkProxy.HttpProxy)
            if proxy_parts.username:
                proxy.setUser(proxy_parts.username)
            if proxy_parts.password:
                proxy.setPassword(proxy_parts.password)
            if proxy_parts.hostname:
                proxy.setHostName(proxy_parts.hostname)
            if proxy_parts.port:
                proxy.setPort(proxy_parts.port)
            self.page().networkAccessManager().setProxy(proxy)

        self.page().setForwardUnsupportedContent(True)
        self.page().unsupportedContent.connect(self.start_download)
        self.page().downloadRequested.connect(self.start_download)
        self.page().networkAccessManager().sslErrors.connect(self.ignore_ssl_errors)
Beispiel #2
0
    def loadSettings(self):
        settings = Settings()
        settings.beginGroup('Language')
        # TODO:
        #langs = settings.value('acceptLanguage', AcceptLanguage.defaultLanguage(), type=[])
        settings.endGroup()
        # TODO:
        #gVar.app.webProfile().setHttpAcceptLanguage(AcceptLanguage.generateHeader(langs))

        proxy = QNetworkProxy()
        settings.beginGroup('Web-Proxy')
        proxyType = settings.value('ProxyType', 2)
        proxy.setHostName(settings.value('HostName', ''))
        proxy.setPort(settings.value('Port', 8080))
        proxy.setUser(settings.value('Username', ''))
        proxy.setPassword(settings.value('Password', ''))
        settings.endGroup()

        if proxyType == 0:
            proxy.setType(QNetworkProxy.NoProxy)
        elif proxyType == 3:
            proxy.setType(QNetworkProxy.HttpProxy)
        elif proxyType == 4:
            proxy.setType(QNetworkProxy.Socks5Proxy)

        if proxyType == 2:
            QNetworkProxy.setApplicationProxy(QNetworkProxy())
            QNetworkProxyFactory.setUseSystemConfiguration(True)
        else:
            QNetworkProxy.setApplicationProxy(proxy)
            QNetworkProxyFactory.setUseSystemConfiguration(False)

        self._urlInterceptor.loadSettings()