2015-11-15 08:48:10 +03:00
/*
* Bittorrent Client using Qt and libtorrent .
* Copyright ( C ) 2016 qBittorrent project
*
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation ; either version 2
* of the License , or ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 , USA .
*
* In addition , as a special exception , the copyright holders give permission to
* link this program with the OpenSSL project ' s " OpenSSL " library ( or with
* modified versions of it that use the same license as the " OpenSSL " library ) ,
* and distribute the linked executables . You must obey the GNU General Public
* License in all respects for all of the code used other than " OpenSSL " . If you
* modify file ( s ) , you may extend this exception to your version of the file ( s ) ,
* but you are not obligated to do so . If you do not wish to do so , delete this
* exception statement from your version .
*/
# include "advancedsettings.h"
2016-05-01 11:05:52 +03:00
2018-07-04 09:02:05 +03:00
# include <limits>
2015-11-15 08:48:10 +03:00
# include <QHeaderView>
# include <QHostAddress>
2019-07-13 08:49:26 +03:00
# include <QLabel>
2015-11-15 08:48:10 +03:00
# include <QNetworkInterface>
2016-05-01 11:05:52 +03:00
# include "base/bittorrent/session.h"
2018-11-18 21:40:37 +03:00
# include "base/global.h"
2015-11-15 08:48:10 +03:00
# include "base/preferences.h"
2017-09-13 23:29:54 +03:00
# include "base/unicodestrings.h"
2017-10-16 16:10:25 +03:00
# include "gui/addnewtorrentdialog.h"
2016-04-17 22:56:51 +03:00
# include "gui/mainwindow.h"
2022-04-14 07:04:58 +03:00
# include "interfaces/iguiapplication.h"
2015-11-15 08:48:10 +03:00
2019-03-09 18:21:02 +03:00
namespace
{
2022-03-29 05:41:17 +03:00
QString makeLink ( const QStringView url , const QStringView linkLabel )
2019-03-09 18:21:02 +03:00
{
2022-03-12 17:00:58 +03:00
return u " <a href= \" %1 \" >%2</a> " _qs . arg ( url , linkLabel ) ;
2019-03-09 18:21:02 +03:00
}
2020-09-09 11:22:33 +03:00
enum AdvSettingsCols
{
PROPERTY ,
VALUE ,
COL_COUNT
} ;
enum AdvSettingsRows
{
// qBittorrent section
QBITTORRENT_HEADER ,
2021-03-24 11:53:47 +03:00
RESUME_DATA_STORAGE ,
2022-06-30 06:23:48 +03:00
# ifdef QBT_USES_LIBTORRENT2
2022-04-16 06:36:58 +03:00
MEMORY_WORKING_SET_LIMIT ,
2022-06-30 06:23:48 +03:00
# endif
2019-09-28 09:21:53 +03:00
# if defined(Q_OS_WIN)
2020-09-09 11:22:33 +03:00
OS_MEMORY_PRIORITY ,
2019-09-28 09:21:53 +03:00
# endif
2020-09-09 11:22:33 +03:00
// network interface
NETWORK_IFACE ,
//Optional network address
NETWORK_IFACE_ADDRESS ,
// behavior
SAVE_RESUME_DATA_INTERVAL ,
CONFIRM_RECHECK_TORRENT ,
RECHECK_COMPLETED ,
// UI related
LIST_REFRESH ,
RESOLVE_HOSTS ,
RESOLVE_COUNTRIES ,
PROGRAM_NOTIFICATIONS ,
TORRENT_ADDED_NOTIFICATIONS ,
2021-04-13 17:22:48 +03:00
# if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)) && defined(QT_DBUS_LIB)
NOTIFICATION_TIMEOUT ,
# endif
2020-09-09 11:22:33 +03:00
CONFIRM_REMOVE_ALL_TAGS ,
2021-05-23 09:26:54 +03:00
REANNOUNCE_WHEN_ADDRESS_CHANGED ,
2020-09-09 11:22:33 +03:00
DOWNLOAD_TRACKER_FAVICON ,
SAVE_PATH_HISTORY_LENGTH ,
ENABLE_SPEED_WIDGET ,
2021-02-19 18:11:52 +03:00
# ifndef Q_OS_MACOS
ENABLE_ICONS_IN_MENUS ,
# endif
2020-12-01 07:09:36 +03:00
// embedded tracker
TRACKER_STATUS ,
TRACKER_PORT ,
2020-09-09 11:22:33 +03:00
// libtorrent section
LIBTORRENT_HEADER ,
ASYNC_IO_THREADS ,
2021-08-08 08:27:22 +03:00
# ifdef QBT_USES_LIBTORRENT2
2020-10-10 08:07:04 +03:00
HASHING_THREADS ,
# endif
2020-09-09 11:22:33 +03:00
FILE_POOL_SIZE ,
CHECKING_MEM_USAGE ,
2021-08-08 08:27:22 +03:00
# ifndef QBT_USES_LIBTORRENT2
2020-09-09 11:22:33 +03:00
// cache
DISK_CACHE ,
DISK_CACHE_TTL ,
2020-09-08 10:10:50 +03:00
# endif
2022-03-01 07:44:48 +03:00
DISK_QUEUE_SIZE ,
2022-05-11 21:28:06 +03:00
# ifdef QBT_USES_LIBTORRENT2
DISK_IO_TYPE ,
# endif
2020-09-09 11:22:33 +03:00
OS_CACHE ,
2021-08-08 08:27:22 +03:00
# ifndef QBT_USES_LIBTORRENT2
2020-09-09 11:22:33 +03:00
COALESCE_RW ,
2020-09-08 10:10:50 +03:00
# endif
2020-09-09 11:22:33 +03:00
PIECE_EXTENT_AFFINITY ,
SUGGEST_MODE ,
SEND_BUF_WATERMARK ,
SEND_BUF_LOW_WATERMARK ,
SEND_BUF_WATERMARK_FACTOR ,
// networking & ports
2021-05-16 20:16:38 +03:00
CONNECTION_SPEED ,
2020-09-09 11:22:33 +03:00
SOCKET_BACKLOG_SIZE ,
OUTGOING_PORT_MIN ,
OUTGOING_PORT_MAX ,
UPNP_LEASE_DURATION ,
2021-03-06 09:17:07 +03:00
PEER_TOS ,
2020-09-09 11:22:33 +03:00
UTP_MIX_MODE ,
2020-12-01 05:53:48 +03:00
IDN_SUPPORT ,
2020-09-09 11:22:33 +03:00
MULTI_CONNECTIONS_PER_IP ,
VALIDATE_HTTPS_TRACKER_CERTIFICATE ,
2021-08-04 06:28:36 +03:00
SSRF_MITIGATION ,
2020-09-21 05:46:28 +03:00
BLOCK_PEERS_ON_PRIVILEGED_PORTS ,
2020-09-09 11:22:33 +03:00
// seeding
CHOKING_ALGORITHM ,
SEED_CHOKING_ALGORITHM ,
// tracker
ANNOUNCE_ALL_TRACKERS ,
ANNOUNCE_ALL_TIERS ,
ANNOUNCE_IP ,
MAX_CONCURRENT_HTTP_ANNOUNCES ,
STOP_TRACKER_TIMEOUT ,
PEER_TURNOVER ,
PEER_TURNOVER_CUTOFF ,
PEER_TURNOVER_INTERVAL ,
2022-03-01 07:44:48 +03:00
REQUEST_QUEUE_SIZE ,
2015-11-15 10:03:43 +03:00
2020-09-09 11:22:33 +03:00
ROW_COUNT
} ;
}
2015-11-15 08:48:10 +03:00
2022-06-25 15:46:55 +03:00
AdvancedSettings : : AdvancedSettings ( IGUIApplication * app , QWidget * parent )
2015-11-15 08:48:10 +03:00
: QTableWidget ( parent )
2022-06-25 15:46:55 +03:00
, GUIApplicationComponent ( app )
2015-11-15 08:48:10 +03:00
{
2015-11-15 09:08:22 +03:00
// column
2015-11-15 10:03:43 +03:00
setColumnCount ( COL_COUNT ) ;
2022-05-14 09:39:28 +03:00
const QStringList header = { tr ( " Setting " ) , tr ( " Value " , " Value set for this setting " ) } ;
2015-11-15 08:48:10 +03:00
setHorizontalHeaderLabels ( header ) ;
2015-11-15 09:08:22 +03:00
// row
2015-11-15 08:48:10 +03:00
setRowCount ( ROW_COUNT ) ;
2015-11-15 09:08:22 +03:00
verticalHeader ( ) - > setVisible ( false ) ;
// etc.
setAlternatingRowColors ( true ) ;
2016-01-31 09:13:21 +03:00
setSelectionMode ( QAbstractItemView : : NoSelection ) ;
2015-11-15 09:08:22 +03:00
setEditTriggers ( QAbstractItemView : : NoEditTriggers ) ;
2015-11-15 08:48:10 +03:00
// Load settings
loadAdvancedSettings ( ) ;
2015-11-15 09:08:22 +03:00
resizeColumnToContents ( 0 ) ;
horizontalHeader ( ) - > setStretchLastSection ( true ) ;
2015-11-15 08:48:10 +03:00
}
2022-05-14 09:39:28 +03:00
void AdvancedSettings : : saveAdvancedSettings ( ) const
2015-11-15 08:48:10 +03:00
{
2018-06-06 16:48:17 +03:00
Preferences * const pref = Preferences : : instance ( ) ;
2016-05-01 11:05:52 +03:00
BitTorrent : : Session * const session = BitTorrent : : Session : : instance ( ) ;
2022-05-13 07:13:04 +03:00
session - > setResumeDataStorageType ( m_comboBoxResumeDataStorage . currentData ( ) . value < BitTorrent : : ResumeDataStorageType > ( ) ) ;
2022-06-30 06:23:48 +03:00
# ifdef QBT_USES_LIBTORRENT2
2022-04-16 06:36:58 +03:00
// Physical memory (RAM) usage limit
2022-06-25 15:46:55 +03:00
app ( ) - > setMemoryWorkingSetLimit ( m_spinBoxMemoryWorkingSetLimit . value ( ) ) ;
2022-06-30 06:23:48 +03:00
# endif
2019-09-28 09:21:53 +03:00
# if defined(Q_OS_WIN)
2022-06-29 11:55:40 +03:00
app ( ) - > setProcessMemoryPriority ( m_comboBoxOSMemoryPriority . currentData ( ) . value < MemoryPriority > ( ) ) ;
2019-09-28 09:21:53 +03:00
# endif
2018-06-18 19:10:57 +03:00
// Async IO threads
2019-07-23 09:34:57 +03:00
session - > setAsyncIOThreads ( m_spinBoxAsyncIOThreads . value ( ) ) ;
2021-08-08 08:27:22 +03:00
# ifdef QBT_USES_LIBTORRENT2
2020-10-10 08:07:04 +03:00
// Hashing threads
session - > setHashingThreads ( m_spinBoxHashingThreads . value ( ) ) ;
# endif
2019-07-03 12:44:16 +03:00
// File pool size
2019-07-23 09:34:57 +03:00
session - > setFilePoolSize ( m_spinBoxFilePoolSize . value ( ) ) ;
2018-08-28 13:18:07 +03:00
// Checking Memory Usage
2019-07-23 09:34:57 +03:00
session - > setCheckingMemUsage ( m_spinBoxCheckingMemUsage . value ( ) ) ;
2021-08-08 08:27:22 +03:00
# ifndef QBT_USES_LIBTORRENT2
2015-11-15 08:48:10 +03:00
// Disk write cache
2019-07-23 09:34:57 +03:00
session - > setDiskCacheSize ( m_spinBoxCache . value ( ) ) ;
session - > setDiskCacheTTL ( m_spinBoxCacheTTL . value ( ) ) ;
2020-09-08 10:10:50 +03:00
# endif
2022-03-01 07:44:48 +03:00
// Disk queue size
session - > setDiskQueueSize ( m_spinBoxDiskQueueSize . value ( ) * 1024 ) ;
2022-05-11 21:28:06 +03:00
# ifdef QBT_USES_LIBTORRENT2
session - > setDiskIOType ( m_comboBoxDiskIOType . currentData ( ) . value < BitTorrent : : DiskIOType > ( ) ) ;
# endif
2015-11-15 08:48:10 +03:00
// Enable OS cache
2019-07-23 09:34:57 +03:00
session - > setUseOSCache ( m_checkBoxOsCache . isChecked ( ) ) ;
2021-08-08 08:27:22 +03:00
# ifndef QBT_USES_LIBTORRENT2
2018-01-29 12:03:14 +03:00
// Coalesce reads & writes
2019-07-23 09:34:57 +03:00
session - > setCoalesceReadWriteEnabled ( m_checkBoxCoalesceRW . isChecked ( ) ) ;
2020-09-08 10:10:50 +03:00
# endif
2020-01-13 03:11:29 +03:00
// Piece extent affinity
session - > setPieceExtentAffinity ( m_checkBoxPieceExtentAffinity . isChecked ( ) ) ;
2017-08-11 14:15:18 +03:00
// Suggest mode
2019-07-23 09:34:57 +03:00
session - > setSuggestMode ( m_checkBoxSuggestMode . isChecked ( ) ) ;
2017-08-11 14:48:58 +03:00
// Send buffer watermark
2019-07-23 09:34:57 +03:00
session - > setSendBufferWatermark ( m_spinBoxSendBufferWatermark . value ( ) ) ;
session - > setSendBufferLowWatermark ( m_spinBoxSendBufferLowWatermark . value ( ) ) ;
session - > setSendBufferWatermarkFactor ( m_spinBoxSendBufferWatermarkFactor . value ( ) ) ;
2021-05-16 20:16:38 +03:00
// Outgoing connections per second
session - > setConnectionSpeed ( m_spinBoxConnectionSpeed . value ( ) ) ;
2019-07-02 07:03:44 +03:00
// Socket listen backlog size
2019-07-23 09:34:57 +03:00
session - > setSocketBacklogSize ( m_spinBoxSocketBacklogSize . value ( ) ) ;
2015-11-15 08:48:10 +03:00
// Save resume data interval
2019-07-23 09:34:57 +03:00
session - > setSaveResumeDataInterval ( m_spinBoxSaveResumeDataInterval . value ( ) ) ;
2015-11-15 08:48:10 +03:00
// Outgoing ports
2019-07-23 09:34:57 +03:00
session - > setOutgoingPortsMin ( m_spinBoxOutgoingPortsMin . value ( ) ) ;
session - > setOutgoingPortsMax ( m_spinBoxOutgoingPortsMax . value ( ) ) ;
2020-03-28 07:32:07 +03:00
// UPnP lease duration
session - > setUPnPLeaseDuration ( m_spinBoxUPnPLeaseDuration . value ( ) ) ;
2021-03-06 09:17:07 +03:00
// Type of service
session - > setPeerToS ( m_spinBoxPeerToS . value ( ) ) ;
2017-08-11 11:28:52 +03:00
// uTP-TCP mixed mode
2022-05-13 07:13:04 +03:00
session - > setUtpMixedMode ( m_comboBoxUtpMixedMode . currentData ( ) . value < BitTorrent : : MixedModeAlgorithm > ( ) ) ;
2020-12-01 05:53:48 +03:00
// Support internationalized domain name (IDN)
session - > setIDNSupportEnabled ( m_checkBoxIDNSupport . isChecked ( ) ) ;
2017-08-11 11:37:32 +03:00
// multiple connections per IP
2019-07-23 09:34:57 +03:00
session - > setMultiConnectionsPerIpEnabled ( m_checkBoxMultiConnectionsPerIp . isChecked ( ) ) ;
2020-04-22 22:50:13 +03:00
// Validate HTTPS tracker certificate
session - > setValidateHTTPSTrackerCertificate ( m_checkBoxValidateHTTPSTrackerCertificate . isChecked ( ) ) ;
2021-08-04 06:28:36 +03:00
// SSRF mitigation
session - > setSSRFMitigationEnabled ( m_checkBoxSSRFMitigation . isChecked ( ) ) ;
2020-09-21 05:46:28 +03:00
// Disallow connection to peers on privileged ports
session - > setBlockPeersOnPrivilegedPorts ( m_checkBoxBlockPeersOnPrivilegedPorts . isChecked ( ) ) ;
2015-11-15 08:48:10 +03:00
// Recheck torrents on completion
2019-07-23 09:34:57 +03:00
pref - > recheckTorrentsOnCompletion ( m_checkBoxRecheckCompleted . isChecked ( ) ) ;
2015-11-15 08:48:10 +03:00
// Transfer list refresh interval
2019-07-23 09:34:57 +03:00
session - > setRefreshInterval ( m_spinBoxListRefresh . value ( ) ) ;
2015-11-15 08:48:10 +03:00
// Peer resolution
2019-07-23 09:34:57 +03:00
pref - > resolvePeerCountries ( m_checkBoxResolveCountries . isChecked ( ) ) ;
pref - > resolvePeerHostNames ( m_checkBoxResolveHosts . isChecked ( ) ) ;
2015-11-15 08:48:10 +03:00
// Network interface
2022-05-14 13:13:42 +03:00
session - > setNetworkInterface ( m_comboBoxInterface . currentData ( ) . toString ( ) ) ;
session - > setNetworkInterfaceName ( ( m_comboBoxInterface . currentIndex ( ) = = 0 )
? QString ( )
: m_comboBoxInterface . currentText ( ) ) ;
2016-04-13 11:51:29 +03:00
// Interface address
2019-12-06 03:24:49 +03:00
// Construct a QHostAddress to filter malformed strings
2022-05-14 13:13:42 +03:00
const QHostAddress ifaceAddr { m_comboBoxInterfaceAddress . currentData ( ) . toString ( ) } ;
2019-12-06 03:24:49 +03:00
session - > setNetworkInterfaceAddress ( ifaceAddr . toString ( ) ) ;
2016-10-31 02:22:11 +03:00
// Announce IP
2019-12-06 03:24:49 +03:00
// Construct a QHostAddress to filter malformed strings
const QHostAddress addr ( m_lineEditAnnounceIP . text ( ) . trimmed ( ) ) ;
session - > setAnnounceIP ( addr . toString ( ) ) ;
2020-09-03 06:24:30 +03:00
// Max concurrent HTTP announces
session - > setMaxConcurrentHTTPAnnounces ( m_spinBoxMaxConcurrentHTTPAnnounces . value ( ) ) ;
2020-01-09 15:43:06 +03:00
// Stop tracker timeout
session - > setStopTrackerTimeout ( m_spinBoxStopTrackerTimeout . value ( ) ) ;
2015-11-15 08:48:10 +03:00
// Program notification
2022-06-25 15:46:55 +03:00
MainWindow * mainWindow = app ( ) - > mainWindow ( ) ;
2019-07-23 09:34:57 +03:00
mainWindow - > setNotificationsEnabled ( m_checkBoxProgramNotifications . isChecked ( ) ) ;
mainWindow - > setTorrentAddedNotificationsEnabled ( m_checkBoxTorrentAddedNotifications . isChecked ( ) ) ;
2021-04-13 17:22:48 +03:00
# if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)) && defined(QT_DBUS_LIB)
mainWindow - > setNotificationTimeout ( m_spinBoxNotificationTimeout . value ( ) ) ;
# endif
2021-05-23 09:26:54 +03:00
// Reannounce to all trackers when ip/port changed
session - > setReannounceWhenAddressChangedEnabled ( m_checkBoxReannounceWhenAddressChanged . isChecked ( ) ) ;
2016-11-13 23:46:17 +03:00
// Misc GUI properties
2019-07-23 09:34:57 +03:00
mainWindow - > setDownloadTrackerFavicon ( m_checkBoxTrackerFavicon . isChecked ( ) ) ;
AddNewTorrentDialog : : setSavePathHistoryLength ( m_spinBoxSavePathHistoryLength . value ( ) ) ;
pref - > setSpeedWidgetEnabled ( m_checkBoxSpeedWidgetEnabled . isChecked ( ) ) ;
2021-02-19 18:11:52 +03:00
# ifndef Q_OS_MACOS
pref - > setIconsInMenusEnabled ( m_checkBoxIconsInMenusEnabled . isChecked ( ) ) ;
# endif
2016-05-01 11:05:52 +03:00
2015-11-15 08:48:10 +03:00
// Tracker
2019-07-23 09:34:57 +03:00
pref - > setTrackerPort ( m_spinBoxTrackerPort . value ( ) ) ;
2019-08-08 18:21:07 +03:00
session - > setTrackerEnabled ( m_checkBoxTrackerStatus . isChecked ( ) ) ;
2017-08-11 12:06:31 +03:00
// Choking algorithm
2022-05-13 07:13:04 +03:00
session - > setChokingAlgorithm ( m_comboBoxChokingAlgorithm . currentData ( ) . value < BitTorrent : : ChokingAlgorithm > ( ) ) ;
2017-08-11 12:06:31 +03:00
// Seed choking algorithm
2022-05-13 07:13:04 +03:00
session - > setSeedChokingAlgorithm ( m_comboBoxSeedChokingAlgorithm . currentData ( ) . value < BitTorrent : : SeedChokingAlgorithm > ( ) ) ;
2017-08-11 12:06:31 +03:00
2019-07-23 09:34:57 +03:00
pref - > setConfirmTorrentRecheck ( m_checkBoxConfirmTorrentRecheck . isChecked ( ) ) ;
2017-06-05 03:22:17 +03:00
2019-07-23 09:34:57 +03:00
pref - > setConfirmRemoveAllTags ( m_checkBoxConfirmRemoveAllTags . isChecked ( ) ) ;
2017-06-05 03:22:17 +03:00
2019-07-23 09:34:57 +03:00
session - > setAnnounceToAllTrackers ( m_checkBoxAnnounceAllTrackers . isChecked ( ) ) ;
session - > setAnnounceToAllTiers ( m_checkBoxAnnounceAllTiers . isChecked ( ) ) ;
2020-08-15 20:29:30 +03:00
session - > setPeerTurnover ( m_spinBoxPeerTurnover . value ( ) ) ;
session - > setPeerTurnoverCutoff ( m_spinBoxPeerTurnoverCutoff . value ( ) ) ;
session - > setPeerTurnoverInterval ( m_spinBoxPeerTurnoverInterval . value ( ) ) ;
2022-03-01 07:44:48 +03:00
// Maximum outstanding requests to a single peer
session - > setRequestQueueSize ( m_spinBoxRequestQueueSize . value ( ) ) ;
2015-11-15 08:48:10 +03:00
}
2021-08-08 08:27:22 +03:00
# ifndef QBT_USES_LIBTORRENT2
2022-05-14 09:39:28 +03:00
void AdvancedSettings : : updateCacheSpinSuffix ( const int value )
2015-11-15 08:48:10 +03:00
{
2017-08-18 03:05:36 +03:00
if ( value = = 0 )
2019-07-23 09:34:57 +03:00
m_spinBoxCache . setSuffix ( tr ( " (disabled) " ) ) ;
2017-08-18 03:05:36 +03:00
else if ( value < 0 )
2019-07-23 09:34:57 +03:00
m_spinBoxCache . setSuffix ( tr ( " (auto) " ) ) ;
2015-11-15 08:48:10 +03:00
else
2019-07-23 09:34:57 +03:00
m_spinBoxCache . setSuffix ( tr ( " MiB " ) ) ;
2015-11-15 08:48:10 +03:00
}
2020-09-08 10:10:50 +03:00
# endif
2015-11-15 08:48:10 +03:00
2018-07-04 09:02:05 +03:00
void AdvancedSettings : : updateSaveResumeDataIntervalSuffix ( const int value )
{
if ( value > 0 )
2019-07-23 09:34:57 +03:00
m_spinBoxSaveResumeDataInterval . setSuffix ( tr ( " min " , " minutes " ) ) ;
2018-07-04 09:02:05 +03:00
else
2019-07-23 09:34:57 +03:00
m_spinBoxSaveResumeDataInterval . setSuffix ( tr ( " (disabled) " ) ) ;
2018-07-04 09:02:05 +03:00
}
2016-05-27 01:35:58 +03:00
void AdvancedSettings : : updateInterfaceAddressCombo ( )
{
2022-05-14 13:13:42 +03:00
const auto toString = [ ] ( const QHostAddress & address ) - > QString
{
switch ( address . protocol ( ) ) {
case QAbstractSocket : : IPv4Protocol :
return address . toString ( ) ;
case QAbstractSocket : : IPv6Protocol :
return Utils : : Net : : canonicalIPv6Addr ( address ) . toString ( ) ;
default :
Q_ASSERT ( false ) ;
break ;
}
return { } ;
} ;
2016-04-21 19:21:49 +03:00
2022-05-14 13:13:42 +03:00
// Clear all items and reinsert them
2019-07-23 09:34:57 +03:00
m_comboBoxInterfaceAddress . clear ( ) ;
2022-05-14 13:13:42 +03:00
m_comboBoxInterfaceAddress . addItem ( tr ( " All addresses " ) , QString ( ) ) ;
m_comboBoxInterfaceAddress . addItem ( tr ( " All IPv4 addresses " ) , QHostAddress ( QHostAddress : : AnyIPv4 ) . toString ( ) ) ;
m_comboBoxInterfaceAddress . addItem ( tr ( " All IPv6 addresses " ) , QHostAddress ( QHostAddress : : AnyIPv6 ) . toString ( ) ) ;
2016-04-21 19:21:49 +03:00
2022-05-14 13:13:42 +03:00
const QString currentIface = m_comboBoxInterface . currentData ( ) . toString ( ) ;
if ( currentIface . isEmpty ( ) ) // `any` interface
2016-05-27 01:35:58 +03:00
{
2022-05-14 13:13:42 +03:00
for ( const QHostAddress & address : asConst ( QNetworkInterface : : allAddresses ( ) ) )
2020-11-16 10:02:11 +03:00
{
2022-05-14 13:13:42 +03:00
const QString addressString = toString ( address ) ;
m_comboBoxInterfaceAddress . addItem ( addressString , addressString ) ;
2019-12-06 03:24:49 +03:00
}
2022-05-14 13:13:42 +03:00
}
else
{
const QList < QNetworkAddressEntry > addresses = QNetworkInterface : : interfaceFromName ( currentIface ) . addressEntries ( ) ;
for ( const QNetworkAddressEntry & entry : addresses )
2020-11-16 10:02:11 +03:00
{
2022-05-14 13:13:42 +03:00
const QString addressString = toString ( entry . ip ( ) ) ;
m_comboBoxInterfaceAddress . addItem ( addressString , addressString ) ;
2019-12-06 03:24:49 +03:00
}
2022-05-14 13:13:42 +03:00
}
2016-05-27 01:35:58 +03:00
2022-05-14 13:13:42 +03:00
const QString currentAddress = BitTorrent : : Session : : instance ( ) - > networkInterfaceAddress ( ) ;
const int index = m_comboBoxInterfaceAddress . findData ( currentAddress ) ;
if ( index > - 1 )
2020-11-16 10:02:11 +03:00
{
2022-05-14 13:13:42 +03:00
m_comboBoxInterfaceAddress . setCurrentIndex ( index ) ;
2016-05-27 01:35:58 +03:00
}
2020-11-16 10:02:11 +03:00
else
{
2022-05-14 13:13:42 +03:00
// not found, for the sake of UI consistency, add such entry
m_comboBoxInterfaceAddress . addItem ( currentAddress , currentAddress ) ;
m_comboBoxInterfaceAddress . setCurrentIndex ( m_comboBoxInterfaceAddress . count ( ) - 1 ) ;
2016-04-21 19:21:49 +03:00
}
}
2015-11-15 08:48:10 +03:00
void AdvancedSettings : : loadAdvancedSettings ( )
{
2018-06-06 16:48:17 +03:00
const Preferences * const pref = Preferences : : instance ( ) ;
2016-10-30 00:11:52 +03:00
const BitTorrent : : Session * const session = BitTorrent : : Session : : instance ( ) ;
2016-05-01 11:05:52 +03:00
2015-11-15 10:03:43 +03:00
// add section headers
2019-07-13 08:49:26 +03:00
auto * labelQbtLink = new QLabel (
2022-03-29 05:41:17 +03:00
makeLink ( u " https://github.com/qbittorrent/qBittorrent/wiki/Explanation-of-Options-in-qBittorrent#Advanced "
2019-07-13 08:49:26 +03:00
, tr ( " Open documentation " ) )
, this ) ;
labelQbtLink - > setOpenExternalLinks ( true ) ;
2022-03-29 05:41:17 +03:00
addRow ( QBITTORRENT_HEADER , u " <b>%1</b> " _qs . arg ( tr ( " qBittorrent Section " ) ) , labelQbtLink ) ;
2019-03-09 18:25:39 +03:00
static_cast < QLabel * > ( cellWidget ( QBITTORRENT_HEADER , PROPERTY ) ) - > setAlignment ( Qt : : AlignCenter | Qt : : AlignVCenter ) ;
2015-11-15 10:03:43 +03:00
2019-07-13 08:49:26 +03:00
auto * labelLibtorrentLink = new QLabel (
2022-03-29 05:41:17 +03:00
makeLink ( u " https://www.libtorrent.org/reference-Settings.html "
2019-07-13 08:49:26 +03:00
, tr ( " Open documentation " ) )
, this ) ;
labelLibtorrentLink - > setOpenExternalLinks ( true ) ;
2022-03-29 05:41:17 +03:00
addRow ( LIBTORRENT_HEADER , u " <b>%1</b> " _qs . arg ( tr ( " libtorrent Section " ) ) , labelLibtorrentLink ) ;
2019-03-09 18:25:39 +03:00
static_cast < QLabel * > ( cellWidget ( LIBTORRENT_HEADER , PROPERTY ) ) - > setAlignment ( Qt : : AlignCenter | Qt : : AlignVCenter ) ;
2018-06-18 19:10:57 +03:00
2022-05-13 07:13:04 +03:00
m_comboBoxResumeDataStorage . addItem ( tr ( " Fastresume files " ) , QVariant : : fromValue ( BitTorrent : : ResumeDataStorageType : : Legacy ) ) ;
m_comboBoxResumeDataStorage . addItem ( tr ( " SQLite database (experimental) " ) , QVariant : : fromValue ( BitTorrent : : ResumeDataStorageType : : SQLite ) ) ;
m_comboBoxResumeDataStorage . setCurrentIndex ( m_comboBoxResumeDataStorage . findData ( QVariant : : fromValue ( session - > resumeDataStorageType ( ) ) ) ) ;
2021-03-24 11:53:47 +03:00
addRow ( RESUME_DATA_STORAGE , tr ( " Resume data storage type (requires restart) " ) , & m_comboBoxResumeDataStorage ) ;
2022-06-30 06:23:48 +03:00
# ifdef QBT_USES_LIBTORRENT2
2022-04-16 06:36:58 +03:00
// Physical memory (RAM) usage limit
m_spinBoxMemoryWorkingSetLimit . setMinimum ( 1 ) ;
m_spinBoxMemoryWorkingSetLimit . setMaximum ( std : : numeric_limits < int > : : max ( ) ) ;
m_spinBoxMemoryWorkingSetLimit . setSuffix ( tr ( " MiB " ) ) ;
m_spinBoxMemoryWorkingSetLimit . setToolTip ( tr ( " This option is less effective on Linux " ) ) ;
2022-06-25 15:46:55 +03:00
m_spinBoxMemoryWorkingSetLimit . setValue ( app ( ) - > memoryWorkingSetLimit ( ) ) ;
2022-04-16 06:36:58 +03:00
addRow ( MEMORY_WORKING_SET_LIMIT , ( tr ( " Physical memory (RAM) usage limit " ) + u ' ' + makeLink ( u " https://wikipedia.org/wiki/Working_set " , u " (?) " ) )
, & m_spinBoxMemoryWorkingSetLimit ) ;
2022-06-30 06:23:48 +03:00
# endif
2019-09-28 09:21:53 +03:00
# if defined(Q_OS_WIN)
2022-06-29 11:55:40 +03:00
m_comboBoxOSMemoryPriority . addItem ( tr ( " Normal " ) , QVariant : : fromValue ( MemoryPriority : : Normal ) ) ;
m_comboBoxOSMemoryPriority . addItem ( tr ( " Below normal " ) , QVariant : : fromValue ( MemoryPriority : : BelowNormal ) ) ;
m_comboBoxOSMemoryPriority . addItem ( tr ( " Medium " ) , QVariant : : fromValue ( MemoryPriority : : Medium ) ) ;
m_comboBoxOSMemoryPriority . addItem ( tr ( " Low " ) , QVariant : : fromValue ( MemoryPriority : : Low ) ) ;
m_comboBoxOSMemoryPriority . addItem ( tr ( " Very low " ) , QVariant : : fromValue ( MemoryPriority : : VeryLow ) ) ;
m_comboBoxOSMemoryPriority . setCurrentIndex ( m_comboBoxOSMemoryPriority . findData ( QVariant : : fromValue ( app ( ) - > processMemoryPriority ( ) ) ) ) ;
2019-09-28 09:21:53 +03:00
addRow ( OS_MEMORY_PRIORITY , ( tr ( " Process memory priority (Windows >= 8 only) " )
2022-03-29 05:41:17 +03:00
+ u ' ' + makeLink ( u " https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/ns-processthreadsapi-memory_priority_information " , u " (?) " ) )
2019-09-28 09:21:53 +03:00
, & m_comboBoxOSMemoryPriority ) ;
# endif
2018-06-18 19:10:57 +03:00
// Async IO threads
2019-07-23 09:34:57 +03:00
m_spinBoxAsyncIOThreads . setMinimum ( 1 ) ;
m_spinBoxAsyncIOThreads . setMaximum ( 1024 ) ;
m_spinBoxAsyncIOThreads . setValue ( session - > asyncIOThreads ( ) ) ;
2022-03-29 05:41:17 +03:00
addRow ( ASYNC_IO_THREADS , ( tr ( " Asynchronous I/O threads " ) + u ' ' + makeLink ( u " https://www.libtorrent.org/reference-Settings.html#aio_threads " , u " (?) " ) )
2019-07-23 09:34:57 +03:00
, & m_spinBoxAsyncIOThreads ) ;
2020-10-10 08:07:04 +03:00
2021-08-08 08:27:22 +03:00
# ifdef QBT_USES_LIBTORRENT2
2020-10-10 08:07:04 +03:00
// Hashing threads
m_spinBoxHashingThreads . setMinimum ( 1 ) ;
m_spinBoxHashingThreads . setMaximum ( 1024 ) ;
m_spinBoxHashingThreads . setValue ( session - > hashingThreads ( ) ) ;
2022-03-29 05:41:17 +03:00
addRow ( HASHING_THREADS , ( tr ( " Hashing threads " ) + u ' ' + makeLink ( u " https://www.libtorrent.org/reference-Settings.html#hashing_threads " , u " (?) " ) )
2020-10-10 08:07:04 +03:00
, & m_spinBoxHashingThreads ) ;
# endif
2019-07-03 12:44:16 +03:00
// File pool size
2019-07-23 09:34:57 +03:00
m_spinBoxFilePoolSize . setMinimum ( 1 ) ;
m_spinBoxFilePoolSize . setMaximum ( std : : numeric_limits < int > : : max ( ) ) ;
m_spinBoxFilePoolSize . setValue ( session - > filePoolSize ( ) ) ;
2022-03-29 05:41:17 +03:00
addRow ( FILE_POOL_SIZE , ( tr ( " File pool size " ) + u ' ' + makeLink ( u " https://www.libtorrent.org/reference-Settings.html#file_pool_size " , u " (?) " ) )
2019-07-23 09:34:57 +03:00
, & m_spinBoxFilePoolSize ) ;
2019-07-03 12:44:16 +03:00
2018-08-28 13:18:07 +03:00
// Checking Memory Usage
2019-07-23 09:34:57 +03:00
m_spinBoxCheckingMemUsage . setMinimum ( 1 ) ;
2019-01-16 09:23:21 +03:00
// When build as 32bit binary, set the maximum value lower to prevent crashes.
2019-01-16 07:52:41 +03:00
# ifdef QBT_APP_64BIT
2019-07-23 09:34:57 +03:00
m_spinBoxCheckingMemUsage . setMaximum ( 1024 ) ;
2019-01-16 09:23:21 +03:00
# else
// Allocate at most 128MiB out of the remaining 512MiB (see the cache part below)
2019-07-23 09:34:57 +03:00
m_spinBoxCheckingMemUsage . setMaximum ( 128 ) ;
2019-01-16 09:23:21 +03:00
# endif
2019-07-23 09:34:57 +03:00
m_spinBoxCheckingMemUsage . setValue ( session - > checkingMemUsage ( ) ) ;
m_spinBoxCheckingMemUsage . setSuffix ( tr ( " MiB " ) ) ;
2022-03-29 05:41:17 +03:00
addRow ( CHECKING_MEM_USAGE , ( tr ( " Outstanding memory when checking torrents " ) + u ' ' + makeLink ( u " https://www.libtorrent.org/reference-Settings.html#checking_mem_usage " , u " (?) " ) )
2019-07-23 09:34:57 +03:00
, & m_spinBoxCheckingMemUsage ) ;
2021-08-08 08:27:22 +03:00
# ifndef QBT_USES_LIBTORRENT2
2015-11-15 08:48:10 +03:00
// Disk write cache
2019-07-23 09:34:57 +03:00
m_spinBoxCache . setMinimum ( - 1 ) ;
2015-11-15 08:48:10 +03:00
// When build as 32bit binary, set the maximum at less than 2GB to prevent crashes.
2019-01-16 07:52:41 +03:00
# ifdef QBT_APP_64BIT
2019-07-23 09:34:57 +03:00
m_spinBoxCache . setMaximum ( 33554431 ) ; // 32768GiB
2015-11-15 08:48:10 +03:00
# else
// allocate 1536MiB and leave 512MiB to the rest of program data in RAM
2019-07-23 09:34:57 +03:00
m_spinBoxCache . setMaximum ( 1536 ) ;
2015-11-15 08:48:10 +03:00
# endif
2019-07-23 09:34:57 +03:00
m_spinBoxCache . setValue ( session - > diskCacheSize ( ) ) ;
updateCacheSpinSuffix ( m_spinBoxCache . value ( ) ) ;
2020-09-08 10:10:50 +03:00
connect ( & m_spinBoxCache , qOverload < int > ( & QSpinBox : : valueChanged )
, this , & AdvancedSettings : : updateCacheSpinSuffix ) ;
2022-03-29 05:41:17 +03:00
addRow ( DISK_CACHE , ( tr ( " Disk cache " ) + u ' ' + makeLink ( u " https://www.libtorrent.org/reference-Settings.html#cache_size " , u " (?) " ) )
2019-07-23 09:34:57 +03:00
, & m_spinBoxCache ) ;
2015-11-15 08:48:10 +03:00
// Disk cache expiry
2019-07-23 09:34:57 +03:00
m_spinBoxCacheTTL . setMinimum ( 1 ) ;
m_spinBoxCacheTTL . setMaximum ( std : : numeric_limits < int > : : max ( ) ) ;
m_spinBoxCacheTTL . setValue ( session - > diskCacheTTL ( ) ) ;
m_spinBoxCacheTTL . setSuffix ( tr ( " s " , " seconds " ) ) ;
2022-03-29 05:41:17 +03:00
addRow ( DISK_CACHE_TTL , ( tr ( " Disk cache expiry interval " ) + u ' ' + makeLink ( u " https://www.libtorrent.org/reference-Settings.html#cache_expiry " , u " (?) " ) )
2019-07-23 09:34:57 +03:00
, & m_spinBoxCacheTTL ) ;
2020-09-08 10:10:50 +03:00
# endif
2022-03-01 07:44:48 +03:00
// Disk queue size
m_spinBoxDiskQueueSize . setMinimum ( 1 ) ;
m_spinBoxDiskQueueSize . setMaximum ( std : : numeric_limits < int > : : max ( ) ) ;
m_spinBoxDiskQueueSize . setValue ( session - > diskQueueSize ( ) / 1024 ) ;
m_spinBoxDiskQueueSize . setSuffix ( tr ( " KiB " ) ) ;
2022-03-29 05:41:17 +03:00
addRow ( DISK_QUEUE_SIZE , ( tr ( " Disk queue size " ) + u ' ' + makeLink ( u " https://www.libtorrent.org/reference-Settings.html#max_queued_disk_bytes " , u " (?) " ) )
2022-03-01 07:44:48 +03:00
, & m_spinBoxDiskQueueSize ) ;
2022-05-11 21:28:06 +03:00
# ifdef QBT_USES_LIBTORRENT2
// Disk IO type
m_comboBoxDiskIOType . addItem ( tr ( " Default " ) , QVariant : : fromValue ( BitTorrent : : DiskIOType : : Default ) ) ;
m_comboBoxDiskIOType . addItem ( tr ( " Memory mapped files " ) , QVariant : : fromValue ( BitTorrent : : DiskIOType : : MMap ) ) ;
m_comboBoxDiskIOType . addItem ( tr ( " POSIX-compliant " ) , QVariant : : fromValue ( BitTorrent : : DiskIOType : : Posix ) ) ;
m_comboBoxDiskIOType . setCurrentIndex ( m_comboBoxDiskIOType . findData ( QVariant : : fromValue ( session - > diskIOType ( ) ) ) ) ;
addRow ( DISK_IO_TYPE , tr ( " Disk IO type (requires restart) " ) + u ' ' + makeLink ( u " https://www.libtorrent.org/single-page-ref.html#default-disk-io-constructor " , u " (?) " )
, & m_comboBoxDiskIOType ) ;
# endif
2015-11-15 08:48:10 +03:00
// Enable OS cache
2019-07-23 09:34:57 +03:00
m_checkBoxOsCache . setChecked ( session - > useOSCache ( ) ) ;
2022-03-29 05:41:17 +03:00
addRow ( OS_CACHE , ( tr ( " Enable OS cache " ) + u ' ' + makeLink ( u " https://www.libtorrent.org/reference-Settings.html#disk_io_write_mode " , u " (?) " ) )
2019-07-23 09:34:57 +03:00
, & m_checkBoxOsCache ) ;
2021-08-08 08:27:22 +03:00
# ifndef QBT_USES_LIBTORRENT2
2018-01-29 12:03:14 +03:00
// Coalesce reads & writes
2019-07-23 09:34:57 +03:00
m_checkBoxCoalesceRW . setChecked ( session - > isCoalesceReadWriteEnabled ( ) ) ;
2022-03-29 05:41:17 +03:00
addRow ( COALESCE_RW , ( tr ( " Coalesce reads & writes " ) + u ' ' + makeLink ( u " https://www.libtorrent.org/reference-Settings.html#coalesce_reads " , u " (?) " ) )
2019-07-23 09:34:57 +03:00
, & m_checkBoxCoalesceRW ) ;
2020-09-08 10:10:50 +03:00
# endif
2020-01-13 03:11:29 +03:00
// Piece extent affinity
m_checkBoxPieceExtentAffinity . setChecked ( session - > usePieceExtentAffinity ( ) ) ;
2022-03-29 05:41:17 +03:00
addRow ( PIECE_EXTENT_AFFINITY , ( tr ( " Use piece extent affinity " ) + u ' ' + makeLink ( u " https://libtorrent.org/single-page-ref.html#piece_extent_affinity " , u " (?) " ) ) , & m_checkBoxPieceExtentAffinity ) ;
2017-08-11 14:15:18 +03:00
// Suggest mode
2019-07-23 09:34:57 +03:00
m_checkBoxSuggestMode . setChecked ( session - > isSuggestModeEnabled ( ) ) ;
2022-03-29 05:41:17 +03:00
addRow ( SUGGEST_MODE , ( tr ( " Send upload piece suggestions " ) + u ' ' + makeLink ( u " https://www.libtorrent.org/reference-Settings.html#suggest_mode " , u " (?) " ) )
2019-07-23 09:34:57 +03:00
, & m_checkBoxSuggestMode ) ;
2017-08-11 14:48:58 +03:00
// Send buffer watermark
2019-07-23 09:34:57 +03:00
m_spinBoxSendBufferWatermark . setMinimum ( 1 ) ;
m_spinBoxSendBufferWatermark . setMaximum ( std : : numeric_limits < int > : : max ( ) ) ;
m_spinBoxSendBufferWatermark . setSuffix ( tr ( " KiB " ) ) ;
m_spinBoxSendBufferWatermark . setValue ( session - > sendBufferWatermark ( ) ) ;
2022-03-29 05:41:17 +03:00
addRow ( SEND_BUF_WATERMARK , ( tr ( " Send buffer watermark " ) + u ' ' + makeLink ( u " https://www.libtorrent.org/reference-Settings.html#send_buffer_watermark " , u " (?) " ) )
2019-07-23 09:34:57 +03:00
, & m_spinBoxSendBufferWatermark ) ;
m_spinBoxSendBufferLowWatermark . setMinimum ( 1 ) ;
m_spinBoxSendBufferLowWatermark . setMaximum ( std : : numeric_limits < int > : : max ( ) ) ;
m_spinBoxSendBufferLowWatermark . setSuffix ( tr ( " KiB " ) ) ;
m_spinBoxSendBufferLowWatermark . setValue ( session - > sendBufferLowWatermark ( ) ) ;
2022-03-29 05:41:17 +03:00
addRow ( SEND_BUF_LOW_WATERMARK , ( tr ( " Send buffer low watermark " ) + u ' ' + makeLink ( u " https://www.libtorrent.org/reference-Settings.html#send_buffer_low_watermark " , u " (?) " ) )
2019-07-23 09:34:57 +03:00
, & m_spinBoxSendBufferLowWatermark ) ;
m_spinBoxSendBufferWatermarkFactor . setMinimum ( 1 ) ;
m_spinBoxSendBufferWatermarkFactor . setMaximum ( std : : numeric_limits < int > : : max ( ) ) ;
2022-03-12 17:00:58 +03:00
m_spinBoxSendBufferWatermarkFactor . setSuffix ( u " % " _qs ) ;
2019-07-23 09:34:57 +03:00
m_spinBoxSendBufferWatermarkFactor . setValue ( session - > sendBufferWatermarkFactor ( ) ) ;
2022-03-29 05:41:17 +03:00
addRow ( SEND_BUF_WATERMARK_FACTOR , ( tr ( " Send buffer watermark factor " ) + u ' ' + makeLink ( u " https://www.libtorrent.org/reference-Settings.html#send_buffer_watermark_factor " , u " (?) " ) )
2019-07-23 09:34:57 +03:00
, & m_spinBoxSendBufferWatermarkFactor ) ;
2021-05-16 20:16:38 +03:00
// Outgoing connections per second
m_spinBoxConnectionSpeed . setMinimum ( 0 ) ;
m_spinBoxConnectionSpeed . setMaximum ( std : : numeric_limits < int > : : max ( ) ) ;
m_spinBoxConnectionSpeed . setValue ( session - > connectionSpeed ( ) ) ;
2022-03-29 05:41:17 +03:00
addRow ( CONNECTION_SPEED , ( tr ( " Outgoing connections per second " ) + u ' ' + makeLink ( u " https://www.libtorrent.org/reference-Settings.html#connection_speed " , u " (?) " ) )
2021-05-16 20:16:38 +03:00
, & m_spinBoxConnectionSpeed ) ;
2019-07-02 07:03:44 +03:00
// Socket listen backlog size
2019-07-23 09:34:57 +03:00
m_spinBoxSocketBacklogSize . setMinimum ( 1 ) ;
m_spinBoxSocketBacklogSize . setMaximum ( std : : numeric_limits < int > : : max ( ) ) ;
m_spinBoxSocketBacklogSize . setValue ( session - > socketBacklogSize ( ) ) ;
2022-03-29 05:41:17 +03:00
addRow ( SOCKET_BACKLOG_SIZE , ( tr ( " Socket backlog size " ) + u ' ' + makeLink ( u " https://www.libtorrent.org/reference-Settings.html#listen_queue_size " , u " (?) " ) )
2019-07-23 09:34:57 +03:00
, & m_spinBoxSocketBacklogSize ) ;
2015-11-15 08:48:10 +03:00
// Save resume data interval
2019-07-23 09:34:57 +03:00
m_spinBoxSaveResumeDataInterval . setMinimum ( 0 ) ;
m_spinBoxSaveResumeDataInterval . setMaximum ( std : : numeric_limits < int > : : max ( ) ) ;
m_spinBoxSaveResumeDataInterval . setValue ( session - > saveResumeDataInterval ( ) ) ;
2020-09-09 11:25:49 +03:00
connect ( & m_spinBoxSaveResumeDataInterval , qOverload < int > ( & QSpinBox : : valueChanged )
, this , & AdvancedSettings : : updateSaveResumeDataIntervalSuffix ) ;
2019-07-23 09:34:57 +03:00
updateSaveResumeDataIntervalSuffix ( m_spinBoxSaveResumeDataInterval . value ( ) ) ;
addRow ( SAVE_RESUME_DATA_INTERVAL , tr ( " Save resume data interval " , " How often the fastresume file is saved. " ) , & m_spinBoxSaveResumeDataInterval ) ;
2015-11-15 08:48:10 +03:00
// Outgoing port Min
2019-07-23 09:34:57 +03:00
m_spinBoxOutgoingPortsMin . setMinimum ( 0 ) ;
m_spinBoxOutgoingPortsMin . setMaximum ( 65535 ) ;
m_spinBoxOutgoingPortsMin . setValue ( session - > outgoingPortsMin ( ) ) ;
2020-12-01 06:51:14 +03:00
addRow ( OUTGOING_PORT_MIN , ( tr ( " Outgoing ports (Min) [0: Disabled] " )
2022-03-29 05:41:17 +03:00
+ u ' ' + makeLink ( u " https://www.libtorrent.org/reference-Settings.html#outgoing_port " , u " (?) " ) )
2020-12-01 06:51:14 +03:00
, & m_spinBoxOutgoingPortsMin ) ;
2015-11-15 08:48:10 +03:00
// Outgoing port Min
2019-07-23 09:34:57 +03:00
m_spinBoxOutgoingPortsMax . setMinimum ( 0 ) ;
m_spinBoxOutgoingPortsMax . setMaximum ( 65535 ) ;
m_spinBoxOutgoingPortsMax . setValue ( session - > outgoingPortsMax ( ) ) ;
2020-12-01 06:51:14 +03:00
addRow ( OUTGOING_PORT_MAX , ( tr ( " Outgoing ports (Max) [0: Disabled] " )
2022-03-29 05:41:17 +03:00
+ u ' ' + makeLink ( u " https://www.libtorrent.org/reference-Settings.html#outgoing_port " , u " (?) " ) )
2020-12-01 06:51:14 +03:00
, & m_spinBoxOutgoingPortsMax ) ;
2020-03-28 07:32:07 +03:00
// UPnP lease duration
m_spinBoxUPnPLeaseDuration . setMinimum ( 0 ) ;
m_spinBoxUPnPLeaseDuration . setMaximum ( std : : numeric_limits < int > : : max ( ) ) ;
m_spinBoxUPnPLeaseDuration . setValue ( session - > UPnPLeaseDuration ( ) ) ;
m_spinBoxUPnPLeaseDuration . setSuffix ( tr ( " s " , " seconds " ) ) ;
2022-03-29 05:41:17 +03:00
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 " (?) " ) )
2020-03-28 07:32:07 +03:00
, & m_spinBoxUPnPLeaseDuration ) ;
2021-03-06 09:17:07 +03:00
// Type of service
m_spinBoxPeerToS . setMinimum ( 0 ) ;
m_spinBoxPeerToS . setMaximum ( 255 ) ;
m_spinBoxPeerToS . setValue ( session - > peerToS ( ) ) ;
2022-03-29 05:41:17 +03:00
addRow ( PEER_TOS , ( tr ( " Type of service (ToS) for connections to peers " ) + u ' ' + makeLink ( u " https://www.libtorrent.org/reference-Settings.html#peer_tos " , u " (?) " ) )
2021-03-06 09:17:07 +03:00
, & m_spinBoxPeerToS ) ;
2017-08-11 11:28:52 +03:00
// uTP-TCP mixed mode
2022-05-13 07:13:04 +03:00
m_comboBoxUtpMixedMode . addItem ( tr ( " Prefer TCP " ) , QVariant : : fromValue ( BitTorrent : : MixedModeAlgorithm : : TCP ) ) ;
m_comboBoxUtpMixedMode . addItem ( tr ( " Peer proportional (throttles TCP) " ) , QVariant : : fromValue ( BitTorrent : : MixedModeAlgorithm : : Proportional ) ) ;
m_comboBoxUtpMixedMode . setCurrentIndex ( m_comboBoxUtpMixedMode . findData ( QVariant : : fromValue ( session - > utpMixedMode ( ) ) ) ) ;
2019-03-09 18:21:02 +03:00
addRow ( UTP_MIX_MODE , ( tr ( " %1-TCP mixed mode algorithm " , " uTP-TCP mixed mode algorithm " ) . arg ( C_UTP )
2022-03-29 05:41:17 +03:00
+ u ' ' + makeLink ( u " https://www.libtorrent.org/reference-Settings.html#mixed_mode_algorithm " , u " (?) " ) )
2019-07-23 09:34:57 +03:00
, & m_comboBoxUtpMixedMode ) ;
2020-12-01 05:53:48 +03:00
// Support internationalized domain name (IDN)
m_checkBoxIDNSupport . setChecked ( session - > isIDNSupportEnabled ( ) ) ;
addRow ( IDN_SUPPORT , ( tr ( " Support internationalized domain name (IDN) " )
2022-03-29 05:41:17 +03:00
+ u ' ' + makeLink ( u " https://www.libtorrent.org/reference-Settings.html#allow_idna " , u " (?) " ) )
2020-12-01 05:53:48 +03:00
, & m_checkBoxIDNSupport ) ;
2017-08-11 11:37:32 +03:00
// multiple connections per IP
2019-07-23 09:34:57 +03:00
m_checkBoxMultiConnectionsPerIp . setChecked ( session - > multiConnectionsPerIpEnabled ( ) ) ;
2020-12-01 06:51:14 +03:00
addRow ( MULTI_CONNECTIONS_PER_IP , ( tr ( " Allow multiple connections from the same IP address " )
2022-03-29 05:41:17 +03:00
+ u ' ' + makeLink ( u " https://www.libtorrent.org/reference-Settings.html#allow_multiple_connections_per_ip " , u " (?) " ) )
2020-12-01 06:51:14 +03:00
, & m_checkBoxMultiConnectionsPerIp ) ;
2020-04-22 22:50:13 +03:00
// Validate HTTPS tracker certificate
m_checkBoxValidateHTTPSTrackerCertificate . setChecked ( session - > validateHTTPSTrackerCertificate ( ) ) ;
addRow ( VALIDATE_HTTPS_TRACKER_CERTIFICATE , ( tr ( " Validate HTTPS tracker certificates " )
2022-03-29 05:41:17 +03:00
+ u ' ' + makeLink ( u " https://www.libtorrent.org/reference-Settings.html#validate_https_trackers " , u " (?) " ) )
2020-04-22 22:50:13 +03:00
, & m_checkBoxValidateHTTPSTrackerCertificate ) ;
2021-08-04 06:28:36 +03:00
// SSRF mitigation
m_checkBoxSSRFMitigation . setChecked ( session - > isSSRFMitigationEnabled ( ) ) ;
addRow ( SSRF_MITIGATION , ( tr ( " Server-side request forgery (SSRF) mitigation " )
2022-03-29 05:41:17 +03:00
+ u ' ' + makeLink ( u " https://www.libtorrent.org/reference-Settings.html#ssrf_mitigation " , u " (?) " ) )
2021-08-04 06:28:36 +03:00
, & m_checkBoxSSRFMitigation ) ;
2020-09-21 05:46:28 +03:00
// Disallow connection to peers on privileged ports
m_checkBoxBlockPeersOnPrivilegedPorts . setChecked ( session - > blockPeersOnPrivilegedPorts ( ) ) ;
2022-03-29 05:41:17 +03:00
addRow ( BLOCK_PEERS_ON_PRIVILEGED_PORTS , ( tr ( " Disallow connection to peers on privileged ports " ) + u ' ' + makeLink ( u " https://libtorrent.org/single-page-ref.html#no_connect_privileged_ports " , u " (?) " ) ) , & m_checkBoxBlockPeersOnPrivilegedPorts ) ;
2015-11-15 08:48:10 +03:00
// Recheck completed torrents
2019-07-23 09:34:57 +03:00
m_checkBoxRecheckCompleted . setChecked ( pref - > recheckTorrentsOnCompletion ( ) ) ;
addRow ( RECHECK_COMPLETED , tr ( " Recheck torrents on completion " ) , & m_checkBoxRecheckCompleted ) ;
2015-11-15 08:48:10 +03:00
// Transfer list refresh interval
2019-07-23 09:34:57 +03:00
m_spinBoxListRefresh . setMinimum ( 30 ) ;
m_spinBoxListRefresh . setMaximum ( 99999 ) ;
m_spinBoxListRefresh . setValue ( session - > refreshInterval ( ) ) ;
m_spinBoxListRefresh . setSuffix ( tr ( " ms " , " milliseconds " ) ) ;
addRow ( LIST_REFRESH , tr ( " Transfer list refresh interval " ) , & m_spinBoxListRefresh ) ;
2015-11-15 08:48:10 +03:00
// Resolve Peer countries
2019-07-23 09:34:57 +03:00
m_checkBoxResolveCountries . setChecked ( pref - > resolvePeerCountries ( ) ) ;
2020-02-14 23:07:19 +03:00
addRow ( RESOLVE_COUNTRIES , tr ( " Resolve peer countries " ) , & m_checkBoxResolveCountries ) ;
2015-11-15 08:48:10 +03:00
// Resolve peer hosts
2019-07-23 09:34:57 +03:00
m_checkBoxResolveHosts . setChecked ( pref - > resolvePeerHostNames ( ) ) ;
addRow ( RESOLVE_HOSTS , tr ( " Resolve peer host names " ) , & m_checkBoxResolveHosts ) ;
2015-11-15 08:48:10 +03:00
// Network interface
2022-05-14 13:13:42 +03:00
m_comboBoxInterface . addItem ( tr ( " Any interface " , " i.e. Any network interface " ) , QString ( ) ) ;
2020-11-16 10:02:11 +03:00
for ( const QNetworkInterface & iface : asConst ( QNetworkInterface : : allInterfaces ( ) ) )
2019-07-23 09:34:57 +03:00
m_comboBoxInterface . addItem ( iface . humanReadableName ( ) , iface . name ( ) ) ;
2022-05-14 13:13:42 +03:00
const QString currentInterface = session - > networkInterface ( ) ;
const int ifaceIndex = m_comboBoxInterface . findData ( currentInterface ) ;
if ( ifaceIndex > - 1 )
{
m_comboBoxInterface . setCurrentIndex ( ifaceIndex ) ;
2015-11-15 08:48:10 +03:00
}
2022-05-14 13:13:42 +03:00
else
2020-11-16 10:02:11 +03:00
{
2022-05-14 13:13:42 +03:00
// Saved interface does not exist, show it
2019-07-23 09:34:57 +03:00
m_comboBoxInterface . addItem ( session - > networkInterfaceName ( ) , currentInterface ) ;
2022-05-14 13:13:42 +03:00
m_comboBoxInterface . setCurrentIndex ( m_comboBoxInterface . count ( ) - 1 ) ;
2015-11-15 08:48:10 +03:00
}
2022-05-14 13:13:42 +03:00
2020-09-09 11:25:49 +03:00
connect ( & m_comboBoxInterface , qOverload < int > ( & QComboBox : : currentIndexChanged )
, this , & AdvancedSettings : : updateInterfaceAddressCombo ) ;
2020-10-08 19:39:11 +03:00
addRow ( NETWORK_IFACE , tr ( " Network interface " ) , & m_comboBoxInterface ) ;
2016-04-21 19:21:49 +03:00
// Network interface address
2016-05-27 01:35:58 +03:00
updateInterfaceAddressCombo ( ) ;
2020-10-08 19:39:11 +03:00
addRow ( NETWORK_IFACE_ADDRESS , tr ( " Optional IP address to bind to " ) , & m_comboBoxInterfaceAddress ) ;
2016-10-31 02:22:11 +03:00
// Announce IP
2019-07-23 09:34:57 +03:00
m_lineEditAnnounceIP . setText ( session - > announceIP ( ) ) ;
2021-09-12 11:45:00 +03:00
addRow ( ANNOUNCE_IP , ( tr ( " IP address reported to trackers (requires restart) " )
2022-03-29 05:41:17 +03:00
+ u ' ' + makeLink ( u " https://www.libtorrent.org/reference-Settings.html#announce_ip " , u " (?) " ) )
2020-12-01 06:51:14 +03:00
, & m_lineEditAnnounceIP ) ;
2020-09-03 06:24:30 +03:00
// Max concurrent HTTP announces
2020-12-01 05:30:47 +03:00
m_spinBoxMaxConcurrentHTTPAnnounces . setMaximum ( std : : numeric_limits < int > : : max ( ) ) ;
2020-09-03 06:24:30 +03:00
m_spinBoxMaxConcurrentHTTPAnnounces . setValue ( session - > maxConcurrentHTTPAnnounces ( ) ) ;
2022-03-29 05:41:17 +03:00
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 " (?) " ) )
2020-09-03 06:24:30 +03:00
, & m_spinBoxMaxConcurrentHTTPAnnounces ) ;
// Stop tracker timeout
2020-01-09 15:43:06 +03:00
m_spinBoxStopTrackerTimeout . setValue ( session - > stopTrackerTimeout ( ) ) ;
m_spinBoxStopTrackerTimeout . setSuffix ( tr ( " s " , " seconds " ) ) ;
2022-03-29 05:41:17 +03:00
addRow ( STOP_TRACKER_TIMEOUT , ( tr ( " Stop tracker timeout " ) + u ' ' + makeLink ( u " https://www.libtorrent.org/reference-Settings.html#stop_tracker_timeout " , u " (?) " ) )
2020-01-09 15:43:06 +03:00
, & m_spinBoxStopTrackerTimeout ) ;
2016-04-09 19:19:22 +03:00
2015-11-15 08:48:10 +03:00
// Program notifications
2022-06-25 15:46:55 +03:00
const MainWindow * mainWindow = app ( ) - > mainWindow ( ) ;
2019-07-23 09:34:57 +03:00
m_checkBoxProgramNotifications . setChecked ( mainWindow - > isNotificationsEnabled ( ) ) ;
addRow ( PROGRAM_NOTIFICATIONS , tr ( " Display notifications " ) , & m_checkBoxProgramNotifications ) ;
2016-04-17 22:56:51 +03:00
// Torrent added notifications
2019-07-23 09:34:57 +03:00
m_checkBoxTorrentAddedNotifications . setChecked ( mainWindow - > isTorrentAddedNotificationsEnabled ( ) ) ;
addRow ( TORRENT_ADDED_NOTIFICATIONS , tr ( " Display notifications for added torrents " ) , & m_checkBoxTorrentAddedNotifications ) ;
2021-04-13 17:22:48 +03:00
# if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)) && defined(QT_DBUS_LIB)
// Notification timeout
m_spinBoxNotificationTimeout . setMinimum ( - 1 ) ;
m_spinBoxNotificationTimeout . setMaximum ( std : : numeric_limits < int > : : max ( ) ) ;
m_spinBoxNotificationTimeout . setValue ( mainWindow - > getNotificationTimeout ( ) ) ;
m_spinBoxNotificationTimeout . setSpecialValueText ( tr ( " System default " ) ) ;
m_spinBoxNotificationTimeout . setSuffix ( tr ( " ms " , " milliseconds " ) ) ;
addRow ( NOTIFICATION_TIMEOUT , tr ( " Notification timeout [0: infinite] " ) , & m_spinBoxNotificationTimeout ) ;
# endif
2021-05-23 09:26:54 +03:00
// Reannounce to all trackers when ip/port changed
m_checkBoxReannounceWhenAddressChanged . setChecked ( session - > isReannounceWhenAddressChangedEnabled ( ) ) ;
addRow ( REANNOUNCE_WHEN_ADDRESS_CHANGED , tr ( " Reannounce to all trackers when IP or port changed " ) , & m_checkBoxReannounceWhenAddressChanged ) ;
2016-11-13 23:46:17 +03:00
// Download tracker's favicon
2019-07-23 09:34:57 +03:00
m_checkBoxTrackerFavicon . setChecked ( mainWindow - > isDownloadTrackerFavicon ( ) ) ;
addRow ( DOWNLOAD_TRACKER_FAVICON , tr ( " Download tracker's favicon " ) , & m_checkBoxTrackerFavicon ) ;
2017-10-16 16:10:25 +03:00
// Save path history length
2019-07-23 09:34:57 +03:00
m_spinBoxSavePathHistoryLength . setRange ( AddNewTorrentDialog : : minPathHistoryLength , AddNewTorrentDialog : : maxPathHistoryLength ) ;
m_spinBoxSavePathHistoryLength . setValue ( AddNewTorrentDialog : : savePathHistoryLength ( ) ) ;
addRow ( SAVE_PATH_HISTORY_LENGTH , tr ( " Save path history length " ) , & m_spinBoxSavePathHistoryLength ) ;
2018-09-23 09:20:05 +03:00
// Enable speed graphs
2019-07-23 09:34:57 +03:00
m_checkBoxSpeedWidgetEnabled . setChecked ( pref - > isSpeedWidgetEnabled ( ) ) ;
addRow ( ENABLE_SPEED_WIDGET , tr ( " Enable speed graphs " ) , & m_checkBoxSpeedWidgetEnabled ) ;
2021-02-19 18:11:52 +03:00
# ifndef Q_OS_MACOS
// Enable icons in menus
m_checkBoxIconsInMenusEnabled . setChecked ( pref - > iconsInMenusEnabled ( ) ) ;
addRow ( ENABLE_ICONS_IN_MENUS , tr ( " Enable icons in menus " ) , & m_checkBoxIconsInMenusEnabled ) ;
# endif
2015-11-15 08:48:10 +03:00
// Tracker State
2019-07-23 09:34:57 +03:00
m_checkBoxTrackerStatus . setChecked ( session - > isTrackerEnabled ( ) ) ;
addRow ( TRACKER_STATUS , tr ( " Enable embedded tracker " ) , & m_checkBoxTrackerStatus ) ;
2015-11-15 08:48:10 +03:00
// Tracker port
2019-07-23 09:34:57 +03:00
m_spinBoxTrackerPort . setMinimum ( 1 ) ;
m_spinBoxTrackerPort . setMaximum ( 65535 ) ;
m_spinBoxTrackerPort . setValue ( pref - > getTrackerPort ( ) ) ;
addRow ( TRACKER_PORT , tr ( " Embedded tracker port " ) , & m_spinBoxTrackerPort ) ;
2017-08-11 12:06:31 +03:00
// Choking algorithm
2022-05-13 07:13:04 +03:00
m_comboBoxChokingAlgorithm . addItem ( tr ( " Fixed slots " ) , QVariant : : fromValue ( BitTorrent : : ChokingAlgorithm : : FixedSlots ) ) ;
m_comboBoxChokingAlgorithm . addItem ( tr ( " Upload rate based " ) , QVariant : : fromValue ( BitTorrent : : ChokingAlgorithm : : RateBased ) ) ;
m_comboBoxChokingAlgorithm . setCurrentIndex ( m_comboBoxChokingAlgorithm . findData ( QVariant : : fromValue ( session - > chokingAlgorithm ( ) ) ) ) ;
2022-03-29 05:41:17 +03:00
addRow ( CHOKING_ALGORITHM , ( tr ( " Upload slots behavior " ) + u ' ' + makeLink ( u " https://www.libtorrent.org/reference-Settings.html#choking_algorithm " , u " (?) " ) )
2019-07-23 09:34:57 +03:00
, & m_comboBoxChokingAlgorithm ) ;
2017-08-11 12:06:31 +03:00
// Seed choking algorithm
2022-05-13 07:13:04 +03:00
m_comboBoxSeedChokingAlgorithm . addItem ( tr ( " Round-robin " ) , QVariant : : fromValue ( BitTorrent : : SeedChokingAlgorithm : : RoundRobin ) ) ;
m_comboBoxSeedChokingAlgorithm . addItem ( tr ( " Fastest upload " ) , QVariant : : fromValue ( BitTorrent : : SeedChokingAlgorithm : : FastestUpload ) ) ;
m_comboBoxSeedChokingAlgorithm . addItem ( tr ( " Anti-leech " ) , QVariant : : fromValue ( BitTorrent : : SeedChokingAlgorithm : : AntiLeech ) ) ;
m_comboBoxSeedChokingAlgorithm . setCurrentIndex ( m_comboBoxSeedChokingAlgorithm . findData ( QVariant : : fromValue ( session - > seedChokingAlgorithm ( ) ) ) ) ;
2022-03-29 05:41:17 +03:00
addRow ( SEED_CHOKING_ALGORITHM , ( tr ( " Upload choking algorithm " ) + u ' ' + makeLink ( u " https://www.libtorrent.org/reference-Settings.html#seed_choking_algorithm " , u " (?) " ) )
2019-07-23 09:34:57 +03:00
, & m_comboBoxSeedChokingAlgorithm ) ;
2017-08-11 12:06:31 +03:00
2015-11-15 08:48:10 +03:00
// Torrent recheck confirmation
2019-07-23 09:34:57 +03:00
m_checkBoxConfirmTorrentRecheck . setChecked ( pref - > confirmTorrentRecheck ( ) ) ;
addRow ( CONFIRM_RECHECK_TORRENT , tr ( " Confirm torrent recheck " ) , & m_checkBoxConfirmTorrentRecheck ) ;
2017-06-05 03:22:17 +03:00
// Remove all tags confirmation
2019-07-23 09:34:57 +03:00
m_checkBoxConfirmRemoveAllTags . setChecked ( pref - > confirmRemoveAllTags ( ) ) ;
addRow ( CONFIRM_REMOVE_ALL_TAGS , tr ( " Confirm removal of all tags " ) , & m_checkBoxConfirmRemoveAllTags ) ;
2017-06-05 03:22:17 +03:00
2017-10-30 21:04:14 +03:00
// Announce to all trackers in a tier
2019-07-23 09:34:57 +03:00
m_checkBoxAnnounceAllTrackers . setChecked ( session - > announceToAllTrackers ( ) ) ;
2020-12-01 06:51:14 +03:00
addRow ( ANNOUNCE_ALL_TRACKERS , ( tr ( " Always announce to all trackers in a tier " )
2022-03-29 05:41:17 +03:00
+ u ' ' + makeLink ( u " https://www.libtorrent.org/reference-Settings.html#announce_to_all_trackers " , u " (?) " ) )
2020-12-01 06:51:14 +03:00
, & m_checkBoxAnnounceAllTrackers ) ;
2017-10-30 21:04:14 +03:00
// Announce to all tiers
2019-07-23 09:34:57 +03:00
m_checkBoxAnnounceAllTiers . setChecked ( session - > announceToAllTiers ( ) ) ;
2020-12-01 06:51:14 +03:00
addRow ( ANNOUNCE_ALL_TIERS , ( tr ( " Always announce to all tiers " )
2022-03-29 05:41:17 +03:00
+ u ' ' + makeLink ( u " https://www.libtorrent.org/reference-Settings.html#announce_to_all_tiers " , u " (?) " ) )
2020-12-01 06:51:14 +03:00
, & m_checkBoxAnnounceAllTiers ) ;
2020-08-15 20:29:30 +03:00
m_spinBoxPeerTurnover . setMinimum ( 0 ) ;
m_spinBoxPeerTurnover . setMaximum ( 100 ) ;
m_spinBoxPeerTurnover . setValue ( session - > peerTurnover ( ) ) ;
2022-03-12 17:00:58 +03:00
m_spinBoxPeerTurnover . setSuffix ( u " % " _qs ) ;
2022-03-29 05:41:17 +03:00
addRow ( PEER_TURNOVER , ( tr ( " Peer turnover disconnect percentage " ) + u ' ' + makeLink ( u " https://www.libtorrent.org/reference-Settings.html#peer_turnover " , u " (?) " ) )
2020-08-15 20:29:30 +03:00
, & m_spinBoxPeerTurnover ) ;
m_spinBoxPeerTurnoverCutoff . setMinimum ( 0 ) ;
m_spinBoxPeerTurnoverCutoff . setMaximum ( 100 ) ;
2022-03-12 17:00:58 +03:00
m_spinBoxPeerTurnoverCutoff . setSuffix ( u " % " _qs ) ;
2020-08-15 20:29:30 +03:00
m_spinBoxPeerTurnoverCutoff . setValue ( session - > peerTurnoverCutoff ( ) ) ;
2022-03-29 05:41:17 +03:00
addRow ( PEER_TURNOVER_CUTOFF , ( tr ( " Peer turnover threshold percentage " ) + u ' ' + makeLink ( u " https://www.libtorrent.org/reference-Settings.html#peer_turnover " , u " (?) " ) )
2020-08-15 20:29:30 +03:00
, & m_spinBoxPeerTurnoverCutoff ) ;
m_spinBoxPeerTurnoverInterval . setMinimum ( 30 ) ;
m_spinBoxPeerTurnoverInterval . setMaximum ( 3600 ) ;
m_spinBoxPeerTurnoverInterval . setSuffix ( tr ( " s " , " seconds " ) ) ;
m_spinBoxPeerTurnoverInterval . setValue ( session - > peerTurnoverInterval ( ) ) ;
2022-03-29 05:41:17 +03:00
addRow ( PEER_TURNOVER_INTERVAL , ( tr ( " Peer turnover disconnect interval " ) + u ' ' + makeLink ( u " https://www.libtorrent.org/reference-Settings.html#peer_turnover " , u " (?) " ) )
2020-08-15 20:29:30 +03:00
, & m_spinBoxPeerTurnoverInterval ) ;
2022-03-01 07:44:48 +03:00
// Maximum outstanding requests to a single peer
m_spinBoxRequestQueueSize . setMinimum ( 1 ) ;
m_spinBoxRequestQueueSize . setMaximum ( std : : numeric_limits < int > : : max ( ) ) ;
m_spinBoxRequestQueueSize . setValue ( session - > requestQueueSize ( ) ) ;
2022-03-29 05:41:17 +03:00
addRow ( REQUEST_QUEUE_SIZE , ( tr ( " Maximum outstanding requests to a single peer " ) + u ' ' + makeLink ( u " https://www.libtorrent.org/reference-Settings.html#max_out_request_queue " , u " (?) " ) )
2022-03-01 07:44:48 +03:00
, & m_spinBoxRequestQueueSize ) ;
2015-11-15 09:56:39 +03:00
}
template < typename T >
2019-03-07 10:31:50 +03:00
void AdvancedSettings : : addRow ( const int row , const QString & text , T * widget )
2015-11-15 09:56:39 +03:00
{
2019-03-07 10:31:50 +03:00
auto label = new QLabel ( text ) ;
label - > setOpenExternalLinks ( true ) ;
setCellWidget ( row , PROPERTY , label ) ;
2015-11-15 09:56:39 +03:00
setCellWidget ( row , VALUE , widget ) ;
2020-12-19 11:03:54 +03:00
if constexpr ( std : : is_same_v < T , QCheckBox > )
connect ( widget , & QCheckBox : : stateChanged , this , & AdvancedSettings : : settingsChanged ) ;
else if constexpr ( std : : is_same_v < T , QSpinBox > )
connect ( widget , qOverload < int > ( & QSpinBox : : valueChanged ) , this , & AdvancedSettings : : settingsChanged ) ;
else if constexpr ( std : : is_same_v < T , QComboBox > )
connect ( widget , qOverload < int > ( & QComboBox : : currentIndexChanged ) , this , & AdvancedSettings : : settingsChanged ) ;
else if constexpr ( std : : is_same_v < T , QLineEdit > )
connect ( widget , & QLineEdit : : textChanged , this , & AdvancedSettings : : settingsChanged ) ;
2015-11-15 08:48:10 +03:00
}