mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-23 04:54:18 +00:00
Merge pull request #11847 from glassez/legacy-defaults
Keep legacy defaults for existing users
This commit is contained in:
commit
1e63dcb400
@ -168,6 +168,8 @@ int main(int argc, char *argv[])
|
||||
if (!qputenv("QBITTORRENT", QBT_VERSION))
|
||||
fprintf(stderr, "Couldn't set environment variable...\n");
|
||||
|
||||
const bool firstTimeUser = !Preferences::instance()->getAcceptedLegal();
|
||||
if (firstTimeUser) {
|
||||
#ifndef DISABLE_GUI
|
||||
if (!userAgreesWithLegalNotice())
|
||||
return EXIT_SUCCESS;
|
||||
@ -184,6 +186,7 @@ int main(int argc, char *argv[])
|
||||
&& !userAgreesWithLegalNotice())
|
||||
return EXIT_SUCCESS;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Check if qBittorrent is already running for this user
|
||||
if (app->isRunning()) {
|
||||
@ -233,6 +236,9 @@ int main(int argc, char *argv[])
|
||||
app->setAttribute(Qt::AA_DontShowIconsInMenus);
|
||||
#endif
|
||||
|
||||
if (!firstTimeUser) {
|
||||
handleChangedDefaults(DefaultPreferencesMode::Legacy);
|
||||
|
||||
#ifndef DISABLE_GUI
|
||||
if (!upgrade()) return EXIT_FAILURE;
|
||||
#elif defined(Q_OS_WIN)
|
||||
@ -243,6 +249,11 @@ int main(int argc, char *argv[])
|
||||
&& isatty(fileno(stdin))
|
||||
&& isatty(fileno(stdout)))) return EXIT_FAILURE;
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
handleChangedDefaults(DefaultPreferencesMode::Current);
|
||||
}
|
||||
|
||||
#if defined(DISABLE_GUI) && !defined(Q_OS_WIN)
|
||||
if (params.shouldDaemonize) {
|
||||
app.reset(); // Destroy current application
|
||||
@ -378,8 +389,7 @@ void displayBadArgMessage(const QString &message)
|
||||
bool userAgreesWithLegalNotice()
|
||||
{
|
||||
Preferences *const pref = Preferences::instance();
|
||||
if (pref->getAcceptedLegal()) // Already accepted once
|
||||
return true;
|
||||
Q_ASSERT(!pref->getAcceptedLegal());
|
||||
|
||||
#ifdef DISABLE_GUI
|
||||
const QString eula = QString("\n*** %1 ***\n").arg(QObject::tr("Legal Notice"))
|
||||
|
@ -82,3 +82,23 @@ bool upgrade(const bool /*ask*/)
|
||||
exportWebUIHttpsFiles();
|
||||
return true;
|
||||
}
|
||||
|
||||
void handleChangedDefaults(const DefaultPreferencesMode mode)
|
||||
{
|
||||
struct DefaultValue
|
||||
{
|
||||
QString name;
|
||||
QVariant legacy;
|
||||
QVariant current;
|
||||
};
|
||||
|
||||
const QVector<DefaultValue> changedDefaults {
|
||||
{QLatin1String {"BitTorrent/Session/QueueingSystemEnabled"}, true, false}
|
||||
};
|
||||
|
||||
SettingsStorage *settingsStorage {SettingsStorage::instance()};
|
||||
for (auto it = changedDefaults.cbegin(); it != changedDefaults.cend(); ++it) {
|
||||
if (settingsStorage->loadValue(it->name).isNull())
|
||||
settingsStorage->storeValue(it->name, (mode == DefaultPreferencesMode::Legacy ? it->legacy : it->current));
|
||||
}
|
||||
}
|
||||
|
@ -28,4 +28,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
enum class DefaultPreferencesMode
|
||||
{
|
||||
Legacy,
|
||||
Current
|
||||
};
|
||||
|
||||
void handleChangedDefaults(DefaultPreferencesMode mode);
|
||||
bool upgrade(bool ask = true);
|
||||
|
Loading…
x
Reference in New Issue
Block a user