From a9ab2d9b9ef1e833442773bb634e355850b93cd4 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Fri, 7 Apr 2023 18:23:26 +0800 Subject: [PATCH 1/2] Use KiB unit for socket buffer sizes https://github.com/qbittorrent/qBittorrent/pull/18806#issuecomment-1499894871 --- src/gui/advancedsettings.cpp | 18 +++++++++--------- src/webui/www/private/views/preferences.html | 12 ++++++------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/gui/advancedsettings.cpp b/src/gui/advancedsettings.cpp index 491090431..06a27edc8 100644 --- a/src/gui/advancedsettings.cpp +++ b/src/gui/advancedsettings.cpp @@ -231,9 +231,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 @@ -506,7 +506,7 @@ void AdvancedSettings::loadAdvancedSettings() #endif // Disk queue size m_spinBoxDiskQueueSize.setMinimum(1); - m_spinBoxDiskQueueSize.setMaximum(std::numeric_limits::max()); + m_spinBoxDiskQueueSize.setMaximum(std::numeric_limits::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,17 +575,17 @@ void AdvancedSettings::loadAdvancedSettings() , &m_spinBoxConnectionSpeed); // Socket send buffer size m_spinBoxSocketSendBufferSize.setMinimum(0); - m_spinBoxSocketSendBufferSize.setMaximum(std::numeric_limits::max()); - m_spinBoxSocketSendBufferSize.setValue(session->socketSendBufferSize()); - m_spinBoxSocketSendBufferSize.setSuffix(tr(" Bytes")); + m_spinBoxSocketSendBufferSize.setMaximum(std::numeric_limits::max() / 1024); + m_spinBoxSocketSendBufferSize.setValue(session->socketSendBufferSize() / 1024); + m_spinBoxSocketSendBufferSize.setSuffix(tr(" KiB")); 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); // Socket receive buffer size m_spinBoxSocketReceiveBufferSize.setMinimum(0); - m_spinBoxSocketReceiveBufferSize.setMaximum(std::numeric_limits::max()); - m_spinBoxSocketReceiveBufferSize.setValue(session->socketReceiveBufferSize()); - m_spinBoxSocketReceiveBufferSize.setSuffix(tr(" Bytes")); + m_spinBoxSocketReceiveBufferSize.setMaximum(std::numeric_limits::max() / 1024); + m_spinBoxSocketReceiveBufferSize.setValue(session->socketReceiveBufferSize() / 1024); + m_spinBoxSocketReceiveBufferSize.setSuffix(tr(" KiB")); 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); diff --git a/src/webui/www/private/views/preferences.html b/src/webui/www/private/views/preferences.html index fdbaad375..33a15f5a3 100644 --- a/src/webui/www/private/views/preferences.html +++ b/src/webui/www/private/views/preferences.html @@ -1189,7 +1189,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD -   QBT_TR(Bytes)QBT_TR[CONTEXT=OptionsDialog] +   QBT_TR(KiB)QBT_TR[CONTEXT=OptionsDialog] @@ -1197,7 +1197,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD -   QBT_TR(Bytes)QBT_TR[CONTEXT=OptionsDialog] +   QBT_TR(KiB)QBT_TR[CONTEXT=OptionsDialog] @@ -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 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')); From 9d7fcea5d61b54b31e3a1f39758ccda945243f34 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Fri, 7 Apr 2023 18:27:13 +0800 Subject: [PATCH 2/2] Describe special values in label https://github.com/qbittorrent/qBittorrent/pull/18806#discussion_r1158346210 https://github.com/qbittorrent/qBittorrent/pull/18812#issuecomment-1500303976 --- src/gui/advancedsettings.cpp | 53 +++++++++++--------- src/gui/advancedsettings.h | 13 +++-- src/webui/www/private/views/preferences.html | 8 +-- 3 files changed, 43 insertions(+), 31 deletions(-) diff --git a/src/gui/advancedsettings.cpp b/src/gui/advancedsettings.cpp index 06a27edc8..2ad64667f 100644 --- a/src/gui/advancedsettings.cpp +++ b/src/gui/advancedsettings.cpp @@ -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 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, @@ -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() { @@ -578,16 +581,16 @@ void AdvancedSettings::loadAdvancedSettings() m_spinBoxSocketSendBufferSize.setMaximum(std::numeric_limits::max() / 1024); m_spinBoxSocketSendBufferSize.setValue(session->socketSendBufferSize() / 1024); m_spinBoxSocketSendBufferSize.setSuffix(tr(" KiB")); - 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.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::max() / 1024); m_spinBoxSocketReceiveBufferSize.setValue(session->socketReceiveBufferSize() / 1024); m_spinBoxSocketReceiveBufferSize.setSuffix(tr(" KiB")); - 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.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() m_spinBoxSaveResumeDataInterval.setMinimum(0); m_spinBoxSaveResumeDataInterval.setMaximum(std::numeric_limits::max()); m_spinBoxSaveResumeDataInterval.setValue(session->saveResumeDataInterval()); - connect(&m_spinBoxSaveResumeDataInterval, qOverload(&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() m_spinBoxUPnPLeaseDuration.setMaximum(std::numeric_limits::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() 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::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() m_spinBoxNotificationTimeout.setMinimum(-1); m_spinBoxNotificationTimeout.setMaximum(std::numeric_limits::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(&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()); diff --git a/src/gui/advancedsettings.h b/src/gui/advancedsettings.h index dee557f90..5b0ab9b70 100644 --- a/src/gui/advancedsettings.h +++ b/src/gui/advancedsettings.h @@ -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 @@ #include #include +#include "gui/desktopintegration.h" #include "guiapplicationcomponent.h" class AdvancedSettings final : public QTableWidget, public GUIApplicationComponent @@ -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: 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 }; diff --git a/src/webui/www/private/views/preferences.html b/src/webui/www/private/views/preferences.html index 33a15f5a3..5d8c06a2e 100644 --- a/src/webui/www/private/views/preferences.html +++ b/src/webui/www/private/views/preferences.html @@ -1210,7 +1210,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 - + @@ -1226,7 +1226,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 - +