mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-09 14:27:56 +00:00
Keep compatibility with qBittorrent < 2.3.0 (import settings from the registry)
This commit is contained in:
parent
b9241ad5ad
commit
0c40a8ab05
@ -35,41 +35,50 @@
|
|||||||
|
|
||||||
class QIniSettings : public QSettings {
|
class QIniSettings : public QSettings {
|
||||||
public:
|
public:
|
||||||
QIniSettings(const QString &organization, const QString &application = QString(), QObject *parent = 0 ):
|
QIniSettings(const QString &organization, const QString &application = QString(), QObject *parent = 0 ):
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_WS_WIN
|
||||||
QSettings(QSettings::IniFormat, QSettings::UserScope, organization, application, parent)
|
QSettings(QSettings::IniFormat, QSettings::UserScope, organization, application, parent)
|
||||||
#else
|
#else
|
||||||
QSettings(organization, application, parent)
|
QSettings(organization, application, parent)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_WS_WIN
|
||||||
QVariant value(const QString & key, const QVariant &defaultValue = QVariant()) const {
|
QVariant value(const QString & key, const QVariant &defaultValue = QVariant()) const {
|
||||||
QVariant ret = QSettings::value(key);
|
QVariant ret = QSettings::value(key);
|
||||||
if(format() == QSettings::NativeFormat) {
|
if(format() == QSettings::NativeFormat) {
|
||||||
if(ret.isNull()) {
|
if(ret.isNull()) {
|
||||||
// Fallback on Windows, use \ in key instead of /
|
// Fallback on Windows, use \ in key instead of /
|
||||||
if(key.contains("/")) {
|
if(key.contains("/")) {
|
||||||
ret = QSettings::value(key.replace("/", "\\"));
|
ret = QSettings::value(key.replace("/", "\\"));
|
||||||
} else {
|
} else {
|
||||||
if(key.contains("\\")) {
|
if(key.contains("\\")) {
|
||||||
ret = QSettings::value(key.replace("\\", "/"));
|
ret = QSettings::value(key.replace("\\", "/"));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(ret.isNull())
|
}
|
||||||
return defaultValue;
|
} else {
|
||||||
return ret;
|
// Keep compatibility with qBittorrent < 2.3.0
|
||||||
|
// Import the setting from the registry
|
||||||
|
QSettings old_settings(organizationName(), applicationName());
|
||||||
|
ret = old_settings.value(key);
|
||||||
|
if(!ret.isEmpty()) {
|
||||||
|
setValue(key, ret);
|
||||||
|
old_settings.remove(key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if(ret.isNull())
|
||||||
|
return defaultValue;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void setValue(const QString &key, const QVariant &val) {
|
void setValue(const QString &key, const QVariant &val) {
|
||||||
if(format() == QSettings::NativeFormat)
|
if(format() == QSettings::NativeFormat)
|
||||||
key = key.replace("/", "\\");
|
key = key.replace("/", "\\");
|
||||||
QSettings::setValue(key, val);
|
QSettings::setValue(key, val);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user