mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-25 10:46:15 +03:00
Merge pull request #15811 from Chocobo1/configVersioning
Introduce versioning on main configuration file
This commit is contained in:
commit
c652123145
5 changed files with 69 additions and 54 deletions
|
@ -36,12 +36,15 @@
|
|||
#include "base/preferences.h"
|
||||
#include "base/profile.h"
|
||||
#include "base/settingsstorage.h"
|
||||
#include "base/settingvalue.h"
|
||||
#include "base/utils/fs.h"
|
||||
#include "base/utils/io.h"
|
||||
#include "base/utils/string.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
const int MIGRATION_VERSION = 1;
|
||||
|
||||
void exportWebUIHttpsFiles()
|
||||
{
|
||||
const auto migrate = [](const QString &oldKey, const QString &newKey, const QString &savePath)
|
||||
|
@ -228,6 +231,12 @@ namespace
|
|||
}
|
||||
|
||||
bool upgrade(const bool /*ask*/)
|
||||
{
|
||||
CachedSettingValue<int> version {"Meta/MigrationVersion", 0};
|
||||
|
||||
if (version != MIGRATION_VERSION)
|
||||
{
|
||||
if (version < 1)
|
||||
{
|
||||
exportWebUIHttpsFiles();
|
||||
upgradeTorrentContentLayout();
|
||||
|
@ -235,6 +244,11 @@ bool upgrade(const bool /*ask*/)
|
|||
upgradeSchedulerDaysSettings();
|
||||
upgradeDNSServiceSettings();
|
||||
upgradeTrayIconStyleSettings();
|
||||
}
|
||||
|
||||
version = MIGRATION_VERSION;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -255,7 +269,7 @@ void handleChangedDefaults(const DefaultPreferencesMode mode)
|
|||
SettingsStorage *settingsStorage {SettingsStorage::instance()};
|
||||
for (auto it = changedDefaults.cbegin(); it != changedDefaults.cend(); ++it)
|
||||
{
|
||||
if (settingsStorage->loadValue<QVariant>(it->name).isNull())
|
||||
if (!settingsStorage->hasKey(it->name))
|
||||
settingsStorage->storeValue(it->name, (mode == DefaultPreferencesMode::Legacy ? it->legacy : it->current));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1296,12 +1296,12 @@ void Preferences::setMainVSplitterState(const QByteArray &state)
|
|||
|
||||
QString Preferences::getMainLastDir() const
|
||||
{
|
||||
return value("MainWindowLastDir", QDir::homePath());
|
||||
return value("MainWindow/LastDir", QDir::homePath());
|
||||
}
|
||||
|
||||
void Preferences::setMainLastDir(const QString &path)
|
||||
{
|
||||
setValue("MainWindowLastDir", path);
|
||||
setValue("MainWindow/LastDir", path);
|
||||
}
|
||||
|
||||
QByteArray Preferences::getPeerListState() const
|
||||
|
|
|
@ -60,17 +60,18 @@ public:
|
|||
{
|
||||
if constexpr (std::is_enum_v<T>)
|
||||
{
|
||||
const auto value = loadValueImpl(key).toString();
|
||||
const auto value = loadValue<QString>(key);
|
||||
return Utils::String::toEnum(value, defaultValue);
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, QVariant>)
|
||||
{
|
||||
return loadValueImpl(key, defaultValue);
|
||||
}
|
||||
else if constexpr (IsQFlags<T>::value)
|
||||
{
|
||||
const QVariant value = loadValueImpl(key, static_cast<typename T::Int>(defaultValue));
|
||||
return T {value.template value<typename T::Int>()};
|
||||
const typename T::Int value = loadValue(key, static_cast<typename T::Int>(defaultValue));
|
||||
return T {value};
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, QVariant>)
|
||||
{
|
||||
// fast path for loading QVariant
|
||||
return loadValueImpl(key, defaultValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -146,9 +146,9 @@ namespace Utils
|
|||
{
|
||||
return Version(s);
|
||||
}
|
||||
catch (const RuntimeError &er)
|
||||
catch (const RuntimeError &error)
|
||||
{
|
||||
qDebug() << "Error parsing version:" << er.message();
|
||||
qDebug() << "Error parsing version:" << error.message();
|
||||
return defaultVersion;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -634,62 +634,62 @@
|
|||
<legend>QBT_TR(Language)QBT_TR[CONTEXT=OptionsDialog]</legend>
|
||||
<label for="locale_select">QBT_TR(User Interface Language:)QBT_TR[CONTEXT=OptionsDialog]</label>
|
||||
<select id="locale_select">
|
||||
<option value="ar_AE">عربي</option>
|
||||
<option value="az@latin">Azərbaycan dili</option>
|
||||
<option value="be_BY">Беларуская</option>
|
||||
<option value="bg_BG">Български</option>
|
||||
<option value="ca_ES">Català</option>
|
||||
<option value="cs_CZ">Čeština</option>
|
||||
<option value="da_DK">Dansk</option>
|
||||
<option value="de_DE">Deutsch</option>
|
||||
<option value="el_GR">Ελληνικά</option>
|
||||
<option value="en">English</option>
|
||||
<option value="en_AU">English (Australia)</option>
|
||||
<option value="en_GB">English (United Kingdom)</option>
|
||||
<option value="eo_EO">Esperanto</option>
|
||||
<option value="et">Eesti, eesti keel</option>
|
||||
<option value="fa">فارسی</option>
|
||||
<option value="fr_FR">Français</option>
|
||||
<option value="de_DE">Deutsch</option>
|
||||
<option value="hu_HU">Magyar</option>
|
||||
<option value="is">Íslenska</option>
|
||||
<option value="id">Bahasa Indonesia</option>
|
||||
<option value="it_IT">Italiano</option>
|
||||
<option value="nl_NL">Nederlands</option>
|
||||
<option value="es_ES">Español</option>
|
||||
<option value="ca_ES">Català</option>
|
||||
<option value="et">Eesti, eesti keel</option>
|
||||
<option value="eu_ES">Euskara</option>
|
||||
<option value="fa">فارسی</option>
|
||||
<option value="fi_FI">Suomi</option>
|
||||
<option value="fr_FR">Français</option>
|
||||
<option value="gl_ES">Galego</option>
|
||||
<option value="oc">lenga d'òc</option>
|
||||
<option value="pt_BR">Português brasileiro</option>
|
||||
<option value="pt_PT">Português</option>
|
||||
<option value="pl_PL">Polski</option>
|
||||
<option value="lv_LV">Latviešu valoda</option>
|
||||
<option value="lt_LT">Lietuvių</option>
|
||||
<option value="he_IL">עברית</option>
|
||||
<option value="hi_IN">हिन्दी, हिंदी</option>
|
||||
<option value="hr_HR">Hrvatski</option>
|
||||
<option value="hu_HU">Magyar</option>
|
||||
<option value="hy_AM">Հայերեն</option>
|
||||
<option value="id">Bahasa Indonesia</option>
|
||||
<option value="is">Íslenska</option>
|
||||
<option value="it_IT">Italiano</option>
|
||||
<option value="ja_JP">日本語</option>
|
||||
<option value="ka_GE">ქართული</option>
|
||||
<option value="ko_KR">한국어</option>
|
||||
<option value="ltg">Latgalīšu volūda</option>
|
||||
<option value="lt_LT">Lietuvių</option>
|
||||
<option value="lv_LV">Latviešu valoda</option>
|
||||
<option value="mn_MN">Монгол хэл</option>
|
||||
<option value="ms_MY">بهاس ملايو</option>
|
||||
<option value="cs_CZ">Čeština</option>
|
||||
<option value="nb_NO">Norsk</option>
|
||||
<option value="nl_NL">Nederlands</option>
|
||||
<option value="oc">lenga d'òc</option>
|
||||
<option value="pl_PL">Polski</option>
|
||||
<option value="pt_BR">Português brasileiro</option>
|
||||
<option value="pt_PT">Português</option>
|
||||
<option value="ro_RO">Română</option>
|
||||
<option value="ru_RU">Русский</option>
|
||||
<option value="sk_SK">Slovenčina</option>
|
||||
<option value="sl_SI">Slovenščina</option>
|
||||
<option value="sr_CS">Српски</option>
|
||||
<option value="hi_IN">हिन्दी, हिंदी</option>
|
||||
<option value="hr_HR">Hrvatski</option>
|
||||
<option value="hy_AM">Հայերեն</option>
|
||||
<option value="ro_RO">Română</option>
|
||||
<option value="sv_SE">Svenska</option>
|
||||
<option value="th">ไทย</option>
|
||||
<option value="tr_TR">Türkçe</option>
|
||||
<option value="el_GR">Ελληνικά</option>
|
||||
<option value="sv_SE">Svenska</option>
|
||||
<option value="fi_FI">Suomi</option>
|
||||
<option value="nb_NO">Norsk</option>
|
||||
<option value="da_DK">Dansk</option>
|
||||
<option value="bg_BG">Български</option>
|
||||
<option value="uk_UA">Українська</option>
|
||||
<option value="uz@Latn">أۇزبېك</option>
|
||||
<option value="ru_RU">Русский</option>
|
||||
<option value="ja_JP">日本語</option>
|
||||
<option value="he_IL">עברית</option>
|
||||
<option value="ar_AE">عربي</option>
|
||||
<option value="ka_GE">ქართული</option>
|
||||
<option value="be_BY">Беларуская</option>
|
||||
<option value="eu_ES">Euskara</option>
|
||||
<option value="vi_VN">Tiếng Việt</option>
|
||||
<option value="zh">简体中文</option>
|
||||
<option value="zh_TW">正體中文</option>
|
||||
<option value="zh_HK">香港正體字</option>
|
||||
<option value="ko_KR">한국어</option>
|
||||
<option value="zh_TW">正體中文</option>
|
||||
</select>
|
||||
</fieldset>
|
||||
|
||||
|
|
Loading…
Reference in a new issue