Use Start/Stop instead of Resume/Pause

PR #20532.

---------

Co-authored-by: Vladimir Golovnev (Glassez) <glassez@yandex.ru>
This commit is contained in:
thalieht
2024-03-25 18:11:04 +02:00
committed by GitHub
parent f2d6129db3
commit 5d1c249606
70 changed files with 413 additions and 391 deletions

View File

@@ -140,8 +140,8 @@ namespace
if (!addTorrentParams.savePath.isEmpty())
result.append(u"@savePath=" + addTorrentParams.savePath.data());
if (addTorrentParams.addPaused.has_value())
result.append(*addTorrentParams.addPaused ? u"@addPaused=1"_s : u"@addPaused=0"_s);
if (addTorrentParams.addStopped.has_value())
result.append(*addTorrentParams.addStopped ? u"@addStopped=1"_s : u"@addStopped=0"_s);
if (addTorrentParams.skipChecking)
result.append(u"@skipChecking"_s);
@@ -180,9 +180,9 @@ namespace
continue;
}
if (param.startsWith(u"@addPaused="))
if (param.startsWith(u"@addStopped="))
{
addTorrentParams.addPaused = (QStringView(param).mid(11).toInt() != 0);
addTorrentParams.addStopped = (QStringView(param).mid(11).toInt() != 0);
continue;
}

View File

@@ -263,8 +263,8 @@ namespace
}
throw CommandLineParameterError(QCoreApplication::translate("CMD Options", "Parameter '%1' must follow syntax '%1=%2'",
"e.g. Parameter '--add-paused' must follow syntax "
"'--add-paused=<true|false>'")
"e.g. Parameter '--add-stopped' must follow syntax "
"'--add-stopped=<true|false>'")
.arg(fullParameter(), u"<true|false>"_s));
}
@@ -318,7 +318,7 @@ namespace
constexpr const StringOption CONFIGURATION_OPTION {"configuration"};
constexpr const BoolOption RELATIVE_FASTRESUME {"relative-fastresume"};
constexpr const StringOption SAVE_PATH_OPTION {"save-path"};
constexpr const TriStateBoolOption PAUSED_OPTION {"add-paused", true};
constexpr const TriStateBoolOption STOPPED_OPTION {"add-stopped", true};
constexpr const BoolOption SKIP_HASH_CHECK_OPTION {"skip-hash-check"};
constexpr const StringOption CATEGORY_OPTION {"category"};
constexpr const BoolOption SEQUENTIAL_OPTION {"sequential"};
@@ -345,7 +345,7 @@ QBtCommandLineParameters::QBtCommandLineParameters(const QProcessEnvironment &en
addTorrentParams.skipChecking = SKIP_HASH_CHECK_OPTION.value(env);
addTorrentParams.sequential = SEQUENTIAL_OPTION.value(env);
addTorrentParams.firstLastPiecePriority = FIRST_AND_LAST_OPTION.value(env);
addTorrentParams.addPaused = PAUSED_OPTION.value(env);
addTorrentParams.addStopped = STOPPED_OPTION.value(env);
}
QBtCommandLineParameters parseCommandLine(const QStringList &args)
@@ -417,9 +417,9 @@ QBtCommandLineParameters parseCommandLine(const QStringList &args)
{
result.addTorrentParams.savePath = Path(SAVE_PATH_OPTION.value(arg));
}
else if (arg == PAUSED_OPTION)
else if (arg == STOPPED_OPTION)
{
result.addTorrentParams.addPaused = PAUSED_OPTION.value(arg);
result.addTorrentParams.addStopped = STOPPED_OPTION.value(arg);
}
else if (arg == SKIP_HASH_CHECK_OPTION)
{
@@ -523,7 +523,7 @@ QString makeUsage(const QString &prgName)
+ wrapText(QCoreApplication::translate("CMD Options", "Options when adding new torrents:"), 0) + u'\n'
+ SAVE_PATH_OPTION.usage(QCoreApplication::translate("CMD Options", "path")) + wrapText(QCoreApplication::translate("CMD Options", "Torrent save path")) + u'\n'
+ PAUSED_OPTION.usage() + wrapText(QCoreApplication::translate("CMD Options", "Add torrents as started or paused")) + u'\n'
+ STOPPED_OPTION.usage() + wrapText(QCoreApplication::translate("CMD Options", "Add torrents as running or stopped")) + u'\n'
+ SKIP_HASH_CHECK_OPTION.usage() + wrapText(QCoreApplication::translate("CMD Options", "Skip hash check")) + u'\n'
+ CATEGORY_OPTION.usage(QCoreApplication::translate("CMD Options", "name"))
+ wrapText(QCoreApplication::translate("CMD Options", "Assign torrents to category. If the category doesn't exist, it will be "

View File

@@ -46,7 +46,7 @@
namespace
{
const int MIGRATION_VERSION = 7;
const int MIGRATION_VERSION = 8;
const QString MIGRATION_VERSION_KEY = u"Meta/MigrationVersion"_s;
void exportWebUIHttpsFiles()
@@ -468,6 +468,16 @@ namespace
settingsStorage->removeValue(oldKey);
}
void migrateAddPausedSetting()
{
auto *settingsStorage = SettingsStorage::instance();
const auto oldKey = u"BitTorrent/Session/AddTorrentPaused"_s;
const auto newKey = u"BitTorrent/Session/AddTorrentStopped"_s;
settingsStorage->storeValue(newKey, settingsStorage->loadValue<bool>(oldKey));
settingsStorage->removeValue(oldKey);
}
}
bool upgrade()
@@ -509,6 +519,9 @@ bool upgrade()
if (version < 7)
migrateShareLimitActionSettings();
if (version < 8)
migrateAddPausedSetting();
version = MIGRATION_VERSION;
}