Skip to content

Commit fccbd81

Browse files
committed
serialize enum value as string instead of number
1 parent 2bb45a9 commit fccbd81

File tree

4 files changed

+10
-12
lines changed

4 files changed

+10
-12
lines changed

WebAPI_Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* [#22989](https://github.com/qbittorrent/qBittorrent/pull/22989)
66
* `sync/maindata` returns one new field: `share_limit_action`
77
* `torrents/setShareLimits` now requires a new `shareLimitAction` param that sets a torrent's shareLimitAction property
8+
* possible values `Default`, `Stop`, `Remove`, `RemoveWithContent` and `EnableSuperSeeding`
89

910
## 2.11.10
1011

src/webui/api/serialize/serialize_torrent.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ QVariantMap serialize(const BitTorrent::Torrent &torrent)
171171
{KEY_TORRENT_POPULARITY, torrent.popularity()},
172172
{KEY_TORRENT_SEEDING_TIME_LIMIT, torrent.seedingTimeLimit()},
173173
{KEY_TORRENT_INACTIVE_SEEDING_TIME_LIMIT, torrent.inactiveSeedingTimeLimit()},
174-
{KEY_TORRENT_SHARE_LIMIT_ACTION, static_cast<int>(torrent.shareLimitAction())},
174+
{KEY_TORRENT_SHARE_LIMIT_ACTION, Utils::String::fromEnum(torrent.shareLimitAction())},
175175
{KEY_TORRENT_LAST_SEEN_COMPLETE_TIME, Utils::DateTime::toSecsSinceEpoch(torrent.lastSeenComplete())},
176176
{KEY_TORRENT_AUTO_TORRENT_MANAGEMENT, torrent.isAutoTMMEnabled()},
177177
{KEY_TORRENT_TIME_ACTIVE, torrent.activeTime()},

src/webui/api/torrentscontroller.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,10 +1367,7 @@ void TorrentsController::setShareLimitsAction()
13671367
const qreal ratioLimit = params()[u"ratioLimit"_s].toDouble();
13681368
const qlonglong seedingTimeLimit = params()[u"seedingTimeLimit"_s].toLongLong();
13691369
const qlonglong inactiveSeedingTimeLimit = params()[u"inactiveSeedingTimeLimit"_s].toLongLong();
1370-
const int shareLimitActionParamValue = params()[u"shareLimitAction"_s].toInt();
1371-
const BitTorrent::ShareLimitAction shareLimitAction = ((shareLimitActionParamValue >= 0) && (shareLimitActionParamValue <= 3))
1372-
? static_cast<BitTorrent::ShareLimitAction>(shareLimitActionParamValue)
1373-
: BitTorrent::ShareLimitAction::Default;
1370+
const BitTorrent::ShareLimitAction shareLimitAction = Utils::String::toEnum(params()[u"shareLimitAction"_s], BitTorrent::ShareLimitAction::Default);
13741371

13751372
const QStringList hashes = params()[u"hashes"_s].split(u'|');
13761373

src/webui/www/private/shareratio.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
maxRatio: Number(origValues[3]),
4141
maxSeedingTime: Number(origValues[4]),
4242
maxInactiveSeedingTime: Number(origValues[5]),
43-
shareLimitAction: Number(origValues[6])
43+
shareLimitAction: String(origValues[6])
4444
};
4545

4646
// select default when orig values not passed. using double equals to compare string and int
@@ -70,7 +70,7 @@
7070
document.getElementById("inactiveMinutes").value = values.inactiveSeedingTimeLimit;
7171
}
7272

73-
limitReachedActionsEl.value = values.shareLimitAction.toString();
73+
limitReachedActionsEl.value = values.shareLimitAction;
7474
}
7575

7676
shareLimitChanged();
@@ -195,11 +195,11 @@
195195
<div style="margin-left: 40px; margin-bottom: 5px;">
196196
<label id="actionListLabel" for="limitReachedActions">QBT_TR(Action when the limit is reached)QBT_TR[CONTEXT=UpDownRatioDialog]</label>
197197
<select id="limitReachedActions" aria-labelledby="actionListLabel">
198-
<option value="-1">QBT_TR(Default)QBT_TR[CONTEXT=UpDownRatioDialog]</option>
199-
<option value="0">QBT_TR(Stop torrent)QBT_TR[CONTEXT=UpDownRatioDialog]</option>
200-
<option value="1">QBT_TR(Remove torrent)QBT_TR[CONTEXT=UpDownRatioDialog]</option>
201-
<option value="3">QBT_TR(Remove torrent and its content)QBT_TR[CONTEXT=UpDownRatioDialog]</option>
202-
<option value="2">QBT_TR(Enable super seeding for torrent)QBT_TR[CONTEXT=UpDownRatioDialog]</option>
198+
<option value="Default">QBT_TR(Default)QBT_TR[CONTEXT=UpDownRatioDialog]</option>
199+
<option value="Stop">QBT_TR(Stop torrent)QBT_TR[CONTEXT=UpDownRatioDialog]</option>
200+
<option value="Remove">QBT_TR(Remove torrent)QBT_TR[CONTEXT=UpDownRatioDialog]</option>
201+
<option value="RemoveWithContent">QBT_TR(Remove torrent and its content)QBT_TR[CONTEXT=UpDownRatioDialog]</option>
202+
<option value="EnableSuperSeeding">QBT_TR(Enable super seeding for torrent)QBT_TR[CONTEXT=UpDownRatioDialog]</option>
203203
</select>
204204
</div>
205205
<div style="text-align: center; padding-top: 10px;">

0 commit comments

Comments
 (0)