--- a/src/eric7/EricNetwork/EricNetworkProxyFactory.py Thu Sep 26 09:48:49 2024 +0200 +++ b/src/eric7/EricNetwork/EricNetworkProxyFactory.py Thu Sep 26 15:49:36 2024 +0200 @@ -14,7 +14,8 @@ from PyQt6.QtNetwork import QNetworkProxy, QNetworkProxyFactory, QNetworkProxyQuery from PyQt6.QtWidgets import QDialog -from eric7 import Preferences, Utilities +from eric7 import EricUtilities +from eric7.EricCore import EricPreferences from eric7.EricWidgets import EricMessageBox from eric7.SystemUtilities import OSUtilities @@ -53,7 +54,7 @@ info = QCoreApplication.translate( "EricNetworkProxyFactory", "<b>Connect to proxy '{0}' using:</b>" - ).format(Utilities.html_encode(proxy.hostName())) + ).format(EricUtilities.html_encode(proxy.hostName())) dlg = EricAuthenticationDialog(info, proxy.user(), True) dlg.setData(proxy.user(), proxy.password()) @@ -64,8 +65,12 @@ if dlg.shallSave(): scheme = schemeFromProxyType(proxy.type()) if scheme and scheme != "NoProxy": - Preferences.setUI("ProxyUser/{0}".format(scheme), username) - Preferences.setUI("ProxyPassword/{0}".format(scheme), password) + EricPreferences.setNetworkProxy( + "ProxyUser/{0}".format(scheme), username + ) + EricPreferences.setNetworkProxy( + "ProxyPassword/{0}".format(scheme), password + ) proxy.setUser(username) proxy.setPassword(password) @@ -163,12 +168,12 @@ query.queryType() == QNetworkProxyQuery.QueryType.UrlRequest and query.protocolTag() in ["http", "https", "ftp"] ): - # use proxy at all ? - if not Preferences.getUI("UseProxy"): + # use proxy at all? + if not EricPreferences.getNetworkProxy("UseProxy"): return [QNetworkProxy(QNetworkProxy.ProxyType.NoProxy)] # test for exceptions - exceptions = Preferences.getUI("ProxyExceptions") + exceptions = EricPreferences.getNetworkProxy("ProxyExceptions") if exceptions != self.__exceptions: self.__setExceptions(exceptions) urlHost = query.url().host() @@ -177,7 +182,7 @@ return [QNetworkProxy(QNetworkProxy.ProxyType.NoProxy)] # determine proxy - if Preferences.getUI("UseSystemProxy"): + if EricPreferences.getNetworkProxy("UseSystemProxy"): proxyList = QNetworkProxyFactory.systemProxyForQuery(query) if ( not OSUtilities.isWindowsPlatform() @@ -216,20 +221,26 @@ scheme = "Http" if scheme != "NoProxy": proxyList[0].setUser( - Preferences.getUI("ProxyUser/{0}".format(scheme)) + EricPreferences.getNetworkProxy( + "ProxyUser/{0}".format(scheme) + ) ) proxyList[0].setPassword( - Preferences.getUI("ProxyPassword/{0}".format(scheme)) + EricPreferences.getNetworkProxy( + "ProxyPassword/{0}".format(scheme) + ) ) return proxyList else: return [QNetworkProxy(QNetworkProxy.ProxyType.NoProxy)] else: - if Preferences.getUI("UseHttpProxyForAll"): + if EricPreferences.getNetworkProxy("UseHttpProxyForAll"): protocolKey = "Http" else: protocolKey = query.protocolTag().capitalize() - host = Preferences.getUI("ProxyHost/{0}".format(protocolKey)) + host = EricPreferences.getNetworkProxy( + "ProxyHost/{0}".format(protocolKey) + ) if not host: EricMessageBox.critical( None, @@ -253,9 +264,11 @@ proxy = QNetworkProxy( proxyType, host, - Preferences.getUI("ProxyPort/" + protocolKey), - Preferences.getUI("ProxyUser/" + protocolKey), - Preferences.getUI("ProxyPassword/" + protocolKey), + EricPreferences.getNetworkProxy("ProxyPort/" + protocolKey), + EricPreferences.getNetworkProxy("ProxyUser/" + protocolKey), + EricPreferences.getNetworkProxy( + "ProxyPassword/" + protocolKey + ), ) else: proxy = QNetworkProxy(QNetworkProxy.ProxyType.DefaultProxy)