Convert the names used in ui and c++ files from snake_case to camelCase

This commit is contained in:
thalieht 2018-06-14 12:38:18 +03:00
parent ca68b86550
commit 6d4434ad66
22 changed files with 315 additions and 314 deletions

View file

@ -125,9 +125,9 @@ AdvancedSettings::AdvancedSettings(QWidget *parent)
setSelectionMode(QAbstractItemView::NoSelection);
setEditTriggers(QAbstractItemView::NoEditTriggers);
// Signals
connect(&spin_cache, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged)
connect(&spinBoxCache, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged)
, this, &AdvancedSettings::updateCacheSpinSuffix);
connect(&combo_iface, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged)
connect(&comboBoxInterface, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged)
, this, &AdvancedSettings::updateInterfaceAddressCombo);
// Load settings
loadAdvancedSettings();
@ -141,116 +141,116 @@ void AdvancedSettings::saveAdvancedSettings()
BitTorrent::Session *const session = BitTorrent::Session::instance();
// Disk write cache
session->setDiskCacheSize(spin_cache.value());
session->setDiskCacheTTL(spin_cache_ttl.value());
session->setDiskCacheSize(spinBoxCache.value());
session->setDiskCacheTTL(spinBoxCacheTTL.value());
// Enable OS cache
session->setUseOSCache(cb_os_cache.isChecked());
session->setUseOSCache(checkBoxOsCache.isChecked());
// Guided read cache
session->setGuidedReadCacheEnabled(cbGuidedReadCache.isChecked());
session->setGuidedReadCacheEnabled(checkBoxGuidedReadCache.isChecked());
// Coalesce reads & writes
session->setCoalesceReadWriteEnabled(cbCoalesceRW.isChecked());
session->setCoalesceReadWriteEnabled(checkBoxCoalesceRW.isChecked());
// Suggest mode
session->setSuggestMode(cbSuggestMode.isChecked());
session->setSuggestMode(checkBoxSuggestMode.isChecked());
// Send buffer watermark
session->setSendBufferWatermark(spinSendBufferWatermark.value());
session->setSendBufferLowWatermark(spinSendBufferLowWatermark.value());
session->setSendBufferWatermarkFactor(spinSendBufferWatermarkFactor.value());
session->setSendBufferWatermark(spinBoxSendBufferWatermark.value());
session->setSendBufferLowWatermark(spinBoxSendBufferLowWatermark.value());
session->setSendBufferWatermarkFactor(spinBoxSendBufferWatermarkFactor.value());
// Save resume data interval
session->setSaveResumeDataInterval(spin_save_resume_data_interval.value());
session->setSaveResumeDataInterval(spinBoxSaveResumeDataInterval.value());
// Outgoing ports
session->setOutgoingPortsMin(outgoing_ports_min.value());
session->setOutgoingPortsMax(outgoing_ports_max.value());
session->setOutgoingPortsMin(spinBoxOutgoingPortsMin.value());
session->setOutgoingPortsMax(spinBoxOutgoingPortsMax.value());
// uTP-TCP mixed mode
session->setUtpMixedMode(static_cast<BitTorrent::MixedModeAlgorithm>(comboUtpMixedMode.currentIndex()));
session->setUtpMixedMode(static_cast<BitTorrent::MixedModeAlgorithm>(comboBoxUtpMixedMode.currentIndex()));
// multiple connections per IP
session->setMultiConnectionsPerIpEnabled(cbMultiConnectionsPerIp.isChecked());
session->setMultiConnectionsPerIpEnabled(checkBoxMultiConnectionsPerIp.isChecked());
// Recheck torrents on completion
pref->recheckTorrentsOnCompletion(cb_recheck_completed.isChecked());
pref->recheckTorrentsOnCompletion(checkBoxRecheckCompleted.isChecked());
// Transfer list refresh interval
session->setRefreshInterval(spin_list_refresh.value());
session->setRefreshInterval(spinBoxListRefresh.value());
// Peer resolution
pref->resolvePeerCountries(cb_resolve_countries.isChecked());
pref->resolvePeerHostNames(cb_resolve_hosts.isChecked());
pref->resolvePeerCountries(checkBoxResolveCountries.isChecked());
pref->resolvePeerHostNames(checkBoxResolveHosts.isChecked());
// Max Half-Open connections
session->setMaxHalfOpenConnections(spin_maxhalfopen.value());
session->setMaxHalfOpenConnections(spinBoxMaxHalfOpen.value());
// Super seeding
session->setSuperSeedingEnabled(cb_super_seeding.isChecked());
session->setSuperSeedingEnabled(checkBoxSuperSeeding.isChecked());
// Network interface
if (combo_iface.currentIndex() == 0) {
if (comboBoxInterface.currentIndex() == 0) {
// All interfaces (default)
session->setNetworkInterface(QString());
session->setNetworkInterfaceName(QString());
}
else {
session->setNetworkInterface(combo_iface.itemData(combo_iface.currentIndex()).toString());
session->setNetworkInterfaceName(combo_iface.currentText());
session->setNetworkInterface(comboBoxInterface.itemData(comboBoxInterface.currentIndex()).toString());
session->setNetworkInterfaceName(comboBoxInterface.currentText());
}
// Interface address
if (combo_iface_address.currentIndex() == 0) {
if (comboBoxInterfaceAddress.currentIndex() == 0) {
// All addresses (default)
session->setNetworkInterfaceAddress(QString::null);
}
else {
QHostAddress ifaceAddr(combo_iface_address.currentText().trimmed());
QHostAddress ifaceAddr(comboBoxInterfaceAddress.currentText().trimmed());
ifaceAddr.isNull() ? session->setNetworkInterfaceAddress(QString::null) : session->setNetworkInterfaceAddress(ifaceAddr.toString());
}
session->setIPv6Enabled(cb_listen_ipv6.isChecked());
session->setIPv6Enabled(checkBoxListenIPv6.isChecked());
// Announce IP
QHostAddress addr(txtAnnounceIP.text().trimmed());
QHostAddress addr(lineEditAnnounceIP.text().trimmed());
session->setAnnounceIP(addr.isNull() ? "" : addr.toString());
// Program notification
MainWindow *const mainWindow = static_cast<Application*>(QCoreApplication::instance())->mainWindow();
mainWindow->setNotificationsEnabled(cb_program_notifications.isChecked());
mainWindow->setTorrentAddedNotificationsEnabled(cb_torrent_added_notifications.isChecked());
mainWindow->setNotificationsEnabled(checkBoxProgramNotifications.isChecked());
mainWindow->setTorrentAddedNotificationsEnabled(checkBoxTorrentAddedNotifications.isChecked());
// Misc GUI properties
mainWindow->setDownloadTrackerFavicon(cb_tracker_favicon.isChecked());
AddNewTorrentDialog::setSavePathHistoryLength(spinSavePathHistoryLength.value());
mainWindow->setDownloadTrackerFavicon(checkBoxTrackerFavicon.isChecked());
AddNewTorrentDialog::setSavePathHistoryLength(spinBoxSavePathHistoryLength.value());
// Tracker
session->setTrackerEnabled(cb_tracker_status.isChecked());
pref->setTrackerPort(spin_tracker_port.value());
session->setTrackerEnabled(checkBoxTrackerStatus.isChecked());
pref->setTrackerPort(spinBoxTrackerPort.value());
// Choking algorithm
session->setChokingAlgorithm(static_cast<BitTorrent::ChokingAlgorithm>(comboChokingAlgorithm.currentIndex()));
session->setChokingAlgorithm(static_cast<BitTorrent::ChokingAlgorithm>(comboBoxChokingAlgorithm.currentIndex()));
// Seed choking algorithm
session->setSeedChokingAlgorithm(static_cast<BitTorrent::SeedChokingAlgorithm>(comboSeedChokingAlgorithm.currentIndex()));
session->setSeedChokingAlgorithm(static_cast<BitTorrent::SeedChokingAlgorithm>(comboBoxSeedChokingAlgorithm.currentIndex()));
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
pref->setUpdateCheckEnabled(cb_update_check.isChecked());
pref->setUpdateCheckEnabled(checkBoxUpdateCheck.isChecked());
#endif
// Icon theme
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
pref->useSystemIconTheme(cb_use_icon_theme.isChecked());
pref->useSystemIconTheme(checkBoxUseIconTheme.isChecked());
#endif
pref->setConfirmTorrentRecheck(cb_confirm_torrent_recheck.isChecked());
pref->setConfirmTorrentRecheck(checkBoxConfirmTorrentRecheck.isChecked());
pref->setConfirmRemoveAllTags(cb_confirm_remove_all_tags.isChecked());
pref->setConfirmRemoveAllTags(checkBoxConfirmRemoveAllTags.isChecked());
session->setAnnounceToAllTrackers(cb_announce_all_trackers.isChecked());
session->setAnnounceToAllTiers(cb_announce_all_tiers.isChecked());
session->setAnnounceToAllTrackers(checkBoxAnnounceAllTrackers.isChecked());
session->setAnnounceToAllTiers(checkBoxAnnounceAllTiers.isChecked());
}
void AdvancedSettings::updateCacheSpinSuffix(int value)
{
if (value == 0)
spin_cache.setSuffix(tr(" (disabled)"));
spinBoxCache.setSuffix(tr(" (disabled)"));
else if (value < 0)
spin_cache.setSuffix(tr(" (auto)"));
spinBoxCache.setSuffix(tr(" (auto)"));
else
spin_cache.setSuffix(tr(" MiB"));
spinBoxCache.setSuffix(tr(" MiB"));
}
void AdvancedSettings::updateInterfaceAddressCombo()
{
// Try to get the currently selected interface name
const QString ifaceName = combo_iface.itemData(combo_iface.currentIndex()).toString(); // Empty string for the first element
const QString ifaceName = comboBoxInterface.itemData(comboBoxInterface.currentIndex()).toString(); // Empty string for the first element
const QString currentAddress = BitTorrent::Session::instance()->networkInterfaceAddress();
// Clear all items and reinsert them, default to all
combo_iface_address.clear();
combo_iface_address.addItem(tr("All addresses"));
combo_iface_address.setCurrentIndex(0);
comboBoxInterfaceAddress.clear();
comboBoxInterfaceAddress.addItem(tr("All addresses"));
comboBoxInterfaceAddress.setCurrentIndex(0);
auto populateCombo = [this, &currentAddress](const QString &ip, const QAbstractSocket::NetworkLayerProtocol &protocol)
{
@ -258,10 +258,10 @@ void AdvancedSettings::updateInterfaceAddressCombo()
// Only take ipv4 for now?
if ((protocol != QAbstractSocket::IPv4Protocol) && (protocol != QAbstractSocket::IPv6Protocol))
return;
combo_iface_address.addItem(ip);
comboBoxInterfaceAddress.addItem(ip);
//Try to select the last added one
if (ip == currentAddress)
combo_iface_address.setCurrentIndex(combo_iface_address.count() - 1);
comboBoxInterfaceAddress.setCurrentIndex(comboBoxInterfaceAddress.count() - 1);
};
if (ifaceName.isEmpty()) {
@ -297,102 +297,102 @@ void AdvancedSettings::loadAdvancedSettings()
labelLibtorrentLink.setText(QString("<a href=\"%1\">%2</a>").arg("https://www.libtorrent.org/reference.html", tr("Open documentation")));
labelLibtorrentLink.setOpenExternalLinks(true);
// Disk write cache
spin_cache.setMinimum(-1);
spinBoxCache.setMinimum(-1);
// When build as 32bit binary, set the maximum at less than 2GB to prevent crashes.
// These macros may not be available on compilers other than MSVC and GCC
#if defined(__x86_64__) || defined(_M_X64)
spin_cache.setMaximum(4096);
spinBoxCache.setMaximum(4096);
#else
// allocate 1536MiB and leave 512MiB to the rest of program data in RAM
spin_cache.setMaximum(1536);
spinBoxCache.setMaximum(1536);
#endif
spin_cache.setValue(session->diskCacheSize());
updateCacheSpinSuffix(spin_cache.value());
addRow(DISK_CACHE, tr("Disk cache"), &spin_cache);
spinBoxCache.setValue(session->diskCacheSize());
updateCacheSpinSuffix(spinBoxCache.value());
addRow(DISK_CACHE, tr("Disk cache"), &spinBoxCache);
// Disk cache expiry
spin_cache_ttl.setMinimum(15);
spin_cache_ttl.setMaximum(600);
spin_cache_ttl.setValue(session->diskCacheTTL());
spin_cache_ttl.setSuffix(tr(" s", " seconds"));
addRow(DISK_CACHE_TTL, tr("Disk cache expiry interval"), &spin_cache_ttl);
spinBoxCacheTTL.setMinimum(15);
spinBoxCacheTTL.setMaximum(600);
spinBoxCacheTTL.setValue(session->diskCacheTTL());
spinBoxCacheTTL.setSuffix(tr(" s", " seconds"));
addRow(DISK_CACHE_TTL, tr("Disk cache expiry interval"), &spinBoxCacheTTL);
// Enable OS cache
cb_os_cache.setChecked(session->useOSCache());
addRow(OS_CACHE, tr("Enable OS cache"), &cb_os_cache);
checkBoxOsCache.setChecked(session->useOSCache());
addRow(OS_CACHE, tr("Enable OS cache"), &checkBoxOsCache);
// Guided read cache
cbGuidedReadCache.setChecked(session->isGuidedReadCacheEnabled());
addRow(GUIDED_READ_CACHE, tr("Guided read cache"), &cbGuidedReadCache);
checkBoxGuidedReadCache.setChecked(session->isGuidedReadCacheEnabled());
addRow(GUIDED_READ_CACHE, tr("Guided read cache"), &checkBoxGuidedReadCache);
// Coalesce reads & writes
cbCoalesceRW.setChecked(session->isCoalesceReadWriteEnabled());
checkBoxCoalesceRW.setChecked(session->isCoalesceReadWriteEnabled());
#if LIBTORRENT_VERSION_NUM >= 10107
addRow(COALESCE_RW, tr("Coalesce reads & writes"), &cbCoalesceRW);
addRow(COALESCE_RW, tr("Coalesce reads & writes"), &checkBoxCoalesceRW);
#endif
// Suggest mode
cbSuggestMode.setChecked(session->isSuggestModeEnabled());
addRow(SUGGEST_MODE, tr("Send upload piece suggestions"), &cbSuggestMode);
checkBoxSuggestMode.setChecked(session->isSuggestModeEnabled());
addRow(SUGGEST_MODE, tr("Send upload piece suggestions"), &checkBoxSuggestMode);
// Send buffer watermark
spinSendBufferWatermark.setMinimum(1);
spinSendBufferWatermark.setMaximum(INT_MAX);
spinSendBufferWatermark.setSuffix(tr(" KiB"));
spinSendBufferWatermark.setValue(session->sendBufferWatermark());
addRow(SEND_BUF_WATERMARK, tr("Send buffer watermark"), &spinSendBufferWatermark);
spinSendBufferLowWatermark.setMinimum(1);
spinSendBufferLowWatermark.setMaximum(INT_MAX);
spinSendBufferLowWatermark.setSuffix(tr(" KiB"));
spinSendBufferLowWatermark.setValue(session->sendBufferLowWatermark());
addRow(SEND_BUF_LOW_WATERMARK, tr("Send buffer low watermark"), &spinSendBufferLowWatermark);
spinSendBufferWatermarkFactor.setMinimum(1);
spinSendBufferWatermarkFactor.setMaximum(INT_MAX);
spinSendBufferWatermarkFactor.setSuffix(" %");
spinSendBufferWatermarkFactor.setValue(session->sendBufferWatermarkFactor());
addRow(SEND_BUF_WATERMARK_FACTOR, tr("Send buffer watermark factor"), &spinSendBufferWatermarkFactor);
spinBoxSendBufferWatermark.setMinimum(1);
spinBoxSendBufferWatermark.setMaximum(INT_MAX);
spinBoxSendBufferWatermark.setSuffix(tr(" KiB"));
spinBoxSendBufferWatermark.setValue(session->sendBufferWatermark());
addRow(SEND_BUF_WATERMARK, tr("Send buffer watermark"), &spinBoxSendBufferWatermark);
spinBoxSendBufferLowWatermark.setMinimum(1);
spinBoxSendBufferLowWatermark.setMaximum(INT_MAX);
spinBoxSendBufferLowWatermark.setSuffix(tr(" KiB"));
spinBoxSendBufferLowWatermark.setValue(session->sendBufferLowWatermark());
addRow(SEND_BUF_LOW_WATERMARK, tr("Send buffer low watermark"), &spinBoxSendBufferLowWatermark);
spinBoxSendBufferWatermarkFactor.setMinimum(1);
spinBoxSendBufferWatermarkFactor.setMaximum(INT_MAX);
spinBoxSendBufferWatermarkFactor.setSuffix(" %");
spinBoxSendBufferWatermarkFactor.setValue(session->sendBufferWatermarkFactor());
addRow(SEND_BUF_WATERMARK_FACTOR, tr("Send buffer watermark factor"), &spinBoxSendBufferWatermarkFactor);
// Save resume data interval
spin_save_resume_data_interval.setMinimum(1);
spin_save_resume_data_interval.setMaximum(1440);
spin_save_resume_data_interval.setValue(session->saveResumeDataInterval());
spin_save_resume_data_interval.setSuffix(tr(" m", " minutes"));
addRow(SAVE_RESUME_DATA_INTERVAL, tr("Save resume data interval", "How often the fastresume file is saved."), &spin_save_resume_data_interval);
spinBoxSaveResumeDataInterval.setMinimum(1);
spinBoxSaveResumeDataInterval.setMaximum(1440);
spinBoxSaveResumeDataInterval.setValue(session->saveResumeDataInterval());
spinBoxSaveResumeDataInterval.setSuffix(tr(" m", " minutes"));
addRow(SAVE_RESUME_DATA_INTERVAL, tr("Save resume data interval", "How often the fastresume file is saved."), &spinBoxSaveResumeDataInterval);
// Outgoing port Min
outgoing_ports_min.setMinimum(0);
outgoing_ports_min.setMaximum(65535);
outgoing_ports_min.setValue(session->outgoingPortsMin());
addRow(OUTGOING_PORT_MIN, tr("Outgoing ports (Min) [0: Disabled]"), &outgoing_ports_min);
spinBoxOutgoingPortsMin.setMinimum(0);
spinBoxOutgoingPortsMin.setMaximum(65535);
spinBoxOutgoingPortsMin.setValue(session->outgoingPortsMin());
addRow(OUTGOING_PORT_MIN, tr("Outgoing ports (Min) [0: Disabled]"), &spinBoxOutgoingPortsMin);
// Outgoing port Min
outgoing_ports_max.setMinimum(0);
outgoing_ports_max.setMaximum(65535);
outgoing_ports_max.setValue(session->outgoingPortsMax());
addRow(OUTGOING_PORT_MAX, tr("Outgoing ports (Max) [0: Disabled]"), &outgoing_ports_max);
spinBoxOutgoingPortsMax.setMinimum(0);
spinBoxOutgoingPortsMax.setMaximum(65535);
spinBoxOutgoingPortsMax.setValue(session->outgoingPortsMax());
addRow(OUTGOING_PORT_MAX, tr("Outgoing ports (Max) [0: Disabled]"), &spinBoxOutgoingPortsMax);
// uTP-TCP mixed mode
comboUtpMixedMode.addItems({tr("Prefer TCP"), tr("Peer proportional (throttles TCP)")});
comboUtpMixedMode.setCurrentIndex(static_cast<int>(session->utpMixedMode()));
addRow(UTP_MIX_MODE, tr("%1-TCP mixed mode algorithm", "uTP-TCP mixed mode algorithm").arg(C_UTP), &comboUtpMixedMode);
comboBoxUtpMixedMode.addItems({tr("Prefer TCP"), tr("Peer proportional (throttles TCP)")});
comboBoxUtpMixedMode.setCurrentIndex(static_cast<int>(session->utpMixedMode()));
addRow(UTP_MIX_MODE, tr("%1-TCP mixed mode algorithm", "uTP-TCP mixed mode algorithm").arg(C_UTP), &comboBoxUtpMixedMode);
// multiple connections per IP
cbMultiConnectionsPerIp.setChecked(session->multiConnectionsPerIpEnabled());
addRow(MULTI_CONNECTIONS_PER_IP, tr("Allow multiple connections from the same IP address"), &cbMultiConnectionsPerIp);
checkBoxMultiConnectionsPerIp.setChecked(session->multiConnectionsPerIpEnabled());
addRow(MULTI_CONNECTIONS_PER_IP, tr("Allow multiple connections from the same IP address"), &checkBoxMultiConnectionsPerIp);
// Recheck completed torrents
cb_recheck_completed.setChecked(pref->recheckTorrentsOnCompletion());
addRow(RECHECK_COMPLETED, tr("Recheck torrents on completion"), &cb_recheck_completed);
checkBoxRecheckCompleted.setChecked(pref->recheckTorrentsOnCompletion());
addRow(RECHECK_COMPLETED, tr("Recheck torrents on completion"), &checkBoxRecheckCompleted);
// Transfer list refresh interval
spin_list_refresh.setMinimum(30);
spin_list_refresh.setMaximum(99999);
spin_list_refresh.setValue(session->refreshInterval());
spin_list_refresh.setSuffix(tr(" ms", " milliseconds"));
addRow(LIST_REFRESH, tr("Transfer list refresh interval"), &spin_list_refresh);
spinBoxListRefresh.setMinimum(30);
spinBoxListRefresh.setMaximum(99999);
spinBoxListRefresh.setValue(session->refreshInterval());
spinBoxListRefresh.setSuffix(tr(" ms", " milliseconds"));
addRow(LIST_REFRESH, tr("Transfer list refresh interval"), &spinBoxListRefresh);
// Resolve Peer countries
cb_resolve_countries.setChecked(pref->resolvePeerCountries());
addRow(RESOLVE_COUNTRIES, tr("Resolve peer countries (GeoIP)"), &cb_resolve_countries);
checkBoxResolveCountries.setChecked(pref->resolvePeerCountries());
addRow(RESOLVE_COUNTRIES, tr("Resolve peer countries (GeoIP)"), &checkBoxResolveCountries);
// Resolve peer hosts
cb_resolve_hosts.setChecked(pref->resolvePeerHostNames());
addRow(RESOLVE_HOSTS, tr("Resolve peer host names"), &cb_resolve_hosts);
checkBoxResolveHosts.setChecked(pref->resolvePeerHostNames());
addRow(RESOLVE_HOSTS, tr("Resolve peer host names"), &checkBoxResolveHosts);
// Max Half Open connections
spin_maxhalfopen.setMinimum(0);
spin_maxhalfopen.setMaximum(99999);
spin_maxhalfopen.setValue(session->maxHalfOpenConnections());
addRow(MAX_HALF_OPEN, tr("Maximum number of half-open connections [0: Unlimited]"), &spin_maxhalfopen);
spinBoxMaxHalfOpen.setMinimum(0);
spinBoxMaxHalfOpen.setMaximum(99999);
spinBoxMaxHalfOpen.setValue(session->maxHalfOpenConnections());
addRow(MAX_HALF_OPEN, tr("Maximum number of half-open connections [0: Unlimited]"), &spinBoxMaxHalfOpen);
// Super seeding
cb_super_seeding.setChecked(session->isSuperSeedingEnabled());
addRow(SUPER_SEEDING, tr("Strict super seeding"), &cb_super_seeding);
checkBoxSuperSeeding.setChecked(session->isSuperSeedingEnabled());
addRow(SUPER_SEEDING, tr("Strict super seeding"), &checkBoxSuperSeeding);
// Network interface
combo_iface.addItem(tr("Any interface", "i.e. Any network interface"));
comboBoxInterface.addItem(tr("Any interface", "i.e. Any network interface"));
const QString current_iface = session->networkInterface();
bool interface_exists = current_iface.isEmpty();
int i = 1;
@ -403,83 +403,83 @@ void AdvancedSettings::loadAdvancedSettings()
// https://github.com/qbittorrent/qBittorrent/pull/5135
if (iface.addressEntries().isEmpty()) continue;
combo_iface.addItem(iface.humanReadableName(), iface.name());
comboBoxInterface.addItem(iface.humanReadableName(), iface.name());
if (!current_iface.isEmpty() && (iface.name() == current_iface)) {
combo_iface.setCurrentIndex(i);
comboBoxInterface.setCurrentIndex(i);
interface_exists = true;
}
++i;
}
// Saved interface does not exist, show it anyway
if (!interface_exists) {
combo_iface.addItem(session->networkInterfaceName(), current_iface);
combo_iface.setCurrentIndex(i);
comboBoxInterface.addItem(session->networkInterfaceName(), current_iface);
comboBoxInterface.setCurrentIndex(i);
}
addRow(NETWORK_IFACE, tr("Network Interface (requires restart)"), &combo_iface);
addRow(NETWORK_IFACE, tr("Network Interface (requires restart)"), &comboBoxInterface);
// Network interface address
updateInterfaceAddressCombo();
addRow(NETWORK_IFACE_ADDRESS, tr("Optional IP Address to bind to (requires restart)"), &combo_iface_address);
addRow(NETWORK_IFACE_ADDRESS, tr("Optional IP Address to bind to (requires restart)"), &comboBoxInterfaceAddress);
// Listen on IPv6 address
cb_listen_ipv6.setChecked(session->isIPv6Enabled());
addRow(NETWORK_LISTEN_IPV6, tr("Listen on IPv6 address (requires restart)"), &cb_listen_ipv6);
checkBoxListenIPv6.setChecked(session->isIPv6Enabled());
addRow(NETWORK_LISTEN_IPV6, tr("Listen on IPv6 address (requires restart)"), &checkBoxListenIPv6);
// Announce IP
txtAnnounceIP.setText(session->announceIP());
addRow(ANNOUNCE_IP, tr("IP Address to report to trackers (requires restart)"), &txtAnnounceIP);
lineEditAnnounceIP.setText(session->announceIP());
addRow(ANNOUNCE_IP, tr("IP Address to report to trackers (requires restart)"), &lineEditAnnounceIP);
// Program notifications
const MainWindow * const mainWindow = static_cast<Application*>(QCoreApplication::instance())->mainWindow();
cb_program_notifications.setChecked(mainWindow->isNotificationsEnabled());
addRow(PROGRAM_NOTIFICATIONS, tr("Display notifications"), &cb_program_notifications);
checkBoxProgramNotifications.setChecked(mainWindow->isNotificationsEnabled());
addRow(PROGRAM_NOTIFICATIONS, tr("Display notifications"), &checkBoxProgramNotifications);
// Torrent added notifications
cb_torrent_added_notifications.setChecked(mainWindow->isTorrentAddedNotificationsEnabled());
addRow(TORRENT_ADDED_NOTIFICATIONS, tr("Display notifications for added torrents"), &cb_torrent_added_notifications);
checkBoxTorrentAddedNotifications.setChecked(mainWindow->isTorrentAddedNotificationsEnabled());
addRow(TORRENT_ADDED_NOTIFICATIONS, tr("Display notifications for added torrents"), &checkBoxTorrentAddedNotifications);
// Download tracker's favicon
cb_tracker_favicon.setChecked(mainWindow->isDownloadTrackerFavicon());
addRow(DOWNLOAD_TRACKER_FAVICON, tr("Download tracker's favicon"), &cb_tracker_favicon);
checkBoxTrackerFavicon.setChecked(mainWindow->isDownloadTrackerFavicon());
addRow(DOWNLOAD_TRACKER_FAVICON, tr("Download tracker's favicon"), &checkBoxTrackerFavicon);
// Save path history length
spinSavePathHistoryLength.setRange(AddNewTorrentDialog::minPathHistoryLength, AddNewTorrentDialog::maxPathHistoryLength);
spinSavePathHistoryLength.setValue(AddNewTorrentDialog::savePathHistoryLength());
addRow(SAVE_PATH_HISTORY_LENGTH, tr("Save path history length"), &spinSavePathHistoryLength);
spinBoxSavePathHistoryLength.setRange(AddNewTorrentDialog::minPathHistoryLength, AddNewTorrentDialog::maxPathHistoryLength);
spinBoxSavePathHistoryLength.setValue(AddNewTorrentDialog::savePathHistoryLength());
addRow(SAVE_PATH_HISTORY_LENGTH, tr("Save path history length"), &spinBoxSavePathHistoryLength);
// Tracker State
cb_tracker_status.setChecked(session->isTrackerEnabled());
addRow(TRACKER_STATUS, tr("Enable embedded tracker"), &cb_tracker_status);
checkBoxTrackerStatus.setChecked(session->isTrackerEnabled());
addRow(TRACKER_STATUS, tr("Enable embedded tracker"), &checkBoxTrackerStatus);
// Tracker port
spin_tracker_port.setMinimum(1);
spin_tracker_port.setMaximum(65535);
spin_tracker_port.setValue(pref->getTrackerPort());
addRow(TRACKER_PORT, tr("Embedded tracker port"), &spin_tracker_port);
spinBoxTrackerPort.setMinimum(1);
spinBoxTrackerPort.setMaximum(65535);
spinBoxTrackerPort.setValue(pref->getTrackerPort());
addRow(TRACKER_PORT, tr("Embedded tracker port"), &spinBoxTrackerPort);
// Choking algorithm
comboChokingAlgorithm.addItems({tr("Fixed slots"), tr("Upload rate based")});
comboChokingAlgorithm.setCurrentIndex(static_cast<int>(session->chokingAlgorithm()));
addRow(CHOKING_ALGORITHM, tr("Upload slots behavior"), &comboChokingAlgorithm);
comboBoxChokingAlgorithm.addItems({tr("Fixed slots"), tr("Upload rate based")});
comboBoxChokingAlgorithm.setCurrentIndex(static_cast<int>(session->chokingAlgorithm()));
addRow(CHOKING_ALGORITHM, tr("Upload slots behavior"), &comboBoxChokingAlgorithm);
// Seed choking algorithm
comboSeedChokingAlgorithm.addItems({tr("Round-robin"), tr("Fastest upload"), tr("Anti-leech")});
comboSeedChokingAlgorithm.setCurrentIndex(static_cast<int>(session->seedChokingAlgorithm()));
addRow(SEED_CHOKING_ALGORITHM, tr("Upload choking algorithm"), &comboSeedChokingAlgorithm);
comboBoxSeedChokingAlgorithm.addItems({tr("Round-robin"), tr("Fastest upload"), tr("Anti-leech")});
comboBoxSeedChokingAlgorithm.setCurrentIndex(static_cast<int>(session->seedChokingAlgorithm()));
addRow(SEED_CHOKING_ALGORITHM, tr("Upload choking algorithm"), &comboBoxSeedChokingAlgorithm);
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
cb_update_check.setChecked(pref->isUpdateCheckEnabled());
addRow(UPDATE_CHECK, tr("Check for software updates"), &cb_update_check);
checkBoxUpdateCheck.setChecked(pref->isUpdateCheckEnabled());
addRow(UPDATE_CHECK, tr("Check for software updates"), &checkBoxUpdateCheck);
#endif
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
cb_use_icon_theme.setChecked(pref->useSystemIconTheme());
addRow(USE_ICON_THEME, tr("Use system icon theme"), &cb_use_icon_theme);
checkBoxUseIconTheme.setChecked(pref->useSystemIconTheme());
addRow(USE_ICON_THEME, tr("Use system icon theme"), &checkBoxUseIconTheme);
#endif
// Torrent recheck confirmation
cb_confirm_torrent_recheck.setChecked(pref->confirmTorrentRecheck());
addRow(CONFIRM_RECHECK_TORRENT, tr("Confirm torrent recheck"), &cb_confirm_torrent_recheck);
checkBoxConfirmTorrentRecheck.setChecked(pref->confirmTorrentRecheck());
addRow(CONFIRM_RECHECK_TORRENT, tr("Confirm torrent recheck"), &checkBoxConfirmTorrentRecheck);
// Remove all tags confirmation
cb_confirm_remove_all_tags.setChecked(pref->confirmRemoveAllTags());
addRow(CONFIRM_REMOVE_ALL_TAGS, tr("Confirm removal of all tags"), &cb_confirm_remove_all_tags);
checkBoxConfirmRemoveAllTags.setChecked(pref->confirmRemoveAllTags());
addRow(CONFIRM_REMOVE_ALL_TAGS, tr("Confirm removal of all tags"), &checkBoxConfirmRemoveAllTags);
// Announce to all trackers in a tier
cb_announce_all_trackers.setChecked(session->announceToAllTrackers());
addRow(ANNOUNCE_ALL_TRACKERS, tr("Always announce to all trackers in a tier"), &cb_announce_all_trackers);
checkBoxAnnounceAllTrackers.setChecked(session->announceToAllTrackers());
addRow(ANNOUNCE_ALL_TRACKERS, tr("Always announce to all trackers in a tier"), &checkBoxAnnounceAllTrackers);
// Announce to all tiers
cb_announce_all_tiers.setChecked(session->announceToAllTiers());
addRow(ANNOUNCE_ALL_TIERS, tr("Always announce to all tiers"), &cb_announce_all_tiers);
checkBoxAnnounceAllTiers.setChecked(session->announceToAllTiers());
addRow(ANNOUNCE_ALL_TIERS, tr("Always announce to all tiers"), &checkBoxAnnounceAllTiers);
}
template <typename T>