Browse Source

Merge pull request #18812 from Chocobo1/buf

Use KiB unit for socket buffer sizes
adaptive-webui-19844
Chocobo1 2 years ago committed by GitHub
parent
commit
4a66d705b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 71
      src/gui/advancedsettings.cpp
  2. 13
      src/gui/advancedsettings.h
  3. 20
      src/webui/www/private/views/preferences.html

71
src/gui/advancedsettings.cpp

@ -40,7 +40,6 @@ @@ -40,7 +40,6 @@
#include "base/preferences.h"
#include "base/unicodestrings.h"
#include "gui/addnewtorrentdialog.h"
#include "gui/desktopintegration.h"
#include "gui/mainwindow.h"
#include "interfaces/iguiapplication.h"
@ -83,7 +82,7 @@ namespace @@ -83,7 +82,7 @@ namespace
RESOLVE_COUNTRIES,
PROGRAM_NOTIFICATIONS,
TORRENT_ADDED_NOTIFICATIONS,
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)) && defined(QT_DBUS_LIB)
#ifdef QBT_USES_CUSTOMDBUSNOTIFICATIONS
NOTIFICATION_TIMEOUT,
#endif
CONFIRM_REMOVE_ALL_TAGS,
@ -231,9 +230,9 @@ void AdvancedSettings::saveAdvancedSettings() const @@ -231,9 +230,9 @@ void AdvancedSettings::saveAdvancedSettings() const
// Outgoing connections per second
session->setConnectionSpeed(m_spinBoxConnectionSpeed.value());
// Socket send buffer size
session->setSocketSendBufferSize(m_spinBoxSocketSendBufferSize.value());
session->setSocketSendBufferSize(m_spinBoxSocketSendBufferSize.value() * 1024);
// Socket receive buffer size
session->setSocketReceiveBufferSize(m_spinBoxSocketReceiveBufferSize.value());
session->setSocketReceiveBufferSize(m_spinBoxSocketReceiveBufferSize.value() * 1024);
// Socket listen backlog size
session->setSocketBacklogSize(m_spinBoxSocketBacklogSize.value());
// Save resume data interval
@ -333,13 +332,17 @@ void AdvancedSettings::updateCacheSpinSuffix(const int value) @@ -333,13 +332,17 @@ void AdvancedSettings::updateCacheSpinSuffix(const int value)
}
#endif
void AdvancedSettings::updateSaveResumeDataIntervalSuffix(const int value)
#ifdef QBT_USES_CUSTOMDBUSNOTIFICATIONS
void AdvancedSettings::updateNotificationTimeoutSuffix(const int value)
{
if (value > 0)
m_spinBoxSaveResumeDataInterval.setSuffix(tr(" min", " minutes"));
if (value == 0)
m_spinBoxNotificationTimeout.setSuffix(tr(" (infinite)"));
else if (value < 0)
m_spinBoxNotificationTimeout.setSuffix(tr(" (system default)"));
else
m_spinBoxSaveResumeDataInterval.setSuffix(tr(" (disabled)"));
m_spinBoxNotificationTimeout.setSuffix(tr(" ms", " milliseconds"));
}
#endif
void AdvancedSettings::updateInterfaceAddressCombo()
{
@ -506,7 +509,7 @@ void AdvancedSettings::loadAdvancedSettings() @@ -506,7 +509,7 @@ void AdvancedSettings::loadAdvancedSettings()
#endif
// Disk queue size
m_spinBoxDiskQueueSize.setMinimum(1);
m_spinBoxDiskQueueSize.setMaximum(std::numeric_limits<int>::max());
m_spinBoxDiskQueueSize.setMaximum(std::numeric_limits<int>::max() / 1024);
m_spinBoxDiskQueueSize.setValue(session->diskQueueSize() / 1024);
m_spinBoxDiskQueueSize.setSuffix(tr(" KiB"));
addRow(DISK_QUEUE_SIZE, (tr("Disk queue size") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#max_queued_disk_bytes", u"(?)"))
@ -575,19 +578,19 @@ void AdvancedSettings::loadAdvancedSettings() @@ -575,19 +578,19 @@ void AdvancedSettings::loadAdvancedSettings()
, &m_spinBoxConnectionSpeed);
// Socket send buffer size
m_spinBoxSocketSendBufferSize.setMinimum(0);
m_spinBoxSocketSendBufferSize.setMaximum(std::numeric_limits<int>::max());
m_spinBoxSocketSendBufferSize.setValue(session->socketSendBufferSize());
m_spinBoxSocketSendBufferSize.setSuffix(tr(" Bytes"));
m_spinBoxSocketSendBufferSize.setSpecialValueText(tr("System default"));
addRow(SOCKET_SEND_BUFFER_SIZE, (tr("Socket send buffer size") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#send_socket_buffer_size", u"(?)"))
m_spinBoxSocketSendBufferSize.setMaximum(std::numeric_limits<int>::max() / 1024);
m_spinBoxSocketSendBufferSize.setValue(session->socketSendBufferSize() / 1024);
m_spinBoxSocketSendBufferSize.setSuffix(tr(" KiB"));
m_spinBoxSocketSendBufferSize.setSpecialValueText(tr("0 (system default)"));
addRow(SOCKET_SEND_BUFFER_SIZE, (tr("Socket send buffer size [0: system default]") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#send_socket_buffer_size", u"(?)"))
, &m_spinBoxSocketSendBufferSize);
// Socket receive buffer size
m_spinBoxSocketReceiveBufferSize.setMinimum(0);
m_spinBoxSocketReceiveBufferSize.setMaximum(std::numeric_limits<int>::max());
m_spinBoxSocketReceiveBufferSize.setValue(session->socketReceiveBufferSize());
m_spinBoxSocketReceiveBufferSize.setSuffix(tr(" Bytes"));
m_spinBoxSocketReceiveBufferSize.setSpecialValueText(tr("System default"));
addRow(SOCKET_RECEIVE_BUFFER_SIZE, (tr("Socket receive buffer size") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#recv_socket_buffer_size", u"(?)"))
m_spinBoxSocketReceiveBufferSize.setMaximum(std::numeric_limits<int>::max() / 1024);
m_spinBoxSocketReceiveBufferSize.setValue(session->socketReceiveBufferSize() / 1024);
m_spinBoxSocketReceiveBufferSize.setSuffix(tr(" KiB"));
m_spinBoxSocketReceiveBufferSize.setSpecialValueText(tr("0 (system default)"));
addRow(SOCKET_RECEIVE_BUFFER_SIZE, (tr("Socket receive buffer size [0: system default]") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#recv_socket_buffer_size", u"(?)"))
, &m_spinBoxSocketReceiveBufferSize);
// Socket listen backlog size
m_spinBoxSocketBacklogSize.setMinimum(1);
@ -599,22 +602,23 @@ void AdvancedSettings::loadAdvancedSettings() @@ -599,22 +602,23 @@ void AdvancedSettings::loadAdvancedSettings()
m_spinBoxSaveResumeDataInterval.setMinimum(0);
m_spinBoxSaveResumeDataInterval.setMaximum(std::numeric_limits<int>::max());
m_spinBoxSaveResumeDataInterval.setValue(session->saveResumeDataInterval());
connect(&m_spinBoxSaveResumeDataInterval, qOverload<int>(&QSpinBox::valueChanged)
, this, &AdvancedSettings::updateSaveResumeDataIntervalSuffix);
updateSaveResumeDataIntervalSuffix(m_spinBoxSaveResumeDataInterval.value());
addRow(SAVE_RESUME_DATA_INTERVAL, tr("Save resume data interval", "How often the fastresume file is saved."), &m_spinBoxSaveResumeDataInterval);
m_spinBoxSaveResumeDataInterval.setSuffix(tr(" min", " minutes"));
m_spinBoxSaveResumeDataInterval.setSpecialValueText(tr("0 (disabled)"));
addRow(SAVE_RESUME_DATA_INTERVAL, tr("Save resume data interval [0: disabled]", "How often the fastresume file is saved."), &m_spinBoxSaveResumeDataInterval);
// Outgoing port Min
m_spinBoxOutgoingPortsMin.setMinimum(0);
m_spinBoxOutgoingPortsMin.setMaximum(65535);
m_spinBoxOutgoingPortsMin.setValue(session->outgoingPortsMin());
addRow(OUTGOING_PORT_MIN, (tr("Outgoing ports (Min) [0: Disabled]")
m_spinBoxOutgoingPortsMin.setSpecialValueText(tr("0 (disabled)"));
addRow(OUTGOING_PORT_MIN, (tr("Outgoing ports (Min) [0: disabled]")
+ u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#outgoing_port", u"(?)"))
, &m_spinBoxOutgoingPortsMin);
// Outgoing port Min
// Outgoing port Max
m_spinBoxOutgoingPortsMax.setMinimum(0);
m_spinBoxOutgoingPortsMax.setMaximum(65535);
m_spinBoxOutgoingPortsMax.setValue(session->outgoingPortsMax());
addRow(OUTGOING_PORT_MAX, (tr("Outgoing ports (Max) [0: Disabled]")
m_spinBoxOutgoingPortsMax.setSpecialValueText(tr("0 (disabled)"));
addRow(OUTGOING_PORT_MAX, (tr("Outgoing ports (Max) [0: disabled]")
+ u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#outgoing_port", u"(?)"))
, &m_spinBoxOutgoingPortsMax);
// UPnP lease duration
@ -622,7 +626,8 @@ void AdvancedSettings::loadAdvancedSettings() @@ -622,7 +626,8 @@ void AdvancedSettings::loadAdvancedSettings()
m_spinBoxUPnPLeaseDuration.setMaximum(std::numeric_limits<int>::max());
m_spinBoxUPnPLeaseDuration.setValue(session->UPnPLeaseDuration());
m_spinBoxUPnPLeaseDuration.setSuffix(tr(" s", " seconds"));
addRow(UPNP_LEASE_DURATION, (tr("UPnP lease duration [0: Permanent lease]") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#upnp_lease_duration", u"(?)"))
m_spinBoxUPnPLeaseDuration.setSpecialValueText(tr("0 (permanent lease)"));
addRow(UPNP_LEASE_DURATION, (tr("UPnP lease duration [0: permanent lease]") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#upnp_lease_duration", u"(?)"))
, &m_spinBoxUPnPLeaseDuration);
// Type of service
m_spinBoxPeerToS.setMinimum(0);
@ -711,11 +716,12 @@ void AdvancedSettings::loadAdvancedSettings() @@ -711,11 +716,12 @@ void AdvancedSettings::loadAdvancedSettings()
addRow(MAX_CONCURRENT_HTTP_ANNOUNCES, (tr("Max concurrent HTTP announces") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#max_concurrent_http_announces", u"(?)"))
, &m_spinBoxMaxConcurrentHTTPAnnounces);
// Stop tracker timeout
m_spinBoxStopTrackerTimeout.setMaximum(std::numeric_limits<int>::max());
m_spinBoxStopTrackerTimeout.setValue(session->stopTrackerTimeout());
m_spinBoxStopTrackerTimeout.setSuffix(tr(" s", " seconds"));
addRow(STOP_TRACKER_TIMEOUT, (tr("Stop tracker timeout") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#stop_tracker_timeout", u"(?)"))
m_spinBoxStopTrackerTimeout.setSpecialValueText(tr("0 (disabled)"));
addRow(STOP_TRACKER_TIMEOUT, (tr("Stop tracker timeout [0: disabled]") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#stop_tracker_timeout", u"(?)"))
, &m_spinBoxStopTrackerTimeout);
// Program notifications
m_checkBoxProgramNotifications.setChecked(app()->desktopIntegration()->isNotificationsEnabled());
addRow(PROGRAM_NOTIFICATIONS, tr("Display notifications"), &m_checkBoxProgramNotifications);
@ -727,9 +733,10 @@ void AdvancedSettings::loadAdvancedSettings() @@ -727,9 +733,10 @@ void AdvancedSettings::loadAdvancedSettings()
m_spinBoxNotificationTimeout.setMinimum(-1);
m_spinBoxNotificationTimeout.setMaximum(std::numeric_limits<int>::max());
m_spinBoxNotificationTimeout.setValue(app()->desktopIntegration()->notificationTimeout());
m_spinBoxNotificationTimeout.setSpecialValueText(tr("System default"));
m_spinBoxNotificationTimeout.setSuffix(tr(" ms", " milliseconds"));
addRow(NOTIFICATION_TIMEOUT, tr("Notification timeout [0: infinite]"), &m_spinBoxNotificationTimeout);
connect(&m_spinBoxNotificationTimeout, qOverload<int>(&QSpinBox::valueChanged)
, this, &AdvancedSettings::updateNotificationTimeoutSuffix);
updateNotificationTimeoutSuffix(m_spinBoxNotificationTimeout.value());
addRow(NOTIFICATION_TIMEOUT, tr("Notification timeout [0: infinite, -1: system default]"), &m_spinBoxNotificationTimeout);
#endif
// Reannounce to all trackers when ip/port changed
m_checkBoxReannounceWhenAddressChanged.setChecked(session->isReannounceWhenAddressChangedEnabled());

13
src/gui/advancedsettings.h

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2015
* Copyright (C) 2015 qBittorrent project
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -34,6 +34,7 @@ @@ -34,6 +34,7 @@
#include <QSpinBox>
#include <QTableWidget>
#include "gui/desktopintegration.h"
#include "guiapplicationcomponent.h"
class AdvancedSettings final : public QTableWidget, public GUIApplicationComponent
@ -51,11 +52,15 @@ signals: @@ -51,11 +52,15 @@ signals:
void settingsChanged();
private slots:
void updateInterfaceAddressCombo();
#ifndef QBT_USES_LIBTORRENT2
void updateCacheSpinSuffix(int value);
#endif
void updateSaveResumeDataIntervalSuffix(int value);
void updateInterfaceAddressCombo();
#ifdef QBT_USES_CUSTOMDBUSNOTIFICATIONS
void updateNotificationTimeoutSuffix(int value);
#endif
private:
void loadAdvancedSettings();
@ -93,7 +98,7 @@ private: @@ -93,7 +98,7 @@ private:
QCheckBox m_checkBoxIconsInMenusEnabled;
#endif
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)) && defined(QT_DBUS_LIB)
#ifdef QBT_USES_CUSTOMDBUSNOTIFICATIONS
QSpinBox m_spinBoxNotificationTimeout;
#endif
};

20
src/webui/www/private/views/preferences.html

@ -1189,7 +1189,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD @@ -1189,7 +1189,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
<label for="socketSendBufferSize">QBT_TR(Socket send buffer size [0: system default]:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#send_socket_buffer_size" target="_blank">(?)</a></label>
</td>
<td>
<input type="text" id="socketSendBufferSize" style="width: 15em;" />&nbsp;&nbsp;QBT_TR(Bytes)QBT_TR[CONTEXT=OptionsDialog]
<input type="text" id="socketSendBufferSize" style="width: 15em;" />&nbsp;&nbsp;QBT_TR(KiB)QBT_TR[CONTEXT=OptionsDialog]
</td>
</tr>
<tr>
@ -1197,7 +1197,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD @@ -1197,7 +1197,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
<label for="socketReceiveBufferSize">QBT_TR(Socket receive buffer size [0: system default]:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#recv_socket_buffer_size" target="_blank">(?)</a></label>
</td>
<td>
<input type="text" id="socketReceiveBufferSize" style="width: 15em;" />&nbsp;&nbsp;QBT_TR(Bytes)QBT_TR[CONTEXT=OptionsDialog]
<input type="text" id="socketReceiveBufferSize" style="width: 15em;" />&nbsp;&nbsp;QBT_TR(KiB)QBT_TR[CONTEXT=OptionsDialog]
</td>
</tr>
<tr>
@ -1210,7 +1210,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD @@ -1210,7 +1210,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
</tr>
<tr>
<td>
<label for="outgoingPortsMin">QBT_TR(Outgoing ports (Min) [0: Disabled]:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#outgoing_port" target="_blank">(?)</a></label>
<label for="outgoingPortsMin">QBT_TR(Outgoing ports (Min) [0: disabled]:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#outgoing_port" target="_blank">(?)</a></label>
</td>
<td>
<input type="text" id="outgoingPortsMin" style="width: 15em;" />
@ -1218,7 +1218,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD @@ -1218,7 +1218,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
</tr>
<tr>
<td>
<label for="outgoingPortsMax">QBT_TR(Outgoing ports (Max) [0: Disabled]:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#outgoing_port" target="_blank">(?)</a></label>
<label for="outgoingPortsMax">QBT_TR(Outgoing ports (Max) [0: disabled]:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#outgoing_port" target="_blank">(?)</a></label>
</td>
<td>
<input type="text" id="outgoingPortsMax" style="width: 15em;" />
@ -1226,7 +1226,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD @@ -1226,7 +1226,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
</tr>
<tr>
<td>
<label for="UPnPLeaseDuration">QBT_TR(UPnP lease duration [0: Permanent lease]:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#upnp_lease_duration" target="_blank">(?)</a></label>
<label for="UPnPLeaseDuration">QBT_TR(UPnP lease duration [0: permanent lease]:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#upnp_lease_duration" target="_blank">(?)</a></label>
</td>
<td>
<input type="text" id="UPnPLeaseDuration" style="width: 15em;" />
@ -1348,7 +1348,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD @@ -1348,7 +1348,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
</tr>
<tr>
<td>
<label for="stopTrackerTimeout">QBT_TR(Stop tracker timeout:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#stop_tracker_timeout" target="_blank">(?)</a></label>
<label for="stopTrackerTimeout">QBT_TR(Stop tracker timeout [0: disabled]:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#stop_tracker_timeout" target="_blank">(?)</a></label>
</td>
<td>
<input type="text" id="stopTrackerTimeout" style="width: 15em;" />
@ -2161,8 +2161,8 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD @@ -2161,8 +2161,8 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
$('sendBufferLowWatermark').setProperty('value', pref.send_buffer_low_watermark);
$('sendBufferWatermarkFactor').setProperty('value', pref.send_buffer_watermark_factor);
$('connectionSpeed').setProperty('value', pref.connection_speed);
$('socketSendBufferSize').setProperty('value', pref.socket_send_buffer_size);
$('socketReceiveBufferSize').setProperty('value', pref.socket_receive_buffer_size);
$('socketSendBufferSize').setProperty('value', (pref.socket_send_buffer_size / 1024));
$('socketReceiveBufferSize').setProperty('value', (pref.socket_receive_buffer_size / 1024));
$('socketBacklogSize').setProperty('value', pref.socket_backlog_size);
$('outgoingPortsMin').setProperty('value', pref.outgoing_ports_min);
$('outgoingPortsMax').setProperty('value', pref.outgoing_ports_max);
@ -2578,8 +2578,8 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD @@ -2578,8 +2578,8 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
settings.set('send_buffer_low_watermark', $('sendBufferLowWatermark').getProperty('value'));
settings.set('send_buffer_watermark_factor', $('sendBufferWatermarkFactor').getProperty('value'));
settings.set('connection_speed', $('connectionSpeed').getProperty('value'));
settings.set('socket_send_buffer_size', $('socketSendBufferSize').getProperty('value'));
settings.set('socket_receive_buffer_size', $('socketReceiveBufferSize').getProperty('value'));
settings.set('socket_send_buffer_size', ($('socketSendBufferSize').getProperty('value') * 1024));
settings.set('socket_receive_buffer_size', ($('socketReceiveBufferSize').getProperty('value') * 1024));
settings.set('socket_backlog_size', $('socketBacklogSize').getProperty('value'));
settings.set('outgoing_ports_min', $('outgoingPortsMin').getProperty('value'));
settings.set('outgoing_ports_max', $('outgoingPortsMax').getProperty('value'));

Loading…
Cancel
Save