mirror of
https://github.com/LorenEteval/Furious.git
synced 2026-10-08 06:48:09 +03:00
Make the settings read/write more robust
Signed-off-by: Loren Eteval <loren.eteval@proton.me>
This commit is contained in:
@@ -76,10 +76,10 @@ class NetworkConnectivityManager(Mixins.ConnectionAware, WebGETManager):
|
||||
# Use custom network connectivity test URL if possible
|
||||
settings = AppSettings.get('CustomNetworkConnectivityTestURL')
|
||||
|
||||
if settings is None:
|
||||
url = NETWORK_CONNECTIVITY_TEST_URL
|
||||
else:
|
||||
if isinstance(settings, str):
|
||||
url = settings
|
||||
else:
|
||||
url = NETWORK_CONNECTIVITY_TEST_URL
|
||||
|
||||
networkReply = self.webGET(url)
|
||||
|
||||
|
||||
@@ -256,10 +256,10 @@ class ConnectAction(AppQAction):
|
||||
# Use custom proxy bypass address if possible
|
||||
settings = AppSettings.get('CustomProxyBypass')
|
||||
|
||||
if settings is None:
|
||||
proxyServerBypass = PROXY_SERVER_BYPASS
|
||||
else:
|
||||
if isinstance(settings, str):
|
||||
proxyServerBypass = settings
|
||||
else:
|
||||
proxyServerBypass = PROXY_SERVER_BYPASS
|
||||
|
||||
try:
|
||||
SystemProxy.set(httpProxy, proxyServerBypass)
|
||||
|
||||
@@ -47,20 +47,20 @@ class GuiCustomizeNetworkTestDialog(AppQDialog):
|
||||
|
||||
speedTestURLSettings = AppSettings.get('CustomNetworkSpeedTestURL')
|
||||
|
||||
if speedTestURLSettings is None:
|
||||
self.speedTestURLEdit.setText(NETWORK_SPEED_TEST_URL)
|
||||
else:
|
||||
if isinstance(speedTestURLSettings, str):
|
||||
self.speedTestURLEdit.setText(speedTestURLSettings)
|
||||
else:
|
||||
self.speedTestURLEdit.setText(NETWORK_SPEED_TEST_URL)
|
||||
|
||||
self.connectivityText = AppQLabel(_('Enter network connectivity test URL:'))
|
||||
self.connectivityEdit = QLineEdit()
|
||||
|
||||
connectivitySettings = AppSettings.get('CustomNetworkConnectivityTestURL')
|
||||
|
||||
if connectivitySettings is None:
|
||||
self.connectivityEdit.setText(NETWORK_CONNECTIVITY_TEST_URL)
|
||||
else:
|
||||
if isinstance(connectivitySettings, str):
|
||||
self.connectivityEdit.setText(connectivitySettings)
|
||||
else:
|
||||
self.connectivityEdit.setText(NETWORK_CONNECTIVITY_TEST_URL)
|
||||
|
||||
self.dialogBtns = AppQDialogButtonBox(QtCore.Qt.Orientation.Horizontal)
|
||||
self.dialogBtns.addButton(_('OK'), AppQDialogButtonBox.ButtonRole.AcceptRole)
|
||||
@@ -127,8 +127,8 @@ class GuiCustomizeNetworkTestDialog(AppQDialog):
|
||||
try:
|
||||
settings = AppSettings.get(settingsName)
|
||||
|
||||
if settings is not None:
|
||||
widget.setText(str(settings))
|
||||
if isinstance(settings, str):
|
||||
widget.setText(settings)
|
||||
else:
|
||||
widget.setText(reset)
|
||||
except Exception as ex:
|
||||
|
||||
@@ -48,10 +48,10 @@ class GuiCustomizeProxyBypassDialog(AppQDialog):
|
||||
|
||||
settings = AppSettings.get('CustomProxyBypass')
|
||||
|
||||
if settings is None:
|
||||
self.proxyBypassEdit.setText(PROXY_SERVER_BYPASS)
|
||||
else:
|
||||
if isinstance(settings, str):
|
||||
self.proxyBypassEdit.setText(settings)
|
||||
else:
|
||||
self.proxyBypassEdit.setText(PROXY_SERVER_BYPASS)
|
||||
|
||||
self.dialogBtns = AppQDialogButtonBox(QtCore.Qt.Orientation.Horizontal)
|
||||
self.dialogBtns.addButton(_('OK'), AppQDialogButtonBox.ButtonRole.AcceptRole)
|
||||
@@ -83,13 +83,24 @@ class GuiCustomizeProxyBypassDialog(AppQDialog):
|
||||
|
||||
def handleResultCode(self, code):
|
||||
if code == PySide6Legacy.enumValueWrapper(AppQDialog.DialogCode.Accepted):
|
||||
value = self.proxyBypassEdit.text()
|
||||
oldValue = AppSettings.get('CustomProxyBypass')
|
||||
newValue = self.proxyBypassEdit.text()
|
||||
|
||||
logger.info(f'setting custom proxy bypass address to \'{value}\'')
|
||||
def writeNewSettings(value):
|
||||
logger.info(f'setting custom proxy bypass address to \'{value}\'')
|
||||
|
||||
AppSettings.set('CustomProxyBypass', value)
|
||||
AppSettings.set('CustomProxyBypass', value)
|
||||
|
||||
showMBoxNewChangesNextTime()
|
||||
showMBoxNewChangesNextTime()
|
||||
|
||||
if not isinstance(oldValue, str):
|
||||
if newValue == PROXY_SERVER_BYPASS:
|
||||
return
|
||||
else:
|
||||
writeNewSettings(newValue)
|
||||
else:
|
||||
if oldValue != newValue:
|
||||
writeNewSettings(newValue)
|
||||
else:
|
||||
try:
|
||||
settings = AppSettings.get('CustomProxyBypass')
|
||||
@@ -103,5 +114,6 @@ class GuiCustomizeProxyBypassDialog(AppQDialog):
|
||||
|
||||
logger.error(f'error restoring proxy bypass address: {ex}')
|
||||
|
||||
@QtCore.Slot()
|
||||
def handleResetButtonClicked(self):
|
||||
self.proxyBypassEdit.setText(PROXY_SERVER_BYPASS)
|
||||
|
||||
@@ -599,10 +599,10 @@ class TestDownloadSpeedWorker(WebGETManager):
|
||||
# Use custom network speed test URL if possible
|
||||
settings = AppSettings.get('CustomNetworkSpeedTestURL')
|
||||
|
||||
if settings is None:
|
||||
url = NETWORK_SPEED_TEST_URL
|
||||
else:
|
||||
if isinstance(settings, str):
|
||||
url = settings
|
||||
else:
|
||||
url = NETWORK_SPEED_TEST_URL
|
||||
|
||||
self.networkReply = self.webGET(url, **self.kwargs)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user