mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-20 21:33:27 -07:00
fix: As advised, move logic away from the settings window into session.
This commit is contained in:
parent
156f6cf3a3
commit
5567d029cf
3 changed files with 6 additions and 36 deletions
|
@ -4105,6 +4105,11 @@ void SessionImpl::updateTrackersFromURL()
|
||||||
{
|
{
|
||||||
if (result.status == Net::DownloadStatus::Success)
|
if (result.status == Net::DownloadStatus::Success)
|
||||||
{
|
{
|
||||||
|
if (!result.contentType.contains(u"text/plain"_s, Qt::CaseInsensitive))
|
||||||
|
{
|
||||||
|
LogMsg(tr("Cannot add trackers from URL, expected Content-Type is \'text/plain\' received \"%1\"").arg(result.contentType), Log::WARNING);
|
||||||
|
return;
|
||||||
|
}
|
||||||
setAdditionalTrackersFromURL(QString::fromUtf8(result.data));
|
setAdditionalTrackersFromURL(QString::fromUtf8(result.data));
|
||||||
LogMsg(tr("Tracker list updated"), Log::INFO);
|
LogMsg(tr("Tracker list updated"), Log::INFO);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -53,6 +53,7 @@
|
||||||
#include "base/bittorrent/sharelimitaction.h"
|
#include "base/bittorrent/sharelimitaction.h"
|
||||||
#include "base/exceptions.h"
|
#include "base/exceptions.h"
|
||||||
#include "base/global.h"
|
#include "base/global.h"
|
||||||
|
#include "base/net/downloadmanager.h"
|
||||||
#include "base/net/portforwarder.h"
|
#include "base/net/portforwarder.h"
|
||||||
#include "base/net/proxyconfigurationmanager.h"
|
#include "base/net/proxyconfigurationmanager.h"
|
||||||
#include "base/path.h"
|
#include "base/path.h"
|
||||||
|
@ -1227,42 +1228,9 @@ void OptionsDialog::saveBittorrentTabOptions() const
|
||||||
BitTorrent::ShareLimitAction::EnableSuperSeeding
|
BitTorrent::ShareLimitAction::EnableSuperSeeding
|
||||||
};
|
};
|
||||||
session->setShareLimitAction(actIndex.value(m_ui->comboRatioLimitAct->currentIndex()));
|
session->setShareLimitAction(actIndex.value(m_ui->comboRatioLimitAct->currentIndex()));
|
||||||
|
|
||||||
session->setAddTrackersEnabled(m_ui->checkEnableAddTrackers->isChecked());
|
session->setAddTrackersEnabled(m_ui->checkEnableAddTrackers->isChecked());
|
||||||
session->setAdditionalTrackers(m_ui->textTrackers->toPlainText());
|
session->setAdditionalTrackers(m_ui->textTrackers->toPlainText());
|
||||||
|
|
||||||
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::onAdditionalTrackersDownload);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
session->setAddTrackersFromURLEnabled(isAddTrackersEnabled);
|
|
||||||
session->setAdditionalTrackersURL(url);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void OptionsDialog::onAdditionalTrackersDownload(const Net::DownloadResult &result)
|
|
||||||
{
|
|
||||||
if (result.status != Net::DownloadStatus::Success)
|
|
||||||
{
|
|
||||||
QMessageBox::warning(this, tr("Download trackers list error")
|
|
||||||
, tr("Error occurred when downloading the trackers list. Reason: \"%1\"").arg(result.errorString));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!result.contentType.contains(u"text/plain"_s, Qt::CaseInsensitive))
|
|
||||||
{
|
|
||||||
QMessageBox::warning(this, tr("Download trackers list error")
|
|
||||||
, tr("The content type of the downloaded file is not plain text. Content-Type: \"%1\"").arg(result.contentType));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto *session = BitTorrent::Session::instance();
|
|
||||||
|
|
||||||
session->setAddTrackersFromURLEnabled(m_ui->checkAddTrackersFromURL->isChecked());
|
session->setAddTrackersFromURLEnabled(m_ui->checkAddTrackersFromURL->isChecked());
|
||||||
session->setAdditionalTrackersURL(m_ui->textTrackersURL->text());
|
session->setAdditionalTrackersURL(m_ui->textTrackersURL->text());
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,6 @@
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
#include "base/net/downloadmanager.h"
|
|
||||||
#include "base/pathfwd.h"
|
#include "base/pathfwd.h"
|
||||||
#include "base/settingvalue.h"
|
#include "base/settingvalue.h"
|
||||||
#include "guiapplicationcomponent.h"
|
#include "guiapplicationcomponent.h"
|
||||||
|
@ -138,8 +137,6 @@ private:
|
||||||
void loadRSSTabOptions();
|
void loadRSSTabOptions();
|
||||||
void saveRSSTabOptions() const;
|
void saveRSSTabOptions() const;
|
||||||
|
|
||||||
void onAdditionalTrackersDownload(const Net::DownloadResult &result);
|
|
||||||
|
|
||||||
void loadSearchTabOptions();
|
void loadSearchTabOptions();
|
||||||
void saveSearchTabOptions() const;
|
void saveSearchTabOptions() const;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue