mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-25 14:04:23 +00:00
Migrate proxy settings
Q_ENUM_NS(ProxyType) was introduced in 4.4.0. Before that wrapping QMetaEnum used the int value itself for loading/storing. Closes #15994
This commit is contained in:
parent
d6fc020ba7
commit
a7c5826e05
@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include "base/bittorrent/torrentcontentlayout.h"
|
#include "base/bittorrent/torrentcontentlayout.h"
|
||||||
#include "base/logger.h"
|
#include "base/logger.h"
|
||||||
|
#include "base/net/proxyconfigurationmanager.h"
|
||||||
#include "base/preferences.h"
|
#include "base/preferences.h"
|
||||||
#include "base/profile.h"
|
#include "base/profile.h"
|
||||||
#include "base/settingsstorage.h"
|
#include "base/settingsstorage.h"
|
||||||
@ -42,7 +43,7 @@
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
const int MIGRATION_VERSION = 2;
|
const int MIGRATION_VERSION = 3;
|
||||||
const char MIGRATION_VERSION_KEY[] = "Meta/MigrationVersion";
|
const char MIGRATION_VERSION_KEY[] = "Meta/MigrationVersion";
|
||||||
|
|
||||||
void exportWebUIHttpsFiles()
|
void exportWebUIHttpsFiles()
|
||||||
@ -326,6 +327,46 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void migrateProxySettingsEnum()
|
||||||
|
{
|
||||||
|
auto *settingsStorage = SettingsStorage::instance();
|
||||||
|
const auto key = QString::fromLatin1("Network/Proxy/Type");
|
||||||
|
const auto value = settingsStorage->loadValue<QString>(key);
|
||||||
|
|
||||||
|
bool ok = false;
|
||||||
|
const auto number = value.toInt(&ok);
|
||||||
|
|
||||||
|
if (ok)
|
||||||
|
{
|
||||||
|
switch (number)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
settingsStorage->storeValue(key, Net::ProxyType::None);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
settingsStorage->storeValue(key, Net::ProxyType::HTTP);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
settingsStorage->storeValue(key, Net::ProxyType::SOCKS5);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
settingsStorage->storeValue(key, Net::ProxyType::HTTP_PW);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
settingsStorage->storeValue(key, Net::ProxyType::SOCKS5_PW);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
settingsStorage->storeValue(key, Net::ProxyType::SOCKS4);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
LogMsg(QObject::tr("Invalid value found in configuration file, reverting it to default. Key: \"%1\". Invalid value: \"%2\".")
|
||||||
|
.arg(key, QString::number(number)), Log::WARNING);
|
||||||
|
settingsStorage->removeValue(key);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool upgrade(const bool /*ask*/)
|
bool upgrade(const bool /*ask*/)
|
||||||
@ -343,9 +384,13 @@ bool upgrade(const bool /*ask*/)
|
|||||||
upgradeDNSServiceSettings();
|
upgradeDNSServiceSettings();
|
||||||
upgradeTrayIconStyleSettings();
|
upgradeTrayIconStyleSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (version < 2)
|
if (version < 2)
|
||||||
migrateSettingKeys();
|
migrateSettingKeys();
|
||||||
|
|
||||||
|
if (version < 3)
|
||||||
|
migrateProxySettingsEnum();
|
||||||
|
|
||||||
version = MIGRATION_VERSION;
|
version = MIGRATION_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user