mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 15:27:54 +00:00
Merge pull request #16594 from Chocobo1/alert
Add option for enable/disable performance warnings from libtorrent
This commit is contained in:
commit
97c28e1e51
@ -443,6 +443,7 @@ Session::Session(QObject *parent)
|
|||||||
, m_altGlobalUploadSpeedLimit(BITTORRENT_SESSION_KEY("AlternativeGlobalUPSpeedLimit"), 10, lowerLimited(0))
|
, m_altGlobalUploadSpeedLimit(BITTORRENT_SESSION_KEY("AlternativeGlobalUPSpeedLimit"), 10, lowerLimited(0))
|
||||||
, m_isAltGlobalSpeedLimitEnabled(BITTORRENT_SESSION_KEY("UseAlternativeGlobalSpeedLimit"), false)
|
, m_isAltGlobalSpeedLimitEnabled(BITTORRENT_SESSION_KEY("UseAlternativeGlobalSpeedLimit"), false)
|
||||||
, m_isBandwidthSchedulerEnabled(BITTORRENT_SESSION_KEY("BandwidthSchedulerEnabled"), false)
|
, m_isBandwidthSchedulerEnabled(BITTORRENT_SESSION_KEY("BandwidthSchedulerEnabled"), false)
|
||||||
|
, m_isPerformanceWarningEnabled(BITTORRENT_SESSION_KEY("PerformanceWarning"), false)
|
||||||
, m_saveResumeDataInterval(BITTORRENT_SESSION_KEY("SaveResumeDataInterval"), 60)
|
, m_saveResumeDataInterval(BITTORRENT_SESSION_KEY("SaveResumeDataInterval"), 60)
|
||||||
, m_port(BITTORRENT_SESSION_KEY("Port"), -1)
|
, m_port(BITTORRENT_SESSION_KEY("Port"), -1)
|
||||||
, m_networkInterface(BITTORRENT_SESSION_KEY("Interface"))
|
, m_networkInterface(BITTORRENT_SESSION_KEY("Interface"))
|
||||||
@ -1123,19 +1124,9 @@ void Session::configureComponents()
|
|||||||
|
|
||||||
void Session::initializeNativeSession()
|
void Session::initializeNativeSession()
|
||||||
{
|
{
|
||||||
const lt::alert_category_t alertMask = lt::alert::error_notification
|
|
||||||
| lt::alert::file_progress_notification
|
|
||||||
| lt::alert::ip_block_notification
|
|
||||||
| lt::alert::peer_notification
|
|
||||||
| lt::alert::performance_warning
|
|
||||||
| lt::alert::port_mapping_notification
|
|
||||||
| lt::alert::status_notification
|
|
||||||
| lt::alert::storage_notification
|
|
||||||
| lt::alert::tracker_notification;
|
|
||||||
const std::string peerId = lt::generate_fingerprint(PEER_ID, QBT_VERSION_MAJOR, QBT_VERSION_MINOR, QBT_VERSION_BUGFIX, QBT_VERSION_BUILD);
|
const std::string peerId = lt::generate_fingerprint(PEER_ID, QBT_VERSION_MAJOR, QBT_VERSION_MINOR, QBT_VERSION_BUGFIX, QBT_VERSION_BUILD);
|
||||||
|
|
||||||
lt::settings_pack pack;
|
lt::settings_pack pack;
|
||||||
pack.set_int(lt::settings_pack::alert_mask, alertMask);
|
|
||||||
pack.set_str(lt::settings_pack::peer_fingerprint, peerId);
|
pack.set_str(lt::settings_pack::peer_fingerprint, peerId);
|
||||||
pack.set_bool(lt::settings_pack::listen_system_port_fallback, false);
|
pack.set_bool(lt::settings_pack::listen_system_port_fallback, false);
|
||||||
pack.set_str(lt::settings_pack::user_agent, USER_AGENT);
|
pack.set_str(lt::settings_pack::user_agent, USER_AGENT);
|
||||||
@ -1258,6 +1249,17 @@ void Session::initMetrics()
|
|||||||
|
|
||||||
void Session::loadLTSettings(lt::settings_pack &settingsPack)
|
void Session::loadLTSettings(lt::settings_pack &settingsPack)
|
||||||
{
|
{
|
||||||
|
const lt::alert_category_t alertMask = lt::alert::error_notification
|
||||||
|
| lt::alert::file_progress_notification
|
||||||
|
| lt::alert::ip_block_notification
|
||||||
|
| lt::alert::peer_notification
|
||||||
|
| (isPerformanceWarningEnabled() ? lt::alert::performance_warning : lt::alert_category_t())
|
||||||
|
| lt::alert::port_mapping_notification
|
||||||
|
| lt::alert::status_notification
|
||||||
|
| lt::alert::storage_notification
|
||||||
|
| lt::alert::tracker_notification;
|
||||||
|
settingsPack.set_int(lt::settings_pack::alert_mask, alertMask);
|
||||||
|
|
||||||
settingsPack.set_int(lt::settings_pack::connection_speed, connectionSpeed());
|
settingsPack.set_int(lt::settings_pack::connection_speed, connectionSpeed());
|
||||||
|
|
||||||
// from libtorrent doc:
|
// from libtorrent doc:
|
||||||
@ -2874,6 +2876,20 @@ void Session::setBandwidthSchedulerEnabled(const bool enabled)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Session::isPerformanceWarningEnabled() const
|
||||||
|
{
|
||||||
|
return m_isPerformanceWarningEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Session::setPerformanceWarningEnabled(const bool enable)
|
||||||
|
{
|
||||||
|
if (enable == m_isPerformanceWarningEnabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_isPerformanceWarningEnabled = enable;
|
||||||
|
configureDeferred();
|
||||||
|
}
|
||||||
|
|
||||||
int Session::saveResumeDataInterval() const
|
int Session::saveResumeDataInterval() const
|
||||||
{
|
{
|
||||||
return m_saveResumeDataInterval;
|
return m_saveResumeDataInterval;
|
||||||
|
@ -312,6 +312,8 @@ namespace BitTorrent
|
|||||||
bool isBandwidthSchedulerEnabled() const;
|
bool isBandwidthSchedulerEnabled() const;
|
||||||
void setBandwidthSchedulerEnabled(bool enabled);
|
void setBandwidthSchedulerEnabled(bool enabled);
|
||||||
|
|
||||||
|
bool isPerformanceWarningEnabled() const;
|
||||||
|
void setPerformanceWarningEnabled(bool enable);
|
||||||
int saveResumeDataInterval() const;
|
int saveResumeDataInterval() const;
|
||||||
void setSaveResumeDataInterval(int value);
|
void setSaveResumeDataInterval(int value);
|
||||||
int port() const;
|
int port() const;
|
||||||
@ -741,6 +743,7 @@ namespace BitTorrent
|
|||||||
CachedSettingValue<int> m_altGlobalUploadSpeedLimit;
|
CachedSettingValue<int> m_altGlobalUploadSpeedLimit;
|
||||||
CachedSettingValue<bool> m_isAltGlobalSpeedLimitEnabled;
|
CachedSettingValue<bool> m_isAltGlobalSpeedLimitEnabled;
|
||||||
CachedSettingValue<bool> m_isBandwidthSchedulerEnabled;
|
CachedSettingValue<bool> m_isBandwidthSchedulerEnabled;
|
||||||
|
CachedSettingValue<bool> m_isPerformanceWarningEnabled;
|
||||||
CachedSettingValue<int> m_saveResumeDataInterval;
|
CachedSettingValue<int> m_saveResumeDataInterval;
|
||||||
CachedSettingValue<int> m_port;
|
CachedSettingValue<int> m_port;
|
||||||
CachedSettingValue<QString> m_networkInterface;
|
CachedSettingValue<QString> m_networkInterface;
|
||||||
|
@ -1925,7 +1925,7 @@ void TorrentImpl::handleMetadataReceivedAlert(const lt::metadata_received_alert
|
|||||||
|
|
||||||
void TorrentImpl::handlePerformanceAlert(const lt::performance_alert *p) const
|
void TorrentImpl::handlePerformanceAlert(const lt::performance_alert *p) const
|
||||||
{
|
{
|
||||||
LogMsg((tr("Performance alert: ") + QString::fromStdString(p->message()))
|
LogMsg((tr("Performance alert: %1. More info: %2").arg(QString::fromStdString(p->message())), u"https://libtorrent.org/reference-Alerts.html#enum-performance-warning-t"_qs)
|
||||||
, Log::INFO);
|
, Log::INFO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,6 +338,7 @@ OptionsDialog::OptionsDialog(QWidget *parent)
|
|||||||
connect(m_ui->checkAssociateMagnetLinks, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
connect(m_ui->checkAssociateMagnetLinks, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||||||
connect(m_ui->checkProgramUpdates, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
connect(m_ui->checkProgramUpdates, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||||||
#endif
|
#endif
|
||||||
|
connect(m_ui->checkBoxPerformanceWarning, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||||||
connect(m_ui->checkFileLog, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
|
connect(m_ui->checkFileLog, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
|
||||||
connect(m_ui->textFileLogPath, &FileSystemPathEdit::selectedPathChanged, this, &ThisType::enableApplyButton);
|
connect(m_ui->textFileLogPath, &FileSystemPathEdit::selectedPathChanged, this, &ThisType::enableApplyButton);
|
||||||
connect(m_ui->checkFileLogBackup, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
connect(m_ui->checkFileLogBackup, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||||||
@ -650,8 +651,11 @@ void OptionsDialog::loadSplitterState()
|
|||||||
|
|
||||||
void OptionsDialog::saveOptions()
|
void OptionsDialog::saveOptions()
|
||||||
{
|
{
|
||||||
|
auto *pref = Preferences::instance();
|
||||||
|
auto *session = BitTorrent::Session::instance();
|
||||||
|
|
||||||
m_applyButton->setEnabled(false);
|
m_applyButton->setEnabled(false);
|
||||||
Preferences *const pref = Preferences::instance();
|
|
||||||
// Load the translation
|
// Load the translation
|
||||||
QString locale = getLocale();
|
QString locale = getLocale();
|
||||||
if (pref->getLocale() != locale)
|
if (pref->getLocale() != locale)
|
||||||
@ -713,6 +717,8 @@ void OptionsDialog::saveOptions()
|
|||||||
#if defined(Q_OS_WIN) || defined(Q_OS_MACOS)
|
#if defined(Q_OS_WIN) || defined(Q_OS_MACOS)
|
||||||
pref->setUpdateCheckEnabled(m_ui->checkProgramUpdates->isChecked());
|
pref->setUpdateCheckEnabled(m_ui->checkProgramUpdates->isChecked());
|
||||||
#endif
|
#endif
|
||||||
|
session->setPerformanceWarningEnabled(m_ui->checkBoxPerformanceWarning->isChecked());
|
||||||
|
|
||||||
auto *const app = static_cast<Application *>(QCoreApplication::instance());
|
auto *const app = static_cast<Application *>(QCoreApplication::instance());
|
||||||
app->setFileLoggerPath(m_ui->textFileLogPath->selectedPath());
|
app->setFileLoggerPath(m_ui->textFileLogPath->selectedPath());
|
||||||
app->setFileLoggerBackup(m_ui->checkFileLogBackup->isChecked());
|
app->setFileLoggerBackup(m_ui->checkFileLogBackup->isChecked());
|
||||||
@ -730,8 +736,6 @@ void OptionsDialog::saveOptions()
|
|||||||
RSS::AutoDownloader::instance()->setSmartEpisodeFilters(m_ui->textSmartEpisodeFilters->toPlainText().split('\n', Qt::SkipEmptyParts));
|
RSS::AutoDownloader::instance()->setSmartEpisodeFilters(m_ui->textSmartEpisodeFilters->toPlainText().split('\n', Qt::SkipEmptyParts));
|
||||||
RSS::AutoDownloader::instance()->setDownloadRepacks(m_ui->checkSmartFilterDownloadRepacks->isChecked());
|
RSS::AutoDownloader::instance()->setDownloadRepacks(m_ui->checkSmartFilterDownloadRepacks->isChecked());
|
||||||
|
|
||||||
auto session = BitTorrent::Session::instance();
|
|
||||||
|
|
||||||
// Downloads preferences
|
// Downloads preferences
|
||||||
session->setSavePath(Path(m_ui->textSavePath->selectedPath()));
|
session->setSavePath(Path(m_ui->textSavePath->selectedPath()));
|
||||||
session->setSubcategoriesEnabled(m_ui->checkUseSubcategories->isChecked());
|
session->setSubcategoriesEnabled(m_ui->checkUseSubcategories->isChecked());
|
||||||
@ -919,11 +923,8 @@ Net::ProxyType OptionsDialog::getProxyType() const
|
|||||||
|
|
||||||
void OptionsDialog::loadOptions()
|
void OptionsDialog::loadOptions()
|
||||||
{
|
{
|
||||||
int intValue;
|
const auto *pref = Preferences::instance();
|
||||||
QString strValue;
|
const auto *session = BitTorrent::Session::instance();
|
||||||
bool fileLogBackup = true;
|
|
||||||
bool fileLogDelete = true;
|
|
||||||
const Preferences *const pref = Preferences::instance();
|
|
||||||
|
|
||||||
// Behavior preferences
|
// Behavior preferences
|
||||||
setLocale(pref->getLocale());
|
setLocale(pref->getLocale());
|
||||||
@ -965,14 +966,15 @@ void OptionsDialog::loadOptions()
|
|||||||
#if defined(Q_OS_WIN) || defined(Q_OS_MACOS)
|
#if defined(Q_OS_WIN) || defined(Q_OS_MACOS)
|
||||||
m_ui->checkProgramUpdates->setChecked(pref->isUpdateCheckEnabled());
|
m_ui->checkProgramUpdates->setChecked(pref->isUpdateCheckEnabled());
|
||||||
#endif
|
#endif
|
||||||
|
m_ui->checkBoxPerformanceWarning->setChecked(session->isPerformanceWarningEnabled());
|
||||||
|
|
||||||
const Application *const app = static_cast<Application*>(QCoreApplication::instance());
|
const Application *const app = static_cast<Application*>(QCoreApplication::instance());
|
||||||
m_ui->checkFileLog->setChecked(app->isFileLoggerEnabled());
|
m_ui->checkFileLog->setChecked(app->isFileLoggerEnabled());
|
||||||
m_ui->textFileLogPath->setSelectedPath(app->fileLoggerPath());
|
m_ui->textFileLogPath->setSelectedPath(app->fileLoggerPath());
|
||||||
fileLogBackup = app->isFileLoggerBackup();
|
const bool fileLogBackup = app->isFileLoggerBackup();
|
||||||
m_ui->checkFileLogBackup->setChecked(fileLogBackup);
|
m_ui->checkFileLogBackup->setChecked(fileLogBackup);
|
||||||
m_ui->spinFileLogSize->setEnabled(fileLogBackup);
|
m_ui->spinFileLogSize->setEnabled(fileLogBackup);
|
||||||
fileLogDelete = app->isFileLoggerDeleteOld();
|
const bool fileLogDelete = app->isFileLoggerDeleteOld();
|
||||||
m_ui->checkFileLogDelete->setChecked(fileLogDelete);
|
m_ui->checkFileLogDelete->setChecked(fileLogDelete);
|
||||||
m_ui->spinFileLogAge->setEnabled(fileLogDelete);
|
m_ui->spinFileLogAge->setEnabled(fileLogDelete);
|
||||||
m_ui->comboFileLogAgeType->setEnabled(fileLogDelete);
|
m_ui->comboFileLogAgeType->setEnabled(fileLogDelete);
|
||||||
@ -989,8 +991,6 @@ void OptionsDialog::loadOptions()
|
|||||||
m_ui->spinRSSRefreshInterval->setValue(RSS::Session::instance()->refreshInterval());
|
m_ui->spinRSSRefreshInterval->setValue(RSS::Session::instance()->refreshInterval());
|
||||||
m_ui->spinRSSMaxArticlesPerFeed->setValue(RSS::Session::instance()->maxArticlesPerFeed());
|
m_ui->spinRSSMaxArticlesPerFeed->setValue(RSS::Session::instance()->maxArticlesPerFeed());
|
||||||
|
|
||||||
const auto *session = BitTorrent::Session::instance();
|
|
||||||
|
|
||||||
// Downloads preferences
|
// Downloads preferences
|
||||||
m_ui->checkAdditionDialog->setChecked(AddNewTorrentDialog::isEnabled());
|
m_ui->checkAdditionDialog->setChecked(AddNewTorrentDialog::isEnabled());
|
||||||
m_ui->checkAdditionDialogFront->setChecked(AddNewTorrentDialog::isTopLevel());
|
m_ui->checkAdditionDialogFront->setChecked(AddNewTorrentDialog::isTopLevel());
|
||||||
@ -1085,7 +1085,7 @@ void OptionsDialog::loadOptions()
|
|||||||
m_ui->spinPort->setValue(session->port());
|
m_ui->spinPort->setValue(session->port());
|
||||||
m_ui->checkUPnP->setChecked(Net::PortForwarder::instance()->isEnabled());
|
m_ui->checkUPnP->setChecked(Net::PortForwarder::instance()->isEnabled());
|
||||||
|
|
||||||
intValue = session->maxConnections();
|
int intValue = session->maxConnections();
|
||||||
if (intValue > 0)
|
if (intValue > 0)
|
||||||
{
|
{
|
||||||
// enable
|
// enable
|
||||||
|
@ -707,6 +707,13 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="checkBoxPerformanceWarning">
|
||||||
|
<property name="text">
|
||||||
|
<string>Log performance warnings</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer_4">
|
<spacer name="verticalSpacer_4">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
@ -97,8 +97,9 @@ void AppController::shutdownAction()
|
|||||||
|
|
||||||
void AppController::preferencesAction()
|
void AppController::preferencesAction()
|
||||||
{
|
{
|
||||||
const Preferences *const pref = Preferences::instance();
|
const auto *pref = Preferences::instance();
|
||||||
const auto *session = BitTorrent::Session::instance();
|
const auto *session = BitTorrent::Session::instance();
|
||||||
|
|
||||||
QJsonObject data;
|
QJsonObject data;
|
||||||
|
|
||||||
// Downloads
|
// Downloads
|
||||||
@ -231,6 +232,7 @@ void AppController::preferencesAction()
|
|||||||
// Web UI
|
// Web UI
|
||||||
// Language
|
// Language
|
||||||
data["locale"] = pref->getLocale();
|
data["locale"] = pref->getLocale();
|
||||||
|
data["performance_warning"] = session->isPerformanceWarningEnabled();
|
||||||
// HTTP Server
|
// HTTP Server
|
||||||
data["web_ui_domain_list"] = pref->getServerDomains();
|
data["web_ui_domain_list"] = pref->getServerDomains();
|
||||||
data["web_ui_address"] = pref->getWebUiAddress();
|
data["web_ui_address"] = pref->getWebUiAddress();
|
||||||
@ -370,8 +372,8 @@ void AppController::setPreferencesAction()
|
|||||||
{
|
{
|
||||||
requireParams({"json"});
|
requireParams({"json"});
|
||||||
|
|
||||||
Preferences *const pref = Preferences::instance();
|
auto *pref = Preferences::instance();
|
||||||
auto session = BitTorrent::Session::instance();
|
auto *session = BitTorrent::Session::instance();
|
||||||
const QVariantHash m = QJsonDocument::fromJson(params()["json"].toUtf8()).toVariant().toHash();
|
const QVariantHash m = QJsonDocument::fromJson(params()["json"].toUtf8()).toVariant().toHash();
|
||||||
|
|
||||||
QVariantHash::ConstIterator it;
|
QVariantHash::ConstIterator it;
|
||||||
@ -643,6 +645,8 @@ void AppController::setPreferencesAction()
|
|||||||
pref->setLocale(locale);
|
pref->setLocale(locale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (hasKey("performance_warning"))
|
||||||
|
session->setPerformanceWarningEnabled(it.value().toBool());
|
||||||
// HTTP Server
|
// HTTP Server
|
||||||
if (hasKey("web_ui_domain_list"))
|
if (hasKey("web_ui_domain_list"))
|
||||||
pref->setServerDomains(it.value().toString());
|
pref->setServerDomains(it.value().toString());
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
#include "base/utils/net.h"
|
#include "base/utils/net.h"
|
||||||
#include "base/utils/version.h"
|
#include "base/utils/version.h"
|
||||||
|
|
||||||
inline const Utils::Version<int, 3, 2> API_VERSION {2, 8, 7};
|
inline const Utils::Version<int, 3, 2> API_VERSION {2, 8, 8};
|
||||||
|
|
||||||
class APIController;
|
class APIController;
|
||||||
class WebApplication;
|
class WebApplication;
|
||||||
|
@ -693,6 +693,11 @@
|
|||||||
</select>
|
</select>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
<div class="formRow">
|
||||||
|
<input type="checkbox" id="performanceWarning" />
|
||||||
|
<label for="performanceWarning">QBT_TR(Log performance warnings)QBT_TR[CONTEXT=OptionsDialog]</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
<fieldset class="settings">
|
<fieldset class="settings">
|
||||||
<legend>QBT_TR(Web User Interface (Remote control))QBT_TR[CONTEXT=OptionsDialog]</legend>
|
<legend>QBT_TR(Web User Interface (Remote control))QBT_TR[CONTEXT=OptionsDialog]</legend>
|
||||||
<table>
|
<table>
|
||||||
@ -1881,6 +1886,7 @@
|
|||||||
// Web UI tab
|
// Web UI tab
|
||||||
// Language
|
// Language
|
||||||
$('locale_select').setProperty('value', pref.locale);
|
$('locale_select').setProperty('value', pref.locale);
|
||||||
|
$('performanceWarning').setProperty('checked', pref.performance_warning);
|
||||||
|
|
||||||
// HTTP Server
|
// HTTP Server
|
||||||
$('webui_domain_textarea').setProperty('value', pref.web_ui_domain_list);
|
$('webui_domain_textarea').setProperty('value', pref.web_ui_domain_list);
|
||||||
@ -2259,6 +2265,7 @@
|
|||||||
// Web UI tab
|
// Web UI tab
|
||||||
// Language
|
// Language
|
||||||
settings.set('locale', $('locale_select').getProperty('value'));
|
settings.set('locale', $('locale_select').getProperty('value'));
|
||||||
|
settings.set('performance_warning', $('performanceWarning').getProperty('checked'));
|
||||||
|
|
||||||
// HTTP Server
|
// HTTP Server
|
||||||
settings.set('web_ui_domain_list', $('webui_domain_textarea').getProperty('value'));
|
settings.set('web_ui_domain_list', $('webui_domain_textarea').getProperty('value'));
|
||||||
|
Loading…
Reference in New Issue
Block a user