def __init__(self, viewport): super(mapillaryViewer, self).__init__() self.viewport = viewport self.viewport.statusBarMessage.connect(self.getJSONmessage) WS = self.viewport.settings() WS.setAttribute(QWebSettings.JavascriptEnabled, True) WS.setAttribute(QWebSettings.DeveloperExtrasEnabled, True) WS.setAttribute(QWebSettings.JavascriptCanAccessClipboard, True) # next parameters can crash qgis if user use arrows after clicked in the sliders of the webview # QtWebKit.QWebSettings.globalSettings().setAttribute(QtWebKit.QWebSettings.SpatialNavigationEnabled,True) WS.setAttribute(QWebSettings.PrintElementBackgrounds, True) WS.setAttribute(QWebSettings.OfflineStorageDatabaseEnabled, True) WS.setAttribute(QWebSettings.LocalStorageEnabled, True) WS.setAttribute(QWebSettings.PluginsEnabled, True) WS.setAttribute(QWebSettings.WebGLEnabled, True) self.viewport.page().setNetworkAccessManager( QgsNetworkAccessManager.instance()) #QtWebKit.QWebSettings.globalSettings().globalSettings().enablePersistentStorage(QtCore.QDir.tempPath()) #self.viewport.setPage(MyBrowser()) s = QSettings() #getting proxy from qgis options settings proxyEnabled = s.value("proxy/proxyEnabled", "") proxyType = s.value("proxy/proxyType", "") proxyHost = s.value("proxy/proxyHost", "") proxyPort = s.value("proxy/proxyPort", "") proxyUser = s.value("proxy/proxyUser", "") proxyPassword = s.value("proxy/proxyPassword", "") print(proxyEnabled + "; " + proxyType + "; " + proxyHost + "; " + proxyPort + "; " + proxyUser + "; " + proxyPassword) if proxyEnabled == "true": # test if there are proxy settings proxy = QNetworkProxy() if proxyType == "DefaultProxy": proxy.setType(QNetworkProxy.DefaultProxy) elif proxyType == "Socks5Proxy": proxy.setType(QNetworkProxy.Socks5Proxy) elif proxyType == "HttpProxy": proxy.setType(QNetworkProxy.HttpProxy) elif proxyType == "HttpCachingProxy": proxy.setType(QNetworkProxy.HttpCachingProxy) elif proxyType == "FtpCachingProxy": proxy.setType(QNetworkProxy.FtpCachingProxy) proxy.setHostName(proxyHost) proxy.setPort(int(proxyPort)) proxy.setUser(proxyUser) proxy.setPassword(proxyPassword) #QNetworkProxy.setApplicationProxy(proxy) #self.page = os.path.join(os.path.dirname(__file__),'res','browser.html') self.page = os.path.join( 'https://enricofer.github.io/go2mapillary/res/browser.html') self.openLocation('') self.enabled = True print(self.page)
def __init__(self, parentInstance): super(mapillaryViewer, self).__init__() self.parentInstance = parentInstance self.viewport = parentInstance.dlg.webView #self.viewport.statusBarMessage.connect(self.getJSONmessage) self.viewport.page().mainFrame().javaScriptWindowObjectCleared.connect( self.registerJS) self.locationKey = None WS = self.viewport.settings() WS.setAttribute(QWebSettings.JavascriptEnabled, True) WS.setAttribute(QWebSettings.DeveloperExtrasEnabled, True) WS.setAttribute(QWebSettings.JavascriptCanAccessClipboard, True) WS.setAttribute(QWebSettings.PrintElementBackgrounds, True) WS.setAttribute(QWebSettings.OfflineStorageDatabaseEnabled, True) WS.setAttribute(QWebSettings.LocalStorageEnabled, True) WS.setAttribute(QWebSettings.PluginsEnabled, True) WS.setAttribute(QWebSettings.WebGLEnabled, True) self.viewport.page().setNetworkAccessManager( QgsNetworkAccessManager.instance()) self.mly_api = mapillaryApi() self.page = os.path.join(os.path.dirname(__file__), 'res', 'browser.html') self.openLocation('') self.enabled = True proxy_conf = getProxySettings() if proxy_conf: proxy = QNetworkProxy() if proxy_conf['type'] == "DefaultProxy": proxy.setType(QNetworkProxy.DefaultProxy) elif proxy_conf['type'] == "Socks5Proxy": proxy.setType(QNetworkProxy.Socks5Proxy) elif proxy_conf['type'] == "HttpProxy": proxy.setType(QNetworkProxy.HttpProxy) elif proxy_conf['type'] == "HttpCachingProxy": proxy.setType(QNetworkProxy.HttpCachingProxy) elif proxy_conf['type'] == "FtpCachingProxy": proxy.setType(QNetworkProxy.FtpCachingProxy) proxy.setHostName(proxy_conf['host']) proxy.setPort(int(proxy_conf['port'])) proxy.setUser(proxy_conf['user']) proxy.setPassword(proxy_conf['password']) QNetworkProxy.setApplicationProxy(proxy)