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