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 <QtVersionChecks>
34 #include <QHeaderView>
35 #include <QHostAddress>
37 #include <QNetworkInterface>
39 #include "base/bittorrent/session.h"
40 #include "base/global.h"
41 #include "base/preferences.h"
42 #include "base/unicodestrings.h"
43 #include "gui/addnewtorrentdialog.h"
44 #include "gui/desktopintegration.h"
45 #include "gui/mainwindow.h"
46 #include "interfaces/iguiapplication.h"
50 QString
makeLink(const QStringView url
, const QStringView linkLabel
)
52 return u
"<a href=\"%1\">%2</a>"_s
.arg(url
, linkLabel
);
64 // qBittorrent section
67 TORRENT_CONTENT_REMOVE_OPTION
,
68 #if defined(QBT_USES_LIBTORRENT2) && !defined(Q_OS_MACOS)
69 MEMORY_WORKING_SET_LIMIT
,
76 //Optional network address
77 NETWORK_IFACE_ADDRESS
,
79 SAVE_RESUME_DATA_INTERVAL
,
80 SAVE_STATISTICS_INTERVAL
,
81 TORRENT_FILE_SIZE_LIMIT
,
82 CONFIRM_RECHECK_TORRENT
,
89 PROGRAM_NOTIFICATIONS
,
90 TORRENT_ADDED_NOTIFICATIONS
,
94 CONFIRM_REMOVE_ALL_TAGS
,
95 CONFIRM_REMOVE_TRACKER_FROM_ALL_TORRENTS
,
96 REANNOUNCE_WHEN_ADDRESS_CHANGED
,
97 DOWNLOAD_TRACKER_FAVICON
,
98 SAVE_PATH_HISTORY_LENGTH
,
101 ENABLE_ICONS_IN_MENUS
,
106 TRACKER_PORT_FORWARDING
,
107 #if defined(Q_OS_MACOS) || defined(Q_OS_WIN)
108 ENABLE_MARK_OF_THE_WEB
,
109 #endif // Q_OS_MACOS || Q_OS_WIN
111 PYTHON_EXECUTABLE_PATH
,
112 START_SESSION_PAUSED
,
113 SESSION_SHUTDOWN_TIMEOUT
,
115 // libtorrent section
120 #ifdef QBT_USES_LIBTORRENT2
125 #ifndef QBT_USES_LIBTORRENT2
131 #ifdef QBT_USES_LIBTORRENT2
136 #ifndef QBT_USES_LIBTORRENT2
139 PIECE_EXTENT_AFFINITY
,
142 SEND_BUF_LOW_WATERMARK
,
143 SEND_BUF_WATERMARK_FACTOR
,
144 // networking & ports
146 SOCKET_SEND_BUFFER_SIZE
,
147 SOCKET_RECEIVE_BUFFER_SIZE
,
155 MULTI_CONNECTIONS_PER_IP
,
156 VALIDATE_HTTPS_TRACKER_CERTIFICATE
,
158 BLOCK_PEERS_ON_PRIVILEGED_PORTS
,
161 SEED_CHOKING_ALGORITHM
,
163 ANNOUNCE_ALL_TRACKERS
,
166 MAX_CONCURRENT_HTTP_ANNOUNCES
,
167 STOP_TRACKER_TIMEOUT
,
169 PEER_TURNOVER_CUTOFF
,
170 PEER_TURNOVER_INTERVAL
,
173 #if defined(QBT_USES_LIBTORRENT2) && TORRENT_USE_I2P
174 I2P_INBOUND_QUANTITY
,
175 I2P_OUTBOUND_QUANTITY
,
184 AdvancedSettings::AdvancedSettings(IGUIApplication
*app
, QWidget
*parent
)
185 : GUIApplicationComponent(app
, parent
)
188 setColumnCount(COL_COUNT
);
189 const QStringList header
= {tr("Setting"), tr("Value", "Value set for this setting")};
190 setHorizontalHeaderLabels(header
);
192 setRowCount(ROW_COUNT
);
193 verticalHeader()->setVisible(false);
195 setAlternatingRowColors(true);
196 setSelectionMode(QAbstractItemView::NoSelection
);
197 setEditTriggers(QAbstractItemView::NoEditTriggers
);
199 loadAdvancedSettings();
200 resizeColumnToContents(0);
201 horizontalHeader()->setStretchLastSection(true);
204 void AdvancedSettings::saveAdvancedSettings() const
206 Preferences
*const pref
= Preferences::instance();
207 BitTorrent::Session
*const session
= BitTorrent::Session::instance();
209 session
->setResumeDataStorageType(m_comboBoxResumeDataStorage
.currentData().value
<BitTorrent::ResumeDataStorageType
>());
210 #if defined(QBT_USES_LIBTORRENT2) && !defined(Q_OS_MACOS)
211 // Physical memory (RAM) usage limit
212 app()->setMemoryWorkingSetLimit(m_spinBoxMemoryWorkingSetLimit
.value());
214 #if defined(Q_OS_WIN)
215 app()->setProcessMemoryPriority(m_comboBoxOSMemoryPriority
.currentData().value
<MemoryPriority
>());
217 // Bdecode depth limit
218 pref
->setBdecodeDepthLimit(m_spinBoxBdecodeDepthLimit
.value());
219 // Bdecode token limit
220 pref
->setBdecodeTokenLimit(m_spinBoxBdecodeTokenLimit
.value());
222 session
->setAsyncIOThreads(m_spinBoxAsyncIOThreads
.value());
223 #ifdef QBT_USES_LIBTORRENT2
225 session
->setHashingThreads(m_spinBoxHashingThreads
.value());
228 session
->setFilePoolSize(m_spinBoxFilePoolSize
.value());
229 // Checking Memory Usage
230 session
->setCheckingMemUsage(m_spinBoxCheckingMemUsage
.value());
231 #ifndef QBT_USES_LIBTORRENT2
233 session
->setDiskCacheSize(m_spinBoxCache
.value());
234 session
->setDiskCacheTTL(m_spinBoxCacheTTL
.value());
237 session
->setDiskQueueSize(m_spinBoxDiskQueueSize
.value() * 1024);
238 #ifdef QBT_USES_LIBTORRENT2
239 session
->setDiskIOType(m_comboBoxDiskIOType
.currentData().value
<BitTorrent::DiskIOType
>());
242 session
->setDiskIOReadMode(m_comboBoxDiskIOReadMode
.currentData().value
<BitTorrent::DiskIOReadMode
>());
243 // Disk IO write mode
244 session
->setDiskIOWriteMode(m_comboBoxDiskIOWriteMode
.currentData().value
<BitTorrent::DiskIOWriteMode
>());
245 #ifndef QBT_USES_LIBTORRENT2
246 // Coalesce reads & writes
247 session
->setCoalesceReadWriteEnabled(m_checkBoxCoalesceRW
.isChecked());
249 // Piece extent affinity
250 session
->setPieceExtentAffinity(m_checkBoxPieceExtentAffinity
.isChecked());
252 session
->setSuggestMode(m_checkBoxSuggestMode
.isChecked());
253 // Send buffer watermark
254 session
->setSendBufferWatermark(m_spinBoxSendBufferWatermark
.value());
255 session
->setSendBufferLowWatermark(m_spinBoxSendBufferLowWatermark
.value());
256 session
->setSendBufferWatermarkFactor(m_spinBoxSendBufferWatermarkFactor
.value());
257 // Outgoing connections per second
258 session
->setConnectionSpeed(m_spinBoxConnectionSpeed
.value());
259 // Socket send buffer size
260 session
->setSocketSendBufferSize(m_spinBoxSocketSendBufferSize
.value() * 1024);
261 // Socket receive buffer size
262 session
->setSocketReceiveBufferSize(m_spinBoxSocketReceiveBufferSize
.value() * 1024);
263 // Socket listen backlog size
264 session
->setSocketBacklogSize(m_spinBoxSocketBacklogSize
.value());
265 // Save resume data interval
266 session
->setSaveResumeDataInterval(m_spinBoxSaveResumeDataInterval
.value());
267 // Save statistics interval
268 session
->setSaveStatisticsInterval(std::chrono::minutes(m_spinBoxSaveStatisticsInterval
.value()));
269 // .torrent file size limit
270 pref
->setTorrentFileSizeLimit(m_spinBoxTorrentFileSizeLimit
.value() * 1024 * 1024);
272 session
->setOutgoingPortsMin(m_spinBoxOutgoingPortsMin
.value());
273 session
->setOutgoingPortsMax(m_spinBoxOutgoingPortsMax
.value());
274 // UPnP lease duration
275 session
->setUPnPLeaseDuration(m_spinBoxUPnPLeaseDuration
.value());
277 session
->setPeerToS(m_spinBoxPeerToS
.value());
278 // uTP-TCP mixed mode
279 session
->setUtpMixedMode(m_comboBoxUtpMixedMode
.currentData().value
<BitTorrent::MixedModeAlgorithm
>());
280 // Support internationalized domain name (IDN)
281 session
->setIDNSupportEnabled(m_checkBoxIDNSupport
.isChecked());
282 // multiple connections per IP
283 session
->setMultiConnectionsPerIpEnabled(m_checkBoxMultiConnectionsPerIp
.isChecked());
284 // Validate HTTPS tracker certificate
285 session
->setValidateHTTPSTrackerCertificate(m_checkBoxValidateHTTPSTrackerCertificate
.isChecked());
287 session
->setSSRFMitigationEnabled(m_checkBoxSSRFMitigation
.isChecked());
288 // Disallow connection to peers on privileged ports
289 session
->setBlockPeersOnPrivilegedPorts(m_checkBoxBlockPeersOnPrivilegedPorts
.isChecked());
290 // Recheck torrents on completion
291 pref
->recheckTorrentsOnCompletion(m_checkBoxRecheckCompleted
.isChecked());
292 // Customize application instance name
293 app()->setInstanceName(m_lineEditAppInstanceName
.text());
294 // Transfer list refresh interval
295 session
->setRefreshInterval(m_spinBoxListRefresh
.value());
297 pref
->resolvePeerCountries(m_checkBoxResolveCountries
.isChecked());
298 pref
->resolvePeerHostNames(m_checkBoxResolveHosts
.isChecked());
300 session
->setNetworkInterface(m_comboBoxInterface
.currentData().toString());
301 session
->setNetworkInterfaceName((m_comboBoxInterface
.currentIndex() == 0)
303 : m_comboBoxInterface
.currentText());
305 // Construct a QHostAddress to filter malformed strings
306 const QHostAddress ifaceAddr
{m_comboBoxInterfaceAddress
.currentData().toString()};
307 session
->setNetworkInterfaceAddress(ifaceAddr
.toString());
309 // Construct a QHostAddress to filter malformed strings
310 const QHostAddress
addr(m_lineEditAnnounceIP
.text().trimmed());
311 session
->setAnnounceIP(addr
.toString());
312 // Max concurrent HTTP announces
313 session
->setMaxConcurrentHTTPAnnounces(m_spinBoxMaxConcurrentHTTPAnnounces
.value());
314 // Stop tracker timeout
315 session
->setStopTrackerTimeout(m_spinBoxStopTrackerTimeout
.value());
316 // Program notification
317 app()->desktopIntegration()->setNotificationsEnabled(m_checkBoxProgramNotifications
.isChecked());
319 app()->desktopIntegration()->setNotificationTimeout(m_spinBoxNotificationTimeout
.value());
321 app()->setTorrentAddedNotificationsEnabled(m_checkBoxTorrentAddedNotifications
.isChecked());
322 // Reannounce to all trackers when ip/port changed
323 session
->setReannounceWhenAddressChangedEnabled(m_checkBoxReannounceWhenAddressChanged
.isChecked());
324 // Misc GUI properties
325 app()->mainWindow()->setDownloadTrackerFavicon(m_checkBoxTrackerFavicon
.isChecked());
326 pref
->setAddNewTorrentDialogSavePathHistoryLength(m_spinBoxSavePathHistoryLength
.value());
327 pref
->setSpeedWidgetEnabled(m_checkBoxSpeedWidgetEnabled
.isChecked());
329 pref
->setIconsInMenusEnabled(m_checkBoxIconsInMenusEnabled
.isChecked());
333 pref
->setTrackerPort(m_spinBoxTrackerPort
.value());
334 pref
->setTrackerPortForwardingEnabled(m_checkBoxTrackerPortForwarding
.isChecked());
335 session
->setTrackerEnabled(m_checkBoxTrackerStatus
.isChecked());
336 #if defined(Q_OS_MACOS) || defined(Q_OS_WIN)
338 pref
->setMarkOfTheWebEnabled(m_checkBoxMarkOfTheWeb
.isChecked());
339 #endif // Q_OS_MACOS || Q_OS_WIN
341 pref
->setIgnoreSSLErrors(m_checkBoxIgnoreSSLErrors
.isChecked());
342 // Python executable path
343 pref
->setPythonExecutablePath(Path(m_pythonExecutablePath
.text().trimmed()));
344 // Start session paused
345 session
->setStartPaused(m_checkBoxStartSessionPaused
.isChecked());
346 // Session shutdown timeout
347 session
->setShutdownTimeout(m_spinBoxSessionShutdownTimeout
.value());
349 session
->setChokingAlgorithm(m_comboBoxChokingAlgorithm
.currentData().value
<BitTorrent::ChokingAlgorithm
>());
350 // Seed choking algorithm
351 session
->setSeedChokingAlgorithm(m_comboBoxSeedChokingAlgorithm
.currentData().value
<BitTorrent::SeedChokingAlgorithm
>());
353 pref
->setConfirmTorrentRecheck(m_checkBoxConfirmTorrentRecheck
.isChecked());
355 pref
->setConfirmRemoveAllTags(m_checkBoxConfirmRemoveAllTags
.isChecked());
356 pref
->setConfirmRemoveTrackerFromAllTorrents(m_checkBoxConfirmRemoveTrackerFromAllTorrents
.isChecked());
358 session
->setAnnounceToAllTrackers(m_checkBoxAnnounceAllTrackers
.isChecked());
359 session
->setAnnounceToAllTiers(m_checkBoxAnnounceAllTiers
.isChecked());
361 session
->setPeerTurnover(m_spinBoxPeerTurnover
.value());
362 session
->setPeerTurnoverCutoff(m_spinBoxPeerTurnoverCutoff
.value());
363 session
->setPeerTurnoverInterval(m_spinBoxPeerTurnoverInterval
.value());
364 // Maximum outstanding requests to a single peer
365 session
->setRequestQueueSize(m_spinBoxRequestQueueSize
.value());
366 // DHT bootstrap nodes
367 session
->setDHTBootstrapNodes(m_lineEditDHTBootstrapNodes
.text());
368 #if defined(QBT_USES_LIBTORRENT2) && TORRENT_USE_I2P
369 // I2P session options
370 session
->setI2PInboundQuantity(m_spinBoxI2PInboundQuantity
.value());
371 session
->setI2POutboundQuantity(m_spinBoxI2POutboundQuantity
.value());
372 session
->setI2PInboundLength(m_spinBoxI2PInboundLength
.value());
373 session
->setI2POutboundLength(m_spinBoxI2POutboundLength
.value());
376 session
->setTorrentContentRemoveOption(m_comboBoxTorrentContentRemoveOption
.currentData().value
<BitTorrent::TorrentContentRemoveOption
>());
379 #ifndef QBT_USES_LIBTORRENT2
380 void AdvancedSettings::updateCacheSpinSuffix(const int value
)
383 m_spinBoxCache
.setSuffix(tr(" (disabled)"));
385 m_spinBoxCache
.setSuffix(tr(" (auto)"));
387 m_spinBoxCache
.setSuffix(tr(" MiB"));
392 void AdvancedSettings::updateNotificationTimeoutSuffix(const int value
)
395 m_spinBoxNotificationTimeout
.setSuffix(tr(" (infinite)"));
397 m_spinBoxNotificationTimeout
.setSuffix(tr(" (system default)"));
399 m_spinBoxNotificationTimeout
.setSuffix(tr(" ms", " milliseconds"));
403 void AdvancedSettings::updateInterfaceAddressCombo()
405 const auto toString
= [](const QHostAddress
&address
) -> QString
407 switch (address
.protocol()) {
408 case QAbstractSocket::IPv4Protocol
:
409 return address
.toString();
410 case QAbstractSocket::IPv6Protocol
:
411 return Utils::Net::canonicalIPv6Addr(address
).toString();
419 // Clear all items and reinsert them
420 m_comboBoxInterfaceAddress
.clear();
421 m_comboBoxInterfaceAddress
.addItem(tr("All addresses"), QString());
422 m_comboBoxInterfaceAddress
.addItem(tr("All IPv4 addresses"), QHostAddress(QHostAddress::AnyIPv4
).toString());
423 m_comboBoxInterfaceAddress
.addItem(tr("All IPv6 addresses"), QHostAddress(QHostAddress::AnyIPv6
).toString());
425 const QString currentIface
= m_comboBoxInterface
.currentData().toString();
426 if (currentIface
.isEmpty()) // `any` interface
428 for (const QHostAddress
&address
: asConst(QNetworkInterface::allAddresses()))
430 const QString addressString
= toString(address
);
431 m_comboBoxInterfaceAddress
.addItem(addressString
, addressString
);
436 const QList
<QNetworkAddressEntry
> addresses
= QNetworkInterface::interfaceFromName(currentIface
).addressEntries();
437 for (const QNetworkAddressEntry
&entry
: addresses
)
439 const QString addressString
= toString(entry
.ip());
440 m_comboBoxInterfaceAddress
.addItem(addressString
, addressString
);
444 const QString currentAddress
= BitTorrent::Session::instance()->networkInterfaceAddress();
445 const int index
= m_comboBoxInterfaceAddress
.findData(currentAddress
);
448 m_comboBoxInterfaceAddress
.setCurrentIndex(index
);
452 // not found, for the sake of UI consistency, add such entry
453 m_comboBoxInterfaceAddress
.addItem(currentAddress
, currentAddress
);
454 m_comboBoxInterfaceAddress
.setCurrentIndex(m_comboBoxInterfaceAddress
.count() - 1);
458 void AdvancedSettings::loadAdvancedSettings()
460 const Preferences
*const pref
= Preferences::instance();
461 const BitTorrent::Session
*const session
= BitTorrent::Session::instance();
463 // add section headers
464 auto *labelQbtLink
= new QLabel(
465 makeLink(u
"https://github.com/qbittorrent/qBittorrent/wiki/Explanation-of-Options-in-qBittorrent#Advanced"
466 , tr("Open documentation"))
468 labelQbtLink
->setOpenExternalLinks(true);
469 addRow(QBITTORRENT_HEADER
, u
"<b>%1</b>"_s
.arg(tr("qBittorrent Section")), labelQbtLink
);
470 static_cast<QLabel
*>(cellWidget(QBITTORRENT_HEADER
, PROPERTY
))->setAlignment(Qt::AlignCenter
| Qt::AlignVCenter
);
472 auto *labelLibtorrentLink
= new QLabel(
473 makeLink(u
"https://www.libtorrent.org/reference-Settings.html"
474 , tr("Open documentation"))
476 labelLibtorrentLink
->setOpenExternalLinks(true);
477 addRow(LIBTORRENT_HEADER
, u
"<b>%1</b>"_s
.arg(tr("libtorrent Section")), labelLibtorrentLink
);
478 static_cast<QLabel
*>(cellWidget(LIBTORRENT_HEADER
, PROPERTY
))->setAlignment(Qt::AlignCenter
| Qt::AlignVCenter
);
480 m_comboBoxResumeDataStorage
.addItem(tr("Fastresume files"), QVariant::fromValue(BitTorrent::ResumeDataStorageType::Legacy
));
481 m_comboBoxResumeDataStorage
.addItem(tr("SQLite database (experimental)"), QVariant::fromValue(BitTorrent::ResumeDataStorageType::SQLite
));
482 m_comboBoxResumeDataStorage
.setCurrentIndex(m_comboBoxResumeDataStorage
.findData(QVariant::fromValue(session
->resumeDataStorageType())));
483 addRow(RESUME_DATA_STORAGE
, tr("Resume data storage type (requires restart)"), &m_comboBoxResumeDataStorage
);
485 m_comboBoxTorrentContentRemoveOption
.addItem(tr("Delete files permanently"), QVariant::fromValue(BitTorrent::TorrentContentRemoveOption::Delete
));
486 m_comboBoxTorrentContentRemoveOption
.addItem(tr("Move files to trash (if possible)"), QVariant::fromValue(BitTorrent::TorrentContentRemoveOption::MoveToTrash
));
487 m_comboBoxTorrentContentRemoveOption
.setCurrentIndex(m_comboBoxTorrentContentRemoveOption
.findData(QVariant::fromValue(session
->torrentContentRemoveOption())));
488 addRow(TORRENT_CONTENT_REMOVE_OPTION
, tr("Torrent content removing mode"), &m_comboBoxTorrentContentRemoveOption
);
490 #if defined(QBT_USES_LIBTORRENT2) && !defined(Q_OS_MACOS)
491 // Physical memory (RAM) usage limit
492 m_spinBoxMemoryWorkingSetLimit
.setMinimum(1);
493 m_spinBoxMemoryWorkingSetLimit
.setMaximum(std::numeric_limits
<int>::max());
494 m_spinBoxMemoryWorkingSetLimit
.setSuffix(tr(" MiB"));
495 m_spinBoxMemoryWorkingSetLimit
.setToolTip(tr("This option is less effective on Linux"));
496 m_spinBoxMemoryWorkingSetLimit
.setValue(app()->memoryWorkingSetLimit());
497 addRow(MEMORY_WORKING_SET_LIMIT
, (tr("Physical memory (RAM) usage limit") + u
' ' + makeLink(u
"https://wikipedia.org/wiki/Working_set", u
"(?)"))
498 , &m_spinBoxMemoryWorkingSetLimit
);
500 #if defined(Q_OS_WIN)
501 m_comboBoxOSMemoryPriority
.addItem(tr("Normal"), QVariant::fromValue(MemoryPriority::Normal
));
502 m_comboBoxOSMemoryPriority
.addItem(tr("Below normal"), QVariant::fromValue(MemoryPriority::BelowNormal
));
503 m_comboBoxOSMemoryPriority
.addItem(tr("Medium"), QVariant::fromValue(MemoryPriority::Medium
));
504 m_comboBoxOSMemoryPriority
.addItem(tr("Low"), QVariant::fromValue(MemoryPriority::Low
));
505 m_comboBoxOSMemoryPriority
.addItem(tr("Very low"), QVariant::fromValue(MemoryPriority::VeryLow
));
506 m_comboBoxOSMemoryPriority
.setCurrentIndex(m_comboBoxOSMemoryPriority
.findData(QVariant::fromValue(app()->processMemoryPriority())));
507 addRow(OS_MEMORY_PRIORITY
, (tr("Process memory priority")
508 + u
' ' + makeLink(u
"https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/ns-processthreadsapi-memory_priority_information", u
"(?)"))
509 , &m_comboBoxOSMemoryPriority
);
511 // Bdecode depth limit
512 m_spinBoxBdecodeDepthLimit
.setMinimum(0);
513 m_spinBoxBdecodeDepthLimit
.setMaximum(std::numeric_limits
<int>::max());
514 m_spinBoxBdecodeDepthLimit
.setValue(pref
->getBdecodeDepthLimit());
515 addRow(BDECODE_DEPTH_LIMIT
, (tr("Bdecode depth limit") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Bdecoding.html#bdecode()", u
"(?)"))
516 , &m_spinBoxBdecodeDepthLimit
);
517 // Bdecode token limit
518 m_spinBoxBdecodeTokenLimit
.setMinimum(0);
519 m_spinBoxBdecodeTokenLimit
.setMaximum(std::numeric_limits
<int>::max());
520 m_spinBoxBdecodeTokenLimit
.setValue(pref
->getBdecodeTokenLimit());
521 addRow(BDECODE_TOKEN_LIMIT
, (tr("Bdecode token limit") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Bdecoding.html#bdecode()", u
"(?)"))
522 , &m_spinBoxBdecodeTokenLimit
);
524 m_spinBoxAsyncIOThreads
.setMinimum(1);
525 m_spinBoxAsyncIOThreads
.setMaximum(1024);
526 m_spinBoxAsyncIOThreads
.setValue(session
->asyncIOThreads());
527 addRow(ASYNC_IO_THREADS
, (tr("Asynchronous I/O threads") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#aio_threads", u
"(?)"))
528 , &m_spinBoxAsyncIOThreads
);
530 #ifdef QBT_USES_LIBTORRENT2
532 m_spinBoxHashingThreads
.setMinimum(1);
533 m_spinBoxHashingThreads
.setMaximum(1024);
534 m_spinBoxHashingThreads
.setValue(session
->hashingThreads());
535 addRow(HASHING_THREADS
, (tr("Hashing threads") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#hashing_threads", u
"(?)"))
536 , &m_spinBoxHashingThreads
);
540 m_spinBoxFilePoolSize
.setMinimum(1);
541 m_spinBoxFilePoolSize
.setMaximum(std::numeric_limits
<int>::max());
542 m_spinBoxFilePoolSize
.setValue(session
->filePoolSize());
543 addRow(FILE_POOL_SIZE
, (tr("File pool size") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#file_pool_size", u
"(?)"))
544 , &m_spinBoxFilePoolSize
);
546 // Checking Memory Usage
547 m_spinBoxCheckingMemUsage
.setMinimum(1);
548 // When build as 32bit binary, set the maximum value lower to prevent crashes.
550 m_spinBoxCheckingMemUsage
.setMaximum(1024);
552 // Allocate at most 128MiB out of the remaining 512MiB (see the cache part below)
553 m_spinBoxCheckingMemUsage
.setMaximum(128);
555 m_spinBoxCheckingMemUsage
.setValue(session
->checkingMemUsage());
556 m_spinBoxCheckingMemUsage
.setSuffix(tr(" MiB"));
557 addRow(CHECKING_MEM_USAGE
, (tr("Outstanding memory when checking torrents") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#checking_mem_usage", u
"(?)"))
558 , &m_spinBoxCheckingMemUsage
);
559 #ifndef QBT_USES_LIBTORRENT2
561 m_spinBoxCache
.setMinimum(-1);
562 // When build as 32bit binary, set the maximum at less than 2GB to prevent crashes.
564 m_spinBoxCache
.setMaximum(33554431); // 32768GiB
566 // allocate 1536MiB and leave 512MiB to the rest of program data in RAM
567 m_spinBoxCache
.setMaximum(1536);
569 m_spinBoxCache
.setValue(session
->diskCacheSize());
570 updateCacheSpinSuffix(m_spinBoxCache
.value());
571 connect(&m_spinBoxCache
, qOverload
<int>(&QSpinBox::valueChanged
)
572 , this, &AdvancedSettings::updateCacheSpinSuffix
);
573 addRow(DISK_CACHE
, (tr("Disk cache") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#cache_size", u
"(?)"))
576 m_spinBoxCacheTTL
.setMinimum(1);
577 m_spinBoxCacheTTL
.setMaximum(std::numeric_limits
<int>::max());
578 m_spinBoxCacheTTL
.setValue(session
->diskCacheTTL());
579 m_spinBoxCacheTTL
.setSuffix(tr(" s", " seconds"));
580 addRow(DISK_CACHE_TTL
, (tr("Disk cache expiry interval") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#cache_expiry", u
"(?)"))
581 , &m_spinBoxCacheTTL
);
584 m_spinBoxDiskQueueSize
.setMinimum(1);
585 m_spinBoxDiskQueueSize
.setMaximum(std::numeric_limits
<int>::max() / 1024);
586 m_spinBoxDiskQueueSize
.setValue(session
->diskQueueSize() / 1024);
587 m_spinBoxDiskQueueSize
.setSuffix(tr(" KiB"));
588 addRow(DISK_QUEUE_SIZE
, (tr("Disk queue size") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#max_queued_disk_bytes", u
"(?)"))
589 , &m_spinBoxDiskQueueSize
);
590 #ifdef QBT_USES_LIBTORRENT2
592 m_comboBoxDiskIOType
.addItem(tr("Default"), QVariant::fromValue(BitTorrent::DiskIOType::Default
));
593 m_comboBoxDiskIOType
.addItem(tr("Memory mapped files"), QVariant::fromValue(BitTorrent::DiskIOType::MMap
));
594 m_comboBoxDiskIOType
.addItem(tr("POSIX-compliant"), QVariant::fromValue(BitTorrent::DiskIOType::Posix
));
595 m_comboBoxDiskIOType
.addItem(tr("Simple pread/pwrite"), QVariant::fromValue(BitTorrent::DiskIOType::SimplePreadPwrite
));
596 m_comboBoxDiskIOType
.setCurrentIndex(m_comboBoxDiskIOType
.findData(QVariant::fromValue(session
->diskIOType())));
597 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
"(?)")
598 , &m_comboBoxDiskIOType
);
601 m_comboBoxDiskIOReadMode
.addItem(tr("Disable OS cache"), QVariant::fromValue(BitTorrent::DiskIOReadMode::DisableOSCache
));
602 m_comboBoxDiskIOReadMode
.addItem(tr("Enable OS cache"), QVariant::fromValue(BitTorrent::DiskIOReadMode::EnableOSCache
));
603 m_comboBoxDiskIOReadMode
.setCurrentIndex(m_comboBoxDiskIOReadMode
.findData(QVariant::fromValue(session
->diskIOReadMode())));
604 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
"(?)"))
605 , &m_comboBoxDiskIOReadMode
);
606 // Disk IO write mode
607 m_comboBoxDiskIOWriteMode
.addItem(tr("Disable OS cache"), QVariant::fromValue(BitTorrent::DiskIOWriteMode::DisableOSCache
));
608 m_comboBoxDiskIOWriteMode
.addItem(tr("Enable OS cache"), QVariant::fromValue(BitTorrent::DiskIOWriteMode::EnableOSCache
));
609 #ifdef QBT_USES_LIBTORRENT2
610 m_comboBoxDiskIOWriteMode
.addItem(tr("Write-through"), QVariant::fromValue(BitTorrent::DiskIOWriteMode::WriteThrough
));
612 m_comboBoxDiskIOWriteMode
.setCurrentIndex(m_comboBoxDiskIOWriteMode
.findData(QVariant::fromValue(session
->diskIOWriteMode())));
613 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
"(?)"))
614 , &m_comboBoxDiskIOWriteMode
);
615 #ifndef QBT_USES_LIBTORRENT2
616 // Coalesce reads & writes
617 m_checkBoxCoalesceRW
.setChecked(session
->isCoalesceReadWriteEnabled());
618 addRow(COALESCE_RW
, (tr("Coalesce reads & writes") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#coalesce_reads", u
"(?)"))
619 , &m_checkBoxCoalesceRW
);
621 // Piece extent affinity
622 m_checkBoxPieceExtentAffinity
.setChecked(session
->usePieceExtentAffinity());
623 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
);
625 m_checkBoxSuggestMode
.setChecked(session
->isSuggestModeEnabled());
626 addRow(SUGGEST_MODE
, (tr("Send upload piece suggestions") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#suggest_mode", u
"(?)"))
627 , &m_checkBoxSuggestMode
);
628 // Send buffer watermark
629 m_spinBoxSendBufferWatermark
.setMinimum(1);
630 m_spinBoxSendBufferWatermark
.setMaximum(std::numeric_limits
<int>::max());
631 m_spinBoxSendBufferWatermark
.setSuffix(tr(" KiB"));
632 m_spinBoxSendBufferWatermark
.setValue(session
->sendBufferWatermark());
633 addRow(SEND_BUF_WATERMARK
, (tr("Send buffer watermark") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#send_buffer_watermark", u
"(?)"))
634 , &m_spinBoxSendBufferWatermark
);
635 m_spinBoxSendBufferLowWatermark
.setMinimum(1);
636 m_spinBoxSendBufferLowWatermark
.setMaximum(std::numeric_limits
<int>::max());
637 m_spinBoxSendBufferLowWatermark
.setSuffix(tr(" KiB"));
638 m_spinBoxSendBufferLowWatermark
.setValue(session
->sendBufferLowWatermark());
639 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
"(?)"))
640 , &m_spinBoxSendBufferLowWatermark
);
641 m_spinBoxSendBufferWatermarkFactor
.setMinimum(1);
642 m_spinBoxSendBufferWatermarkFactor
.setMaximum(std::numeric_limits
<int>::max());
643 m_spinBoxSendBufferWatermarkFactor
.setSuffix(u
" %"_s
);
644 m_spinBoxSendBufferWatermarkFactor
.setValue(session
->sendBufferWatermarkFactor());
645 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
"(?)"))
646 , &m_spinBoxSendBufferWatermarkFactor
);
647 // Outgoing connections per second
648 m_spinBoxConnectionSpeed
.setMinimum(0);
649 m_spinBoxConnectionSpeed
.setMaximum(std::numeric_limits
<int>::max());
650 m_spinBoxConnectionSpeed
.setValue(session
->connectionSpeed());
651 addRow(CONNECTION_SPEED
, (tr("Outgoing connections per second") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#connection_speed", u
"(?)"))
652 , &m_spinBoxConnectionSpeed
);
653 // Socket send buffer size
654 m_spinBoxSocketSendBufferSize
.setMinimum(0);
655 m_spinBoxSocketSendBufferSize
.setMaximum(std::numeric_limits
<int>::max() / 1024);
656 m_spinBoxSocketSendBufferSize
.setValue(session
->socketSendBufferSize() / 1024);
657 m_spinBoxSocketSendBufferSize
.setSuffix(tr(" KiB"));
658 m_spinBoxSocketSendBufferSize
.setSpecialValueText(tr("0 (system default)"));
659 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
"(?)"))
660 , &m_spinBoxSocketSendBufferSize
);
661 // Socket receive buffer size
662 m_spinBoxSocketReceiveBufferSize
.setMinimum(0);
663 m_spinBoxSocketReceiveBufferSize
.setMaximum(std::numeric_limits
<int>::max() / 1024);
664 m_spinBoxSocketReceiveBufferSize
.setValue(session
->socketReceiveBufferSize() / 1024);
665 m_spinBoxSocketReceiveBufferSize
.setSuffix(tr(" KiB"));
666 m_spinBoxSocketReceiveBufferSize
.setSpecialValueText(tr("0 (system default)"));
667 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
"(?)"))
668 , &m_spinBoxSocketReceiveBufferSize
);
669 // Socket listen backlog size
670 m_spinBoxSocketBacklogSize
.setMinimum(1);
671 m_spinBoxSocketBacklogSize
.setMaximum(std::numeric_limits
<int>::max());
672 m_spinBoxSocketBacklogSize
.setValue(session
->socketBacklogSize());
673 addRow(SOCKET_BACKLOG_SIZE
, (tr("Socket backlog size") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#listen_queue_size", u
"(?)"))
674 , &m_spinBoxSocketBacklogSize
);
675 // Save resume data interval
676 m_spinBoxSaveResumeDataInterval
.setMinimum(0);
677 m_spinBoxSaveResumeDataInterval
.setMaximum(std::numeric_limits
<int>::max());
678 m_spinBoxSaveResumeDataInterval
.setValue(session
->saveResumeDataInterval());
679 m_spinBoxSaveResumeDataInterval
.setSuffix(tr(" min", " minutes"));
680 m_spinBoxSaveResumeDataInterval
.setSpecialValueText(tr("0 (disabled)"));
681 addRow(SAVE_RESUME_DATA_INTERVAL
, tr("Save resume data interval [0: disabled]", "How often the fastresume file is saved."), &m_spinBoxSaveResumeDataInterval
);
682 // Save statistics interval
683 m_spinBoxSaveStatisticsInterval
.setMinimum(0);
684 m_spinBoxSaveStatisticsInterval
.setMaximum(std::numeric_limits
<int>::max());
685 m_spinBoxSaveStatisticsInterval
.setValue(session
->saveStatisticsInterval().count());
686 m_spinBoxSaveStatisticsInterval
.setSuffix(tr(" min", " minutes"));
687 m_spinBoxSaveStatisticsInterval
.setSpecialValueText(tr("0 (disabled)"));
688 addRow(SAVE_STATISTICS_INTERVAL
, tr("Save statistics interval [0: disabled]", "How often the statistics file is saved."), &m_spinBoxSaveStatisticsInterval
);
689 // .torrent file size limit
690 m_spinBoxTorrentFileSizeLimit
.setMinimum(1);
691 m_spinBoxTorrentFileSizeLimit
.setMaximum(std::numeric_limits
<int>::max() / 1024 / 1024);
692 m_spinBoxTorrentFileSizeLimit
.setValue(pref
->getTorrentFileSizeLimit() / 1024 / 1024);
693 m_spinBoxTorrentFileSizeLimit
.setSuffix(tr(" MiB"));
694 addRow(TORRENT_FILE_SIZE_LIMIT
, tr(".torrent file size limit"), &m_spinBoxTorrentFileSizeLimit
);
696 m_spinBoxOutgoingPortsMin
.setMinimum(0);
697 m_spinBoxOutgoingPortsMin
.setMaximum(65535);
698 m_spinBoxOutgoingPortsMin
.setValue(session
->outgoingPortsMin());
699 m_spinBoxOutgoingPortsMin
.setSpecialValueText(tr("0 (disabled)"));
700 addRow(OUTGOING_PORT_MIN
, (tr("Outgoing ports (Min) [0: disabled]")
701 + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#outgoing_port", u
"(?)"))
702 , &m_spinBoxOutgoingPortsMin
);
704 m_spinBoxOutgoingPortsMax
.setMinimum(0);
705 m_spinBoxOutgoingPortsMax
.setMaximum(65535);
706 m_spinBoxOutgoingPortsMax
.setValue(session
->outgoingPortsMax());
707 m_spinBoxOutgoingPortsMax
.setSpecialValueText(tr("0 (disabled)"));
708 addRow(OUTGOING_PORT_MAX
, (tr("Outgoing ports (Max) [0: disabled]")
709 + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#outgoing_port", u
"(?)"))
710 , &m_spinBoxOutgoingPortsMax
);
711 // UPnP lease duration
712 m_spinBoxUPnPLeaseDuration
.setMinimum(0);
713 m_spinBoxUPnPLeaseDuration
.setMaximum(std::numeric_limits
<int>::max());
714 m_spinBoxUPnPLeaseDuration
.setValue(session
->UPnPLeaseDuration());
715 m_spinBoxUPnPLeaseDuration
.setSuffix(tr(" s", " seconds"));
716 m_spinBoxUPnPLeaseDuration
.setSpecialValueText(tr("0 (permanent lease)"));
717 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
"(?)"))
718 , &m_spinBoxUPnPLeaseDuration
);
720 m_spinBoxPeerToS
.setMinimum(0);
721 m_spinBoxPeerToS
.setMaximum(255);
722 m_spinBoxPeerToS
.setValue(session
->peerToS());
723 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
"(?)"))
724 , &m_spinBoxPeerToS
);
725 // uTP-TCP mixed mode
726 m_comboBoxUtpMixedMode
.addItem(tr("Prefer TCP"), QVariant::fromValue(BitTorrent::MixedModeAlgorithm::TCP
));
727 m_comboBoxUtpMixedMode
.addItem(tr("Peer proportional (throttles TCP)"), QVariant::fromValue(BitTorrent::MixedModeAlgorithm::Proportional
));
728 m_comboBoxUtpMixedMode
.setCurrentIndex(m_comboBoxUtpMixedMode
.findData(QVariant::fromValue(session
->utpMixedMode())));
729 addRow(UTP_MIX_MODE
, (tr("%1-TCP mixed mode algorithm", "uTP-TCP mixed mode algorithm").arg(C_UTP
)
730 + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#mixed_mode_algorithm", u
"(?)"))
731 , &m_comboBoxUtpMixedMode
);
732 // Support internationalized domain name (IDN)
733 m_checkBoxIDNSupport
.setChecked(session
->isIDNSupportEnabled());
734 addRow(IDN_SUPPORT
, (tr("Support internationalized domain name (IDN)")
735 + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#allow_idna", u
"(?)"))
736 , &m_checkBoxIDNSupport
);
737 // multiple connections per IP
738 m_checkBoxMultiConnectionsPerIp
.setChecked(session
->multiConnectionsPerIpEnabled());
739 addRow(MULTI_CONNECTIONS_PER_IP
, (tr("Allow multiple connections from the same IP address")
740 + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#allow_multiple_connections_per_ip", u
"(?)"))
741 , &m_checkBoxMultiConnectionsPerIp
);
742 // Validate HTTPS tracker certificate
743 m_checkBoxValidateHTTPSTrackerCertificate
.setChecked(session
->validateHTTPSTrackerCertificate());
744 addRow(VALIDATE_HTTPS_TRACKER_CERTIFICATE
, (tr("Validate HTTPS tracker certificates")
745 + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#validate_https_trackers", u
"(?)"))
746 , &m_checkBoxValidateHTTPSTrackerCertificate
);
748 m_checkBoxSSRFMitigation
.setChecked(session
->isSSRFMitigationEnabled());
749 addRow(SSRF_MITIGATION
, (tr("Server-side request forgery (SSRF) mitigation")
750 + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#ssrf_mitigation", u
"(?)"))
751 , &m_checkBoxSSRFMitigation
);
752 // Disallow connection to peers on privileged ports
753 m_checkBoxBlockPeersOnPrivilegedPorts
.setChecked(session
->blockPeersOnPrivilegedPorts());
754 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
);
755 // Recheck completed torrents
756 m_checkBoxRecheckCompleted
.setChecked(pref
->recheckTorrentsOnCompletion());
757 addRow(RECHECK_COMPLETED
, tr("Recheck torrents on completion"), &m_checkBoxRecheckCompleted
);
758 // Customize application instance name
759 m_lineEditAppInstanceName
.setText(app()->instanceName());
760 m_lineEditAppInstanceName
.setToolTip(tr("It appends the text to the window title to help distinguish qBittorent instances"));
761 addRow(APP_INSTANCE_NAME
, tr("Customize application instance name"), &m_lineEditAppInstanceName
);
763 m_spinBoxListRefresh
.setMinimum(30);
764 m_spinBoxListRefresh
.setMaximum(99999);
765 m_spinBoxListRefresh
.setValue(session
->refreshInterval());
766 m_spinBoxListRefresh
.setSuffix(tr(" ms", " milliseconds"));
767 m_spinBoxListRefresh
.setToolTip(tr("It controls the internal state update interval which in turn will affect UI updates"));
768 addRow(LIST_REFRESH
, tr("Refresh interval"), &m_spinBoxListRefresh
);
769 // Resolve Peer countries
770 m_checkBoxResolveCountries
.setChecked(pref
->resolvePeerCountries());
771 addRow(RESOLVE_COUNTRIES
, tr("Resolve peer countries"), &m_checkBoxResolveCountries
);
772 // Resolve peer hosts
773 m_checkBoxResolveHosts
.setChecked(pref
->resolvePeerHostNames());
774 addRow(RESOLVE_HOSTS
, tr("Resolve peer host names"), &m_checkBoxResolveHosts
);
776 m_comboBoxInterface
.addItem(tr("Any interface", "i.e. Any network interface"), QString());
777 for (const QNetworkInterface
&iface
: asConst(QNetworkInterface::allInterfaces()))
778 m_comboBoxInterface
.addItem(iface
.humanReadableName(), iface
.name());
780 const QString currentInterface
= session
->networkInterface();
781 const int ifaceIndex
= m_comboBoxInterface
.findData(currentInterface
);
784 m_comboBoxInterface
.setCurrentIndex(ifaceIndex
);
788 // Saved interface does not exist, show it
789 m_comboBoxInterface
.addItem(session
->networkInterfaceName(), currentInterface
);
790 m_comboBoxInterface
.setCurrentIndex(m_comboBoxInterface
.count() - 1);
793 connect(&m_comboBoxInterface
, qOverload
<int>(&QComboBox::currentIndexChanged
)
794 , this, &AdvancedSettings::updateInterfaceAddressCombo
);
795 addRow(NETWORK_IFACE
, tr("Network interface"), &m_comboBoxInterface
);
796 // Network interface address
797 updateInterfaceAddressCombo();
798 addRow(NETWORK_IFACE_ADDRESS
, tr("Optional IP address to bind to"), &m_comboBoxInterfaceAddress
);
800 m_lineEditAnnounceIP
.setText(session
->announceIP());
801 addRow(ANNOUNCE_IP
, (tr("IP address reported to trackers (requires restart)")
802 + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#announce_ip", u
"(?)"))
803 , &m_lineEditAnnounceIP
);
804 // Max concurrent HTTP announces
805 m_spinBoxMaxConcurrentHTTPAnnounces
.setMaximum(std::numeric_limits
<int>::max());
806 m_spinBoxMaxConcurrentHTTPAnnounces
.setValue(session
->maxConcurrentHTTPAnnounces());
807 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
"(?)"))
808 , &m_spinBoxMaxConcurrentHTTPAnnounces
);
809 // Stop tracker timeout
810 m_spinBoxStopTrackerTimeout
.setMaximum(std::numeric_limits
<int>::max());
811 m_spinBoxStopTrackerTimeout
.setValue(session
->stopTrackerTimeout());
812 m_spinBoxStopTrackerTimeout
.setSuffix(tr(" s", " seconds"));
813 m_spinBoxStopTrackerTimeout
.setSpecialValueText(tr("0 (disabled)"));
814 addRow(STOP_TRACKER_TIMEOUT
, (tr("Stop tracker timeout [0: disabled]") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#stop_tracker_timeout", u
"(?)"))
815 , &m_spinBoxStopTrackerTimeout
);
816 // Program notifications
817 m_checkBoxProgramNotifications
.setChecked(app()->desktopIntegration()->isNotificationsEnabled());
818 addRow(PROGRAM_NOTIFICATIONS
, tr("Display notifications"), &m_checkBoxProgramNotifications
);
819 // Torrent added notifications
820 m_checkBoxTorrentAddedNotifications
.setChecked(app()->isTorrentAddedNotificationsEnabled());
821 addRow(TORRENT_ADDED_NOTIFICATIONS
, tr("Display notifications for added torrents"), &m_checkBoxTorrentAddedNotifications
);
823 // Notification timeout
824 m_spinBoxNotificationTimeout
.setMinimum(-1);
825 m_spinBoxNotificationTimeout
.setMaximum(std::numeric_limits
<int>::max());
826 m_spinBoxNotificationTimeout
.setValue(app()->desktopIntegration()->notificationTimeout());
827 connect(&m_spinBoxNotificationTimeout
, qOverload
<int>(&QSpinBox::valueChanged
)
828 , this, &AdvancedSettings::updateNotificationTimeoutSuffix
);
829 updateNotificationTimeoutSuffix(m_spinBoxNotificationTimeout
.value());
830 addRow(NOTIFICATION_TIMEOUT
, tr("Notification timeout [0: infinite, -1: system default]"), &m_spinBoxNotificationTimeout
);
832 // Reannounce to all trackers when ip/port changed
833 m_checkBoxReannounceWhenAddressChanged
.setChecked(session
->isReannounceWhenAddressChangedEnabled());
834 addRow(REANNOUNCE_WHEN_ADDRESS_CHANGED
, tr("Reannounce to all trackers when IP or port changed"), &m_checkBoxReannounceWhenAddressChanged
);
835 // Download tracker's favicon
836 m_checkBoxTrackerFavicon
.setChecked(app()->mainWindow()->isDownloadTrackerFavicon());
837 addRow(DOWNLOAD_TRACKER_FAVICON
, tr("Download tracker's favicon"), &m_checkBoxTrackerFavicon
);
838 // Save path history length
839 m_spinBoxSavePathHistoryLength
.setRange(0, 99);
840 m_spinBoxSavePathHistoryLength
.setValue(pref
->addNewTorrentDialogSavePathHistoryLength());
841 addRow(SAVE_PATH_HISTORY_LENGTH
, tr("Save path history length"), &m_spinBoxSavePathHistoryLength
);
842 // Enable speed graphs
843 m_checkBoxSpeedWidgetEnabled
.setChecked(pref
->isSpeedWidgetEnabled());
844 addRow(ENABLE_SPEED_WIDGET
, tr("Enable speed graphs"), &m_checkBoxSpeedWidgetEnabled
);
846 // Enable icons in menus
847 m_checkBoxIconsInMenusEnabled
.setChecked(pref
->iconsInMenusEnabled());
848 addRow(ENABLE_ICONS_IN_MENUS
, tr("Enable icons in menus"), &m_checkBoxIconsInMenusEnabled
);
851 m_checkBoxTrackerStatus
.setChecked(session
->isTrackerEnabled());
852 addRow(TRACKER_STATUS
, tr("Enable embedded tracker"), &m_checkBoxTrackerStatus
);
854 m_spinBoxTrackerPort
.setMinimum(1);
855 m_spinBoxTrackerPort
.setMaximum(65535);
856 m_spinBoxTrackerPort
.setValue(pref
->getTrackerPort());
857 addRow(TRACKER_PORT
, tr("Embedded tracker port"), &m_spinBoxTrackerPort
);
858 // Tracker port forwarding
859 m_checkBoxTrackerPortForwarding
.setChecked(pref
->isTrackerPortForwardingEnabled());
860 addRow(TRACKER_PORT_FORWARDING
, tr("Enable port forwarding for embedded tracker"), &m_checkBoxTrackerPortForwarding
);
861 #if defined(Q_OS_MACOS) || defined(Q_OS_WIN)
864 const QString motwLabel
= tr("Enable quarantine for downloaded files");
865 #elif defined(Q_OS_WIN)
866 const QString motwLabel
= tr("Enable Mark-of-the-Web (MOTW) for downloaded files");
868 m_checkBoxMarkOfTheWeb
.setChecked(pref
->isMarkOfTheWebEnabled());
869 addRow(ENABLE_MARK_OF_THE_WEB
, motwLabel
, &m_checkBoxMarkOfTheWeb
);
870 #endif // Q_OS_MACOS || Q_OS_WIN
872 m_checkBoxIgnoreSSLErrors
.setChecked(pref
->isIgnoreSSLErrors());
873 m_checkBoxIgnoreSSLErrors
.setToolTip(tr("Affects certificate validation and non-torrent protocol activities (e.g. RSS feeds, program updates, torrent files, geoip db, etc)"));
874 addRow(IGNORE_SSL_ERRORS
, tr("Ignore SSL errors"), &m_checkBoxIgnoreSSLErrors
);
875 // Python executable path
876 m_pythonExecutablePath
.setPlaceholderText(tr("(Auto detect if empty)"));
877 m_pythonExecutablePath
.setText(pref
->getPythonExecutablePath().toString());
878 addRow(PYTHON_EXECUTABLE_PATH
, tr("Python executable path (may require restart)"), &m_pythonExecutablePath
);
879 // Start session paused
880 m_checkBoxStartSessionPaused
.setChecked(session
->isStartPaused());
881 addRow(START_SESSION_PAUSED
, tr("Start BitTorrent session in paused state"), &m_checkBoxStartSessionPaused
);
882 // Session shutdown timeout
883 m_spinBoxSessionShutdownTimeout
.setMinimum(-1);
884 m_spinBoxSessionShutdownTimeout
.setMaximum(std::numeric_limits
<int>::max());
885 m_spinBoxSessionShutdownTimeout
.setValue(session
->shutdownTimeout());
886 m_spinBoxSessionShutdownTimeout
.setSuffix(tr(" sec", " seconds"));
887 m_spinBoxSessionShutdownTimeout
.setSpecialValueText(tr("-1 (unlimited)"));
888 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
);
889 addRow(SESSION_SHUTDOWN_TIMEOUT
, tr("BitTorrent session shutdown timeout [-1: unlimited]"), &m_spinBoxSessionShutdownTimeout
);
891 m_comboBoxChokingAlgorithm
.addItem(tr("Fixed slots"), QVariant::fromValue(BitTorrent::ChokingAlgorithm::FixedSlots
));
892 m_comboBoxChokingAlgorithm
.addItem(tr("Upload rate based"), QVariant::fromValue(BitTorrent::ChokingAlgorithm::RateBased
));
893 m_comboBoxChokingAlgorithm
.setCurrentIndex(m_comboBoxChokingAlgorithm
.findData(QVariant::fromValue(session
->chokingAlgorithm())));
894 addRow(CHOKING_ALGORITHM
, (tr("Upload slots behavior") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#choking_algorithm", u
"(?)"))
895 , &m_comboBoxChokingAlgorithm
);
896 // Seed choking algorithm
897 m_comboBoxSeedChokingAlgorithm
.addItem(tr("Round-robin"), QVariant::fromValue(BitTorrent::SeedChokingAlgorithm::RoundRobin
));
898 m_comboBoxSeedChokingAlgorithm
.addItem(tr("Fastest upload"), QVariant::fromValue(BitTorrent::SeedChokingAlgorithm::FastestUpload
));
899 m_comboBoxSeedChokingAlgorithm
.addItem(tr("Anti-leech"), QVariant::fromValue(BitTorrent::SeedChokingAlgorithm::AntiLeech
));
900 m_comboBoxSeedChokingAlgorithm
.setCurrentIndex(m_comboBoxSeedChokingAlgorithm
.findData(QVariant::fromValue(session
->seedChokingAlgorithm())));
901 addRow(SEED_CHOKING_ALGORITHM
, (tr("Upload choking algorithm") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#seed_choking_algorithm", u
"(?)"))
902 , &m_comboBoxSeedChokingAlgorithm
);
904 // Torrent recheck confirmation
905 m_checkBoxConfirmTorrentRecheck
.setChecked(pref
->confirmTorrentRecheck());
906 addRow(CONFIRM_RECHECK_TORRENT
, tr("Confirm torrent recheck"), &m_checkBoxConfirmTorrentRecheck
);
908 // Remove all tags confirmation
909 m_checkBoxConfirmRemoveAllTags
.setChecked(pref
->confirmRemoveAllTags());
910 addRow(CONFIRM_REMOVE_ALL_TAGS
, tr("Confirm removal of all tags"), &m_checkBoxConfirmRemoveAllTags
);
912 // Remove tracker from all torrents confirmation
913 m_checkBoxConfirmRemoveTrackerFromAllTorrents
.setChecked(pref
->confirmRemoveTrackerFromAllTorrents());
914 addRow(CONFIRM_REMOVE_TRACKER_FROM_ALL_TORRENTS
, tr("Confirm removal of tracker from all torrents"), &m_checkBoxConfirmRemoveTrackerFromAllTorrents
);
916 // Announce to all trackers in a tier
917 m_checkBoxAnnounceAllTrackers
.setChecked(session
->announceToAllTrackers());
918 addRow(ANNOUNCE_ALL_TRACKERS
, (tr("Always announce to all trackers in a tier")
919 + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#announce_to_all_trackers", u
"(?)"))
920 , &m_checkBoxAnnounceAllTrackers
);
922 // Announce to all tiers
923 m_checkBoxAnnounceAllTiers
.setChecked(session
->announceToAllTiers());
924 addRow(ANNOUNCE_ALL_TIERS
, (tr("Always announce to all tiers")
925 + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#announce_to_all_tiers", u
"(?)"))
926 , &m_checkBoxAnnounceAllTiers
);
928 m_spinBoxPeerTurnover
.setMinimum(0);
929 m_spinBoxPeerTurnover
.setMaximum(100);
930 m_spinBoxPeerTurnover
.setValue(session
->peerTurnover());
931 m_spinBoxPeerTurnover
.setSuffix(u
" %"_s
);
932 addRow(PEER_TURNOVER
, (tr("Peer turnover disconnect percentage") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#peer_turnover", u
"(?)"))
933 , &m_spinBoxPeerTurnover
);
934 m_spinBoxPeerTurnoverCutoff
.setMinimum(0);
935 m_spinBoxPeerTurnoverCutoff
.setMaximum(100);
936 m_spinBoxPeerTurnoverCutoff
.setSuffix(u
" %"_s
);
937 m_spinBoxPeerTurnoverCutoff
.setValue(session
->peerTurnoverCutoff());
938 addRow(PEER_TURNOVER_CUTOFF
, (tr("Peer turnover threshold percentage") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#peer_turnover", u
"(?)"))
939 , &m_spinBoxPeerTurnoverCutoff
);
940 m_spinBoxPeerTurnoverInterval
.setMinimum(30);
941 m_spinBoxPeerTurnoverInterval
.setMaximum(3600);
942 m_spinBoxPeerTurnoverInterval
.setSuffix(tr(" s", " seconds"));
943 m_spinBoxPeerTurnoverInterval
.setValue(session
->peerTurnoverInterval());
944 addRow(PEER_TURNOVER_INTERVAL
, (tr("Peer turnover disconnect interval") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#peer_turnover", u
"(?)"))
945 , &m_spinBoxPeerTurnoverInterval
);
946 // Maximum outstanding requests to a single peer
947 m_spinBoxRequestQueueSize
.setMinimum(1);
948 m_spinBoxRequestQueueSize
.setMaximum(std::numeric_limits
<int>::max());
949 m_spinBoxRequestQueueSize
.setValue(session
->requestQueueSize());
950 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
"(?)"))
951 , &m_spinBoxRequestQueueSize
);
952 // DHT bootstrap nodes
953 m_lineEditDHTBootstrapNodes
.setPlaceholderText(tr("Resets to default if empty"));
954 m_lineEditDHTBootstrapNodes
.setText(session
->getDHTBootstrapNodes());
955 addRow(DHT_BOOTSTRAP_NODES
, (tr("DHT bootstrap nodes") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#dht_bootstrap_nodes", u
"(?)"))
956 , &m_lineEditDHTBootstrapNodes
);
957 #if defined(QBT_USES_LIBTORRENT2) && TORRENT_USE_I2P
958 // I2P session options
959 m_spinBoxI2PInboundQuantity
.setMinimum(1);
960 m_spinBoxI2PInboundQuantity
.setMaximum(16);
961 m_spinBoxI2PInboundQuantity
.setValue(session
->I2PInboundQuantity());
962 addRow(I2P_INBOUND_QUANTITY
, (tr("I2P inbound quantity") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#i2p_inbound_quantity", u
"(?)"))
963 , &m_spinBoxI2PInboundQuantity
);
964 m_spinBoxI2POutboundQuantity
.setMinimum(1);
965 m_spinBoxI2POutboundQuantity
.setMaximum(16);
966 m_spinBoxI2POutboundQuantity
.setValue(session
->I2POutboundQuantity());
967 addRow(I2P_OUTBOUND_QUANTITY
, (tr("I2P outbound quantity") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#i2p_outbound_quantity", u
"(?)"))
968 , &m_spinBoxI2POutboundQuantity
);
969 m_spinBoxI2PInboundLength
.setMinimum(0);
970 m_spinBoxI2PInboundLength
.setMaximum(7);
971 m_spinBoxI2PInboundLength
.setValue(session
->I2PInboundLength());
972 addRow(I2P_INBOUND_LENGTH
, (tr("I2P inbound length") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#i2p_inbound_length", u
"(?)"))
973 , &m_spinBoxI2PInboundLength
);
974 m_spinBoxI2POutboundLength
.setMinimum(0);
975 m_spinBoxI2POutboundLength
.setMaximum(7);
976 m_spinBoxI2POutboundLength
.setValue(session
->I2POutboundLength());
977 addRow(I2P_OUTBOUND_LENGTH
, (tr("I2P outbound length") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#i2p_outbound_length", u
"(?)"))
978 , &m_spinBoxI2POutboundLength
);
982 template <typename T
>
983 void AdvancedSettings::addRow(const int row
, const QString
&text
, T
*widget
)
985 auto *label
= new QLabel(text
);
986 label
->setOpenExternalLinks(true);
987 label
->setToolTip(widget
->toolTip());
989 setCellWidget(row
, PROPERTY
, label
);
990 setCellWidget(row
, VALUE
, widget
);
992 if constexpr (std::is_same_v
<T
, QCheckBox
>)
994 #if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
995 connect(widget
, &QCheckBox::checkStateChanged
, this, &AdvancedSettings::settingsChanged
);
997 connect(widget
, &QCheckBox::stateChanged
, this, &AdvancedSettings::settingsChanged
);
1000 else if constexpr (std::is_same_v
<T
, QSpinBox
>)
1001 connect(widget
, qOverload
<int>(&QSpinBox::valueChanged
), this, &AdvancedSettings::settingsChanged
);
1002 else if constexpr (std::is_same_v
<T
, QComboBox
>)
1003 connect(widget
, qOverload
<int>(&QComboBox::currentIndexChanged
), this, &AdvancedSettings::settingsChanged
);
1004 else if constexpr (std::is_same_v
<T
, QLineEdit
>)
1005 connect(widget
, &QLineEdit::textChanged
, this, &AdvancedSettings::settingsChanged
);