@@ -46,6 +46,7 @@ constexpr auto serverVersionC = "serverVersion";
4646constexpr auto serverColorC = " serverColor" ;
4747constexpr auto serverTextColorC = " serverTextColor" ;
4848constexpr auto skipE2eeMetadataChecksumValidationC = " skipE2eeMetadataChecksumValidation" ;
49+ constexpr auto networkProxySettingC = " networkProxySetting" ;
4950constexpr auto networkProxyTypeC = " networkProxyType" ;
5051constexpr auto networkProxyHostNameC = " networkProxyHostName" ;
5152constexpr auto networkProxyPortC = " networkProxyPort" ;
@@ -524,28 +525,22 @@ void AccountManager::migrateNetworkSettings(const AccountPtr &account, const QSe
524525 auto accountProxyNeedsAuth = settings.value (networkProxyNeedsAuthC).toBool ();
525526 auto accountProxyUser = settings.value (networkProxyUserC).toString ();
526527
528+ // Override user settings with global settings if user is set to use global settings
527529 ConfigFile configFile;
528- const auto globalProxyType = static_cast <QNetworkProxy::ProxyType>(configFile.proxyType ());
529-
530- // Check if any proxy was set in the global settings
531- const auto accountHasDefaultOrNoProxy = accountProxyType == QNetworkProxy::NoProxy
532- || accountProxyType == QNetworkProxy::DefaultProxy;
533- const auto globalHasDefinedProxy = globalProxyType != QNetworkProxy::NoProxy;
534- if (globalHasDefinedProxy && accountHasDefaultOrNoProxy) {
535- accountProxyType = globalProxyType;
530+ auto accountProxySetting = settings.value (networkProxySettingC).toInt ();
531+ if (accountProxySetting == 0 && configFile.isMigrationInProgress ()) {
532+ accountProxyType = static_cast <QNetworkProxy::ProxyType>(configFile.proxyType ());
536533 accountProxyHost = configFile.proxyHostName ();
537534 accountProxyPort = configFile.proxyPort ();
538535 accountProxyNeedsAuth = configFile.proxyNeedsAuth ();
539536 accountProxyUser = configFile.proxyUser ();
540- qCInfo (lcAccountManager) << " Account has no proxy set, using global proxy instead :" << accountProxyType;
537+ qCInfo (lcAccountManager) << " Account is using global settings :" << accountProxyType;
541538 }
542539 account->setProxyType (accountProxyType);
543540 account->setProxyHostName (accountProxyHost);
544541 account->setProxyPort (accountProxyPort);
545542 account->setProxyNeedsAuth (accountProxyNeedsAuth);
546543 account->setProxyUser (accountProxyUser);
547-
548- // Global network settings vs User network settings
549544 const auto globalUseUploadLimit = static_cast <Account::AccountNetworkTransferLimitSetting>(configFile.useUploadLimit ());
550545 const auto globalUseDownloadLimit = static_cast <Account::AccountNetworkTransferLimitSetting>(configFile.useDownloadLimit ());
551546 // User network settings
@@ -555,26 +550,18 @@ void AccountManager::migrateNetworkSettings(const AccountPtr &account, const QSe
555550 auto userUseDownloadLimit = static_cast <Account::AccountNetworkTransferLimitSetting>(settings.value (networkDownloadLimitSettingC,
556551 QVariant::fromValue (account->downloadLimitSetting ())).toInt ());
557552 auto userDownloadLimit = settings.value (networkDownloadLimitC, account->downloadLimit ()).toInt ();
558-
559- // Override user settings with global settings if the global setting exists
560- const auto globalNetworkIsDefined = globalUseUploadLimit != Account::AccountNetworkTransferLimitSetting::NoLimit;
561- const auto userNetworkIsNotDefined = [](Account::AccountNetworkTransferLimitSetting userNetworkLimit) -> bool {
562- return userNetworkLimit == Account::AccountNetworkTransferLimitSetting::LegacyGlobalLimit
563- || userNetworkLimit == Account::AccountNetworkTransferLimitSetting::NoLimit;
564- };
565- if (globalNetworkIsDefined && userNetworkIsNotDefined (userUseUploadLimit)) {
553+ if (userUseUploadLimit == Account::AccountNetworkTransferLimitSetting::LegacyGlobalLimit) {
566554 userUseUploadLimit = globalUseUploadLimit;
567555 userUploadLimit = configFile.uploadLimit ();
568556 qCDebug (lcAccountManager) << " Overriding upload limit with global setting:" << userUseUploadLimit
569557 << " - upload limit:" << userUploadLimit;
570558 }
571- if (globalNetworkIsDefined && userNetworkIsNotDefined (userUseDownloadLimit) ) {
559+ if (userUseDownloadLimit == Account::AccountNetworkTransferLimitSetting::LegacyGlobalLimit ) {
572560 userUseDownloadLimit = globalUseDownloadLimit;
573561 userDownloadLimit = configFile.downloadLimit ();
574562 qCDebug (lcAccountManager) << " Overriding download limit with global setting" << userUseDownloadLimit
575563 << " - download limit:" << userDownloadLimit;
576564 }
577-
578565 if (userUseUploadLimit != Account::AccountNetworkTransferLimitSetting::NoLimit) {
579566 account->setUploadLimitSetting (userUseUploadLimit);
580567 account->setUploadLimit (userUploadLimit);
0 commit comments