2 * Bittorrent Client using Qt and libtorrent.
3 * Copyright (C) 2016-2024 qBittorrent project
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * In addition, as a special exception, the copyright holders give permission to
20 * link this program with the OpenSSL project's "OpenSSL" library (or with
21 * modified versions of it that use the same license as the "OpenSSL" library),
22 * and distribute the linked executables. You must obey the GNU General Public
23 * License in all respects for all of the code used other than "OpenSSL". If you
24 * modify file(s), you may extend this exception to your version of the file(s),
25 * but you are not obligated to do so. If you do not wish to do so, delete this
26 * exception statement from your version.
29 #include "advancedsettings.h"
33 #include <QHeaderView>
34 #include <QHostAddress>
36 #include <QNetworkInterface>
38 #include "base/bittorrent/session.h"
39 #include "base/global.h"
40 #include "base/preferences.h"
41 #include "base/unicodestrings.h"
42 #include "gui/addnewtorrentdialog.h"
43 #include "gui/desktopintegration.h"
44 #include "gui/mainwindow.h"
45 #include "interfaces/iguiapplication.h"
49 QString
makeLink(const QStringView url
, const QStringView linkLabel
)
51 return u
"<a href=\"%1\">%2</a>"_s
.arg(url
, linkLabel
);
63 // qBittorrent section
66 TORRENT_CONTENT_REMOVE_OPTION
,
67 #if defined(QBT_USES_LIBTORRENT2) && !defined(Q_OS_MACOS)
68 MEMORY_WORKING_SET_LIMIT
,
75 //Optional network address
76 NETWORK_IFACE_ADDRESS
,
78 SAVE_RESUME_DATA_INTERVAL
,
79 SAVE_STATISTICS_INTERVAL
,
80 TORRENT_FILE_SIZE_LIMIT
,
81 CONFIRM_RECHECK_TORRENT
,
88 PROGRAM_NOTIFICATIONS
,
89 TORRENT_ADDED_NOTIFICATIONS
,
93 CONFIRM_REMOVE_ALL_TAGS
,
94 CONFIRM_REMOVE_TRACKER_FROM_ALL_TORRENTS
,
95 REANNOUNCE_WHEN_ADDRESS_CHANGED
,
96 DOWNLOAD_TRACKER_FAVICON
,
97 SAVE_PATH_HISTORY_LENGTH
,
100 ENABLE_ICONS_IN_MENUS
,
105 TRACKER_PORT_FORWARDING
,
106 #if defined(Q_OS_MACOS) || defined(Q_OS_WIN)
107 ENABLE_MARK_OF_THE_WEB
,
108 #endif // Q_OS_MACOS || Q_OS_WIN
109 PYTHON_EXECUTABLE_PATH
,
110 START_SESSION_PAUSED
,
111 SESSION_SHUTDOWN_TIMEOUT
,
113 // libtorrent section
118 #ifdef QBT_USES_LIBTORRENT2
123 #ifndef QBT_USES_LIBTORRENT2
129 #ifdef QBT_USES_LIBTORRENT2
134 #ifndef QBT_USES_LIBTORRENT2
137 PIECE_EXTENT_AFFINITY
,
140 SEND_BUF_LOW_WATERMARK
,
141 SEND_BUF_WATERMARK_FACTOR
,
142 // networking & ports
144 SOCKET_SEND_BUFFER_SIZE
,
145 SOCKET_RECEIVE_BUFFER_SIZE
,
153 MULTI_CONNECTIONS_PER_IP
,
154 VALIDATE_HTTPS_TRACKER_CERTIFICATE
,
156 BLOCK_PEERS_ON_PRIVILEGED_PORTS
,
159 SEED_CHOKING_ALGORITHM
,
161 ANNOUNCE_ALL_TRACKERS
,
164 MAX_CONCURRENT_HTTP_ANNOUNCES
,
165 STOP_TRACKER_TIMEOUT
,
167 PEER_TURNOVER_CUTOFF
,
168 PEER_TURNOVER_INTERVAL
,
171 #if defined(QBT_USES_LIBTORRENT2) && TORRENT_USE_I2P
172 I2P_INBOUND_QUANTITY
,
173 I2P_OUTBOUND_QUANTITY
,
182 AdvancedSettings::AdvancedSettings(IGUIApplication
*app
, QWidget
*parent
)
183 : GUIApplicationComponent(app
, parent
)
186 setColumnCount(COL_COUNT
);
187 const QStringList header
= {tr("Setting"), tr("Value", "Value set for this setting")};
188 setHorizontalHeaderLabels(header
);
190 setRowCount(ROW_COUNT
);
191 verticalHeader()->setVisible(false);
193 setAlternatingRowColors(true);
194 setSelectionMode(QAbstractItemView::NoSelection
);
195 setEditTriggers(QAbstractItemView::NoEditTriggers
);
197 loadAdvancedSettings();
198 resizeColumnToContents(0);
199 horizontalHeader()->setStretchLastSection(true);
202 void AdvancedSettings::saveAdvancedSettings() const
204 Preferences
*const pref
= Preferences::instance();
205 BitTorrent::Session
*const session
= BitTorrent::Session::instance();
207 session
->setResumeDataStorageType(m_comboBoxResumeDataStorage
.currentData().value
<BitTorrent::ResumeDataStorageType
>());
208 #if defined(QBT_USES_LIBTORRENT2) && !defined(Q_OS_MACOS)
209 // Physical memory (RAM) usage limit
210 app()->setMemoryWorkingSetLimit(m_spinBoxMemoryWorkingSetLimit
.value());
212 #if defined(Q_OS_WIN)
213 app()->setProcessMemoryPriority(m_comboBoxOSMemoryPriority
.currentData().value
<MemoryPriority
>());
215 // Bdecode depth limit
216 pref
->setBdecodeDepthLimit(m_spinBoxBdecodeDepthLimit
.value());
217 // Bdecode token limit
218 pref
->setBdecodeTokenLimit(m_spinBoxBdecodeTokenLimit
.value());
220 session
->setAsyncIOThreads(m_spinBoxAsyncIOThreads
.value());
221 #ifdef QBT_USES_LIBTORRENT2
223 session
->setHashingThreads(m_spinBoxHashingThreads
.value());
226 session
->setFilePoolSize(m_spinBoxFilePoolSize
.value());
227 // Checking Memory Usage
228 session
->setCheckingMemUsage(m_spinBoxCheckingMemUsage
.value());
229 #ifndef QBT_USES_LIBTORRENT2
231 session
->setDiskCacheSize(m_spinBoxCache
.value());
232 session
->setDiskCacheTTL(m_spinBoxCacheTTL
.value());
235 session
->setDiskQueueSize(m_spinBoxDiskQueueSize
.value() * 1024);
236 #ifdef QBT_USES_LIBTORRENT2
237 session
->setDiskIOType(m_comboBoxDiskIOType
.currentData().value
<BitTorrent::DiskIOType
>());
240 session
->setDiskIOReadMode(m_comboBoxDiskIOReadMode
.currentData().value
<BitTorrent::DiskIOReadMode
>());
241 // Disk IO write mode
242 session
->setDiskIOWriteMode(m_comboBoxDiskIOWriteMode
.currentData().value
<BitTorrent::DiskIOWriteMode
>());
243 #ifndef QBT_USES_LIBTORRENT2
244 // Coalesce reads & writes
245 session
->setCoalesceReadWriteEnabled(m_checkBoxCoalesceRW
.isChecked());
247 // Piece extent affinity
248 session
->setPieceExtentAffinity(m_checkBoxPieceExtentAffinity
.isChecked());
250 session
->setSuggestMode(m_checkBoxSuggestMode
.isChecked());
251 // Send buffer watermark
252 session
->setSendBufferWatermark(m_spinBoxSendBufferWatermark
.value());
253 session
->setSendBufferLowWatermark(m_spinBoxSendBufferLowWatermark
.value());
254 session
->setSendBufferWatermarkFactor(m_spinBoxSendBufferWatermarkFactor
.value());
255 // Outgoing connections per second
256 session
->setConnectionSpeed(m_spinBoxConnectionSpeed
.value());
257 // Socket send buffer size
258 session
->setSocketSendBufferSize(m_spinBoxSocketSendBufferSize
.value() * 1024);
259 // Socket receive buffer size
260 session
->setSocketReceiveBufferSize(m_spinBoxSocketReceiveBufferSize
.value() * 1024);
261 // Socket listen backlog size
262 session
->setSocketBacklogSize(m_spinBoxSocketBacklogSize
.value());
263 // Save resume data interval
264 session
->setSaveResumeDataInterval(m_spinBoxSaveResumeDataInterval
.value());
265 // Save statistics interval
266 session
->setSaveStatisticsInterval(std::chrono::minutes(m_spinBoxSaveStatisticsInterval
.value()));
267 // .torrent file size limit
268 pref
->setTorrentFileSizeLimit(m_spinBoxTorrentFileSizeLimit
.value() * 1024 * 1024);
270 session
->setOutgoingPortsMin(m_spinBoxOutgoingPortsMin
.value());
271 session
->setOutgoingPortsMax(m_spinBoxOutgoingPortsMax
.value());
272 // UPnP lease duration
273 session
->setUPnPLeaseDuration(m_spinBoxUPnPLeaseDuration
.value());
275 session
->setPeerToS(m_spinBoxPeerToS
.value());
276 // uTP-TCP mixed mode
277 session
->setUtpMixedMode(m_comboBoxUtpMixedMode
.currentData().value
<BitTorrent::MixedModeAlgorithm
>());
278 // Support internationalized domain name (IDN)
279 session
->setIDNSupportEnabled(m_checkBoxIDNSupport
.isChecked());
280 // multiple connections per IP
281 session
->setMultiConnectionsPerIpEnabled(m_checkBoxMultiConnectionsPerIp
.isChecked());
282 // Validate HTTPS tracker certificate
283 session
->setValidateHTTPSTrackerCertificate(m_checkBoxValidateHTTPSTrackerCertificate
.isChecked());
285 session
->setSSRFMitigationEnabled(m_checkBoxSSRFMitigation
.isChecked());
286 // Disallow connection to peers on privileged ports
287 session
->setBlockPeersOnPrivilegedPorts(m_checkBoxBlockPeersOnPrivilegedPorts
.isChecked());
288 // Recheck torrents on completion
289 pref
->recheckTorrentsOnCompletion(m_checkBoxRecheckCompleted
.isChecked());
290 // Customize application instance name
291 app()->setInstanceName(m_lineEditAppInstanceName
.text());
292 // Transfer list refresh interval
293 session
->setRefreshInterval(m_spinBoxListRefresh
.value());
295 pref
->resolvePeerCountries(m_checkBoxResolveCountries
.isChecked());
296 pref
->resolvePeerHostNames(m_checkBoxResolveHosts
.isChecked());
298 session
->setNetworkInterface(m_comboBoxInterface
.currentData().toString());
299 session
->setNetworkInterfaceName((m_comboBoxInterface
.currentIndex() == 0)
301 : m_comboBoxInterface
.currentText());
303 // Construct a QHostAddress to filter malformed strings
304 const QHostAddress ifaceAddr
{m_comboBoxInterfaceAddress
.currentData().toString()};
305 session
->setNetworkInterfaceAddress(ifaceAddr
.toString());
307 // Construct a QHostAddress to filter malformed strings
308 const QHostAddress
addr(m_lineEditAnnounceIP
.text().trimmed());
309 session
->setAnnounceIP(addr
.toString());
310 // Max concurrent HTTP announces
311 session
->setMaxConcurrentHTTPAnnounces(m_spinBoxMaxConcurrentHTTPAnnounces
.value());
312 // Stop tracker timeout
313 session
->setStopTrackerTimeout(m_spinBoxStopTrackerTimeout
.value());
314 // Program notification
315 app()->desktopIntegration()->setNotificationsEnabled(m_checkBoxProgramNotifications
.isChecked());
317 app()->desktopIntegration()->setNotificationTimeout(m_spinBoxNotificationTimeout
.value());
319 app()->setTorrentAddedNotificationsEnabled(m_checkBoxTorrentAddedNotifications
.isChecked());
320 // Reannounce to all trackers when ip/port changed
321 session
->setReannounceWhenAddressChangedEnabled(m_checkBoxReannounceWhenAddressChanged
.isChecked());
322 // Misc GUI properties
323 app()->mainWindow()->setDownloadTrackerFavicon(m_checkBoxTrackerFavicon
.isChecked());
324 pref
->setAddNewTorrentDialogSavePathHistoryLength(m_spinBoxSavePathHistoryLength
.value());
325 pref
->setSpeedWidgetEnabled(m_checkBoxSpeedWidgetEnabled
.isChecked());
327 pref
->setIconsInMenusEnabled(m_checkBoxIconsInMenusEnabled
.isChecked());
331 pref
->setTrackerPort(m_spinBoxTrackerPort
.value());
332 pref
->setTrackerPortForwardingEnabled(m_checkBoxTrackerPortForwarding
.isChecked());
333 session
->setTrackerEnabled(m_checkBoxTrackerStatus
.isChecked());
334 #if defined(Q_OS_MACOS) || defined(Q_OS_WIN)
336 pref
->setMarkOfTheWebEnabled(m_checkBoxMarkOfTheWeb
.isChecked());
337 #endif // Q_OS_MACOS || Q_OS_WIN
338 // Python executable path
339 pref
->setPythonExecutablePath(Path(m_pythonExecutablePath
.text().trimmed()));
340 // Start session paused
341 session
->setStartPaused(m_checkBoxStartSessionPaused
.isChecked());
342 // Session shutdown timeout
343 session
->setShutdownTimeout(m_spinBoxSessionShutdownTimeout
.value());
345 session
->setChokingAlgorithm(m_comboBoxChokingAlgorithm
.currentData().value
<BitTorrent::ChokingAlgorithm
>());
346 // Seed choking algorithm
347 session
->setSeedChokingAlgorithm(m_comboBoxSeedChokingAlgorithm
.currentData().value
<BitTorrent::SeedChokingAlgorithm
>());
349 pref
->setConfirmTorrentRecheck(m_checkBoxConfirmTorrentRecheck
.isChecked());
351 pref
->setConfirmRemoveAllTags(m_checkBoxConfirmRemoveAllTags
.isChecked());
352 pref
->setConfirmRemoveTrackerFromAllTorrents(m_checkBoxConfirmRemoveTrackerFromAllTorrents
.isChecked());
354 session
->setAnnounceToAllTrackers(m_checkBoxAnnounceAllTrackers
.isChecked());
355 session
->setAnnounceToAllTiers(m_checkBoxAnnounceAllTiers
.isChecked());
357 session
->setPeerTurnover(m_spinBoxPeerTurnover
.value());
358 session
->setPeerTurnoverCutoff(m_spinBoxPeerTurnoverCutoff
.value());
359 session
->setPeerTurnoverInterval(m_spinBoxPeerTurnoverInterval
.value());
360 // Maximum outstanding requests to a single peer
361 session
->setRequestQueueSize(m_spinBoxRequestQueueSize
.value());
362 // DHT bootstrap nodes
363 session
->setDHTBootstrapNodes(m_lineEditDHTBootstrapNodes
.text());
364 #if defined(QBT_USES_LIBTORRENT2) && TORRENT_USE_I2P
365 // I2P session options
366 session
->setI2PInboundQuantity(m_spinBoxI2PInboundQuantity
.value());
367 session
->setI2POutboundQuantity(m_spinBoxI2POutboundQuantity
.value());
368 session
->setI2PInboundLength(m_spinBoxI2PInboundLength
.value());
369 session
->setI2POutboundLength(m_spinBoxI2POutboundLength
.value());
372 session
->setTorrentContentRemoveOption(m_comboBoxTorrentContentRemoveOption
.currentData().value
<BitTorrent::TorrentContentRemoveOption
>());
375 #ifndef QBT_USES_LIBTORRENT2
376 void AdvancedSettings::updateCacheSpinSuffix(const int value
)
379 m_spinBoxCache
.setSuffix(tr(" (disabled)"));
381 m_spinBoxCache
.setSuffix(tr(" (auto)"));
383 m_spinBoxCache
.setSuffix(tr(" MiB"));
388 void AdvancedSettings::updateNotificationTimeoutSuffix(const int value
)
391 m_spinBoxNotificationTimeout
.setSuffix(tr(" (infinite)"));
393 m_spinBoxNotificationTimeout
.setSuffix(tr(" (system default)"));
395 m_spinBoxNotificationTimeout
.setSuffix(tr(" ms", " milliseconds"));
399 void AdvancedSettings::updateInterfaceAddressCombo()
401 const auto toString
= [](const QHostAddress
&address
) -> QString
403 switch (address
.protocol()) {
404 case QAbstractSocket::IPv4Protocol
:
405 return address
.toString();
406 case QAbstractSocket::IPv6Protocol
:
407 return Utils::Net::canonicalIPv6Addr(address
).toString();
415 // Clear all items and reinsert them
416 m_comboBoxInterfaceAddress
.clear();
417 m_comboBoxInterfaceAddress
.addItem(tr("All addresses"), QString());
418 m_comboBoxInterfaceAddress
.addItem(tr("All IPv4 addresses"), QHostAddress(QHostAddress::AnyIPv4
).toString());
419 m_comboBoxInterfaceAddress
.addItem(tr("All IPv6 addresses"), QHostAddress(QHostAddress::AnyIPv6
).toString());
421 const QString currentIface
= m_comboBoxInterface
.currentData().toString();
422 if (currentIface
.isEmpty()) // `any` interface
424 for (const QHostAddress
&address
: asConst(QNetworkInterface::allAddresses()))
426 const QString addressString
= toString(address
);
427 m_comboBoxInterfaceAddress
.addItem(addressString
, addressString
);
432 const QList
<QNetworkAddressEntry
> addresses
= QNetworkInterface::interfaceFromName(currentIface
).addressEntries();
433 for (const QNetworkAddressEntry
&entry
: addresses
)
435 const QString addressString
= toString(entry
.ip());
436 m_comboBoxInterfaceAddress
.addItem(addressString
, addressString
);
440 const QString currentAddress
= BitTorrent::Session::instance()->networkInterfaceAddress();
441 const int index
= m_comboBoxInterfaceAddress
.findData(currentAddress
);
444 m_comboBoxInterfaceAddress
.setCurrentIndex(index
);
448 // not found, for the sake of UI consistency, add such entry
449 m_comboBoxInterfaceAddress
.addItem(currentAddress
, currentAddress
);
450 m_comboBoxInterfaceAddress
.setCurrentIndex(m_comboBoxInterfaceAddress
.count() - 1);
454 void AdvancedSettings::loadAdvancedSettings()
456 const Preferences
*const pref
= Preferences::instance();
457 const BitTorrent::Session
*const session
= BitTorrent::Session::instance();
459 // add section headers
460 auto *labelQbtLink
= new QLabel(
461 makeLink(u
"https://github.com/qbittorrent/qBittorrent/wiki/Explanation-of-Options-in-qBittorrent#Advanced"
462 , tr("Open documentation"))
464 labelQbtLink
->setOpenExternalLinks(true);
465 addRow(QBITTORRENT_HEADER
, u
"<b>%1</b>"_s
.arg(tr("qBittorrent Section")), labelQbtLink
);
466 static_cast<QLabel
*>(cellWidget(QBITTORRENT_HEADER
, PROPERTY
))->setAlignment(Qt::AlignCenter
| Qt::AlignVCenter
);
468 auto *labelLibtorrentLink
= new QLabel(
469 makeLink(u
"https://www.libtorrent.org/reference-Settings.html"
470 , tr("Open documentation"))
472 labelLibtorrentLink
->setOpenExternalLinks(true);
473 addRow(LIBTORRENT_HEADER
, u
"<b>%1</b>"_s
.arg(tr("libtorrent Section")), labelLibtorrentLink
);
474 static_cast<QLabel
*>(cellWidget(LIBTORRENT_HEADER
, PROPERTY
))->setAlignment(Qt::AlignCenter
| Qt::AlignVCenter
);
476 m_comboBoxResumeDataStorage
.addItem(tr("Fastresume files"), QVariant::fromValue(BitTorrent::ResumeDataStorageType::Legacy
));
477 m_comboBoxResumeDataStorage
.addItem(tr("SQLite database (experimental)"), QVariant::fromValue(BitTorrent::ResumeDataStorageType::SQLite
));
478 m_comboBoxResumeDataStorage
.setCurrentIndex(m_comboBoxResumeDataStorage
.findData(QVariant::fromValue(session
->resumeDataStorageType())));
479 addRow(RESUME_DATA_STORAGE
, tr("Resume data storage type (requires restart)"), &m_comboBoxResumeDataStorage
);
481 m_comboBoxTorrentContentRemoveOption
.addItem(tr("Delete files permanently"), QVariant::fromValue(BitTorrent::TorrentContentRemoveOption::Delete
));
482 m_comboBoxTorrentContentRemoveOption
.addItem(tr("Move files to trash (if possible)"), QVariant::fromValue(BitTorrent::TorrentContentRemoveOption::MoveToTrash
));
483 m_comboBoxTorrentContentRemoveOption
.setCurrentIndex(m_comboBoxTorrentContentRemoveOption
.findData(QVariant::fromValue(session
->torrentContentRemoveOption())));
484 addRow(TORRENT_CONTENT_REMOVE_OPTION
, tr("Torrent content removing mode"), &m_comboBoxTorrentContentRemoveOption
);
486 #if defined(QBT_USES_LIBTORRENT2) && !defined(Q_OS_MACOS)
487 // Physical memory (RAM) usage limit
488 m_spinBoxMemoryWorkingSetLimit
.setMinimum(1);
489 m_spinBoxMemoryWorkingSetLimit
.setMaximum(std::numeric_limits
<int>::max());
490 m_spinBoxMemoryWorkingSetLimit
.setSuffix(tr(" MiB"));
491 m_spinBoxMemoryWorkingSetLimit
.setToolTip(tr("This option is less effective on Linux"));
492 m_spinBoxMemoryWorkingSetLimit
.setValue(app()->memoryWorkingSetLimit());
493 addRow(MEMORY_WORKING_SET_LIMIT
, (tr("Physical memory (RAM) usage limit") + u
' ' + makeLink(u
"https://wikipedia.org/wiki/Working_set", u
"(?)"))
494 , &m_spinBoxMemoryWorkingSetLimit
);
496 #if defined(Q_OS_WIN)
497 m_comboBoxOSMemoryPriority
.addItem(tr("Normal"), QVariant::fromValue(MemoryPriority::Normal
));
498 m_comboBoxOSMemoryPriority
.addItem(tr("Below normal"), QVariant::fromValue(MemoryPriority::BelowNormal
));
499 m_comboBoxOSMemoryPriority
.addItem(tr("Medium"), QVariant::fromValue(MemoryPriority::Medium
));
500 m_comboBoxOSMemoryPriority
.addItem(tr("Low"), QVariant::fromValue(MemoryPriority::Low
));
501 m_comboBoxOSMemoryPriority
.addItem(tr("Very low"), QVariant::fromValue(MemoryPriority::VeryLow
));
502 m_comboBoxOSMemoryPriority
.setCurrentIndex(m_comboBoxOSMemoryPriority
.findData(QVariant::fromValue(app()->processMemoryPriority())));
503 addRow(OS_MEMORY_PRIORITY
, (tr("Process memory priority")
504 + u
' ' + makeLink(u
"https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/ns-processthreadsapi-memory_priority_information", u
"(?)"))
505 , &m_comboBoxOSMemoryPriority
);
507 // Bdecode depth limit
508 m_spinBoxBdecodeDepthLimit
.setMinimum(0);
509 m_spinBoxBdecodeDepthLimit
.setMaximum(std::numeric_limits
<int>::max());
510 m_spinBoxBdecodeDepthLimit
.setValue(pref
->getBdecodeDepthLimit());
511 addRow(BDECODE_DEPTH_LIMIT
, (tr("Bdecode depth limit") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Bdecoding.html#bdecode()", u
"(?)"))
512 , &m_spinBoxBdecodeDepthLimit
);
513 // Bdecode token limit
514 m_spinBoxBdecodeTokenLimit
.setMinimum(0);
515 m_spinBoxBdecodeTokenLimit
.setMaximum(std::numeric_limits
<int>::max());
516 m_spinBoxBdecodeTokenLimit
.setValue(pref
->getBdecodeTokenLimit());
517 addRow(BDECODE_TOKEN_LIMIT
, (tr("Bdecode token limit") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Bdecoding.html#bdecode()", u
"(?)"))
518 , &m_spinBoxBdecodeTokenLimit
);
520 m_spinBoxAsyncIOThreads
.setMinimum(1);
521 m_spinBoxAsyncIOThreads
.setMaximum(1024);
522 m_spinBoxAsyncIOThreads
.setValue(session
->asyncIOThreads());
523 addRow(ASYNC_IO_THREADS
, (tr("Asynchronous I/O threads") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#aio_threads", u
"(?)"))
524 , &m_spinBoxAsyncIOThreads
);
526 #ifdef QBT_USES_LIBTORRENT2
528 m_spinBoxHashingThreads
.setMinimum(1);
529 m_spinBoxHashingThreads
.setMaximum(1024);
530 m_spinBoxHashingThreads
.setValue(session
->hashingThreads());
531 addRow(HASHING_THREADS
, (tr("Hashing threads") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#hashing_threads", u
"(?)"))
532 , &m_spinBoxHashingThreads
);
536 m_spinBoxFilePoolSize
.setMinimum(1);
537 m_spinBoxFilePoolSize
.setMaximum(std::numeric_limits
<int>::max());
538 m_spinBoxFilePoolSize
.setValue(session
->filePoolSize());
539 addRow(FILE_POOL_SIZE
, (tr("File pool size") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#file_pool_size", u
"(?)"))
540 , &m_spinBoxFilePoolSize
);
542 // Checking Memory Usage
543 m_spinBoxCheckingMemUsage
.setMinimum(1);
544 // When build as 32bit binary, set the maximum value lower to prevent crashes.
546 m_spinBoxCheckingMemUsage
.setMaximum(1024);
548 // Allocate at most 128MiB out of the remaining 512MiB (see the cache part below)
549 m_spinBoxCheckingMemUsage
.setMaximum(128);
551 m_spinBoxCheckingMemUsage
.setValue(session
->checkingMemUsage());
552 m_spinBoxCheckingMemUsage
.setSuffix(tr(" MiB"));
553 addRow(CHECKING_MEM_USAGE
, (tr("Outstanding memory when checking torrents") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#checking_mem_usage", u
"(?)"))
554 , &m_spinBoxCheckingMemUsage
);
555 #ifndef QBT_USES_LIBTORRENT2
557 m_spinBoxCache
.setMinimum(-1);
558 // When build as 32bit binary, set the maximum at less than 2GB to prevent crashes.
560 m_spinBoxCache
.setMaximum(33554431); // 32768GiB
562 // allocate 1536MiB and leave 512MiB to the rest of program data in RAM
563 m_spinBoxCache
.setMaximum(1536);
565 m_spinBoxCache
.setValue(session
->diskCacheSize());
566 updateCacheSpinSuffix(m_spinBoxCache
.value());
567 connect(&m_spinBoxCache
, qOverload
<int>(&QSpinBox::valueChanged
)
568 , this, &AdvancedSettings::updateCacheSpinSuffix
);
569 addRow(DISK_CACHE
, (tr("Disk cache") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#cache_size", u
"(?)"))
572 m_spinBoxCacheTTL
.setMinimum(1);
573 m_spinBoxCacheTTL
.setMaximum(std::numeric_limits
<int>::max());
574 m_spinBoxCacheTTL
.setValue(session
->diskCacheTTL());
575 m_spinBoxCacheTTL
.setSuffix(tr(" s", " seconds"));
576 addRow(DISK_CACHE_TTL
, (tr("Disk cache expiry interval") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#cache_expiry", u
"(?)"))
577 , &m_spinBoxCacheTTL
);
580 m_spinBoxDiskQueueSize
.setMinimum(1);
581 m_spinBoxDiskQueueSize
.setMaximum(std::numeric_limits
<int>::max() / 1024);
582 m_spinBoxDiskQueueSize
.setValue(session
->diskQueueSize() / 1024);
583 m_spinBoxDiskQueueSize
.setSuffix(tr(" KiB"));
584 addRow(DISK_QUEUE_SIZE
, (tr("Disk queue size") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#max_queued_disk_bytes", u
"(?)"))
585 , &m_spinBoxDiskQueueSize
);
586 #ifdef QBT_USES_LIBTORRENT2
588 m_comboBoxDiskIOType
.addItem(tr("Default"), QVariant::fromValue(BitTorrent::DiskIOType::Default
));
589 m_comboBoxDiskIOType
.addItem(tr("Memory mapped files"), QVariant::fromValue(BitTorrent::DiskIOType::MMap
));
590 m_comboBoxDiskIOType
.addItem(tr("POSIX-compliant"), QVariant::fromValue(BitTorrent::DiskIOType::Posix
));
591 m_comboBoxDiskIOType
.setCurrentIndex(m_comboBoxDiskIOType
.findData(QVariant::fromValue(session
->diskIOType())));
592 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
"(?)")
593 , &m_comboBoxDiskIOType
);
596 m_comboBoxDiskIOReadMode
.addItem(tr("Disable OS cache"), QVariant::fromValue(BitTorrent::DiskIOReadMode::DisableOSCache
));
597 m_comboBoxDiskIOReadMode
.addItem(tr("Enable OS cache"), QVariant::fromValue(BitTorrent::DiskIOReadMode::EnableOSCache
));
598 m_comboBoxDiskIOReadMode
.setCurrentIndex(m_comboBoxDiskIOReadMode
.findData(QVariant::fromValue(session
->diskIOReadMode())));
599 addRow(DISK_IO_READ_MODE
, (tr("Disk IO read mode") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#disk_io_read_mode", u
"(?)"))
600 , &m_comboBoxDiskIOReadMode
);
601 // Disk IO write mode
602 m_comboBoxDiskIOWriteMode
.addItem(tr("Disable OS cache"), QVariant::fromValue(BitTorrent::DiskIOWriteMode::DisableOSCache
));
603 m_comboBoxDiskIOWriteMode
.addItem(tr("Enable OS cache"), QVariant::fromValue(BitTorrent::DiskIOWriteMode::EnableOSCache
));
604 #ifdef QBT_USES_LIBTORRENT2
605 m_comboBoxDiskIOWriteMode
.addItem(tr("Write-through"), QVariant::fromValue(BitTorrent::DiskIOWriteMode::WriteThrough
));
607 m_comboBoxDiskIOWriteMode
.setCurrentIndex(m_comboBoxDiskIOWriteMode
.findData(QVariant::fromValue(session
->diskIOWriteMode())));
608 addRow(DISK_IO_WRITE_MODE
, (tr("Disk IO write mode") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#disk_io_write_mode", u
"(?)"))
609 , &m_comboBoxDiskIOWriteMode
);
610 #ifndef QBT_USES_LIBTORRENT2
611 // Coalesce reads & writes
612 m_checkBoxCoalesceRW
.setChecked(session
->isCoalesceReadWriteEnabled());
613 addRow(COALESCE_RW
, (tr("Coalesce reads & writes") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#coalesce_reads", u
"(?)"))
614 , &m_checkBoxCoalesceRW
);
616 // Piece extent affinity
617 m_checkBoxPieceExtentAffinity
.setChecked(session
->usePieceExtentAffinity());
618 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
);
620 m_checkBoxSuggestMode
.setChecked(session
->isSuggestModeEnabled());
621 addRow(SUGGEST_MODE
, (tr("Send upload piece suggestions") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#suggest_mode", u
"(?)"))
622 , &m_checkBoxSuggestMode
);
623 // Send buffer watermark
624 m_spinBoxSendBufferWatermark
.setMinimum(1);
625 m_spinBoxSendBufferWatermark
.setMaximum(std::numeric_limits
<int>::max());
626 m_spinBoxSendBufferWatermark
.setSuffix(tr(" KiB"));
627 m_spinBoxSendBufferWatermark
.setValue(session
->sendBufferWatermark());
628 addRow(SEND_BUF_WATERMARK
, (tr("Send buffer watermark") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#send_buffer_watermark", u
"(?)"))
629 , &m_spinBoxSendBufferWatermark
);
630 m_spinBoxSendBufferLowWatermark
.setMinimum(1);
631 m_spinBoxSendBufferLowWatermark
.setMaximum(std::numeric_limits
<int>::max());
632 m_spinBoxSendBufferLowWatermark
.setSuffix(tr(" KiB"));
633 m_spinBoxSendBufferLowWatermark
.setValue(session
->sendBufferLowWatermark());
634 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
"(?)"))
635 , &m_spinBoxSendBufferLowWatermark
);
636 m_spinBoxSendBufferWatermarkFactor
.setMinimum(1);
637 m_spinBoxSendBufferWatermarkFactor
.setMaximum(std::numeric_limits
<int>::max());
638 m_spinBoxSendBufferWatermarkFactor
.setSuffix(u
" %"_s
);
639 m_spinBoxSendBufferWatermarkFactor
.setValue(session
->sendBufferWatermarkFactor());
640 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
"(?)"))
641 , &m_spinBoxSendBufferWatermarkFactor
);
642 // Outgoing connections per second
643 m_spinBoxConnectionSpeed
.setMinimum(0);
644 m_spinBoxConnectionSpeed
.setMaximum(std::numeric_limits
<int>::max());
645 m_spinBoxConnectionSpeed
.setValue(session
->connectionSpeed());
646 addRow(CONNECTION_SPEED
, (tr("Outgoing connections per second") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#connection_speed", u
"(?)"))
647 , &m_spinBoxConnectionSpeed
);
648 // Socket send buffer size
649 m_spinBoxSocketSendBufferSize
.setMinimum(0);
650 m_spinBoxSocketSendBufferSize
.setMaximum(std::numeric_limits
<int>::max() / 1024);
651 m_spinBoxSocketSendBufferSize
.setValue(session
->socketSendBufferSize() / 1024);
652 m_spinBoxSocketSendBufferSize
.setSuffix(tr(" KiB"));
653 m_spinBoxSocketSendBufferSize
.setSpecialValueText(tr("0 (system default)"));
654 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
"(?)"))
655 , &m_spinBoxSocketSendBufferSize
);
656 // Socket receive buffer size
657 m_spinBoxSocketReceiveBufferSize
.setMinimum(0);
658 m_spinBoxSocketReceiveBufferSize
.setMaximum(std::numeric_limits
<int>::max() / 1024);
659 m_spinBoxSocketReceiveBufferSize
.setValue(session
->socketReceiveBufferSize() / 1024);
660 m_spinBoxSocketReceiveBufferSize
.setSuffix(tr(" KiB"));
661 m_spinBoxSocketReceiveBufferSize
.setSpecialValueText(tr("0 (system default)"));
662 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
"(?)"))
663 , &m_spinBoxSocketReceiveBufferSize
);
664 // Socket listen backlog size
665 m_spinBoxSocketBacklogSize
.setMinimum(1);
666 m_spinBoxSocketBacklogSize
.setMaximum(std::numeric_limits
<int>::max());
667 m_spinBoxSocketBacklogSize
.setValue(session
->socketBacklogSize());
668 addRow(SOCKET_BACKLOG_SIZE
, (tr("Socket backlog size") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#listen_queue_size", u
"(?)"))
669 , &m_spinBoxSocketBacklogSize
);
670 // Save resume data interval
671 m_spinBoxSaveResumeDataInterval
.setMinimum(0);
672 m_spinBoxSaveResumeDataInterval
.setMaximum(std::numeric_limits
<int>::max());
673 m_spinBoxSaveResumeDataInterval
.setValue(session
->saveResumeDataInterval());
674 m_spinBoxSaveResumeDataInterval
.setSuffix(tr(" min", " minutes"));
675 m_spinBoxSaveResumeDataInterval
.setSpecialValueText(tr("0 (disabled)"));
676 addRow(SAVE_RESUME_DATA_INTERVAL
, tr("Save resume data interval [0: disabled]", "How often the fastresume file is saved."), &m_spinBoxSaveResumeDataInterval
);
677 // Save statistics interval
678 m_spinBoxSaveStatisticsInterval
.setMinimum(0);
679 m_spinBoxSaveStatisticsInterval
.setMaximum(std::numeric_limits
<int>::max());
680 m_spinBoxSaveStatisticsInterval
.setValue(session
->saveStatisticsInterval().count());
681 m_spinBoxSaveStatisticsInterval
.setSuffix(tr(" min", " minutes"));
682 m_spinBoxSaveStatisticsInterval
.setSpecialValueText(tr("0 (disabled)"));
683 addRow(SAVE_STATISTICS_INTERVAL
, tr("Save statistics interval [0: disabled]", "How often the statistics file is saved."), &m_spinBoxSaveStatisticsInterval
);
684 // .torrent file size limit
685 m_spinBoxTorrentFileSizeLimit
.setMinimum(1);
686 m_spinBoxTorrentFileSizeLimit
.setMaximum(std::numeric_limits
<int>::max() / 1024 / 1024);
687 m_spinBoxTorrentFileSizeLimit
.setValue(pref
->getTorrentFileSizeLimit() / 1024 / 1024);
688 m_spinBoxTorrentFileSizeLimit
.setSuffix(tr(" MiB"));
689 addRow(TORRENT_FILE_SIZE_LIMIT
, tr(".torrent file size limit"), &m_spinBoxTorrentFileSizeLimit
);
691 m_spinBoxOutgoingPortsMin
.setMinimum(0);
692 m_spinBoxOutgoingPortsMin
.setMaximum(65535);
693 m_spinBoxOutgoingPortsMin
.setValue(session
->outgoingPortsMin());
694 m_spinBoxOutgoingPortsMin
.setSpecialValueText(tr("0 (disabled)"));
695 addRow(OUTGOING_PORT_MIN
, (tr("Outgoing ports (Min) [0: disabled]")
696 + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#outgoing_port", u
"(?)"))
697 , &m_spinBoxOutgoingPortsMin
);
699 m_spinBoxOutgoingPortsMax
.setMinimum(0);
700 m_spinBoxOutgoingPortsMax
.setMaximum(65535);
701 m_spinBoxOutgoingPortsMax
.setValue(session
->outgoingPortsMax());
702 m_spinBoxOutgoingPortsMax
.setSpecialValueText(tr("0 (disabled)"));
703 addRow(OUTGOING_PORT_MAX
, (tr("Outgoing ports (Max) [0: disabled]")
704 + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#outgoing_port", u
"(?)"))
705 , &m_spinBoxOutgoingPortsMax
);
706 // UPnP lease duration
707 m_spinBoxUPnPLeaseDuration
.setMinimum(0);
708 m_spinBoxUPnPLeaseDuration
.setMaximum(std::numeric_limits
<int>::max());
709 m_spinBoxUPnPLeaseDuration
.setValue(session
->UPnPLeaseDuration());
710 m_spinBoxUPnPLeaseDuration
.setSuffix(tr(" s", " seconds"));
711 m_spinBoxUPnPLeaseDuration
.setSpecialValueText(tr("0 (permanent lease)"));
712 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
"(?)"))
713 , &m_spinBoxUPnPLeaseDuration
);
715 m_spinBoxPeerToS
.setMinimum(0);
716 m_spinBoxPeerToS
.setMaximum(255);
717 m_spinBoxPeerToS
.setValue(session
->peerToS());
718 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
"(?)"))
719 , &m_spinBoxPeerToS
);
720 // uTP-TCP mixed mode
721 m_comboBoxUtpMixedMode
.addItem(tr("Prefer TCP"), QVariant::fromValue(BitTorrent::MixedModeAlgorithm::TCP
));
722 m_comboBoxUtpMixedMode
.addItem(tr("Peer proportional (throttles TCP)"), QVariant::fromValue(BitTorrent::MixedModeAlgorithm::Proportional
));
723 m_comboBoxUtpMixedMode
.setCurrentIndex(m_comboBoxUtpMixedMode
.findData(QVariant::fromValue(session
->utpMixedMode())));
724 addRow(UTP_MIX_MODE
, (tr("%1-TCP mixed mode algorithm", "uTP-TCP mixed mode algorithm").arg(C_UTP
)
725 + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#mixed_mode_algorithm", u
"(?)"))
726 , &m_comboBoxUtpMixedMode
);
727 // Support internationalized domain name (IDN)
728 m_checkBoxIDNSupport
.setChecked(session
->isIDNSupportEnabled());
729 addRow(IDN_SUPPORT
, (tr("Support internationalized domain name (IDN)")
730 + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#allow_idna", u
"(?)"))
731 , &m_checkBoxIDNSupport
);
732 // multiple connections per IP
733 m_checkBoxMultiConnectionsPerIp
.setChecked(session
->multiConnectionsPerIpEnabled());
734 addRow(MULTI_CONNECTIONS_PER_IP
, (tr("Allow multiple connections from the same IP address")
735 + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#allow_multiple_connections_per_ip", u
"(?)"))
736 , &m_checkBoxMultiConnectionsPerIp
);
737 // Validate HTTPS tracker certificate
738 m_checkBoxValidateHTTPSTrackerCertificate
.setChecked(session
->validateHTTPSTrackerCertificate());
739 addRow(VALIDATE_HTTPS_TRACKER_CERTIFICATE
, (tr("Validate HTTPS tracker certificates")
740 + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#validate_https_trackers", u
"(?)"))
741 , &m_checkBoxValidateHTTPSTrackerCertificate
);
743 m_checkBoxSSRFMitigation
.setChecked(session
->isSSRFMitigationEnabled());
744 addRow(SSRF_MITIGATION
, (tr("Server-side request forgery (SSRF) mitigation")
745 + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#ssrf_mitigation", u
"(?)"))
746 , &m_checkBoxSSRFMitigation
);
747 // Disallow connection to peers on privileged ports
748 m_checkBoxBlockPeersOnPrivilegedPorts
.setChecked(session
->blockPeersOnPrivilegedPorts());
749 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
);
750 // Recheck completed torrents
751 m_checkBoxRecheckCompleted
.setChecked(pref
->recheckTorrentsOnCompletion());
752 addRow(RECHECK_COMPLETED
, tr("Recheck torrents on completion"), &m_checkBoxRecheckCompleted
);
753 // Customize application instance name
754 m_lineEditAppInstanceName
.setText(app()->instanceName());
755 m_lineEditAppInstanceName
.setToolTip(tr("It appends the text to the window title to help distinguish qBittorent instances"));
756 addRow(APP_INSTANCE_NAME
, tr("Customize application instance name"), &m_lineEditAppInstanceName
);
758 m_spinBoxListRefresh
.setMinimum(30);
759 m_spinBoxListRefresh
.setMaximum(99999);
760 m_spinBoxListRefresh
.setValue(session
->refreshInterval());
761 m_spinBoxListRefresh
.setSuffix(tr(" ms", " milliseconds"));
762 m_spinBoxListRefresh
.setToolTip(tr("It controls the internal state update interval which in turn will affect UI updates"));
763 addRow(LIST_REFRESH
, tr("Refresh interval"), &m_spinBoxListRefresh
);
764 // Resolve Peer countries
765 m_checkBoxResolveCountries
.setChecked(pref
->resolvePeerCountries());
766 addRow(RESOLVE_COUNTRIES
, tr("Resolve peer countries"), &m_checkBoxResolveCountries
);
767 // Resolve peer hosts
768 m_checkBoxResolveHosts
.setChecked(pref
->resolvePeerHostNames());
769 addRow(RESOLVE_HOSTS
, tr("Resolve peer host names"), &m_checkBoxResolveHosts
);
771 m_comboBoxInterface
.addItem(tr("Any interface", "i.e. Any network interface"), QString());
772 for (const QNetworkInterface
&iface
: asConst(QNetworkInterface::allInterfaces()))
773 m_comboBoxInterface
.addItem(iface
.humanReadableName(), iface
.name());
775 const QString currentInterface
= session
->networkInterface();
776 const int ifaceIndex
= m_comboBoxInterface
.findData(currentInterface
);
779 m_comboBoxInterface
.setCurrentIndex(ifaceIndex
);
783 // Saved interface does not exist, show it
784 m_comboBoxInterface
.addItem(session
->networkInterfaceName(), currentInterface
);
785 m_comboBoxInterface
.setCurrentIndex(m_comboBoxInterface
.count() - 1);
788 connect(&m_comboBoxInterface
, qOverload
<int>(&QComboBox::currentIndexChanged
)
789 , this, &AdvancedSettings::updateInterfaceAddressCombo
);
790 addRow(NETWORK_IFACE
, tr("Network interface"), &m_comboBoxInterface
);
791 // Network interface address
792 updateInterfaceAddressCombo();
793 addRow(NETWORK_IFACE_ADDRESS
, tr("Optional IP address to bind to"), &m_comboBoxInterfaceAddress
);
795 m_lineEditAnnounceIP
.setText(session
->announceIP());
796 addRow(ANNOUNCE_IP
, (tr("IP address reported to trackers (requires restart)")
797 + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#announce_ip", u
"(?)"))
798 , &m_lineEditAnnounceIP
);
799 // Max concurrent HTTP announces
800 m_spinBoxMaxConcurrentHTTPAnnounces
.setMaximum(std::numeric_limits
<int>::max());
801 m_spinBoxMaxConcurrentHTTPAnnounces
.setValue(session
->maxConcurrentHTTPAnnounces());
802 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
"(?)"))
803 , &m_spinBoxMaxConcurrentHTTPAnnounces
);
804 // Stop tracker timeout
805 m_spinBoxStopTrackerTimeout
.setMaximum(std::numeric_limits
<int>::max());
806 m_spinBoxStopTrackerTimeout
.setValue(session
->stopTrackerTimeout());
807 m_spinBoxStopTrackerTimeout
.setSuffix(tr(" s", " seconds"));
808 m_spinBoxStopTrackerTimeout
.setSpecialValueText(tr("0 (disabled)"));
809 addRow(STOP_TRACKER_TIMEOUT
, (tr("Stop tracker timeout [0: disabled]") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#stop_tracker_timeout", u
"(?)"))
810 , &m_spinBoxStopTrackerTimeout
);
811 // Program notifications
812 m_checkBoxProgramNotifications
.setChecked(app()->desktopIntegration()->isNotificationsEnabled());
813 addRow(PROGRAM_NOTIFICATIONS
, tr("Display notifications"), &m_checkBoxProgramNotifications
);
814 // Torrent added notifications
815 m_checkBoxTorrentAddedNotifications
.setChecked(app()->isTorrentAddedNotificationsEnabled());
816 addRow(TORRENT_ADDED_NOTIFICATIONS
, tr("Display notifications for added torrents"), &m_checkBoxTorrentAddedNotifications
);
818 // Notification timeout
819 m_spinBoxNotificationTimeout
.setMinimum(-1);
820 m_spinBoxNotificationTimeout
.setMaximum(std::numeric_limits
<int>::max());
821 m_spinBoxNotificationTimeout
.setValue(app()->desktopIntegration()->notificationTimeout());
822 connect(&m_spinBoxNotificationTimeout
, qOverload
<int>(&QSpinBox::valueChanged
)
823 , this, &AdvancedSettings::updateNotificationTimeoutSuffix
);
824 updateNotificationTimeoutSuffix(m_spinBoxNotificationTimeout
.value());
825 addRow(NOTIFICATION_TIMEOUT
, tr("Notification timeout [0: infinite, -1: system default]"), &m_spinBoxNotificationTimeout
);
827 // Reannounce to all trackers when ip/port changed
828 m_checkBoxReannounceWhenAddressChanged
.setChecked(session
->isReannounceWhenAddressChangedEnabled());
829 addRow(REANNOUNCE_WHEN_ADDRESS_CHANGED
, tr("Reannounce to all trackers when IP or port changed"), &m_checkBoxReannounceWhenAddressChanged
);
830 // Download tracker's favicon
831 m_checkBoxTrackerFavicon
.setChecked(app()->mainWindow()->isDownloadTrackerFavicon());
832 addRow(DOWNLOAD_TRACKER_FAVICON
, tr("Download tracker's favicon"), &m_checkBoxTrackerFavicon
);
833 // Save path history length
834 m_spinBoxSavePathHistoryLength
.setRange(0, 99);
835 m_spinBoxSavePathHistoryLength
.setValue(pref
->addNewTorrentDialogSavePathHistoryLength());
836 addRow(SAVE_PATH_HISTORY_LENGTH
, tr("Save path history length"), &m_spinBoxSavePathHistoryLength
);
837 // Enable speed graphs
838 m_checkBoxSpeedWidgetEnabled
.setChecked(pref
->isSpeedWidgetEnabled());
839 addRow(ENABLE_SPEED_WIDGET
, tr("Enable speed graphs"), &m_checkBoxSpeedWidgetEnabled
);
841 // Enable icons in menus
842 m_checkBoxIconsInMenusEnabled
.setChecked(pref
->iconsInMenusEnabled());
843 addRow(ENABLE_ICONS_IN_MENUS
, tr("Enable icons in menus"), &m_checkBoxIconsInMenusEnabled
);
846 m_checkBoxTrackerStatus
.setChecked(session
->isTrackerEnabled());
847 addRow(TRACKER_STATUS
, tr("Enable embedded tracker"), &m_checkBoxTrackerStatus
);
849 m_spinBoxTrackerPort
.setMinimum(1);
850 m_spinBoxTrackerPort
.setMaximum(65535);
851 m_spinBoxTrackerPort
.setValue(pref
->getTrackerPort());
852 addRow(TRACKER_PORT
, tr("Embedded tracker port"), &m_spinBoxTrackerPort
);
853 // Tracker port forwarding
854 m_checkBoxTrackerPortForwarding
.setChecked(pref
->isTrackerPortForwardingEnabled());
855 addRow(TRACKER_PORT_FORWARDING
, tr("Enable port forwarding for embedded tracker"), &m_checkBoxTrackerPortForwarding
);
856 #if defined(Q_OS_MACOS) || defined(Q_OS_WIN)
859 const QString motwLabel
= tr("Enable quarantine for downloaded files");
860 #elif defined(Q_OS_WIN)
861 const QString motwLabel
= tr("Enable Mark-of-the-Web (MOTW) for downloaded files");
863 m_checkBoxMarkOfTheWeb
.setChecked(pref
->isMarkOfTheWebEnabled());
864 addRow(ENABLE_MARK_OF_THE_WEB
, motwLabel
, &m_checkBoxMarkOfTheWeb
);
865 #endif // Q_OS_MACOS || Q_OS_WIN
866 // Python executable path
867 m_pythonExecutablePath
.setPlaceholderText(tr("(Auto detect if empty)"));
868 m_pythonExecutablePath
.setText(pref
->getPythonExecutablePath().toString());
869 addRow(PYTHON_EXECUTABLE_PATH
, tr("Python executable path (may require restart)"), &m_pythonExecutablePath
);
870 // Start session paused
871 m_checkBoxStartSessionPaused
.setChecked(session
->isStartPaused());
872 addRow(START_SESSION_PAUSED
, tr("Start BitTorrent session in paused state"), &m_checkBoxStartSessionPaused
);
873 // Session shutdown timeout
874 m_spinBoxSessionShutdownTimeout
.setMinimum(-1);
875 m_spinBoxSessionShutdownTimeout
.setMaximum(std::numeric_limits
<int>::max());
876 m_spinBoxSessionShutdownTimeout
.setValue(session
->shutdownTimeout());
877 m_spinBoxSessionShutdownTimeout
.setSuffix(tr(" sec", " seconds"));
878 m_spinBoxSessionShutdownTimeout
.setSpecialValueText(tr("-1 (unlimited)"));
879 m_spinBoxSessionShutdownTimeout
.setToolTip(u
"Sets the timeout for the session to be shut down gracefully, at which point it will be forcibly terminated.<br>Note that this does not apply to the saving resume data time."_s
);
880 addRow(SESSION_SHUTDOWN_TIMEOUT
, tr("BitTorrent session shutdown timeout [-1: unlimited]"), &m_spinBoxSessionShutdownTimeout
);
882 m_comboBoxChokingAlgorithm
.addItem(tr("Fixed slots"), QVariant::fromValue(BitTorrent::ChokingAlgorithm::FixedSlots
));
883 m_comboBoxChokingAlgorithm
.addItem(tr("Upload rate based"), QVariant::fromValue(BitTorrent::ChokingAlgorithm::RateBased
));
884 m_comboBoxChokingAlgorithm
.setCurrentIndex(m_comboBoxChokingAlgorithm
.findData(QVariant::fromValue(session
->chokingAlgorithm())));
885 addRow(CHOKING_ALGORITHM
, (tr("Upload slots behavior") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#choking_algorithm", u
"(?)"))
886 , &m_comboBoxChokingAlgorithm
);
887 // Seed choking algorithm
888 m_comboBoxSeedChokingAlgorithm
.addItem(tr("Round-robin"), QVariant::fromValue(BitTorrent::SeedChokingAlgorithm::RoundRobin
));
889 m_comboBoxSeedChokingAlgorithm
.addItem(tr("Fastest upload"), QVariant::fromValue(BitTorrent::SeedChokingAlgorithm::FastestUpload
));
890 m_comboBoxSeedChokingAlgorithm
.addItem(tr("Anti-leech"), QVariant::fromValue(BitTorrent::SeedChokingAlgorithm::AntiLeech
));
891 m_comboBoxSeedChokingAlgorithm
.setCurrentIndex(m_comboBoxSeedChokingAlgorithm
.findData(QVariant::fromValue(session
->seedChokingAlgorithm())));
892 addRow(SEED_CHOKING_ALGORITHM
, (tr("Upload choking algorithm") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#seed_choking_algorithm", u
"(?)"))
893 , &m_comboBoxSeedChokingAlgorithm
);
895 // Torrent recheck confirmation
896 m_checkBoxConfirmTorrentRecheck
.setChecked(pref
->confirmTorrentRecheck());
897 addRow(CONFIRM_RECHECK_TORRENT
, tr("Confirm torrent recheck"), &m_checkBoxConfirmTorrentRecheck
);
899 // Remove all tags confirmation
900 m_checkBoxConfirmRemoveAllTags
.setChecked(pref
->confirmRemoveAllTags());
901 addRow(CONFIRM_REMOVE_ALL_TAGS
, tr("Confirm removal of all tags"), &m_checkBoxConfirmRemoveAllTags
);
903 // Remove tracker from all torrents confirmation
904 m_checkBoxConfirmRemoveTrackerFromAllTorrents
.setChecked(pref
->confirmRemoveTrackerFromAllTorrents());
905 addRow(CONFIRM_REMOVE_TRACKER_FROM_ALL_TORRENTS
, tr("Confirm removal of tracker from all torrents"), &m_checkBoxConfirmRemoveTrackerFromAllTorrents
);
907 // Announce to all trackers in a tier
908 m_checkBoxAnnounceAllTrackers
.setChecked(session
->announceToAllTrackers());
909 addRow(ANNOUNCE_ALL_TRACKERS
, (tr("Always announce to all trackers in a tier")
910 + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#announce_to_all_trackers", u
"(?)"))
911 , &m_checkBoxAnnounceAllTrackers
);
913 // Announce to all tiers
914 m_checkBoxAnnounceAllTiers
.setChecked(session
->announceToAllTiers());
915 addRow(ANNOUNCE_ALL_TIERS
, (tr("Always announce to all tiers")
916 + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#announce_to_all_tiers", u
"(?)"))
917 , &m_checkBoxAnnounceAllTiers
);
919 m_spinBoxPeerTurnover
.setMinimum(0);
920 m_spinBoxPeerTurnover
.setMaximum(100);
921 m_spinBoxPeerTurnover
.setValue(session
->peerTurnover());
922 m_spinBoxPeerTurnover
.setSuffix(u
" %"_s
);
923 addRow(PEER_TURNOVER
, (tr("Peer turnover disconnect percentage") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#peer_turnover", u
"(?)"))
924 , &m_spinBoxPeerTurnover
);
925 m_spinBoxPeerTurnoverCutoff
.setMinimum(0);
926 m_spinBoxPeerTurnoverCutoff
.setMaximum(100);
927 m_spinBoxPeerTurnoverCutoff
.setSuffix(u
" %"_s
);
928 m_spinBoxPeerTurnoverCutoff
.setValue(session
->peerTurnoverCutoff());
929 addRow(PEER_TURNOVER_CUTOFF
, (tr("Peer turnover threshold percentage") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#peer_turnover", u
"(?)"))
930 , &m_spinBoxPeerTurnoverCutoff
);
931 m_spinBoxPeerTurnoverInterval
.setMinimum(30);
932 m_spinBoxPeerTurnoverInterval
.setMaximum(3600);
933 m_spinBoxPeerTurnoverInterval
.setSuffix(tr(" s", " seconds"));
934 m_spinBoxPeerTurnoverInterval
.setValue(session
->peerTurnoverInterval());
935 addRow(PEER_TURNOVER_INTERVAL
, (tr("Peer turnover disconnect interval") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#peer_turnover", u
"(?)"))
936 , &m_spinBoxPeerTurnoverInterval
);
937 // Maximum outstanding requests to a single peer
938 m_spinBoxRequestQueueSize
.setMinimum(1);
939 m_spinBoxRequestQueueSize
.setMaximum(std::numeric_limits
<int>::max());
940 m_spinBoxRequestQueueSize
.setValue(session
->requestQueueSize());
941 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
"(?)"))
942 , &m_spinBoxRequestQueueSize
);
943 // DHT bootstrap nodes
944 m_lineEditDHTBootstrapNodes
.setPlaceholderText(tr("Resets to default if empty"));
945 m_lineEditDHTBootstrapNodes
.setText(session
->getDHTBootstrapNodes());
946 addRow(DHT_BOOTSTRAP_NODES
, (tr("DHT bootstrap nodes") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#dht_bootstrap_nodes", u
"(?)"))
947 , &m_lineEditDHTBootstrapNodes
);
948 #if defined(QBT_USES_LIBTORRENT2) && TORRENT_USE_I2P
949 // I2P session options
950 m_spinBoxI2PInboundQuantity
.setMinimum(1);
951 m_spinBoxI2PInboundQuantity
.setMaximum(16);
952 m_spinBoxI2PInboundQuantity
.setValue(session
->I2PInboundQuantity());
953 addRow(I2P_INBOUND_QUANTITY
, (tr("I2P inbound quantity") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#i2p_inbound_quantity", u
"(?)"))
954 , &m_spinBoxI2PInboundQuantity
);
955 m_spinBoxI2POutboundQuantity
.setMinimum(1);
956 m_spinBoxI2POutboundQuantity
.setMaximum(16);
957 m_spinBoxI2POutboundQuantity
.setValue(session
->I2POutboundQuantity());
958 addRow(I2P_OUTBOUND_QUANTITY
, (tr("I2P outbound quantity") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#i2p_outbound_quantity", u
"(?)"))
959 , &m_spinBoxI2POutboundQuantity
);
960 m_spinBoxI2PInboundLength
.setMinimum(0);
961 m_spinBoxI2PInboundLength
.setMaximum(7);
962 m_spinBoxI2PInboundLength
.setValue(session
->I2PInboundLength());
963 addRow(I2P_INBOUND_LENGTH
, (tr("I2P inbound length") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#i2p_inbound_length", u
"(?)"))
964 , &m_spinBoxI2PInboundLength
);
965 m_spinBoxI2POutboundLength
.setMinimum(0);
966 m_spinBoxI2POutboundLength
.setMaximum(7);
967 m_spinBoxI2POutboundLength
.setValue(session
->I2POutboundLength());
968 addRow(I2P_OUTBOUND_LENGTH
, (tr("I2P outbound length") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#i2p_outbound_length", u
"(?)"))
969 , &m_spinBoxI2POutboundLength
);
973 template <typename T
>
974 void AdvancedSettings::addRow(const int row
, const QString
&text
, T
*widget
)
976 auto *label
= new QLabel(text
);
977 label
->setOpenExternalLinks(true);
978 label
->setToolTip(widget
->toolTip());
980 setCellWidget(row
, PROPERTY
, label
);
981 setCellWidget(row
, VALUE
, widget
);
983 if constexpr (std::is_same_v
<T
, QCheckBox
>)
984 connect(widget
, &QCheckBox::stateChanged
, this, &AdvancedSettings::settingsChanged
);
985 else if constexpr (std::is_same_v
<T
, QSpinBox
>)
986 connect(widget
, qOverload
<int>(&QSpinBox::valueChanged
), this, &AdvancedSettings::settingsChanged
);
987 else if constexpr (std::is_same_v
<T
, QComboBox
>)
988 connect(widget
, qOverload
<int>(&QComboBox::currentIndexChanged
), this, &AdvancedSettings::settingsChanged
);
989 else if constexpr (std::is_same_v
<T
, QLineEdit
>)
990 connect(widget
, &QLineEdit::textChanged
, this, &AdvancedSettings::settingsChanged
);