mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-21 05:43:32 -07:00
Add check to Bittorrent tab in preferences too.
This commit is contained in:
parent
db41945db7
commit
db5fc72950
2 changed files with 36 additions and 0 deletions
|
@ -83,6 +83,7 @@
|
|||
#include "watchedfolderoptionsdialog.h"
|
||||
#include "watchedfoldersmodel.h"
|
||||
#include "webui/webui.h"
|
||||
#include "base/net/downloadmanager.h"
|
||||
|
||||
#ifndef DISABLE_WEBUI
|
||||
#include "base/net/dnsupdater.h"
|
||||
|
@ -1232,8 +1233,42 @@ 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)
|
||||
{
|
||||
Net::DownloadManager::instance()->download(url, Preferences::instance()->useProxyForGeneralPurposes()
|
||||
, this, &OptionsDialog::onAddTrackersDownload);
|
||||
}
|
||||
else
|
||||
{
|
||||
session->setAddTrackersFromURLEnabled(enabledAddTrackers);
|
||||
session->setAdditionalTrackersURL(url);
|
||||
}
|
||||
}
|
||||
|
||||
void OptionsDialog::onAddTrackersDownload(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->setAdditionalTrackersURL(m_ui->textTrackersURL->text());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void OptionsDialog::loadRSSTabOptions()
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "base/pathfwd.h"
|
||||
#include "base/settingvalue.h"
|
||||
#include "guiapplicationcomponent.h"
|
||||
#include "base/net/downloadmanager.h"
|
||||
|
||||
class QListWidgetItem;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue