mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-23 08:48:07 -06:00
Adjust tracker tier when adding additional trackers
Closes #20102. PR #20729.
This commit is contained in:
@@ -3069,7 +3069,7 @@ Disable encryption: Only connect to peers without protocol encryption</string>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="checkEnableAddTrackers">
|
||||
<property name="title">
|
||||
<string>A&utomatically add these trackers to new downloads:</string>
|
||||
<string>A&utomatically append these trackers to new downloads:</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
|
||||
@@ -36,9 +36,11 @@
|
||||
|
||||
#include "base/bittorrent/torrent.h"
|
||||
#include "base/bittorrent/trackerentry.h"
|
||||
#include "base/bittorrent/trackerentrystatus.h"
|
||||
#include "base/global.h"
|
||||
#include "base/net/downloadmanager.h"
|
||||
#include "base/preferences.h"
|
||||
#include "base/utils/number.h"
|
||||
#include "gui/uithememanager.h"
|
||||
#include "ui_trackersadditiondialog.h"
|
||||
|
||||
@@ -74,7 +76,13 @@ TrackersAdditionDialog::~TrackersAdditionDialog()
|
||||
|
||||
void TrackersAdditionDialog::onAccepted() const
|
||||
{
|
||||
const QVector<BitTorrent::TrackerEntry> entries = BitTorrent::parseTrackerEntries(m_ui->textEditTrackersList->toPlainText());
|
||||
const QVector<BitTorrent::TrackerEntryStatus> currentTrackers = m_torrent->trackers();
|
||||
const int baseTier = !currentTrackers.isEmpty() ? (currentTrackers.last().tier + 1) : 0;
|
||||
|
||||
QVector<BitTorrent::TrackerEntry> entries = BitTorrent::parseTrackerEntries(m_ui->textEditTrackersList->toPlainText());
|
||||
for (BitTorrent::TrackerEntry &entry : entries)
|
||||
entry.tier = Utils::Number::clampingAdd(entry.tier, baseTier);
|
||||
|
||||
m_torrent->addTrackers(entries);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user