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,22 +168,25 @@ int main(int argc, char *argv[])
|
|||||||
if (!qputenv("QBITTORRENT", QBT_VERSION))
|
if (!qputenv("QBITTORRENT", QBT_VERSION))
|
||||||
fprintf(stderr, "Couldn't set environment variable...\n");
|
fprintf(stderr, "Couldn't set environment variable...\n");
|
||||||
|
|
||||||
|
const bool firstTimeUser = !Preferences::instance()->getAcceptedLegal();
|
||||||
|
if (firstTimeUser) {
|
||||||
#ifndef DISABLE_GUI
|
#ifndef DISABLE_GUI
|
||||||
if (!userAgreesWithLegalNotice())
|
if (!userAgreesWithLegalNotice())
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
|
||||||
#elif defined(Q_OS_WIN)
|
#elif defined(Q_OS_WIN)
|
||||||
if (_isatty(_fileno(stdin))
|
if (_isatty(_fileno(stdin))
|
||||||
&& _isatty(_fileno(stdout))
|
&& _isatty(_fileno(stdout))
|
||||||
&& !userAgreesWithLegalNotice())
|
&& !userAgreesWithLegalNotice())
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
#else
|
#else
|
||||||
if (!params.shouldDaemonize
|
if (!params.shouldDaemonize
|
||||||
&& isatty(fileno(stdin))
|
&& isatty(fileno(stdin))
|
||||||
&& isatty(fileno(stdout))
|
&& isatty(fileno(stdout))
|
||||||
&& !userAgreesWithLegalNotice())
|
&& !userAgreesWithLegalNotice())
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// Check if qBittorrent is already running for this user
|
// Check if qBittorrent is already running for this user
|
||||||
if (app->isRunning()) {
|
if (app->isRunning()) {
|
||||||
@ -233,16 +236,24 @@ int main(int argc, char *argv[])
|
|||||||
app->setAttribute(Qt::AA_DontShowIconsInMenus);
|
app->setAttribute(Qt::AA_DontShowIconsInMenus);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (!firstTimeUser) {
|
||||||
|
handleChangedDefaults(DefaultPreferencesMode::Legacy);
|
||||||
|
|
||||||
#ifndef DISABLE_GUI
|
#ifndef DISABLE_GUI
|
||||||
if (!upgrade()) return EXIT_FAILURE;
|
if (!upgrade()) return EXIT_FAILURE;
|
||||||
#elif defined(Q_OS_WIN)
|
#elif defined(Q_OS_WIN)
|
||||||
if (!upgrade(_isatty(_fileno(stdin))
|
if (!upgrade(_isatty(_fileno(stdin))
|
||||||
&& _isatty(_fileno(stdout)))) return EXIT_FAILURE;
|
&& _isatty(_fileno(stdout)))) return EXIT_FAILURE;
|
||||||
#else
|
#else
|
||||||
if (!upgrade(!params.shouldDaemonize
|
if (!upgrade(!params.shouldDaemonize
|
||||||
&& isatty(fileno(stdin))
|
&& isatty(fileno(stdin))
|
||||||
&& isatty(fileno(stdout)))) return EXIT_FAILURE;
|
&& isatty(fileno(stdout)))) return EXIT_FAILURE;
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
handleChangedDefaults(DefaultPreferencesMode::Current);
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(DISABLE_GUI) && !defined(Q_OS_WIN)
|
#if defined(DISABLE_GUI) && !defined(Q_OS_WIN)
|
||||||
if (params.shouldDaemonize) {
|
if (params.shouldDaemonize) {
|
||||||
app.reset(); // Destroy current application
|
app.reset(); // Destroy current application
|
||||||
@ -378,8 +389,7 @@ void displayBadArgMessage(const QString &message)
|
|||||||
bool userAgreesWithLegalNotice()
|
bool userAgreesWithLegalNotice()
|
||||||
{
|
{
|
||||||
Preferences *const pref = Preferences::instance();
|
Preferences *const pref = Preferences::instance();
|
||||||
if (pref->getAcceptedLegal()) // Already accepted once
|
Q_ASSERT(!pref->getAcceptedLegal());
|
||||||
return true;
|
|
||||||
|
|
||||||
#ifdef DISABLE_GUI
|
#ifdef DISABLE_GUI
|
||||||
const QString eula = QString("\n*** %1 ***\n").arg(QObject::tr("Legal Notice"))
|
const QString eula = QString("\n*** %1 ***\n").arg(QObject::tr("Legal Notice"))
|
||||||
|
@ -82,3 +82,23 @@ bool upgrade(const bool /*ask*/)
|
|||||||
exportWebUIHttpsFiles();
|
exportWebUIHttpsFiles();
|
||||||
return true;
|
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
|
#pragma once
|
||||||
|
|
||||||
|
enum class DefaultPreferencesMode
|
||||||
|
{
|
||||||
|
Legacy,
|
||||||
|
Current
|
||||||
|
};
|
||||||
|
|
||||||
|
void handleChangedDefaults(DefaultPreferencesMode mode);
|
||||||
bool upgrade(bool ask = true);
|
bool upgrade(bool ask = true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user