2 * Bittorrent Client using Qt and libtorrent.
3 * Copyright (C) 2016 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 #if defined(QBT_USES_LIBTORRENT2) && !defined(Q_OS_MACOS)
67 MEMORY_WORKING_SET_LIMIT
,
74 //Optional network address
75 NETWORK_IFACE_ADDRESS
,
77 SAVE_RESUME_DATA_INTERVAL
,
78 TORRENT_FILE_SIZE_LIMIT
,
79 CONFIRM_RECHECK_TORRENT
,
86 PROGRAM_NOTIFICATIONS
,
87 TORRENT_ADDED_NOTIFICATIONS
,
91 CONFIRM_REMOVE_ALL_TAGS
,
92 CONFIRM_REMOVE_TRACKER_FROM_ALL_TORRENTS
,
93 REANNOUNCE_WHEN_ADDRESS_CHANGED
,
94 DOWNLOAD_TRACKER_FAVICON
,
95 SAVE_PATH_HISTORY_LENGTH
,
98 ENABLE_ICONS_IN_MENUS
,
103 TRACKER_PORT_FORWARDING
,
104 #if defined(Q_OS_MACOS) || defined(Q_OS_WIN)
105 ENABLE_MARK_OF_THE_WEB
,
106 #endif // Q_OS_MACOS || Q_OS_WIN
107 PYTHON_EXECUTABLE_PATH
,
109 // libtorrent section
114 #ifdef QBT_USES_LIBTORRENT2
119 #ifndef QBT_USES_LIBTORRENT2
125 #ifdef QBT_USES_LIBTORRENT2
130 #ifndef QBT_USES_LIBTORRENT2
133 PIECE_EXTENT_AFFINITY
,
136 SEND_BUF_LOW_WATERMARK
,
137 SEND_BUF_WATERMARK_FACTOR
,
138 // networking & ports
140 SOCKET_SEND_BUFFER_SIZE
,
141 SOCKET_RECEIVE_BUFFER_SIZE
,
149 MULTI_CONNECTIONS_PER_IP
,
150 VALIDATE_HTTPS_TRACKER_CERTIFICATE
,
152 BLOCK_PEERS_ON_PRIVILEGED_PORTS
,
155 SEED_CHOKING_ALGORITHM
,
157 ANNOUNCE_ALL_TRACKERS
,
160 MAX_CONCURRENT_HTTP_ANNOUNCES
,
161 STOP_TRACKER_TIMEOUT
,
163 PEER_TURNOVER_CUTOFF
,
164 PEER_TURNOVER_INTERVAL
,
167 #if defined(QBT_USES_LIBTORRENT2) && TORRENT_USE_I2P
168 I2P_INBOUND_QUANTITY
,
169 I2P_OUTBOUND_QUANTITY
,
178 AdvancedSettings::AdvancedSettings(IGUIApplication
*app
, QWidget
*parent
)
179 : GUIApplicationComponent(app
, parent
)
182 setColumnCount(COL_COUNT
);
183 const QStringList header
= {tr("Setting"), tr("Value", "Value set for this setting")};
184 setHorizontalHeaderLabels(header
);
186 setRowCount(ROW_COUNT
);
187 verticalHeader()->setVisible(false);
189 setAlternatingRowColors(true);
190 setSelectionMode(QAbstractItemView::NoSelection
);
191 setEditTriggers(QAbstractItemView::NoEditTriggers
);
193 loadAdvancedSettings();
194 resizeColumnToContents(0);
195 horizontalHeader()->setStretchLastSection(true);
198 void AdvancedSettings::saveAdvancedSettings() const
200 Preferences
*const pref
= Preferences::instance();
201 BitTorrent::Session
*const session
= BitTorrent::Session::instance();
203 session
->setResumeDataStorageType(m_comboBoxResumeDataStorage
.currentData().value
<BitTorrent::ResumeDataStorageType
>());
204 #if defined(QBT_USES_LIBTORRENT2) && !defined(Q_OS_MACOS)
205 // Physical memory (RAM) usage limit
206 app()->setMemoryWorkingSetLimit(m_spinBoxMemoryWorkingSetLimit
.value());
208 #if defined(Q_OS_WIN)
209 app()->setProcessMemoryPriority(m_comboBoxOSMemoryPriority
.currentData().value
<MemoryPriority
>());
211 // Bdecode depth limit
212 pref
->setBdecodeDepthLimit(m_spinBoxBdecodeDepthLimit
.value());
213 // Bdecode token limit
214 pref
->setBdecodeTokenLimit(m_spinBoxBdecodeTokenLimit
.value());
216 session
->setAsyncIOThreads(m_spinBoxAsyncIOThreads
.value());
217 #ifdef QBT_USES_LIBTORRENT2
219 session
->setHashingThreads(m_spinBoxHashingThreads
.value());
222 session
->setFilePoolSize(m_spinBoxFilePoolSize
.value());
223 // Checking Memory Usage
224 session
->setCheckingMemUsage(m_spinBoxCheckingMemUsage
.value());
225 #ifndef QBT_USES_LIBTORRENT2
227 session
->setDiskCacheSize(m_spinBoxCache
.value());
228 session
->setDiskCacheTTL(m_spinBoxCacheTTL
.value());
231 session
->setDiskQueueSize(m_spinBoxDiskQueueSize
.value() * 1024);
232 #ifdef QBT_USES_LIBTORRENT2
233 session
->setDiskIOType(m_comboBoxDiskIOType
.currentData().value
<BitTorrent::DiskIOType
>());
236 session
->setDiskIOReadMode(m_comboBoxDiskIOReadMode
.currentData().value
<BitTorrent::DiskIOReadMode
>());
237 // Disk IO write mode
238 session
->setDiskIOWriteMode(m_comboBoxDiskIOWriteMode
.currentData().value
<BitTorrent::DiskIOWriteMode
>());
239 #ifndef QBT_USES_LIBTORRENT2
240 // Coalesce reads & writes
241 session
->setCoalesceReadWriteEnabled(m_checkBoxCoalesceRW
.isChecked());
243 // Piece extent affinity
244 session
->setPieceExtentAffinity(m_checkBoxPieceExtentAffinity
.isChecked());
246 session
->setSuggestMode(m_checkBoxSuggestMode
.isChecked());
247 // Send buffer watermark
248 session
->setSendBufferWatermark(m_spinBoxSendBufferWatermark
.value());
249 session
->setSendBufferLowWatermark(m_spinBoxSendBufferLowWatermark
.value());
250 session
->setSendBufferWatermarkFactor(m_spinBoxSendBufferWatermarkFactor
.value());
251 // Outgoing connections per second
252 session
->setConnectionSpeed(m_spinBoxConnectionSpeed
.value());
253 // Socket send buffer size
254 session
->setSocketSendBufferSize(m_spinBoxSocketSendBufferSize
.value() * 1024);
255 // Socket receive buffer size
256 session
->setSocketReceiveBufferSize(m_spinBoxSocketReceiveBufferSize
.value() * 1024);
257 // Socket listen backlog size
258 session
->setSocketBacklogSize(m_spinBoxSocketBacklogSize
.value());
259 // Save resume data interval
260 session
->setSaveResumeDataInterval(m_spinBoxSaveResumeDataInterval
.value());
261 // .torrent file size limit
262 pref
->setTorrentFileSizeLimit(m_spinBoxTorrentFileSizeLimit
.value() * 1024 * 1024);
264 session
->setOutgoingPortsMin(m_spinBoxOutgoingPortsMin
.value());
265 session
->setOutgoingPortsMax(m_spinBoxOutgoingPortsMax
.value());
266 // UPnP lease duration
267 session
->setUPnPLeaseDuration(m_spinBoxUPnPLeaseDuration
.value());
269 session
->setPeerToS(m_spinBoxPeerToS
.value());
270 // uTP-TCP mixed mode
271 session
->setUtpMixedMode(m_comboBoxUtpMixedMode
.currentData().value
<BitTorrent::MixedModeAlgorithm
>());
272 // Support internationalized domain name (IDN)
273 session
->setIDNSupportEnabled(m_checkBoxIDNSupport
.isChecked());
274 // multiple connections per IP
275 session
->setMultiConnectionsPerIpEnabled(m_checkBoxMultiConnectionsPerIp
.isChecked());
276 // Validate HTTPS tracker certificate
277 session
->setValidateHTTPSTrackerCertificate(m_checkBoxValidateHTTPSTrackerCertificate
.isChecked());
279 session
->setSSRFMitigationEnabled(m_checkBoxSSRFMitigation
.isChecked());
280 // Disallow connection to peers on privileged ports
281 session
->setBlockPeersOnPrivilegedPorts(m_checkBoxBlockPeersOnPrivilegedPorts
.isChecked());
282 // Recheck torrents on completion
283 pref
->recheckTorrentsOnCompletion(m_checkBoxRecheckCompleted
.isChecked());
284 // Customize application instance name
285 app()->setInstanceName(m_lineEditAppInstanceName
.text());
286 // Transfer list refresh interval
287 session
->setRefreshInterval(m_spinBoxListRefresh
.value());
289 pref
->resolvePeerCountries(m_checkBoxResolveCountries
.isChecked());
290 pref
->resolvePeerHostNames(m_checkBoxResolveHosts
.isChecked());
292 session
->setNetworkInterface(m_comboBoxInterface
.currentData().toString());
293 session
->setNetworkInterfaceName((m_comboBoxInterface
.currentIndex() == 0)
295 : m_comboBoxInterface
.currentText());
297 // Construct a QHostAddress to filter malformed strings
298 const QHostAddress ifaceAddr
{m_comboBoxInterfaceAddress
.currentData().toString()};
299 session
->setNetworkInterfaceAddress(ifaceAddr
.toString());
301 // Construct a QHostAddress to filter malformed strings
302 const QHostAddress
addr(m_lineEditAnnounceIP
.text().trimmed());
303 session
->setAnnounceIP(addr
.toString());
304 // Max concurrent HTTP announces
305 session
->setMaxConcurrentHTTPAnnounces(m_spinBoxMaxConcurrentHTTPAnnounces
.value());
306 // Stop tracker timeout
307 session
->setStopTrackerTimeout(m_spinBoxStopTrackerTimeout
.value());
308 // Program notification
309 app()->desktopIntegration()->setNotificationsEnabled(m_checkBoxProgramNotifications
.isChecked());
311 app()->desktopIntegration()->setNotificationTimeout(m_spinBoxNotificationTimeout
.value());
313 app()->setTorrentAddedNotificationsEnabled(m_checkBoxTorrentAddedNotifications
.isChecked());
314 // Reannounce to all trackers when ip/port changed
315 session
->setReannounceWhenAddressChangedEnabled(m_checkBoxReannounceWhenAddressChanged
.isChecked());
316 // Misc GUI properties
317 app()->mainWindow()->setDownloadTrackerFavicon(m_checkBoxTrackerFavicon
.isChecked());
318 pref
->setAddNewTorrentDialogSavePathHistoryLength(m_spinBoxSavePathHistoryLength
.value());
319 pref
->setSpeedWidgetEnabled(m_checkBoxSpeedWidgetEnabled
.isChecked());
321 pref
->setIconsInMenusEnabled(m_checkBoxIconsInMenusEnabled
.isChecked());
325 pref
->setTrackerPort(m_spinBoxTrackerPort
.value());
326 pref
->setTrackerPortForwardingEnabled(m_checkBoxTrackerPortForwarding
.isChecked());
327 session
->setTrackerEnabled(m_checkBoxTrackerStatus
.isChecked());
328 #if defined(Q_OS_MACOS) || defined(Q_OS_WIN)
330 pref
->setMarkOfTheWebEnabled(m_checkBoxMarkOfTheWeb
.isChecked());
331 #endif // Q_OS_MACOS || Q_OS_WIN
332 // Python executable path
333 pref
->setPythonExecutablePath(Path(m_pythonExecutablePath
.text().trimmed()));
335 session
->setChokingAlgorithm(m_comboBoxChokingAlgorithm
.currentData().value
<BitTorrent::ChokingAlgorithm
>());
336 // Seed choking algorithm
337 session
->setSeedChokingAlgorithm(m_comboBoxSeedChokingAlgorithm
.currentData().value
<BitTorrent::SeedChokingAlgorithm
>());
339 pref
->setConfirmTorrentRecheck(m_checkBoxConfirmTorrentRecheck
.isChecked());
341 pref
->setConfirmRemoveAllTags(m_checkBoxConfirmRemoveAllTags
.isChecked());
342 pref
->setConfirmRemoveTrackerFromAllTorrents(m_checkBoxConfirmRemoveTrackerFromAllTorrents
.isChecked());
344 session
->setAnnounceToAllTrackers(m_checkBoxAnnounceAllTrackers
.isChecked());
345 session
->setAnnounceToAllTiers(m_checkBoxAnnounceAllTiers
.isChecked());
347 session
->setPeerTurnover(m_spinBoxPeerTurnover
.value());
348 session
->setPeerTurnoverCutoff(m_spinBoxPeerTurnoverCutoff
.value());
349 session
->setPeerTurnoverInterval(m_spinBoxPeerTurnoverInterval
.value());
350 // Maximum outstanding requests to a single peer
351 session
->setRequestQueueSize(m_spinBoxRequestQueueSize
.value());
352 // DHT bootstrap nodes
353 session
->setDHTBootstrapNodes(m_lineEditDHTBootstrapNodes
.text());
354 #if defined(QBT_USES_LIBTORRENT2) && TORRENT_USE_I2P
355 // I2P session options
356 session
->setI2PInboundQuantity(m_spinBoxI2PInboundQuantity
.value());
357 session
->setI2POutboundQuantity(m_spinBoxI2POutboundQuantity
.value());
358 session
->setI2PInboundLength(m_spinBoxI2PInboundLength
.value());
359 session
->setI2POutboundLength(m_spinBoxI2POutboundLength
.value());
363 #ifndef QBT_USES_LIBTORRENT2
364 void AdvancedSettings::updateCacheSpinSuffix(const int value
)
367 m_spinBoxCache
.setSuffix(tr(" (disabled)"));
369 m_spinBoxCache
.setSuffix(tr(" (auto)"));
371 m_spinBoxCache
.setSuffix(tr(" MiB"));
376 void AdvancedSettings::updateNotificationTimeoutSuffix(const int value
)
379 m_spinBoxNotificationTimeout
.setSuffix(tr(" (infinite)"));
381 m_spinBoxNotificationTimeout
.setSuffix(tr(" (system default)"));
383 m_spinBoxNotificationTimeout
.setSuffix(tr(" ms", " milliseconds"));
387 void AdvancedSettings::updateInterfaceAddressCombo()
389 const auto toString
= [](const QHostAddress
&address
) -> QString
391 switch (address
.protocol()) {
392 case QAbstractSocket::IPv4Protocol
:
393 return address
.toString();
394 case QAbstractSocket::IPv6Protocol
:
395 return Utils::Net::canonicalIPv6Addr(address
).toString();
403 // Clear all items and reinsert them
404 m_comboBoxInterfaceAddress
.clear();
405 m_comboBoxInterfaceAddress
.addItem(tr("All addresses"), QString());
406 m_comboBoxInterfaceAddress
.addItem(tr("All IPv4 addresses"), QHostAddress(QHostAddress::AnyIPv4
).toString());
407 m_comboBoxInterfaceAddress
.addItem(tr("All IPv6 addresses"), QHostAddress(QHostAddress::AnyIPv6
).toString());
409 const QString currentIface
= m_comboBoxInterface
.currentData().toString();
410 if (currentIface
.isEmpty()) // `any` interface
412 for (const QHostAddress
&address
: asConst(QNetworkInterface::allAddresses()))
414 const QString addressString
= toString(address
);
415 m_comboBoxInterfaceAddress
.addItem(addressString
, addressString
);
420 const QList
<QNetworkAddressEntry
> addresses
= QNetworkInterface::interfaceFromName(currentIface
).addressEntries();
421 for (const QNetworkAddressEntry
&entry
: addresses
)
423 const QString addressString
= toString(entry
.ip());
424 m_comboBoxInterfaceAddress
.addItem(addressString
, addressString
);
428 const QString currentAddress
= BitTorrent::Session::instance()->networkInterfaceAddress();
429 const int index
= m_comboBoxInterfaceAddress
.findData(currentAddress
);
432 m_comboBoxInterfaceAddress
.setCurrentIndex(index
);
436 // not found, for the sake of UI consistency, add such entry
437 m_comboBoxInterfaceAddress
.addItem(currentAddress
, currentAddress
);
438 m_comboBoxInterfaceAddress
.setCurrentIndex(m_comboBoxInterfaceAddress
.count() - 1);
442 void AdvancedSettings::loadAdvancedSettings()
444 const Preferences
*const pref
= Preferences::instance();
445 const BitTorrent::Session
*const session
= BitTorrent::Session::instance();
447 // add section headers
448 auto *labelQbtLink
= new QLabel(
449 makeLink(u
"https://github.com/qbittorrent/qBittorrent/wiki/Explanation-of-Options-in-qBittorrent#Advanced"
450 , tr("Open documentation"))
452 labelQbtLink
->setOpenExternalLinks(true);
453 addRow(QBITTORRENT_HEADER
, u
"<b>%1</b>"_s
.arg(tr("qBittorrent Section")), labelQbtLink
);
454 static_cast<QLabel
*>(cellWidget(QBITTORRENT_HEADER
, PROPERTY
))->setAlignment(Qt::AlignCenter
| Qt::AlignVCenter
);
456 auto *labelLibtorrentLink
= new QLabel(
457 makeLink(u
"https://www.libtorrent.org/reference-Settings.html"
458 , tr("Open documentation"))
460 labelLibtorrentLink
->setOpenExternalLinks(true);
461 addRow(LIBTORRENT_HEADER
, u
"<b>%1</b>"_s
.arg(tr("libtorrent Section")), labelLibtorrentLink
);
462 static_cast<QLabel
*>(cellWidget(LIBTORRENT_HEADER
, PROPERTY
))->setAlignment(Qt::AlignCenter
| Qt::AlignVCenter
);
464 m_comboBoxResumeDataStorage
.addItem(tr("Fastresume files"), QVariant::fromValue(BitTorrent::ResumeDataStorageType::Legacy
));
465 m_comboBoxResumeDataStorage
.addItem(tr("SQLite database (experimental)"), QVariant::fromValue(BitTorrent::ResumeDataStorageType::SQLite
));
466 m_comboBoxResumeDataStorage
.setCurrentIndex(m_comboBoxResumeDataStorage
.findData(QVariant::fromValue(session
->resumeDataStorageType())));
467 addRow(RESUME_DATA_STORAGE
, tr("Resume data storage type (requires restart)"), &m_comboBoxResumeDataStorage
);
469 #if defined(QBT_USES_LIBTORRENT2) && !defined(Q_OS_MACOS)
470 // Physical memory (RAM) usage limit
471 m_spinBoxMemoryWorkingSetLimit
.setMinimum(1);
472 m_spinBoxMemoryWorkingSetLimit
.setMaximum(std::numeric_limits
<int>::max());
473 m_spinBoxMemoryWorkingSetLimit
.setSuffix(tr(" MiB"));
474 m_spinBoxMemoryWorkingSetLimit
.setToolTip(tr("This option is less effective on Linux"));
475 m_spinBoxMemoryWorkingSetLimit
.setValue(app()->memoryWorkingSetLimit());
476 addRow(MEMORY_WORKING_SET_LIMIT
, (tr("Physical memory (RAM) usage limit") + u
' ' + makeLink(u
"https://wikipedia.org/wiki/Working_set", u
"(?)"))
477 , &m_spinBoxMemoryWorkingSetLimit
);
479 #if defined(Q_OS_WIN)
480 m_comboBoxOSMemoryPriority
.addItem(tr("Normal"), QVariant::fromValue(MemoryPriority::Normal
));
481 m_comboBoxOSMemoryPriority
.addItem(tr("Below normal"), QVariant::fromValue(MemoryPriority::BelowNormal
));
482 m_comboBoxOSMemoryPriority
.addItem(tr("Medium"), QVariant::fromValue(MemoryPriority::Medium
));
483 m_comboBoxOSMemoryPriority
.addItem(tr("Low"), QVariant::fromValue(MemoryPriority::Low
));
484 m_comboBoxOSMemoryPriority
.addItem(tr("Very low"), QVariant::fromValue(MemoryPriority::VeryLow
));
485 m_comboBoxOSMemoryPriority
.setCurrentIndex(m_comboBoxOSMemoryPriority
.findData(QVariant::fromValue(app()->processMemoryPriority())));
486 addRow(OS_MEMORY_PRIORITY
, (tr("Process memory priority")
487 + u
' ' + makeLink(u
"https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/ns-processthreadsapi-memory_priority_information", u
"(?)"))
488 , &m_comboBoxOSMemoryPriority
);
490 // Bdecode depth limit
491 m_spinBoxBdecodeDepthLimit
.setMinimum(0);
492 m_spinBoxBdecodeDepthLimit
.setMaximum(std::numeric_limits
<int>::max());
493 m_spinBoxBdecodeDepthLimit
.setValue(pref
->getBdecodeDepthLimit());
494 addRow(BDECODE_DEPTH_LIMIT
, (tr("Bdecode depth limit") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Bdecoding.html#bdecode()", u
"(?)"))
495 , &m_spinBoxBdecodeDepthLimit
);
496 // Bdecode token limit
497 m_spinBoxBdecodeTokenLimit
.setMinimum(0);
498 m_spinBoxBdecodeTokenLimit
.setMaximum(std::numeric_limits
<int>::max());
499 m_spinBoxBdecodeTokenLimit
.setValue(pref
->getBdecodeTokenLimit());
500 addRow(BDECODE_TOKEN_LIMIT
, (tr("Bdecode token limit") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Bdecoding.html#bdecode()", u
"(?)"))
501 , &m_spinBoxBdecodeTokenLimit
);
503 m_spinBoxAsyncIOThreads
.setMinimum(1);
504 m_spinBoxAsyncIOThreads
.setMaximum(1024);
505 m_spinBoxAsyncIOThreads
.setValue(session
->asyncIOThreads());
506 addRow(ASYNC_IO_THREADS
, (tr("Asynchronous I/O threads") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#aio_threads", u
"(?)"))
507 , &m_spinBoxAsyncIOThreads
);
509 #ifdef QBT_USES_LIBTORRENT2
511 m_spinBoxHashingThreads
.setMinimum(1);
512 m_spinBoxHashingThreads
.setMaximum(1024);
513 m_spinBoxHashingThreads
.setValue(session
->hashingThreads());
514 addRow(HASHING_THREADS
, (tr("Hashing threads") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#hashing_threads", u
"(?)"))
515 , &m_spinBoxHashingThreads
);
519 m_spinBoxFilePoolSize
.setMinimum(1);
520 m_spinBoxFilePoolSize
.setMaximum(std::numeric_limits
<int>::max());
521 m_spinBoxFilePoolSize
.setValue(session
->filePoolSize());
522 addRow(FILE_POOL_SIZE
, (tr("File pool size") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#file_pool_size", u
"(?)"))
523 , &m_spinBoxFilePoolSize
);
525 // Checking Memory Usage
526 m_spinBoxCheckingMemUsage
.setMinimum(1);
527 // When build as 32bit binary, set the maximum value lower to prevent crashes.
529 m_spinBoxCheckingMemUsage
.setMaximum(1024);
531 // Allocate at most 128MiB out of the remaining 512MiB (see the cache part below)
532 m_spinBoxCheckingMemUsage
.setMaximum(128);
534 m_spinBoxCheckingMemUsage
.setValue(session
->checkingMemUsage());
535 m_spinBoxCheckingMemUsage
.setSuffix(tr(" MiB"));
536 addRow(CHECKING_MEM_USAGE
, (tr("Outstanding memory when checking torrents") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#checking_mem_usage", u
"(?)"))
537 , &m_spinBoxCheckingMemUsage
);
538 #ifndef QBT_USES_LIBTORRENT2
540 m_spinBoxCache
.setMinimum(-1);
541 // When build as 32bit binary, set the maximum at less than 2GB to prevent crashes.
543 m_spinBoxCache
.setMaximum(33554431); // 32768GiB
545 // allocate 1536MiB and leave 512MiB to the rest of program data in RAM
546 m_spinBoxCache
.setMaximum(1536);
548 m_spinBoxCache
.setValue(session
->diskCacheSize());
549 updateCacheSpinSuffix(m_spinBoxCache
.value());
550 connect(&m_spinBoxCache
, qOverload
<int>(&QSpinBox::valueChanged
)
551 , this, &AdvancedSettings::updateCacheSpinSuffix
);
552 addRow(DISK_CACHE
, (tr("Disk cache") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#cache_size", u
"(?)"))
555 m_spinBoxCacheTTL
.setMinimum(1);
556 m_spinBoxCacheTTL
.setMaximum(std::numeric_limits
<int>::max());
557 m_spinBoxCacheTTL
.setValue(session
->diskCacheTTL());
558 m_spinBoxCacheTTL
.setSuffix(tr(" s", " seconds"));
559 addRow(DISK_CACHE_TTL
, (tr("Disk cache expiry interval") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#cache_expiry", u
"(?)"))
560 , &m_spinBoxCacheTTL
);
563 m_spinBoxDiskQueueSize
.setMinimum(1);
564 m_spinBoxDiskQueueSize
.setMaximum(std::numeric_limits
<int>::max() / 1024);
565 m_spinBoxDiskQueueSize
.setValue(session
->diskQueueSize() / 1024);
566 m_spinBoxDiskQueueSize
.setSuffix(tr(" KiB"));
567 addRow(DISK_QUEUE_SIZE
, (tr("Disk queue size") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#max_queued_disk_bytes", u
"(?)"))
568 , &m_spinBoxDiskQueueSize
);
569 #ifdef QBT_USES_LIBTORRENT2
571 m_comboBoxDiskIOType
.addItem(tr("Default"), QVariant::fromValue(BitTorrent::DiskIOType::Default
));
572 m_comboBoxDiskIOType
.addItem(tr("Memory mapped files"), QVariant::fromValue(BitTorrent::DiskIOType::MMap
));
573 m_comboBoxDiskIOType
.addItem(tr("POSIX-compliant"), QVariant::fromValue(BitTorrent::DiskIOType::Posix
));
574 m_comboBoxDiskIOType
.setCurrentIndex(m_comboBoxDiskIOType
.findData(QVariant::fromValue(session
->diskIOType())));
575 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
"(?)")
576 , &m_comboBoxDiskIOType
);
579 m_comboBoxDiskIOReadMode
.addItem(tr("Disable OS cache"), QVariant::fromValue(BitTorrent::DiskIOReadMode::DisableOSCache
));
580 m_comboBoxDiskIOReadMode
.addItem(tr("Enable OS cache"), QVariant::fromValue(BitTorrent::DiskIOReadMode::EnableOSCache
));
581 m_comboBoxDiskIOReadMode
.setCurrentIndex(m_comboBoxDiskIOReadMode
.findData(QVariant::fromValue(session
->diskIOReadMode())));
582 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
"(?)"))
583 , &m_comboBoxDiskIOReadMode
);
584 // Disk IO write mode
585 m_comboBoxDiskIOWriteMode
.addItem(tr("Disable OS cache"), QVariant::fromValue(BitTorrent::DiskIOWriteMode::DisableOSCache
));
586 m_comboBoxDiskIOWriteMode
.addItem(tr("Enable OS cache"), QVariant::fromValue(BitTorrent::DiskIOWriteMode::EnableOSCache
));
587 #ifdef QBT_USES_LIBTORRENT2
588 m_comboBoxDiskIOWriteMode
.addItem(tr("Write-through"), QVariant::fromValue(BitTorrent::DiskIOWriteMode::WriteThrough
));
590 m_comboBoxDiskIOWriteMode
.setCurrentIndex(m_comboBoxDiskIOWriteMode
.findData(QVariant::fromValue(session
->diskIOWriteMode())));
591 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
"(?)"))
592 , &m_comboBoxDiskIOWriteMode
);
593 #ifndef QBT_USES_LIBTORRENT2
594 // Coalesce reads & writes
595 m_checkBoxCoalesceRW
.setChecked(session
->isCoalesceReadWriteEnabled());
596 addRow(COALESCE_RW
, (tr("Coalesce reads & writes") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#coalesce_reads", u
"(?)"))
597 , &m_checkBoxCoalesceRW
);
599 // Piece extent affinity
600 m_checkBoxPieceExtentAffinity
.setChecked(session
->usePieceExtentAffinity());
601 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
);
603 m_checkBoxSuggestMode
.setChecked(session
->isSuggestModeEnabled());
604 addRow(SUGGEST_MODE
, (tr("Send upload piece suggestions") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#suggest_mode", u
"(?)"))
605 , &m_checkBoxSuggestMode
);
606 // Send buffer watermark
607 m_spinBoxSendBufferWatermark
.setMinimum(1);
608 m_spinBoxSendBufferWatermark
.setMaximum(std::numeric_limits
<int>::max());
609 m_spinBoxSendBufferWatermark
.setSuffix(tr(" KiB"));
610 m_spinBoxSendBufferWatermark
.setValue(session
->sendBufferWatermark());
611 addRow(SEND_BUF_WATERMARK
, (tr("Send buffer watermark") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#send_buffer_watermark", u
"(?)"))
612 , &m_spinBoxSendBufferWatermark
);
613 m_spinBoxSendBufferLowWatermark
.setMinimum(1);
614 m_spinBoxSendBufferLowWatermark
.setMaximum(std::numeric_limits
<int>::max());
615 m_spinBoxSendBufferLowWatermark
.setSuffix(tr(" KiB"));
616 m_spinBoxSendBufferLowWatermark
.setValue(session
->sendBufferLowWatermark());
617 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
"(?)"))
618 , &m_spinBoxSendBufferLowWatermark
);
619 m_spinBoxSendBufferWatermarkFactor
.setMinimum(1);
620 m_spinBoxSendBufferWatermarkFactor
.setMaximum(std::numeric_limits
<int>::max());
621 m_spinBoxSendBufferWatermarkFactor
.setSuffix(u
" %"_s
);
622 m_spinBoxSendBufferWatermarkFactor
.setValue(session
->sendBufferWatermarkFactor());
623 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
"(?)"))
624 , &m_spinBoxSendBufferWatermarkFactor
);
625 // Outgoing connections per second
626 m_spinBoxConnectionSpeed
.setMinimum(0);
627 m_spinBoxConnectionSpeed
.setMaximum(std::numeric_limits
<int>::max());
628 m_spinBoxConnectionSpeed
.setValue(session
->connectionSpeed());
629 addRow(CONNECTION_SPEED
, (tr("Outgoing connections per second") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#connection_speed", u
"(?)"))
630 , &m_spinBoxConnectionSpeed
);
631 // Socket send buffer size
632 m_spinBoxSocketSendBufferSize
.setMinimum(0);
633 m_spinBoxSocketSendBufferSize
.setMaximum(std::numeric_limits
<int>::max() / 1024);
634 m_spinBoxSocketSendBufferSize
.setValue(session
->socketSendBufferSize() / 1024);
635 m_spinBoxSocketSendBufferSize
.setSuffix(tr(" KiB"));
636 m_spinBoxSocketSendBufferSize
.setSpecialValueText(tr("0 (system default)"));
637 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
"(?)"))
638 , &m_spinBoxSocketSendBufferSize
);
639 // Socket receive buffer size
640 m_spinBoxSocketReceiveBufferSize
.setMinimum(0);
641 m_spinBoxSocketReceiveBufferSize
.setMaximum(std::numeric_limits
<int>::max() / 1024);
642 m_spinBoxSocketReceiveBufferSize
.setValue(session
->socketReceiveBufferSize() / 1024);
643 m_spinBoxSocketReceiveBufferSize
.setSuffix(tr(" KiB"));
644 m_spinBoxSocketReceiveBufferSize
.setSpecialValueText(tr("0 (system default)"));
645 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
"(?)"))
646 , &m_spinBoxSocketReceiveBufferSize
);
647 // Socket listen backlog size
648 m_spinBoxSocketBacklogSize
.setMinimum(1);
649 m_spinBoxSocketBacklogSize
.setMaximum(std::numeric_limits
<int>::max());
650 m_spinBoxSocketBacklogSize
.setValue(session
->socketBacklogSize());
651 addRow(SOCKET_BACKLOG_SIZE
, (tr("Socket backlog size") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#listen_queue_size", u
"(?)"))
652 , &m_spinBoxSocketBacklogSize
);
653 // Save resume data interval
654 m_spinBoxSaveResumeDataInterval
.setMinimum(0);
655 m_spinBoxSaveResumeDataInterval
.setMaximum(std::numeric_limits
<int>::max());
656 m_spinBoxSaveResumeDataInterval
.setValue(session
->saveResumeDataInterval());
657 m_spinBoxSaveResumeDataInterval
.setSuffix(tr(" min", " minutes"));
658 m_spinBoxSaveResumeDataInterval
.setSpecialValueText(tr("0 (disabled)"));
659 addRow(SAVE_RESUME_DATA_INTERVAL
, tr("Save resume data interval [0: disabled]", "How often the fastresume file is saved."), &m_spinBoxSaveResumeDataInterval
);
660 // .torrent file size limit
661 m_spinBoxTorrentFileSizeLimit
.setMinimum(1);
662 m_spinBoxTorrentFileSizeLimit
.setMaximum(std::numeric_limits
<int>::max() / 1024 / 1024);
663 m_spinBoxTorrentFileSizeLimit
.setValue(pref
->getTorrentFileSizeLimit() / 1024 / 1024);
664 m_spinBoxTorrentFileSizeLimit
.setSuffix(tr(" MiB"));
665 addRow(TORRENT_FILE_SIZE_LIMIT
, tr(".torrent file size limit"), &m_spinBoxTorrentFileSizeLimit
);
667 m_spinBoxOutgoingPortsMin
.setMinimum(0);
668 m_spinBoxOutgoingPortsMin
.setMaximum(65535);
669 m_spinBoxOutgoingPortsMin
.setValue(session
->outgoingPortsMin());
670 m_spinBoxOutgoingPortsMin
.setSpecialValueText(tr("0 (disabled)"));
671 addRow(OUTGOING_PORT_MIN
, (tr("Outgoing ports (Min) [0: disabled]")
672 + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#outgoing_port", u
"(?)"))
673 , &m_spinBoxOutgoingPortsMin
);
675 m_spinBoxOutgoingPortsMax
.setMinimum(0);
676 m_spinBoxOutgoingPortsMax
.setMaximum(65535);
677 m_spinBoxOutgoingPortsMax
.setValue(session
->outgoingPortsMax());
678 m_spinBoxOutgoingPortsMax
.setSpecialValueText(tr("0 (disabled)"));
679 addRow(OUTGOING_PORT_MAX
, (tr("Outgoing ports (Max) [0: disabled]")
680 + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#outgoing_port", u
"(?)"))
681 , &m_spinBoxOutgoingPortsMax
);
682 // UPnP lease duration
683 m_spinBoxUPnPLeaseDuration
.setMinimum(0);
684 m_spinBoxUPnPLeaseDuration
.setMaximum(std::numeric_limits
<int>::max());
685 m_spinBoxUPnPLeaseDuration
.setValue(session
->UPnPLeaseDuration());
686 m_spinBoxUPnPLeaseDuration
.setSuffix(tr(" s", " seconds"));
687 m_spinBoxUPnPLeaseDuration
.setSpecialValueText(tr("0 (permanent lease)"));
688 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
"(?)"))
689 , &m_spinBoxUPnPLeaseDuration
);
691 m_spinBoxPeerToS
.setMinimum(0);
692 m_spinBoxPeerToS
.setMaximum(255);
693 m_spinBoxPeerToS
.setValue(session
->peerToS());
694 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
"(?)"))
695 , &m_spinBoxPeerToS
);
696 // uTP-TCP mixed mode
697 m_comboBoxUtpMixedMode
.addItem(tr("Prefer TCP"), QVariant::fromValue(BitTorrent::MixedModeAlgorithm::TCP
));
698 m_comboBoxUtpMixedMode
.addItem(tr("Peer proportional (throttles TCP)"), QVariant::fromValue(BitTorrent::MixedModeAlgorithm::Proportional
));
699 m_comboBoxUtpMixedMode
.setCurrentIndex(m_comboBoxUtpMixedMode
.findData(QVariant::fromValue(session
->utpMixedMode())));
700 addRow(UTP_MIX_MODE
, (tr("%1-TCP mixed mode algorithm", "uTP-TCP mixed mode algorithm").arg(C_UTP
)
701 + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#mixed_mode_algorithm", u
"(?)"))
702 , &m_comboBoxUtpMixedMode
);
703 // Support internationalized domain name (IDN)
704 m_checkBoxIDNSupport
.setChecked(session
->isIDNSupportEnabled());
705 addRow(IDN_SUPPORT
, (tr("Support internationalized domain name (IDN)")
706 + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#allow_idna", u
"(?)"))
707 , &m_checkBoxIDNSupport
);
708 // multiple connections per IP
709 m_checkBoxMultiConnectionsPerIp
.setChecked(session
->multiConnectionsPerIpEnabled());
710 addRow(MULTI_CONNECTIONS_PER_IP
, (tr("Allow multiple connections from the same IP address")
711 + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#allow_multiple_connections_per_ip", u
"(?)"))
712 , &m_checkBoxMultiConnectionsPerIp
);
713 // Validate HTTPS tracker certificate
714 m_checkBoxValidateHTTPSTrackerCertificate
.setChecked(session
->validateHTTPSTrackerCertificate());
715 addRow(VALIDATE_HTTPS_TRACKER_CERTIFICATE
, (tr("Validate HTTPS tracker certificates")
716 + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#validate_https_trackers", u
"(?)"))
717 , &m_checkBoxValidateHTTPSTrackerCertificate
);
719 m_checkBoxSSRFMitigation
.setChecked(session
->isSSRFMitigationEnabled());
720 addRow(SSRF_MITIGATION
, (tr("Server-side request forgery (SSRF) mitigation")
721 + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#ssrf_mitigation", u
"(?)"))
722 , &m_checkBoxSSRFMitigation
);
723 // Disallow connection to peers on privileged ports
724 m_checkBoxBlockPeersOnPrivilegedPorts
.setChecked(session
->blockPeersOnPrivilegedPorts());
725 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
);
726 // Recheck completed torrents
727 m_checkBoxRecheckCompleted
.setChecked(pref
->recheckTorrentsOnCompletion());
728 addRow(RECHECK_COMPLETED
, tr("Recheck torrents on completion"), &m_checkBoxRecheckCompleted
);
729 // Customize application instance name
730 m_lineEditAppInstanceName
.setText(app()->instanceName());
731 m_lineEditAppInstanceName
.setToolTip(tr("It appends the text to the window title to help distinguish qBittorent instances"));
732 addRow(APP_INSTANCE_NAME
, tr("Customize application instance name"), &m_lineEditAppInstanceName
);
734 m_spinBoxListRefresh
.setMinimum(30);
735 m_spinBoxListRefresh
.setMaximum(99999);
736 m_spinBoxListRefresh
.setValue(session
->refreshInterval());
737 m_spinBoxListRefresh
.setSuffix(tr(" ms", " milliseconds"));
738 m_spinBoxListRefresh
.setToolTip(tr("It controls the internal state update interval which in turn will affect UI updates"));
739 addRow(LIST_REFRESH
, tr("Refresh interval"), &m_spinBoxListRefresh
);
740 // Resolve Peer countries
741 m_checkBoxResolveCountries
.setChecked(pref
->resolvePeerCountries());
742 addRow(RESOLVE_COUNTRIES
, tr("Resolve peer countries"), &m_checkBoxResolveCountries
);
743 // Resolve peer hosts
744 m_checkBoxResolveHosts
.setChecked(pref
->resolvePeerHostNames());
745 addRow(RESOLVE_HOSTS
, tr("Resolve peer host names"), &m_checkBoxResolveHosts
);
747 m_comboBoxInterface
.addItem(tr("Any interface", "i.e. Any network interface"), QString());
748 for (const QNetworkInterface
&iface
: asConst(QNetworkInterface::allInterfaces()))
749 m_comboBoxInterface
.addItem(iface
.humanReadableName(), iface
.name());
751 const QString currentInterface
= session
->networkInterface();
752 const int ifaceIndex
= m_comboBoxInterface
.findData(currentInterface
);
755 m_comboBoxInterface
.setCurrentIndex(ifaceIndex
);
759 // Saved interface does not exist, show it
760 m_comboBoxInterface
.addItem(session
->networkInterfaceName(), currentInterface
);
761 m_comboBoxInterface
.setCurrentIndex(m_comboBoxInterface
.count() - 1);
764 connect(&m_comboBoxInterface
, qOverload
<int>(&QComboBox::currentIndexChanged
)
765 , this, &AdvancedSettings::updateInterfaceAddressCombo
);
766 addRow(NETWORK_IFACE
, tr("Network interface"), &m_comboBoxInterface
);
767 // Network interface address
768 updateInterfaceAddressCombo();
769 addRow(NETWORK_IFACE_ADDRESS
, tr("Optional IP address to bind to"), &m_comboBoxInterfaceAddress
);
771 m_lineEditAnnounceIP
.setText(session
->announceIP());
772 addRow(ANNOUNCE_IP
, (tr("IP address reported to trackers (requires restart)")
773 + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#announce_ip", u
"(?)"))
774 , &m_lineEditAnnounceIP
);
775 // Max concurrent HTTP announces
776 m_spinBoxMaxConcurrentHTTPAnnounces
.setMaximum(std::numeric_limits
<int>::max());
777 m_spinBoxMaxConcurrentHTTPAnnounces
.setValue(session
->maxConcurrentHTTPAnnounces());
778 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
"(?)"))
779 , &m_spinBoxMaxConcurrentHTTPAnnounces
);
780 // Stop tracker timeout
781 m_spinBoxStopTrackerTimeout
.setMaximum(std::numeric_limits
<int>::max());
782 m_spinBoxStopTrackerTimeout
.setValue(session
->stopTrackerTimeout());
783 m_spinBoxStopTrackerTimeout
.setSuffix(tr(" s", " seconds"));
784 m_spinBoxStopTrackerTimeout
.setSpecialValueText(tr("0 (disabled)"));
785 addRow(STOP_TRACKER_TIMEOUT
, (tr("Stop tracker timeout [0: disabled]") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#stop_tracker_timeout", u
"(?)"))
786 , &m_spinBoxStopTrackerTimeout
);
787 // Program notifications
788 m_checkBoxProgramNotifications
.setChecked(app()->desktopIntegration()->isNotificationsEnabled());
789 addRow(PROGRAM_NOTIFICATIONS
, tr("Display notifications"), &m_checkBoxProgramNotifications
);
790 // Torrent added notifications
791 m_checkBoxTorrentAddedNotifications
.setChecked(app()->isTorrentAddedNotificationsEnabled());
792 addRow(TORRENT_ADDED_NOTIFICATIONS
, tr("Display notifications for added torrents"), &m_checkBoxTorrentAddedNotifications
);
794 // Notification timeout
795 m_spinBoxNotificationTimeout
.setMinimum(-1);
796 m_spinBoxNotificationTimeout
.setMaximum(std::numeric_limits
<int>::max());
797 m_spinBoxNotificationTimeout
.setValue(app()->desktopIntegration()->notificationTimeout());
798 connect(&m_spinBoxNotificationTimeout
, qOverload
<int>(&QSpinBox::valueChanged
)
799 , this, &AdvancedSettings::updateNotificationTimeoutSuffix
);
800 updateNotificationTimeoutSuffix(m_spinBoxNotificationTimeout
.value());
801 addRow(NOTIFICATION_TIMEOUT
, tr("Notification timeout [0: infinite, -1: system default]"), &m_spinBoxNotificationTimeout
);
803 // Reannounce to all trackers when ip/port changed
804 m_checkBoxReannounceWhenAddressChanged
.setChecked(session
->isReannounceWhenAddressChangedEnabled());
805 addRow(REANNOUNCE_WHEN_ADDRESS_CHANGED
, tr("Reannounce to all trackers when IP or port changed"), &m_checkBoxReannounceWhenAddressChanged
);
806 // Download tracker's favicon
807 m_checkBoxTrackerFavicon
.setChecked(app()->mainWindow()->isDownloadTrackerFavicon());
808 addRow(DOWNLOAD_TRACKER_FAVICON
, tr("Download tracker's favicon"), &m_checkBoxTrackerFavicon
);
809 // Save path history length
810 m_spinBoxSavePathHistoryLength
.setRange(0, 99);
811 m_spinBoxSavePathHistoryLength
.setValue(pref
->addNewTorrentDialogSavePathHistoryLength());
812 addRow(SAVE_PATH_HISTORY_LENGTH
, tr("Save path history length"), &m_spinBoxSavePathHistoryLength
);
813 // Enable speed graphs
814 m_checkBoxSpeedWidgetEnabled
.setChecked(pref
->isSpeedWidgetEnabled());
815 addRow(ENABLE_SPEED_WIDGET
, tr("Enable speed graphs"), &m_checkBoxSpeedWidgetEnabled
);
817 // Enable icons in menus
818 m_checkBoxIconsInMenusEnabled
.setChecked(pref
->iconsInMenusEnabled());
819 addRow(ENABLE_ICONS_IN_MENUS
, tr("Enable icons in menus"), &m_checkBoxIconsInMenusEnabled
);
822 m_checkBoxTrackerStatus
.setChecked(session
->isTrackerEnabled());
823 addRow(TRACKER_STATUS
, tr("Enable embedded tracker"), &m_checkBoxTrackerStatus
);
825 m_spinBoxTrackerPort
.setMinimum(1);
826 m_spinBoxTrackerPort
.setMaximum(65535);
827 m_spinBoxTrackerPort
.setValue(pref
->getTrackerPort());
828 addRow(TRACKER_PORT
, tr("Embedded tracker port"), &m_spinBoxTrackerPort
);
829 // Tracker port forwarding
830 m_checkBoxTrackerPortForwarding
.setChecked(pref
->isTrackerPortForwardingEnabled());
831 addRow(TRACKER_PORT_FORWARDING
, tr("Enable port forwarding for embedded tracker"), &m_checkBoxTrackerPortForwarding
);
832 #if defined(Q_OS_MACOS) || defined(Q_OS_WIN)
835 const QString motwLabel
= tr("Enable quarantine for downloaded files");
836 #elif defined(Q_OS_WIN)
837 const QString motwLabel
= tr("Enable Mark-of-the-Web (MOTW) for downloaded files");
839 m_checkBoxMarkOfTheWeb
.setChecked(pref
->isMarkOfTheWebEnabled());
840 addRow(ENABLE_MARK_OF_THE_WEB
, motwLabel
, &m_checkBoxMarkOfTheWeb
);
841 #endif // Q_OS_MACOS || Q_OS_WIN
842 // Python executable path
843 m_pythonExecutablePath
.setPlaceholderText(tr("(Auto detect if empty)"));
844 m_pythonExecutablePath
.setText(pref
->getPythonExecutablePath().toString());
845 addRow(PYTHON_EXECUTABLE_PATH
, tr("Python executable path (may require restart)"), &m_pythonExecutablePath
);
847 m_comboBoxChokingAlgorithm
.addItem(tr("Fixed slots"), QVariant::fromValue(BitTorrent::ChokingAlgorithm::FixedSlots
));
848 m_comboBoxChokingAlgorithm
.addItem(tr("Upload rate based"), QVariant::fromValue(BitTorrent::ChokingAlgorithm::RateBased
));
849 m_comboBoxChokingAlgorithm
.setCurrentIndex(m_comboBoxChokingAlgorithm
.findData(QVariant::fromValue(session
->chokingAlgorithm())));
850 addRow(CHOKING_ALGORITHM
, (tr("Upload slots behavior") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#choking_algorithm", u
"(?)"))
851 , &m_comboBoxChokingAlgorithm
);
852 // Seed choking algorithm
853 m_comboBoxSeedChokingAlgorithm
.addItem(tr("Round-robin"), QVariant::fromValue(BitTorrent::SeedChokingAlgorithm::RoundRobin
));
854 m_comboBoxSeedChokingAlgorithm
.addItem(tr("Fastest upload"), QVariant::fromValue(BitTorrent::SeedChokingAlgorithm::FastestUpload
));
855 m_comboBoxSeedChokingAlgorithm
.addItem(tr("Anti-leech"), QVariant::fromValue(BitTorrent::SeedChokingAlgorithm::AntiLeech
));
856 m_comboBoxSeedChokingAlgorithm
.setCurrentIndex(m_comboBoxSeedChokingAlgorithm
.findData(QVariant::fromValue(session
->seedChokingAlgorithm())));
857 addRow(SEED_CHOKING_ALGORITHM
, (tr("Upload choking algorithm") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#seed_choking_algorithm", u
"(?)"))
858 , &m_comboBoxSeedChokingAlgorithm
);
860 // Torrent recheck confirmation
861 m_checkBoxConfirmTorrentRecheck
.setChecked(pref
->confirmTorrentRecheck());
862 addRow(CONFIRM_RECHECK_TORRENT
, tr("Confirm torrent recheck"), &m_checkBoxConfirmTorrentRecheck
);
864 // Remove all tags confirmation
865 m_checkBoxConfirmRemoveAllTags
.setChecked(pref
->confirmRemoveAllTags());
866 addRow(CONFIRM_REMOVE_ALL_TAGS
, tr("Confirm removal of all tags"), &m_checkBoxConfirmRemoveAllTags
);
868 // Remove tracker from all torrents confirmation
869 m_checkBoxConfirmRemoveTrackerFromAllTorrents
.setChecked(pref
->confirmRemoveTrackerFromAllTorrents());
870 addRow(CONFIRM_REMOVE_TRACKER_FROM_ALL_TORRENTS
, tr("Confirm removal of tracker from all torrents"), &m_checkBoxConfirmRemoveTrackerFromAllTorrents
);
872 // Announce to all trackers in a tier
873 m_checkBoxAnnounceAllTrackers
.setChecked(session
->announceToAllTrackers());
874 addRow(ANNOUNCE_ALL_TRACKERS
, (tr("Always announce to all trackers in a tier")
875 + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#announce_to_all_trackers", u
"(?)"))
876 , &m_checkBoxAnnounceAllTrackers
);
878 // Announce to all tiers
879 m_checkBoxAnnounceAllTiers
.setChecked(session
->announceToAllTiers());
880 addRow(ANNOUNCE_ALL_TIERS
, (tr("Always announce to all tiers")
881 + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#announce_to_all_tiers", u
"(?)"))
882 , &m_checkBoxAnnounceAllTiers
);
884 m_spinBoxPeerTurnover
.setMinimum(0);
885 m_spinBoxPeerTurnover
.setMaximum(100);
886 m_spinBoxPeerTurnover
.setValue(session
->peerTurnover());
887 m_spinBoxPeerTurnover
.setSuffix(u
" %"_s
);
888 addRow(PEER_TURNOVER
, (tr("Peer turnover disconnect percentage") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#peer_turnover", u
"(?)"))
889 , &m_spinBoxPeerTurnover
);
890 m_spinBoxPeerTurnoverCutoff
.setMinimum(0);
891 m_spinBoxPeerTurnoverCutoff
.setMaximum(100);
892 m_spinBoxPeerTurnoverCutoff
.setSuffix(u
" %"_s
);
893 m_spinBoxPeerTurnoverCutoff
.setValue(session
->peerTurnoverCutoff());
894 addRow(PEER_TURNOVER_CUTOFF
, (tr("Peer turnover threshold percentage") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#peer_turnover", u
"(?)"))
895 , &m_spinBoxPeerTurnoverCutoff
);
896 m_spinBoxPeerTurnoverInterval
.setMinimum(30);
897 m_spinBoxPeerTurnoverInterval
.setMaximum(3600);
898 m_spinBoxPeerTurnoverInterval
.setSuffix(tr(" s", " seconds"));
899 m_spinBoxPeerTurnoverInterval
.setValue(session
->peerTurnoverInterval());
900 addRow(PEER_TURNOVER_INTERVAL
, (tr("Peer turnover disconnect interval") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#peer_turnover", u
"(?)"))
901 , &m_spinBoxPeerTurnoverInterval
);
902 // Maximum outstanding requests to a single peer
903 m_spinBoxRequestQueueSize
.setMinimum(1);
904 m_spinBoxRequestQueueSize
.setMaximum(std::numeric_limits
<int>::max());
905 m_spinBoxRequestQueueSize
.setValue(session
->requestQueueSize());
906 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
"(?)"))
907 , &m_spinBoxRequestQueueSize
);
908 // DHT bootstrap nodes
909 m_lineEditDHTBootstrapNodes
.setPlaceholderText(tr("Resets to default if empty"));
910 m_lineEditDHTBootstrapNodes
.setText(session
->getDHTBootstrapNodes());
911 addRow(DHT_BOOTSTRAP_NODES
, (tr("DHT bootstrap nodes") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#dht_bootstrap_nodes", u
"(?)"))
912 , &m_lineEditDHTBootstrapNodes
);
913 #if defined(QBT_USES_LIBTORRENT2) && TORRENT_USE_I2P
914 // I2P session options
915 m_spinBoxI2PInboundQuantity
.setMinimum(1);
916 m_spinBoxI2PInboundQuantity
.setMaximum(16);
917 m_spinBoxI2PInboundQuantity
.setValue(session
->I2PInboundQuantity());
918 addRow(I2P_INBOUND_QUANTITY
, (tr("I2P inbound quantity") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#i2p_inbound_quantity", u
"(?)"))
919 , &m_spinBoxI2PInboundQuantity
);
920 m_spinBoxI2POutboundQuantity
.setMinimum(1);
921 m_spinBoxI2POutboundQuantity
.setMaximum(16);
922 m_spinBoxI2POutboundQuantity
.setValue(session
->I2POutboundQuantity());
923 addRow(I2P_OUTBOUND_QUANTITY
, (tr("I2P outbound quantity") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#i2p_outbound_quantity", u
"(?)"))
924 , &m_spinBoxI2POutboundQuantity
);
925 m_spinBoxI2PInboundLength
.setMinimum(0);
926 m_spinBoxI2PInboundLength
.setMaximum(7);
927 m_spinBoxI2PInboundLength
.setValue(session
->I2PInboundLength());
928 addRow(I2P_INBOUND_LENGTH
, (tr("I2P inbound length") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#i2p_inbound_length", u
"(?)"))
929 , &m_spinBoxI2PInboundLength
);
930 m_spinBoxI2POutboundLength
.setMinimum(0);
931 m_spinBoxI2POutboundLength
.setMaximum(7);
932 m_spinBoxI2POutboundLength
.setValue(session
->I2POutboundLength());
933 addRow(I2P_OUTBOUND_LENGTH
, (tr("I2P outbound length") + u
' ' + makeLink(u
"https://www.libtorrent.org/reference-Settings.html#i2p_outbound_length", u
"(?)"))
934 , &m_spinBoxI2POutboundLength
);
938 template <typename T
>
939 void AdvancedSettings::addRow(const int row
, const QString
&text
, T
*widget
)
941 auto *label
= new QLabel(text
);
942 label
->setOpenExternalLinks(true);
944 setCellWidget(row
, PROPERTY
, label
);
945 setCellWidget(row
, VALUE
, widget
);
947 if constexpr (std::is_same_v
<T
, QCheckBox
>)
948 connect(widget
, &QCheckBox::stateChanged
, this, &AdvancedSettings::settingsChanged
);
949 else if constexpr (std::is_same_v
<T
, QSpinBox
>)
950 connect(widget
, qOverload
<int>(&QSpinBox::valueChanged
), this, &AdvancedSettings::settingsChanged
);
951 else if constexpr (std::is_same_v
<T
, QComboBox
>)
952 connect(widget
, qOverload
<int>(&QComboBox::currentIndexChanged
), this, &AdvancedSettings::settingsChanged
);
953 else if constexpr (std::is_same_v
<T
, QLineEdit
>)
954 connect(widget
, &QLineEdit::textChanged
, this, &AdvancedSettings::settingsChanged
);