mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-16 02:03:07 -07:00
parent
f4e6b515c2
commit
b3690494ab
11 changed files with 19 additions and 24 deletions
|
@ -1222,7 +1222,7 @@ qreal SessionImpl::globalMaxRatio() const
|
|||
void SessionImpl::setGlobalMaxRatio(qreal ratio)
|
||||
{
|
||||
if (ratio < 0)
|
||||
ratio = -1.;
|
||||
ratio = Torrent::NO_RATIO_LIMIT;
|
||||
|
||||
if (ratio != globalMaxRatio())
|
||||
{
|
||||
|
@ -2313,7 +2313,7 @@ void SessionImpl::processTorrentShareLimits(TorrentImpl *torrent)
|
|||
QString description;
|
||||
|
||||
if (const qreal ratio = torrent->realRatio();
|
||||
(ratioLimit >= 0) && (ratio <= Torrent::MAX_RATIO) && (ratio >= ratioLimit))
|
||||
(ratioLimit >= 0) && (ratio >= ratioLimit))
|
||||
{
|
||||
reached = true;
|
||||
description = tr("Torrent reached the share ratio limit.");
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
|
||||
#include "torrent.h"
|
||||
|
||||
#include <limits>
|
||||
|
||||
#include <QHash>
|
||||
|
||||
#include "infohash.h"
|
||||
|
@ -51,7 +53,7 @@ namespace BitTorrent
|
|||
const int Torrent::USE_GLOBAL_INACTIVE_SEEDING_TIME = -2;
|
||||
const int Torrent::NO_INACTIVE_SEEDING_TIME_LIMIT = -1;
|
||||
|
||||
const qreal Torrent::MAX_RATIO = 9999;
|
||||
const qreal Torrent::MAX_RATIO = std::numeric_limits<qreal>::infinity();
|
||||
|
||||
TorrentID Torrent::id() const
|
||||
{
|
||||
|
|
|
@ -1549,7 +1549,8 @@ qreal TorrentImpl::realRatio() const
|
|||
|
||||
const qreal ratio = upload / static_cast<qreal>(download);
|
||||
Q_ASSERT(ratio >= 0);
|
||||
return (ratio > MAX_RATIO) ? MAX_RATIO : ratio;
|
||||
|
||||
return ratio;
|
||||
}
|
||||
|
||||
int TorrentImpl::uploadPayloadRate() const
|
||||
|
@ -2712,8 +2713,6 @@ void TorrentImpl::setRatioLimit(qreal limit)
|
|||
{
|
||||
if (limit < USE_GLOBAL_RATIO)
|
||||
limit = NO_RATIO_LIMIT;
|
||||
else if (limit > MAX_RATIO)
|
||||
limit = MAX_RATIO;
|
||||
|
||||
if (m_ratioLimit != limit)
|
||||
{
|
||||
|
|
|
@ -3021,9 +3021,6 @@ Disable encryption: Only connect to peers without protocol encryption</string>
|
|||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>9998.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.050000000000000</double>
|
||||
</property>
|
||||
|
|
|
@ -439,10 +439,10 @@ void PropertiesWidget::loadDynamicData()
|
|||
|
||||
// Update ratio info
|
||||
const qreal ratio = m_torrent->realRatio();
|
||||
m_ui->labelShareRatioVal->setText(ratio > BitTorrent::Torrent::MAX_RATIO ? C_INFINITY : Utils::String::fromDouble(ratio, 2));
|
||||
m_ui->labelShareRatioVal->setText(ratio >= BitTorrent::Torrent::MAX_RATIO ? C_INFINITY : Utils::String::fromDouble(ratio, 2));
|
||||
|
||||
const qreal popularity = m_torrent->popularity();
|
||||
m_ui->labelPopularityVal->setText(popularity > BitTorrent::Torrent::MAX_RATIO ? C_INFINITY : Utils::String::fromDouble(popularity, 2));
|
||||
m_ui->labelPopularityVal->setText(popularity >= BitTorrent::Torrent::MAX_RATIO ? C_INFINITY : Utils::String::fromDouble(popularity, 2));
|
||||
|
||||
m_ui->labelSeedsVal->setText(tr("%1 (%2 total)", "%1 and %2 are numbers, e.g. 3 (10 total)")
|
||||
.arg(QString::number(m_torrent->seedsCount())
|
||||
|
|
|
@ -47,9 +47,6 @@
|
|||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>9998.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.050000000000000</double>
|
||||
</property>
|
||||
|
|
|
@ -293,7 +293,7 @@ QString TransferListModel::displayValue(const BitTorrent::Torrent *torrent, cons
|
|||
if (hideValues && (value <= 0))
|
||||
return {};
|
||||
|
||||
return ((static_cast<int>(value) == -1) || (value > BitTorrent::Torrent::MAX_RATIO))
|
||||
return ((static_cast<int>(value) == -1) || (value >= BitTorrent::Torrent::MAX_RATIO))
|
||||
? C_INFINITY : Utils::String::fromDouble(value, 2);
|
||||
};
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ QVariantMap serialize(const BitTorrent::Torrent &torrent)
|
|||
|
||||
const auto adjustRatio = [](const qreal ratio) -> qreal
|
||||
{
|
||||
return (ratio > BitTorrent::Torrent::MAX_RATIO) ? -1 : ratio;
|
||||
return (ratio >= BitTorrent::Torrent::MAX_RATIO) ? -1 : ratio;
|
||||
};
|
||||
|
||||
const auto getLastActivityTime = [&torrent]() -> qlonglong
|
||||
|
|
|
@ -522,8 +522,8 @@ void TorrentsController::propertiesAction()
|
|||
{KEY_PROP_SEEDS_TOTAL, torrent->totalSeedsCount()},
|
||||
{KEY_PROP_PEERS, torrent->leechsCount()},
|
||||
{KEY_PROP_PEERS_TOTAL, torrent->totalLeechersCount()},
|
||||
{KEY_PROP_RATIO, ((ratio > BitTorrent::Torrent::MAX_RATIO) ? -1 : ratio)},
|
||||
{KEY_PROP_POPULARITY, ((popularity > BitTorrent::Torrent::MAX_RATIO) ? -1 : popularity)},
|
||||
{KEY_PROP_RATIO, ((ratio >= BitTorrent::Torrent::MAX_RATIO) ? -1 : ratio)},
|
||||
{KEY_PROP_POPULARITY, ((popularity >= BitTorrent::Torrent::MAX_RATIO) ? -1 : popularity)},
|
||||
{KEY_PROP_REANNOUNCE, torrent->nextAnnounce()},
|
||||
{KEY_PROP_TOTAL_SIZE, torrent->totalSize()},
|
||||
{KEY_PROP_PIECES_NUM, torrent->piecesCount()},
|
||||
|
|
|
@ -172,7 +172,7 @@
|
|||
<div style="margin-left: 40px; margin-bottom: 5px;">
|
||||
<input type="checkbox" id="setRatio" class="shareLimitInput" onclick="enableInputBoxes()">
|
||||
<label id="ratioLabel" for="setRatio">QBT_TR(ratio)QBT_TR[CONTEXT=UpDownRatioDialog]</label>
|
||||
<input type="number" id="ratio" value="0.00" step=".01" min="0" max="9999" class="shareLimitInput" aria-labelledby="ratioLabel">
|
||||
<input type="number" id="ratio" value="0.00" step=".01" min="0" class="shareLimitInput" aria-labelledby="ratioLabel">
|
||||
</div>
|
||||
<div style="margin-left: 40px; margin-bottom: 5px;">
|
||||
<input type="checkbox" id="setTotalMinutes" class="shareLimitInput" onclick="enableInputBoxes()">
|
||||
|
|
|
@ -2876,11 +2876,11 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
|
|||
}
|
||||
|
||||
// Share Ratio Limiting
|
||||
let max_ratio = -1;
|
||||
if ($("max_ratio_checkbox").checked) {
|
||||
max_ratio = Number($("max_ratio_value").value);
|
||||
if (isNaN(max_ratio) || (max_ratio < 0) || (max_ratio > 9998)) {
|
||||
alert("QBT_TR(Share ratio limit must be between 0 and 9998.)QBT_TR[CONTEXT=HttpServer]");
|
||||
let maxRatio = -1;
|
||||
if (document.getElementById("maxRatioCheckbox").checked) {
|
||||
maxRatio = Number(document.getElementById("maxRatioValue").value);
|
||||
if (isNaN(maxRatio) || (maxRatio < 0)) {
|
||||
alert("QBT_TR(Share ratio limit must not have a negative value.)QBT_TR[CONTEXT=HttpServer]");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue