diff --git a/WebAPI_Changelog.md b/WebAPI_Changelog.md index 1cf511c84..aaac52308 100644 --- a/WebAPI_Changelog.md +++ b/WebAPI_Changelog.md @@ -5,6 +5,7 @@ * [#22989](https://github.com/qbittorrent/qBittorrent/pull/22989) * `sync/maindata` returns one new field: `share_limit_action` * `torrents/setShareLimits` now requires a new `shareLimitAction` param that sets a torrent's shareLimitAction property + * possible values `Default`, `Stop`, `Remove`, `RemoveWithContent` and `EnableSuperSeeding` ## 2.11.10 diff --git a/src/webui/api/serialize/serialize_torrent.cpp b/src/webui/api/serialize/serialize_torrent.cpp index bae7ec4e8..1a64bd797 100644 --- a/src/webui/api/serialize/serialize_torrent.cpp +++ b/src/webui/api/serialize/serialize_torrent.cpp @@ -171,7 +171,7 @@ QVariantMap serialize(const BitTorrent::Torrent &torrent) {KEY_TORRENT_POPULARITY, torrent.popularity()}, {KEY_TORRENT_SEEDING_TIME_LIMIT, torrent.seedingTimeLimit()}, {KEY_TORRENT_INACTIVE_SEEDING_TIME_LIMIT, torrent.inactiveSeedingTimeLimit()}, - {KEY_TORRENT_SHARE_LIMIT_ACTION, static_cast(torrent.shareLimitAction())}, + {KEY_TORRENT_SHARE_LIMIT_ACTION, Utils::String::fromEnum(torrent.shareLimitAction())}, {KEY_TORRENT_LAST_SEEN_COMPLETE_TIME, Utils::DateTime::toSecsSinceEpoch(torrent.lastSeenComplete())}, {KEY_TORRENT_AUTO_TORRENT_MANAGEMENT, torrent.isAutoTMMEnabled()}, {KEY_TORRENT_TIME_ACTIVE, torrent.activeTime()}, diff --git a/src/webui/api/torrentscontroller.cpp b/src/webui/api/torrentscontroller.cpp index c7c58e0cd..0d3cb10df 100644 --- a/src/webui/api/torrentscontroller.cpp +++ b/src/webui/api/torrentscontroller.cpp @@ -1367,10 +1367,7 @@ void TorrentsController::setShareLimitsAction() const qreal ratioLimit = params()[u"ratioLimit"_s].toDouble(); const qlonglong seedingTimeLimit = params()[u"seedingTimeLimit"_s].toLongLong(); const qlonglong inactiveSeedingTimeLimit = params()[u"inactiveSeedingTimeLimit"_s].toLongLong(); - const int shareLimitActionParamValue = params()[u"shareLimitAction"_s].toInt(); - const BitTorrent::ShareLimitAction shareLimitAction = ((shareLimitActionParamValue >= 0) && (shareLimitActionParamValue <= 3)) - ? static_cast(shareLimitActionParamValue) - : BitTorrent::ShareLimitAction::Default; + const BitTorrent::ShareLimitAction shareLimitAction = Utils::String::toEnum(params()[u"shareLimitAction"_s], BitTorrent::ShareLimitAction::Default); const QStringList hashes = params()[u"hashes"_s].split(u'|'); diff --git a/src/webui/www/private/shareratio.html b/src/webui/www/private/shareratio.html index 057f58797..c1f007522 100644 --- a/src/webui/www/private/shareratio.html +++ b/src/webui/www/private/shareratio.html @@ -40,7 +40,7 @@ maxRatio: Number(origValues[3]), maxSeedingTime: Number(origValues[4]), maxInactiveSeedingTime: Number(origValues[5]), - shareLimitAction: Number(origValues[6]) + shareLimitAction: String(origValues[6]) }; // select default when orig values not passed. using double equals to compare string and int @@ -70,7 +70,7 @@ document.getElementById("inactiveMinutes").value = values.inactiveSeedingTimeLimit; } - limitReachedActionsEl.value = values.shareLimitAction.toString(); + limitReachedActionsEl.value = values.shareLimitAction; } shareLimitChanged(); @@ -195,11 +195,11 @@