mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-20 21:33:27 -07:00
Address PR comments.
This commit is contained in:
parent
db5fc72950
commit
c194b4512d
5 changed files with 23 additions and 25 deletions
|
@ -104,10 +104,10 @@ namespace Net
|
|||
QString url;
|
||||
DownloadStatus status = DownloadStatus::Failed;
|
||||
QString errorString;
|
||||
QString contentType;
|
||||
QByteArray data;
|
||||
Path filePath;
|
||||
QString magnetURI;
|
||||
QString contentType;
|
||||
};
|
||||
|
||||
class DownloadHandler : public QObject
|
||||
|
|
|
@ -53,7 +53,6 @@
|
|||
#include "base/bittorrent/sharelimitaction.h"
|
||||
#include "base/exceptions.h"
|
||||
#include "base/global.h"
|
||||
#include "base/net/downloadmanager.h"
|
||||
#include "base/net/portforwarder.h"
|
||||
#include "base/net/proxyconfigurationmanager.h"
|
||||
#include "base/path.h"
|
||||
|
@ -1233,21 +1232,21 @@ void OptionsDialog::saveBittorrentTabOptions() const
|
|||
session->setAddTrackersEnabled(m_ui->checkEnableAddTrackers->isChecked());
|
||||
session->setAdditionalTrackers(m_ui->textTrackers->toPlainText());
|
||||
|
||||
auto enabledAddTrackers = m_ui->checkAddTrackersFromURL->isChecked();
|
||||
auto url = m_ui->textTrackersURL->text();
|
||||
if (!url.isEmpty() && enabledAddTrackers)
|
||||
const bool isAddTrackersEnabled = m_ui->checkAddTrackersFromURL->isChecked();
|
||||
const QString url = m_ui->textTrackersURL->text();
|
||||
if (isAddTrackersEnabled && !url.isEmpty())
|
||||
{
|
||||
Net::DownloadManager::instance()->download(url, Preferences::instance()->useProxyForGeneralPurposes()
|
||||
, this, &OptionsDialog::onAddTrackersDownload);
|
||||
, this, &OptionsDialog::onAdditionalTrackersDownload);
|
||||
}
|
||||
else
|
||||
{
|
||||
session->setAddTrackersFromURLEnabled(enabledAddTrackers);
|
||||
session->setAddTrackersFromURLEnabled(isAddTrackersEnabled);
|
||||
session->setAdditionalTrackersURL(url);
|
||||
}
|
||||
}
|
||||
|
||||
void OptionsDialog::onAddTrackersDownload(const Net::DownloadResult &result)
|
||||
void OptionsDialog::onAdditionalTrackersDownload(const Net::DownloadResult &result)
|
||||
{
|
||||
if (result.status != Net::DownloadStatus::Success)
|
||||
{
|
||||
|
@ -1267,8 +1266,6 @@ void OptionsDialog::onAddTrackersDownload(const Net::DownloadResult &result)
|
|||
|
||||
session->setAddTrackersFromURLEnabled(m_ui->checkAddTrackersFromURL->isChecked());
|
||||
session->setAdditionalTrackersURL(m_ui->textTrackersURL->text());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void OptionsDialog::loadRSSTabOptions()
|
||||
|
|
|
@ -31,10 +31,10 @@
|
|||
|
||||
#include <QDialog>
|
||||
|
||||
#include "base/net/downloadmanager.h"
|
||||
#include "base/pathfwd.h"
|
||||
#include "base/settingvalue.h"
|
||||
#include "guiapplicationcomponent.h"
|
||||
#include "base/net/downloadmanager.h"
|
||||
|
||||
class QListWidgetItem;
|
||||
|
||||
|
@ -138,6 +138,8 @@ private:
|
|||
void loadRSSTabOptions();
|
||||
void saveRSSTabOptions() const;
|
||||
|
||||
void onAdditionalTrackersDownload(const Net::DownloadResult &result);
|
||||
|
||||
void loadSearchTabOptions();
|
||||
void saveSearchTabOptions() const;
|
||||
|
||||
|
|
|
@ -74,31 +74,31 @@ TrackersAdditionDialog::~TrackersAdditionDialog()
|
|||
delete m_ui;
|
||||
}
|
||||
|
||||
int TrackersAdditionDialog::isValidEndpoint(const QStringView &endpoint) const
|
||||
bool isValidEndpoint(const QStringView endpoint)
|
||||
{
|
||||
if (endpoint.isEmpty())
|
||||
return 0;
|
||||
QUrl url(endpoint.toString());
|
||||
return false;
|
||||
const QUrl url {endpoint.toString()};
|
||||
if (!url.isValid())
|
||||
return 0;
|
||||
return false;
|
||||
if (url.scheme().isEmpty())
|
||||
return 0;
|
||||
return false;
|
||||
if (url.host().isEmpty())
|
||||
return 0;
|
||||
return 1;
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void TrackersAdditionDialog::onAccepted() const
|
||||
void TrackersAdditionDialog::onAccepted()
|
||||
{
|
||||
const QList<BitTorrent::TrackerEntryStatus> currentTrackers = m_torrent->trackers();
|
||||
const int baseTier = !currentTrackers.isEmpty() ? (currentTrackers.last().tier + 1) : 0;
|
||||
|
||||
QList<BitTorrent::TrackerEntry> entries = BitTorrent::parseTrackerEntries(m_ui->textEditTrackersList->toPlainText());
|
||||
for (BitTorrent::TrackerEntry &entry : entries) {
|
||||
auto isValid = isValidEndpoint(entry.url);
|
||||
if (!isValid)
|
||||
for (BitTorrent::TrackerEntry &entry : entries)
|
||||
{
|
||||
QMessageBox::warning(const_cast<TrackersAdditionDialog *>(this), tr("Invalid tracker URL"), tr("The tracker URL \"%1\" is invalid").arg(entry.url));
|
||||
if (!isValidEndpoint(entry.url))
|
||||
{
|
||||
QMessageBox::warning(this, tr("Invalid tracker URL"), tr("The tracker URL \"%1\" is invalid").arg(entry.url));
|
||||
return;
|
||||
}
|
||||
entry.tier = Utils::Number::clampingAdd(entry.tier, baseTier);
|
||||
|
|
|
@ -58,14 +58,13 @@ public:
|
|||
~TrackersAdditionDialog();
|
||||
|
||||
private slots:
|
||||
void onAccepted() const;
|
||||
void onAccepted();
|
||||
void onDownloadButtonClicked();
|
||||
void onTorrentListDownloadFinished(const Net::DownloadResult &result);
|
||||
|
||||
private:
|
||||
void saveSettings();
|
||||
void loadSettings();
|
||||
int isValidEndpoint(const QStringView &endpoint) const;
|
||||
|
||||
Ui::TrackersAdditionDialog *m_ui = nullptr;
|
||||
BitTorrent::Torrent *const m_torrent = nullptr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue