mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-20 15:37:26 -06:00
Merge pull request #5342 from glassez/session
Optimize BitTorrent::Session settings applying
This commit is contained in:
@@ -27,11 +27,14 @@
|
||||
*/
|
||||
|
||||
#include "advancedsettings.h"
|
||||
|
||||
#include <QFont>
|
||||
#include <QHeaderView>
|
||||
#include <QHostAddress>
|
||||
#include <QNetworkInterface>
|
||||
|
||||
#include "app/application.h"
|
||||
#include "base/bittorrent/session.h"
|
||||
#include "base/preferences.h"
|
||||
#include "gui/mainwindow.h"
|
||||
|
||||
@@ -116,39 +119,40 @@ AdvancedSettings::AdvancedSettings(QWidget *parent)
|
||||
void AdvancedSettings::saveAdvancedSettings()
|
||||
{
|
||||
Preferences* const pref = Preferences::instance();
|
||||
BitTorrent::Session *const session = BitTorrent::Session::instance();
|
||||
|
||||
// Disk write cache
|
||||
pref->setDiskCacheSize(spin_cache.value());
|
||||
pref->setDiskCacheTTL(spin_cache_ttl.value());
|
||||
session->setDiskCacheSize(spin_cache.value());
|
||||
session->setDiskCacheTTL(spin_cache_ttl.value());
|
||||
// Enable OS cache
|
||||
pref->setOsCache(cb_os_cache.isChecked());
|
||||
session->setUseOSCache(cb_os_cache.isChecked());
|
||||
// Save resume data interval
|
||||
pref->setSaveResumeDataInterval(spin_save_resume_data_interval.value());
|
||||
session->setSaveResumeDataInterval(spin_save_resume_data_interval.value());
|
||||
// Outgoing ports
|
||||
pref->setOutgoingPortsMin(outgoing_ports_min.value());
|
||||
pref->setOutgoingPortsMax(outgoing_ports_max.value());
|
||||
session->setOutgoingPortsMin(outgoing_ports_min.value());
|
||||
session->setOutgoingPortsMax(outgoing_ports_max.value());
|
||||
// Recheck torrents on completion
|
||||
pref->recheckTorrentsOnCompletion(cb_recheck_completed.isChecked());
|
||||
// Transfer list refresh interval
|
||||
pref->setRefreshInterval(spin_list_refresh.value());
|
||||
session->setRefreshInterval(spin_list_refresh.value());
|
||||
// Peer resolution
|
||||
pref->resolvePeerCountries(cb_resolve_countries.isChecked());
|
||||
pref->resolvePeerHostNames(cb_resolve_hosts.isChecked());
|
||||
// Max Half-Open connections
|
||||
pref->setMaxHalfOpenConnections(spin_maxhalfopen.value());
|
||||
session->setMaxHalfOpenConnections(spin_maxhalfopen.value());
|
||||
// Super seeding
|
||||
pref->enableSuperSeeding(cb_super_seeding.isChecked());
|
||||
session->setSuperSeedingEnabled(cb_super_seeding.isChecked());
|
||||
// Network interface
|
||||
if (combo_iface.currentIndex() == 0) {
|
||||
// All interfaces (default)
|
||||
pref->setNetworkInterface(QString::null);
|
||||
pref->setNetworkInterfaceName(QString::null);
|
||||
session->setNetworkInterface(QString());
|
||||
pref->setNetworkInterfaceName(QString());
|
||||
}
|
||||
else {
|
||||
pref->setNetworkInterface(combo_iface.itemData(combo_iface.currentIndex()).toString());
|
||||
session->setNetworkInterface(combo_iface.itemData(combo_iface.currentIndex()).toString());
|
||||
pref->setNetworkInterfaceName(combo_iface.currentText());
|
||||
}
|
||||
// Listen on IPv6 address
|
||||
pref->setListenIPv6(cb_listen_ipv6.isChecked());
|
||||
|
||||
// Interface address
|
||||
if (combo_iface_address.currentIndex() == 0) {
|
||||
// All addresses (default)
|
||||
@@ -158,19 +162,18 @@ void AdvancedSettings::saveAdvancedSettings()
|
||||
QHostAddress ifaceAddr(combo_iface_address.currentText().trimmed());
|
||||
ifaceAddr.isNull() ? pref->setNetworkInterfaceAddress(QString::null) : pref->setNetworkInterfaceAddress(ifaceAddr.toString());
|
||||
}
|
||||
// Network Announce address
|
||||
QHostAddress networkAddr(txt_network_address.text().trimmed());
|
||||
if (networkAddr.isNull())
|
||||
pref->setNetworkAddress("");
|
||||
else
|
||||
pref->setNetworkAddress(networkAddr.toString());
|
||||
session->setIPv6Enabled(cb_listen_ipv6.isChecked());
|
||||
// Network address
|
||||
QHostAddress addr(txt_network_address.text().trimmed());
|
||||
session->setNetworkAddress(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());
|
||||
|
||||
// Tracker
|
||||
pref->setTrackerEnabled(cb_tracker_status.isChecked());
|
||||
session->setTrackerEnabled(cb_tracker_status.isChecked());
|
||||
pref->setTrackerPort(spin_tracker_port.value());
|
||||
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
|
||||
pref->setUpdateCheckEnabled(cb_update_check.isChecked());
|
||||
@@ -181,8 +184,8 @@ void AdvancedSettings::saveAdvancedSettings()
|
||||
#endif
|
||||
pref->setConfirmTorrentRecheck(cb_confirm_torrent_recheck.isChecked());
|
||||
// Tracker exchange
|
||||
pref->setTrackerExchangeEnabled(cb_enable_tracker_ext.isChecked());
|
||||
pref->setAnnounceToAllTrackers(cb_announce_all_trackers.isChecked());
|
||||
session->setTrackerExchangeEnabled(cb_enable_tracker_ext.isChecked());
|
||||
session->setAnnounceToAllTrackers(cb_announce_all_trackers.isChecked());
|
||||
}
|
||||
|
||||
void AdvancedSettings::updateCacheSpinSuffix(int value)
|
||||
@@ -233,6 +236,8 @@ void AdvancedSettings::updateInterfaceAddressCombo()
|
||||
void AdvancedSettings::loadAdvancedSettings()
|
||||
{
|
||||
const Preferences* const pref = Preferences::instance();
|
||||
BitTorrent::Session *const session = BitTorrent::Session::instance();
|
||||
|
||||
// add section headers
|
||||
QFont boldFont;
|
||||
boldFont.setBold(true);
|
||||
@@ -255,33 +260,33 @@ void AdvancedSettings::loadAdvancedSettings()
|
||||
// allocate 1536MiB and leave 512MiB to the rest of program data in RAM
|
||||
spin_cache.setMaximum(1536);
|
||||
#endif
|
||||
spin_cache.setValue(pref->diskCacheSize());
|
||||
spin_cache.setValue(session->diskCacheSize());
|
||||
updateCacheSpinSuffix(spin_cache.value());
|
||||
addRow(DISK_CACHE, tr("Disk write cache size"), &spin_cache);
|
||||
// Disk cache expiry
|
||||
spin_cache_ttl.setMinimum(15);
|
||||
spin_cache_ttl.setMaximum(600);
|
||||
spin_cache_ttl.setValue(pref->diskCacheTTL());
|
||||
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);
|
||||
// Enable OS cache
|
||||
cb_os_cache.setChecked(pref->osCache());
|
||||
cb_os_cache.setChecked(session->useOSCache());
|
||||
addRow(OS_CACHE, tr("Enable OS cache"), &cb_os_cache);
|
||||
// Save resume data interval
|
||||
spin_save_resume_data_interval.setMinimum(1);
|
||||
spin_save_resume_data_interval.setMaximum(1440);
|
||||
spin_save_resume_data_interval.setValue(pref->saveResumeDataInterval());
|
||||
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);
|
||||
// Outgoing port Min
|
||||
outgoing_ports_min.setMinimum(0);
|
||||
outgoing_ports_min.setMaximum(65535);
|
||||
outgoing_ports_min.setValue(pref->outgoingPortsMin());
|
||||
outgoing_ports_min.setValue(session->outgoingPortsMin());
|
||||
addRow(OUTGOING_PORT_MIN, tr("Outgoing ports (Min) [0: Disabled]"), &outgoing_ports_min);
|
||||
// Outgoing port Min
|
||||
outgoing_ports_max.setMinimum(0);
|
||||
outgoing_ports_max.setMaximum(65535);
|
||||
outgoing_ports_max.setValue(pref->outgoingPortsMax());
|
||||
outgoing_ports_max.setValue(session->outgoingPortsMax());
|
||||
addRow(OUTGOING_PORT_MAX, tr("Outgoing ports (Max) [0: Disabled]"), &outgoing_ports_max);
|
||||
// Recheck completed torrents
|
||||
cb_recheck_completed.setChecked(pref->recheckTorrentsOnCompletion());
|
||||
@@ -289,7 +294,7 @@ void AdvancedSettings::loadAdvancedSettings()
|
||||
// Transfer list refresh interval
|
||||
spin_list_refresh.setMinimum(30);
|
||||
spin_list_refresh.setMaximum(99999);
|
||||
spin_list_refresh.setValue(pref->getRefreshInterval());
|
||||
spin_list_refresh.setValue(session->refreshInterval());
|
||||
spin_list_refresh.setSuffix(tr(" ms", " milliseconds"));
|
||||
addRow(LIST_REFRESH, tr("Transfer list refresh interval"), &spin_list_refresh);
|
||||
// Resolve Peer countries
|
||||
@@ -301,14 +306,14 @@ void AdvancedSettings::loadAdvancedSettings()
|
||||
// Max Half Open connections
|
||||
spin_maxhalfopen.setMinimum(0);
|
||||
spin_maxhalfopen.setMaximum(99999);
|
||||
spin_maxhalfopen.setValue(pref->getMaxHalfOpenConnections());
|
||||
spin_maxhalfopen.setValue(session->maxHalfOpenConnections());
|
||||
addRow(MAX_HALF_OPEN, tr("Maximum number of half-open connections [0: Unlimited]"), &spin_maxhalfopen);
|
||||
// Super seeding
|
||||
cb_super_seeding.setChecked(pref->isSuperSeedingEnabled());
|
||||
cb_super_seeding.setChecked(session->isSuperSeedingEnabled());
|
||||
addRow(SUPER_SEEDING, tr("Strict super seeding"), &cb_super_seeding);
|
||||
// Network interface
|
||||
combo_iface.addItem(tr("Any interface", "i.e. Any network interface"));
|
||||
const QString current_iface = pref->getNetworkInterface();
|
||||
const QString current_iface = session->networkInterface();
|
||||
bool interface_exists = current_iface.isEmpty();
|
||||
int i = 1;
|
||||
foreach (const QNetworkInterface& iface, QNetworkInterface::allInterfaces()) {
|
||||
@@ -336,10 +341,10 @@ void AdvancedSettings::loadAdvancedSettings()
|
||||
updateInterfaceAddressCombo();
|
||||
addRow(NETWORK_IFACE_ADDRESS, tr("Optional IP Address to bind to (requires restart)"), &combo_iface_address);
|
||||
// Listen on IPv6 address
|
||||
cb_listen_ipv6.setChecked(pref->getListenIPv6());
|
||||
cb_listen_ipv6.setChecked(session->isIPv6Enabled());
|
||||
addRow(NETWORK_LISTEN_IPV6, tr("Listen on IPv6 address (requires restart)"), &cb_listen_ipv6);
|
||||
// Announce address
|
||||
txt_network_address.setText(pref->getNetworkAddress());
|
||||
txt_network_address.setText(session->networkAddress());
|
||||
addRow(NETWORK_ADDRESS, tr("IP Address to report to trackers (requires restart)"), &txt_network_address);
|
||||
|
||||
// Program notifications
|
||||
@@ -349,8 +354,9 @@ void AdvancedSettings::loadAdvancedSettings()
|
||||
// Torrent added notifications
|
||||
cb_torrent_added_notifications.setChecked(mainWindow->isTorrentAddedNotificationsEnabled());
|
||||
addRow(TORRENT_ADDED_NOTIFICATIONS, tr("Display notifications for added torrents"), &cb_torrent_added_notifications);
|
||||
|
||||
// Tracker State
|
||||
cb_tracker_status.setChecked(pref->isTrackerEnabled());
|
||||
cb_tracker_status.setChecked(session->isTrackerEnabled());
|
||||
addRow(TRACKER_STATUS, tr("Enable embedded tracker"), &cb_tracker_status);
|
||||
// Tracker port
|
||||
spin_tracker_port.setMinimum(1);
|
||||
@@ -369,10 +375,10 @@ void AdvancedSettings::loadAdvancedSettings()
|
||||
cb_confirm_torrent_recheck.setChecked(pref->confirmTorrentRecheck());
|
||||
addRow(CONFIRM_RECHECK_TORRENT, tr("Confirm torrent recheck"), &cb_confirm_torrent_recheck);
|
||||
// Tracker exchange
|
||||
cb_enable_tracker_ext.setChecked(pref->trackerExchangeEnabled());
|
||||
cb_enable_tracker_ext.setChecked(session->isTrackerExchangeEnabled());
|
||||
addRow(TRACKER_EXCHANGE, tr("Exchange trackers with other peers"), &cb_enable_tracker_ext);
|
||||
// Announce to all trackers
|
||||
cb_announce_all_trackers.setChecked(pref->announceToAllTrackers());
|
||||
cb_announce_all_trackers.setChecked(session->announceToAllTrackers());
|
||||
addRow(ANNOUNCE_ALL_TRACKERS, tr("Always announce to all trackers"), &cb_announce_all_trackers);
|
||||
}
|
||||
|
||||
|
||||
@@ -816,32 +816,26 @@ void MainWindow::handleDownloadFromUrlFailure(QString url, QString reason) const
|
||||
void MainWindow::on_actionSetGlobalUploadLimit_triggered()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
BitTorrent::Session *const session = BitTorrent::Session::instance();
|
||||
bool ok;
|
||||
int curLimit = BitTorrent::Session::instance()->uploadRateLimit();
|
||||
const long newLimit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Global Upload Speed Limit"), curLimit);
|
||||
const long newLimit = SpeedLimitDialog::askSpeedLimit(
|
||||
&ok, tr("Global Upload Speed Limit"), session->uploadSpeedLimit());
|
||||
if (ok) {
|
||||
qDebug("Setting global upload rate limit to %.1fKb/s", newLimit / 1024.);
|
||||
BitTorrent::Session::instance()->setUploadRateLimit(newLimit);
|
||||
if (newLimit <= 0)
|
||||
Preferences::instance()->setGlobalUploadLimit(-1);
|
||||
else
|
||||
Preferences::instance()->setGlobalUploadLimit(newLimit / 1024.);
|
||||
session->setUploadSpeedLimit(newLimit);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_actionSetGlobalDownloadLimit_triggered()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
BitTorrent::Session *const session = BitTorrent::Session::instance();
|
||||
bool ok;
|
||||
int curLimit = BitTorrent::Session::instance()->downloadRateLimit();
|
||||
const long newLimit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Global Download Speed Limit"), curLimit);
|
||||
const long newLimit = SpeedLimitDialog::askSpeedLimit(
|
||||
&ok, tr("Global Download Speed Limit"), session->downloadSpeedLimit());
|
||||
if (ok) {
|
||||
qDebug("Setting global download rate limit to %.1fKb/s", newLimit / 1024.);
|
||||
BitTorrent::Session::instance()->setDownloadRateLimit(newLimit);
|
||||
if (newLimit <= 0)
|
||||
Preferences::instance()->setGlobalDownloadLimit(-1);
|
||||
else
|
||||
Preferences::instance()->setGlobalDownloadLimit(newLimit / 1024.);
|
||||
session->setDownloadSpeedLimit(newLimit);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1217,7 +1211,7 @@ void MainWindow::loadPreferences(bool configureSession)
|
||||
m_propertiesWidget->getPeerList()->setAlternatingRowColors(pref->useAlternatingRowColors());
|
||||
|
||||
// Queueing System
|
||||
if (pref->isQueueingSystemEnabled()) {
|
||||
if (BitTorrent::Session::instance()->isQueueingSystemEnabled()) {
|
||||
if (!m_ui->actionDecreasePriority->isVisible()) {
|
||||
m_transferListWidget->hidePriorityColumn(false);
|
||||
m_ui->actionDecreasePriority->setVisible(true);
|
||||
@@ -1408,7 +1402,7 @@ QMenu* MainWindow::trayIconMenu()
|
||||
m_trayIconMenu->addAction(m_ui->actionOpen);
|
||||
m_trayIconMenu->addAction(m_ui->actionDownloadFromURL);
|
||||
m_trayIconMenu->addSeparator();
|
||||
const bool isAltBWEnabled = Preferences::instance()->isAltBandwidthEnabled();
|
||||
const bool isAltBWEnabled = BitTorrent::Session::instance()->isAltGlobalSpeedLimitEnabled();
|
||||
updateAltSpeedsBtn(isAltBWEnabled);
|
||||
m_ui->actionUseAlternativeSpeedLimits->setChecked(isAltBWEnabled);
|
||||
m_trayIconMenu->addAction(m_ui->actionUseAlternativeSpeedLimits);
|
||||
|
||||
@@ -51,6 +51,8 @@
|
||||
#include "app/application.h"
|
||||
#include "base/bittorrent/session.h"
|
||||
#include "base/net/dnsupdater.h"
|
||||
#include "base/net/portforwarder.h"
|
||||
#include "base/net/proxyconfigurationmanager.h"
|
||||
#include "base/preferences.h"
|
||||
#include "base/scanfoldersmodel.h"
|
||||
#include "base/torrentfileguard.h"
|
||||
@@ -507,8 +509,8 @@ void OptionsDialog::saveOptions()
|
||||
session->setDisableAutoTMMWhenDefaultSavePathChanged(m_ui->comboCategoryDefaultPathChanged->currentIndex() == 1);
|
||||
session->setTempPathEnabled(m_ui->checkTempFolder->isChecked());
|
||||
session->setTempPath(Utils::Fs::expandPathAbs(m_ui->textTempPath->text()));
|
||||
pref->useIncompleteFilesExtension(m_ui->checkAppendqB->isChecked());
|
||||
pref->preAllocateAllFiles(preAllocateAllFiles());
|
||||
session->setAppendExtensionEnabled(m_ui->checkAppendqB->isChecked());
|
||||
session->setPreallocationEnabled(preAllocateAllFiles());
|
||||
AddNewTorrentDialog::setEnabled(useAdditionDialog());
|
||||
AddNewTorrentDialog::setTopLevel(m_ui->checkAdditionDialogFront->isChecked());
|
||||
session->setAddTorrentPaused(addTorrentsInPause());
|
||||
@@ -517,8 +519,8 @@ void OptionsDialog::saveOptions()
|
||||
ScanFoldersModel::instance()->makePersistent();
|
||||
removedScanDirs.clear();
|
||||
addedScanDirs.clear();
|
||||
pref->setTorrentExportDir(getTorrentExportDir());
|
||||
pref->setFinishedTorrentExportDir(getFinishedTorrentExportDir());
|
||||
session->setTorrentExportDirectory(getTorrentExportDir());
|
||||
session->setFinishedTorrentExportDirectory(getFinishedTorrentExportDir());
|
||||
pref->setMailNotificationEnabled(m_ui->groupMailNotification->isChecked());
|
||||
pref->setMailNotificationEmail(m_ui->dest_email_txt->text());
|
||||
pref->setMailNotificationSMTP(m_ui->smtp_server_txt->text());
|
||||
@@ -536,61 +538,66 @@ void OptionsDialog::saveOptions()
|
||||
// End Downloads preferences
|
||||
|
||||
// Connection preferences
|
||||
pref->setSessionPort(getPort());
|
||||
pref->setRandomPort(m_ui->checkRandomPort->isChecked());
|
||||
pref->setUPnPEnabled(isUPnPEnabled());
|
||||
session->setPort(getPort());
|
||||
session->setUseRandomPort(m_ui->checkRandomPort->isChecked());
|
||||
Net::PortForwarder::instance()->setEnabled(isUPnPEnabled());
|
||||
const QPair<int, int> down_up_limit = getGlobalBandwidthLimits();
|
||||
pref->setGlobalDownloadLimit(down_up_limit.first);
|
||||
pref->setGlobalUploadLimit(down_up_limit.second);
|
||||
pref->setuTPEnabled(m_ui->checkuTP->isChecked());
|
||||
pref->setuTPRateLimited(m_ui->checkLimituTPConnections->isChecked());
|
||||
pref->includeOverheadInLimits(m_ui->checkLimitTransportOverhead->isChecked());
|
||||
pref->setIgnoreLimitsOnLAN(!m_ui->checkLimitLocalPeerRate->isChecked());
|
||||
session->setGlobalDownloadSpeedLimit(down_up_limit.first);
|
||||
session->setGlobalUploadSpeedLimit(down_up_limit.second);
|
||||
session->setUTPEnabled(m_ui->checkuTP->isChecked());
|
||||
session->setUTPRateLimited(m_ui->checkLimituTPConnections->isChecked());
|
||||
session->setIncludeOverheadInLimits(m_ui->checkLimitTransportOverhead->isChecked());
|
||||
session->setIgnoreLimitsOnLAN(!m_ui->checkLimitLocalPeerRate->isChecked());
|
||||
const QPair<int, int> alt_down_up_limit = getAltGlobalBandwidthLimits();
|
||||
pref->setAltGlobalDownloadLimit(alt_down_up_limit.first);
|
||||
pref->setAltGlobalUploadLimit(alt_down_up_limit.second);
|
||||
pref->setSchedulerEnabled(m_ui->check_schedule->isChecked());
|
||||
session->setAltGlobalDownloadSpeedLimit(alt_down_up_limit.first);
|
||||
session->setAltGlobalUploadSpeedLimit(alt_down_up_limit.second);
|
||||
session->setBandwidthSchedulerEnabled(m_ui->check_schedule->isChecked());
|
||||
pref->setSchedulerStartTime(m_ui->schedule_from->time());
|
||||
pref->setSchedulerEndTime(m_ui->schedule_to->time());
|
||||
pref->setSchedulerDays((scheduler_days)m_ui->schedule_days->currentIndex());
|
||||
pref->setProxyType(getProxyType());
|
||||
pref->setProxyIp(getProxyIp());
|
||||
pref->setProxyPort(getProxyPort());
|
||||
pref->setProxyPeerConnections(m_ui->checkProxyPeerConnecs->isChecked());
|
||||
pref->setForceProxy(m_ui->checkForceProxy->isChecked());
|
||||
pref->setProxyOnlyForTorrents(m_ui->isProxyOnlyForTorrents->isChecked());
|
||||
pref->setProxyAuthEnabled(isProxyAuthEnabled());
|
||||
pref->setProxyUsername(getProxyUsername());
|
||||
pref->setProxyPassword(getProxyPassword());
|
||||
|
||||
auto proxyConfigManager = Net::ProxyConfigurationManager::instance();
|
||||
Net::ProxyConfiguration proxyConf;
|
||||
proxyConf.type = getProxyType();
|
||||
proxyConf.ip = getProxyIp();
|
||||
proxyConf.port = getProxyPort();
|
||||
proxyConf.username = getProxyUsername();
|
||||
proxyConf.password = getProxyPassword();
|
||||
proxyConfigManager->setProxyDisabled(m_ui->isProxyOnlyForTorrents->isChecked());
|
||||
proxyConfigManager->setProxyConfiguration(proxyConf);
|
||||
|
||||
session->setProxyPeerConnectionsEnabled(m_ui->checkProxyPeerConnecs->isChecked());
|
||||
session->setForceProxyEnabled(m_ui->checkForceProxy->isChecked());
|
||||
// End Connection preferences
|
||||
|
||||
// Bittorrent preferences
|
||||
pref->setMaxConnecs(getMaxConnecs());
|
||||
pref->setMaxConnecsPerTorrent(getMaxConnecsPerTorrent());
|
||||
pref->setMaxUploads(getMaxUploads());
|
||||
pref->setMaxUploadsPerTorrent(getMaxUploadsPerTorrent());
|
||||
pref->setDHTEnabled(isDHTEnabled());
|
||||
pref->setPeXEnabled(m_ui->checkPeX->isChecked());
|
||||
pref->setLSDEnabled(isLSDEnabled());
|
||||
pref->setEncryptionSetting(getEncryptionSetting());
|
||||
pref->enableAnonymousMode(m_ui->checkAnonymousMode->isChecked());
|
||||
pref->setAddTrackersEnabled(m_ui->checkEnableAddTrackers->isChecked());
|
||||
pref->setTrackersList(m_ui->textTrackers->toPlainText());
|
||||
pref->setGlobalMaxRatio(getMaxRatio());
|
||||
session->setMaxConnections(getMaxConnecs());
|
||||
session->setMaxConnectionsPerTorrent(getMaxConnecsPerTorrent());
|
||||
session->setMaxUploads(getMaxUploads());
|
||||
session->setMaxUploadsPerTorrent(getMaxUploadsPerTorrent());
|
||||
session->setDHTEnabled(isDHTEnabled());
|
||||
session->setPeXEnabled(m_ui->checkPeX->isChecked());
|
||||
session->setLSDEnabled(isLSDEnabled());
|
||||
session->setEncryption(getEncryptionSetting());
|
||||
session->setAnonymousModeEnabled(m_ui->checkAnonymousMode->isChecked());
|
||||
session->setAddTrackersEnabled(m_ui->checkEnableAddTrackers->isChecked());
|
||||
session->setAdditionalTrackers(m_ui->textTrackers->toPlainText());
|
||||
session->setGlobalMaxRatio(getMaxRatio());
|
||||
session->setMaxRatioAction(static_cast<MaxRatioAction>(m_ui->comboRatioLimitAct->currentIndex()));
|
||||
// End Bittorrent preferences
|
||||
|
||||
// Misc preferences
|
||||
// * IPFilter
|
||||
pref->setFilteringEnabled(isFilteringEnabled());
|
||||
pref->setFilteringTrackerEnabled(m_ui->checkIpFilterTrackers->isChecked());
|
||||
pref->setFilter(m_ui->textFilterPath->text());
|
||||
session->setFilteringEnabled(isFilteringEnabled());
|
||||
session->setTrackerFilteringEnabled(m_ui->checkIpFilterTrackers->isChecked());
|
||||
session->setIPFilterFile(m_ui->textFilterPath->text());
|
||||
// End IPFilter preferences
|
||||
// Queueing system
|
||||
pref->setQueueingSystemEnabled(isQueueingSystemEnabled());
|
||||
pref->setMaxActiveDownloads(m_ui->spinMaxActiveDownloads->value());
|
||||
pref->setMaxActiveUploads(m_ui->spinMaxActiveUploads->value());
|
||||
pref->setMaxActiveTorrents(m_ui->spinMaxActiveTorrents->value());
|
||||
pref->setIgnoreSlowTorrentsForQueueing(m_ui->checkIgnoreSlowTorrentsForQueueing->isChecked());
|
||||
session->setQueueingSystemEnabled(isQueueingSystemEnabled());
|
||||
session->setMaxActiveDownloads(m_ui->spinMaxActiveDownloads->value());
|
||||
session->setMaxActiveUploads(m_ui->spinMaxActiveUploads->value());
|
||||
session->setMaxActiveTorrents(m_ui->spinMaxActiveTorrents->value());
|
||||
session->setIgnoreSlowTorrentsForQueueing(m_ui->checkIgnoreSlowTorrentsForQueueing->isChecked());
|
||||
// End Queueing system preferences
|
||||
// Web UI
|
||||
pref->setWebUiEnabled(isWebUiEnabled());
|
||||
@@ -626,29 +633,28 @@ bool OptionsDialog::isFilteringEnabled() const
|
||||
return m_ui->checkIPFilter->isChecked();
|
||||
}
|
||||
|
||||
int OptionsDialog::getProxyType() const
|
||||
Net::ProxyType OptionsDialog::getProxyType() const
|
||||
{
|
||||
switch (m_ui->comboProxyType->currentIndex()) {
|
||||
case 1:
|
||||
return Proxy::SOCKS4;
|
||||
return Net::ProxyType::SOCKS4;
|
||||
break;
|
||||
case 2:
|
||||
if (isProxyAuthEnabled())
|
||||
return Proxy::SOCKS5_PW;
|
||||
return Proxy::SOCKS5;
|
||||
return Net::ProxyType::SOCKS5_PW;
|
||||
return Net::ProxyType::SOCKS5;
|
||||
case 3:
|
||||
if (isProxyAuthEnabled())
|
||||
return Proxy::HTTP_PW;
|
||||
return Proxy::HTTP;
|
||||
return Net::ProxyType::HTTP_PW;
|
||||
return Net::ProxyType::HTTP;
|
||||
default:
|
||||
return -1;
|
||||
return Net::ProxyType::None;
|
||||
}
|
||||
}
|
||||
|
||||
void OptionsDialog::loadOptions()
|
||||
{
|
||||
int intValue;
|
||||
qreal floatValue;
|
||||
QString strValue;
|
||||
bool fileLogBackup = true;
|
||||
bool fileLogDelete = true;
|
||||
@@ -723,10 +729,10 @@ void OptionsDialog::loadOptions()
|
||||
m_ui->textTempPath->setEnabled(m_ui->checkTempFolder->isChecked());
|
||||
m_ui->browseTempDirButton->setEnabled(m_ui->checkTempFolder->isChecked());
|
||||
m_ui->textTempPath->setText(Utils::Fs::toNativePath(session->tempPath()));
|
||||
m_ui->checkAppendqB->setChecked(pref->useIncompleteFilesExtension());
|
||||
m_ui->checkPreallocateAll->setChecked(pref->preAllocateAllFiles());
|
||||
m_ui->checkAppendqB->setChecked(session->isAppendExtensionEnabled());
|
||||
m_ui->checkPreallocateAll->setChecked(session->isPreallocationEnabled());
|
||||
|
||||
strValue = Utils::Fs::toNativePath(pref->getTorrentExportDir());
|
||||
strValue = Utils::Fs::toNativePath(session->torrentExportDirectory());
|
||||
if (strValue.isEmpty()) {
|
||||
// Disable
|
||||
m_ui->checkExportDir->setChecked(false);
|
||||
@@ -741,7 +747,7 @@ void OptionsDialog::loadOptions()
|
||||
m_ui->textExportDir->setText(strValue);
|
||||
}
|
||||
|
||||
strValue = Utils::Fs::toNativePath(pref->getFinishedTorrentExportDir());
|
||||
strValue = Utils::Fs::toNativePath(session->finishedTorrentExportDirectory());
|
||||
if (strValue.isEmpty()) {
|
||||
// Disable
|
||||
m_ui->checkExportDirFin->setChecked(false);
|
||||
@@ -777,12 +783,12 @@ void OptionsDialog::loadOptions()
|
||||
// End Downloads preferences
|
||||
|
||||
// Connection preferences
|
||||
m_ui->checkUPnP->setChecked(pref->isUPnPEnabled());
|
||||
m_ui->checkRandomPort->setChecked(pref->useRandomPort());
|
||||
m_ui->spinPort->setValue(pref->getSessionPort());
|
||||
m_ui->checkUPnP->setChecked(Net::PortForwarder::instance()->isEnabled());
|
||||
m_ui->checkRandomPort->setChecked(session->useRandomPort());
|
||||
m_ui->spinPort->setValue(session->port());
|
||||
m_ui->spinPort->setDisabled(m_ui->checkRandomPort->isChecked());
|
||||
|
||||
intValue = pref->getMaxConnecs();
|
||||
intValue = session->maxConnections();
|
||||
if (intValue > 0) {
|
||||
// enable
|
||||
m_ui->checkMaxConnecs->setChecked(true);
|
||||
@@ -794,7 +800,7 @@ void OptionsDialog::loadOptions()
|
||||
m_ui->checkMaxConnecs->setChecked(false);
|
||||
m_ui->spinMaxConnec->setEnabled(false);
|
||||
}
|
||||
intValue = pref->getMaxConnecsPerTorrent();
|
||||
intValue = session->maxConnectionsPerTorrent();
|
||||
if (intValue > 0) {
|
||||
// enable
|
||||
m_ui->checkMaxConnecsPerTorrent->setChecked(true);
|
||||
@@ -806,7 +812,7 @@ void OptionsDialog::loadOptions()
|
||||
m_ui->checkMaxConnecsPerTorrent->setChecked(false);
|
||||
m_ui->spinMaxConnecPerTorrent->setEnabled(false);
|
||||
}
|
||||
intValue = pref->getMaxUploads();
|
||||
intValue = session->maxUploads();
|
||||
if (intValue > 0) {
|
||||
// enable
|
||||
m_ui->checkMaxUploads->setChecked(true);
|
||||
@@ -818,7 +824,7 @@ void OptionsDialog::loadOptions()
|
||||
m_ui->checkMaxUploads->setChecked(false);
|
||||
m_ui->spinMaxUploads->setEnabled(false);
|
||||
}
|
||||
intValue = pref->getMaxUploadsPerTorrent();
|
||||
intValue = session->maxUploadsPerTorrent();
|
||||
if (intValue > 0) {
|
||||
// enable
|
||||
m_ui->checkMaxUploadsPerTorrent->setChecked(true);
|
||||
@@ -831,39 +837,45 @@ void OptionsDialog::loadOptions()
|
||||
m_ui->spinMaxUploadsPerTorrent->setEnabled(false);
|
||||
}
|
||||
|
||||
intValue = pref->getProxyType();
|
||||
switch (intValue) {
|
||||
case Proxy::SOCKS4:
|
||||
auto proxyConfigManager = Net::ProxyConfigurationManager::instance();
|
||||
Net::ProxyConfiguration proxyConf = proxyConfigManager->proxyConfiguration();
|
||||
using Net::ProxyType;
|
||||
bool useProxyAuth = false;
|
||||
switch (proxyConf.type) {
|
||||
case ProxyType::SOCKS4:
|
||||
m_ui->comboProxyType->setCurrentIndex(1);
|
||||
break;
|
||||
case Proxy::SOCKS5:
|
||||
case Proxy::SOCKS5_PW:
|
||||
case ProxyType::SOCKS5_PW:
|
||||
useProxyAuth = true;
|
||||
case ProxyType::SOCKS5:
|
||||
m_ui->comboProxyType->setCurrentIndex(2);
|
||||
break;
|
||||
case Proxy::HTTP:
|
||||
case Proxy::HTTP_PW:
|
||||
case ProxyType::HTTP_PW:
|
||||
useProxyAuth = true;
|
||||
case ProxyType::HTTP:
|
||||
m_ui->comboProxyType->setCurrentIndex(3);
|
||||
break;
|
||||
default:
|
||||
m_ui->comboProxyType->setCurrentIndex(0);
|
||||
}
|
||||
enableProxy(m_ui->comboProxyType->currentIndex());
|
||||
m_ui->textProxyIP->setText(pref->getProxyIp());
|
||||
m_ui->spinProxyPort->setValue(pref->getProxyPort());
|
||||
m_ui->checkProxyPeerConnecs->setChecked(pref->proxyPeerConnections());
|
||||
m_ui->checkForceProxy->setChecked(pref->getForceProxy());
|
||||
m_ui->isProxyOnlyForTorrents->setChecked(pref->isProxyOnlyForTorrents());
|
||||
m_ui->checkProxyAuth->setChecked(pref->isProxyAuthEnabled());
|
||||
m_ui->textProxyUsername->setText(pref->getProxyUsername());
|
||||
m_ui->textProxyPassword->setText(pref->getProxyPassword());
|
||||
enableProxy(m_ui->comboProxyType->currentIndex() > 0);
|
||||
m_ui->textProxyIP->setText(proxyConf.ip);
|
||||
m_ui->spinProxyPort->setValue(proxyConf.port);
|
||||
m_ui->checkProxyAuth->setChecked(useProxyAuth);
|
||||
m_ui->textProxyUsername->setText(proxyConf.username);
|
||||
m_ui->textProxyPassword->setText(proxyConf.password);
|
||||
|
||||
m_ui->checkIPFilter->setChecked(pref->isFilteringEnabled());
|
||||
m_ui->checkIpFilterTrackers->setChecked(pref->isFilteringTrackerEnabled());
|
||||
m_ui->textFilterPath->setText(Utils::Fs::toNativePath(pref->getFilter()));
|
||||
m_ui->checkProxyPeerConnecs->setChecked(session->isProxyPeerConnectionsEnabled());
|
||||
m_ui->checkForceProxy->setChecked(session->isForceProxyEnabled());
|
||||
m_ui->isProxyOnlyForTorrents->setChecked(proxyConfigManager->isProxyDisabled());
|
||||
|
||||
m_ui->checkIPFilter->setChecked(session->isFilteringEnabled());
|
||||
m_ui->checkIpFilterTrackers->setChecked(session->isTrackerFilteringEnabled());
|
||||
m_ui->textFilterPath->setText(Utils::Fs::toNativePath(session->IPFilterFile()));
|
||||
// End Connection preferences
|
||||
|
||||
// Speed preferences
|
||||
intValue = pref->getGlobalDownloadLimit();
|
||||
intValue = session->globalDownloadSpeedLimit();
|
||||
if (intValue > 0) {
|
||||
// Enabled
|
||||
m_ui->checkDownloadLimit->setChecked(true);
|
||||
@@ -875,8 +887,8 @@ void OptionsDialog::loadOptions()
|
||||
m_ui->checkDownloadLimit->setChecked(false);
|
||||
m_ui->spinDownloadLimit->setEnabled(false);
|
||||
}
|
||||
intValue = pref->getGlobalUploadLimit();
|
||||
if (intValue != -1) {
|
||||
intValue = session->globalUploadSpeedLimit();
|
||||
if (intValue > 0) {
|
||||
// Enabled
|
||||
m_ui->checkUploadLimit->setChecked(true);
|
||||
m_ui->spinUploadLimit->setEnabled(true);
|
||||
@@ -888,7 +900,7 @@ void OptionsDialog::loadOptions()
|
||||
m_ui->spinUploadLimit->setEnabled(false);
|
||||
}
|
||||
|
||||
intValue = pref->getAltGlobalDownloadLimit();
|
||||
intValue = session->altGlobalDownloadSpeedLimit();
|
||||
if (intValue > 0) {
|
||||
// Enabled
|
||||
m_ui->checkDownloadLimitAlt->setChecked(true);
|
||||
@@ -900,8 +912,8 @@ void OptionsDialog::loadOptions()
|
||||
m_ui->checkDownloadLimitAlt->setChecked(false);
|
||||
m_ui->spinDownloadLimitAlt->setEnabled(false);
|
||||
}
|
||||
intValue = pref->getAltGlobalUploadLimit();
|
||||
if (intValue != -1) {
|
||||
intValue = session->altGlobalUploadSpeedLimit();
|
||||
if (intValue > 0) {
|
||||
// Enabled
|
||||
m_ui->checkUploadLimitAlt->setChecked(true);
|
||||
m_ui->spinUploadLimitAlt->setEnabled(true);
|
||||
@@ -913,40 +925,39 @@ void OptionsDialog::loadOptions()
|
||||
m_ui->spinUploadLimitAlt->setEnabled(false);
|
||||
}
|
||||
|
||||
m_ui->checkuTP->setChecked(pref->isuTPEnabled());
|
||||
m_ui->checkuTP->setChecked(session->isUTPEnabled());
|
||||
m_ui->checkLimituTPConnections->setEnabled(m_ui->checkuTP->isChecked());
|
||||
m_ui->checkLimituTPConnections->setChecked(pref->isuTPRateLimited());
|
||||
m_ui->checkLimitTransportOverhead->setChecked(pref->includeOverheadInLimits());
|
||||
m_ui->checkLimitLocalPeerRate->setChecked(!pref->getIgnoreLimitsOnLAN());
|
||||
m_ui->checkLimituTPConnections->setChecked(session->isUTPRateLimited());
|
||||
m_ui->checkLimitTransportOverhead->setChecked(session->includeOverheadInLimits());
|
||||
m_ui->checkLimitLocalPeerRate->setChecked(!session->ignoreLimitsOnLAN());
|
||||
|
||||
m_ui->check_schedule->setChecked(pref->isSchedulerEnabled());
|
||||
m_ui->check_schedule->setChecked(session->isBandwidthSchedulerEnabled());
|
||||
m_ui->schedule_from->setTime(pref->getSchedulerStartTime());
|
||||
m_ui->schedule_to->setTime(pref->getSchedulerEndTime());
|
||||
m_ui->schedule_days->setCurrentIndex((int)pref->getSchedulerDays());
|
||||
// End Speed preferences
|
||||
|
||||
// Bittorrent preferences
|
||||
m_ui->checkDHT->setChecked(pref->isDHTEnabled());
|
||||
m_ui->checkPeX->setChecked(pref->isPeXEnabled());
|
||||
m_ui->checkLSD->setChecked(pref->isLSDEnabled());
|
||||
m_ui->comboEncryption->setCurrentIndex(pref->getEncryptionSetting());
|
||||
m_ui->checkAnonymousMode->setChecked(pref->isAnonymousModeEnabled());
|
||||
m_ui->checkEnableAddTrackers->setChecked(pref->isAddTrackersEnabled());
|
||||
m_ui->textTrackers->setPlainText(pref->getTrackersList());
|
||||
m_ui->checkDHT->setChecked(session->isDHTEnabled());
|
||||
m_ui->checkPeX->setChecked(session->isPeXEnabled());
|
||||
m_ui->checkLSD->setChecked(session->isLSDEnabled());
|
||||
m_ui->comboEncryption->setCurrentIndex(session->encryption());
|
||||
m_ui->checkAnonymousMode->setChecked(session->isAnonymousModeEnabled());
|
||||
m_ui->checkEnableAddTrackers->setChecked(session->isAddTrackersEnabled());
|
||||
m_ui->textTrackers->setPlainText(session->additionalTrackers());
|
||||
|
||||
m_ui->checkEnableQueueing->setChecked(pref->isQueueingSystemEnabled());
|
||||
m_ui->spinMaxActiveDownloads->setValue(pref->getMaxActiveDownloads());
|
||||
m_ui->spinMaxActiveUploads->setValue(pref->getMaxActiveUploads());
|
||||
m_ui->spinMaxActiveTorrents->setValue(pref->getMaxActiveTorrents());
|
||||
m_ui->checkIgnoreSlowTorrentsForQueueing->setChecked(pref->ignoreSlowTorrentsForQueueing());
|
||||
m_ui->checkEnableQueueing->setChecked(session->isQueueingSystemEnabled());
|
||||
m_ui->spinMaxActiveDownloads->setValue(session->maxActiveDownloads());
|
||||
m_ui->spinMaxActiveUploads->setValue(session->maxActiveUploads());
|
||||
m_ui->spinMaxActiveTorrents->setValue(session->maxActiveTorrents());
|
||||
m_ui->checkIgnoreSlowTorrentsForQueueing->setChecked(session->ignoreSlowTorrentsForQueueing());
|
||||
|
||||
floatValue = pref->getGlobalMaxRatio();
|
||||
if (floatValue >= 0.) {
|
||||
if (session->globalMaxRatio() >= 0.) {
|
||||
// Enable
|
||||
m_ui->checkMaxRatio->setChecked(true);
|
||||
m_ui->spinMaxRatio->setEnabled(true);
|
||||
m_ui->comboRatioLimitAct->setEnabled(true);
|
||||
m_ui->spinMaxRatio->setValue(floatValue);
|
||||
m_ui->spinMaxRatio->setValue(session->globalMaxRatio());
|
||||
}
|
||||
else {
|
||||
// Disable
|
||||
@@ -1522,13 +1533,12 @@ void OptionsDialog::on_IpFilterRefreshBtn_clicked()
|
||||
if (m_refreshingIpFilter) return;
|
||||
m_refreshingIpFilter = true;
|
||||
// Updating program preferences
|
||||
Preferences* const pref = Preferences::instance();
|
||||
pref->setFilteringEnabled(true);
|
||||
pref->setFilter(getFilter());
|
||||
// Force refresh
|
||||
connect(BitTorrent::Session::instance(), SIGNAL(ipFilterParsed(bool, int)), SLOT(handleIPFilterParsed(bool, int)));
|
||||
BitTorrent::Session *const session = BitTorrent::Session::instance();
|
||||
session->setFilteringEnabled(true);
|
||||
session->setIPFilterFile(""); // forcing Session reload filter file
|
||||
session->setIPFilterFile(getFilter());
|
||||
connect(session, SIGNAL(IPFilterParsed(bool, int)), SLOT(handleIPFilterParsed(bool, int)));
|
||||
setCursor(QCursor(Qt::WaitCursor));
|
||||
BitTorrent::Session::instance()->enableIPFilter(getFilter(), true);
|
||||
}
|
||||
|
||||
void OptionsDialog::handleIPFilterParsed(bool error, int ruleCount)
|
||||
@@ -1539,7 +1549,7 @@ void OptionsDialog::handleIPFilterParsed(bool error, int ruleCount)
|
||||
else
|
||||
QMessageBox::information(this, tr("Successfully refreshed"), tr("Successfully parsed the provided IP filter: %1 rules were applied.", "%1 is a number").arg(ruleCount));
|
||||
m_refreshingIpFilter = false;
|
||||
disconnect(BitTorrent::Session::instance(), SIGNAL(ipFilterParsed(bool, int)), this, SLOT(handleIPFilterParsed(bool, int)));
|
||||
disconnect(BitTorrent::Session::instance(), SIGNAL(IPFilterParsed(bool, int)), this, SLOT(handleIPFilterParsed(bool, int)));
|
||||
}
|
||||
|
||||
QString OptionsDialog::languageToLocalizedString(const QLocale &locale)
|
||||
|
||||
@@ -47,6 +47,11 @@ enum DoubleClickAction
|
||||
NO_ACTION
|
||||
};
|
||||
|
||||
namespace Net
|
||||
{
|
||||
enum class ProxyType;
|
||||
}
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class OptionsDialog;
|
||||
@@ -149,7 +154,7 @@ private:
|
||||
unsigned short getProxyPort() const;
|
||||
QString getProxyUsername() const;
|
||||
QString getProxyPassword() const;
|
||||
int getProxyType() const;
|
||||
Net::ProxyType getProxyType() const;
|
||||
// IP Filter
|
||||
bool isFilteringEnabled() const;
|
||||
QString getFilter() const;
|
||||
|
||||
@@ -224,7 +224,7 @@ void TrackerList::loadStickyItems(BitTorrent::TorrentHandle *const torrent) {
|
||||
dht_item->setText(COL_STATUS, disabled);
|
||||
|
||||
// Load PeX Information
|
||||
if (BitTorrent::Session::instance()->isPexEnabled() && !torrent->isPrivate())
|
||||
if (BitTorrent::Session::instance()->isPeXEnabled() && !torrent->isPrivate())
|
||||
pex_item->setText(COL_STATUS, working);
|
||||
else
|
||||
pex_item->setText(COL_STATUS, disabled);
|
||||
|
||||
@@ -43,7 +43,6 @@
|
||||
#include "base/bittorrent/sessionstatus.h"
|
||||
#include "speedlimitdlg.h"
|
||||
#include "guiiconprovider.h"
|
||||
#include "base/preferences.h"
|
||||
#include "base/utils/misc.h"
|
||||
#include "base/logger.h"
|
||||
|
||||
@@ -52,8 +51,8 @@ StatusBar::StatusBar(QStatusBar *bar)
|
||||
{
|
||||
qApp->setStyleSheet("QStatusBar::item { border-width: 0; }");
|
||||
|
||||
Preferences* const pref = Preferences::instance();
|
||||
connect(BitTorrent::Session::instance(), SIGNAL(speedLimitModeChanged(bool)), this, SLOT(updateAltSpeedsBtn(bool)));
|
||||
BitTorrent::Session *const session = BitTorrent::Session::instance();
|
||||
connect(session, SIGNAL(speedLimitModeChanged(bool)), this, SLOT(updateAltSpeedsBtn(bool)));
|
||||
m_container = new QWidget(bar);
|
||||
m_layout = new QHBoxLayout(m_container);
|
||||
m_layout->setContentsMargins(0,0,0,0);
|
||||
@@ -91,7 +90,7 @@ StatusBar::StatusBar(QStatusBar *bar)
|
||||
m_altSpeedsBtn->setFlat(true);
|
||||
m_altSpeedsBtn->setFocusPolicy(Qt::NoFocus);
|
||||
m_altSpeedsBtn->setCursor(Qt::PointingHandCursor);
|
||||
updateAltSpeedsBtn(pref->isAltBandwidthEnabled());
|
||||
updateAltSpeedsBtn(session->isAltGlobalSpeedLimitEnabled());
|
||||
connect(m_altSpeedsBtn, SIGNAL(clicked()), this, SLOT(toggleAlternativeSpeeds()));
|
||||
|
||||
// Because on some platforms the default icon size is bigger
|
||||
@@ -134,7 +133,7 @@ StatusBar::StatusBar(QStatusBar *bar)
|
||||
m_container->adjustSize();
|
||||
bar->adjustSize();
|
||||
// Is DHT enabled
|
||||
m_DHTLbl->setVisible(pref->isDHTEnabled());
|
||||
m_DHTLbl->setVisible(session->isDHTEnabled());
|
||||
m_refreshTimer = new QTimer(bar);
|
||||
refreshStatusBar();
|
||||
connect(m_refreshTimer, SIGNAL(timeout()), this, SLOT(refreshStatusBar()));
|
||||
@@ -175,18 +174,18 @@ void StatusBar::stopTimer()
|
||||
void StatusBar::updateConnectionStatus(const BitTorrent::SessionStatus &sessionStatus)
|
||||
{
|
||||
if (!BitTorrent::Session::instance()->isListening()) {
|
||||
m_connecStatusLblIcon->setIcon(QIcon(QString::fromUtf8(":/icons/skin/disconnected.png")));
|
||||
m_connecStatusLblIcon->setToolTip(QString::fromUtf8("<b>") + tr("Connection Status:") + QString::fromUtf8("</b><br>") + tr("Offline. This usually means that qBittorrent failed to listen on the selected port for incoming connections."));
|
||||
m_connecStatusLblIcon->setIcon(QIcon(QLatin1String(":/icons/skin/disconnected.png")));
|
||||
m_connecStatusLblIcon->setToolTip(QLatin1String("<b>") + tr("Connection Status:") + QLatin1String("</b><br>") + tr("Offline. This usually means that qBittorrent failed to listen on the selected port for incoming connections."));
|
||||
}
|
||||
else {
|
||||
if (sessionStatus.hasIncomingConnections()) {
|
||||
// Connection OK
|
||||
m_connecStatusLblIcon->setIcon(QIcon(QString::fromUtf8(":/icons/skin/connected.png")));
|
||||
m_connecStatusLblIcon->setToolTip(QString::fromUtf8("<b>") + tr("Connection Status:") + QString::fromUtf8("</b><br>") + tr("Online"));
|
||||
m_connecStatusLblIcon->setIcon(QIcon(QLatin1String(":/icons/skin/connected.png")));
|
||||
m_connecStatusLblIcon->setToolTip(QLatin1String("<b>") + tr("Connection Status:") + QLatin1String("</b><br>") + tr("Online"));
|
||||
}
|
||||
else {
|
||||
m_connecStatusLblIcon->setIcon(QIcon(QString::fromUtf8(":/icons/skin/firewalled.png")));
|
||||
m_connecStatusLblIcon->setToolTip(QString::fromUtf8("<b>") + tr("Connection status:") + QString::fromUtf8("</b><br>") + QString::fromUtf8("<i>") + tr("No direct connections. This may indicate network configuration problems.") + QString::fromUtf8("</i>"));
|
||||
m_connecStatusLblIcon->setIcon(QIcon(QLatin1String(":/icons/skin/firewalled.png")));
|
||||
m_connecStatusLblIcon->setToolTip(QLatin1String("<b>") + tr("Connection status:") + QLatin1String("</b><br>") + QLatin1String("<i>") + tr("No direct connections. This may indicate network configuration problems.") + QLatin1String("</i>"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -205,14 +204,14 @@ void StatusBar::updateDHTNodesNumber(const BitTorrent::SessionStatus &sessionSta
|
||||
void StatusBar::updateSpeedLabels(const BitTorrent::SessionStatus &sessionStatus)
|
||||
{
|
||||
QString speedLbl = Utils::Misc::friendlyUnit(sessionStatus.payloadDownloadRate(), true);
|
||||
int speedLimit = BitTorrent::Session::instance()->downloadRateLimit();
|
||||
if (speedLimit)
|
||||
int speedLimit = BitTorrent::Session::instance()->downloadSpeedLimit();
|
||||
if (speedLimit >= 0)
|
||||
speedLbl += " [" + Utils::Misc::friendlyUnit(speedLimit, true) + "]";
|
||||
speedLbl += " (" + Utils::Misc::friendlyUnit(sessionStatus.totalPayloadDownload()) + ")";
|
||||
m_dlSpeedLbl->setText(speedLbl);
|
||||
speedLimit = BitTorrent::Session::instance()->uploadRateLimit();
|
||||
speedLimit = BitTorrent::Session::instance()->uploadSpeedLimit();
|
||||
speedLbl = Utils::Misc::friendlyUnit(sessionStatus.payloadUploadRate(), true);
|
||||
if (speedLimit)
|
||||
if (speedLimit >= 0)
|
||||
speedLbl += " [" + Utils::Misc::friendlyUnit(speedLimit, true) + "]";
|
||||
speedLbl += " (" + Utils::Misc::friendlyUnit(sessionStatus.totalPayloadUpload()) + ")";
|
||||
m_upSpeedLbl->setText(speedLbl);
|
||||
@@ -243,35 +242,26 @@ void StatusBar::updateAltSpeedsBtn(bool alternative)
|
||||
|
||||
void StatusBar::toggleAlternativeSpeeds()
|
||||
{
|
||||
Preferences* const pref = Preferences::instance();
|
||||
if (pref->isSchedulerEnabled())
|
||||
BitTorrent::Session *const session = BitTorrent::Session::instance();
|
||||
if (session->isBandwidthSchedulerEnabled())
|
||||
m_bar->showMessage(tr("Manual change of rate limits mode. The scheduler is disabled."), 5000);
|
||||
BitTorrent::Session::instance()->changeSpeedLimitMode(!pref->isAltBandwidthEnabled());
|
||||
session->setAltGlobalSpeedLimitEnabled(!session->isAltGlobalSpeedLimitEnabled());
|
||||
}
|
||||
|
||||
void StatusBar::capDownloadSpeed()
|
||||
{
|
||||
BitTorrent::Session *const session = BitTorrent::Session::instance();
|
||||
bool ok = false;
|
||||
int curLimit = BitTorrent::Session::instance()->downloadRateLimit();
|
||||
long newLimit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Global Download Speed Limit"), curLimit);
|
||||
long newLimit = SpeedLimitDialog::askSpeedLimit(
|
||||
&ok, tr("Global Download Speed Limit"), session->downloadSpeedLimit());
|
||||
if (ok) {
|
||||
Preferences* const pref = Preferences::instance();
|
||||
bool alt = pref->isAltBandwidthEnabled();
|
||||
if (newLimit <= 0) {
|
||||
qDebug("Setting global download rate limit to Unlimited");
|
||||
BitTorrent::Session::instance()->setDownloadRateLimit(-1);
|
||||
if (!alt)
|
||||
pref->setGlobalDownloadLimit(-1);
|
||||
else
|
||||
pref->setAltGlobalDownloadLimit(-1);
|
||||
session->setDownloadSpeedLimit(-1);
|
||||
}
|
||||
else {
|
||||
qDebug("Setting global download rate limit to %.1fKb/s", newLimit / 1024.);
|
||||
BitTorrent::Session::instance()->setDownloadRateLimit(newLimit);
|
||||
if (!alt)
|
||||
pref->setGlobalDownloadLimit(newLimit / 1024.);
|
||||
else
|
||||
pref->setAltGlobalDownloadLimit(newLimit / 1024.);
|
||||
session->setDownloadSpeedLimit(newLimit);
|
||||
}
|
||||
refreshStatusBar();
|
||||
}
|
||||
@@ -279,27 +269,18 @@ void StatusBar::capDownloadSpeed()
|
||||
|
||||
void StatusBar::capUploadSpeed()
|
||||
{
|
||||
BitTorrent::Session *const session = BitTorrent::Session::instance();
|
||||
bool ok = false;
|
||||
int curLimit = BitTorrent::Session::instance()->uploadRateLimit();
|
||||
long newLimit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Global Upload Speed Limit"), curLimit);
|
||||
long newLimit = SpeedLimitDialog::askSpeedLimit(
|
||||
&ok, tr("Global Upload Speed Limit"), session->uploadSpeedLimit());
|
||||
if (ok) {
|
||||
Preferences* const pref = Preferences::instance();
|
||||
bool alt = pref->isAltBandwidthEnabled();
|
||||
if (newLimit <= 0) {
|
||||
qDebug("Setting global upload rate limit to Unlimited");
|
||||
BitTorrent::Session::instance()->setUploadRateLimit(-1);
|
||||
if (!alt)
|
||||
Preferences::instance()->setGlobalUploadLimit(-1);
|
||||
else
|
||||
Preferences::instance()->setAltGlobalUploadLimit(-1);
|
||||
session->setUploadSpeedLimit(-1);
|
||||
}
|
||||
else {
|
||||
qDebug("Setting global upload rate limit to %.1fKb/s", newLimit / 1024.);
|
||||
BitTorrent::Session::instance()->setUploadRateLimit(newLimit);
|
||||
if (!alt)
|
||||
Preferences::instance()->setGlobalUploadLimit(newLimit / 1024.);
|
||||
else
|
||||
Preferences::instance()->setAltGlobalUploadLimit(newLimit / 1024.);
|
||||
session->setUploadSpeedLimit(newLimit);
|
||||
}
|
||||
refreshStatusBar();
|
||||
}
|
||||
|
||||
@@ -447,7 +447,9 @@ void TransferListWidget::setDlLimitSelectedTorrents()
|
||||
int default_limit = -1;
|
||||
if (all_same_limit)
|
||||
default_limit = selected_torrents.first()->downloadLimit();
|
||||
const long new_limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Torrent Download Speed Limiting"), default_limit, Preferences::instance()->getGlobalDownloadLimit() * 1024.);
|
||||
const long new_limit = SpeedLimitDialog::askSpeedLimit(
|
||||
&ok, tr("Torrent Download Speed Limiting"), default_limit
|
||||
, BitTorrent::Session::instance()->globalDownloadSpeedLimit());
|
||||
if (ok) {
|
||||
foreach (BitTorrent::TorrentHandle *const torrent, selected_torrents) {
|
||||
qDebug("Applying download speed limit of %ld Kb/s to torrent %s", (long)(new_limit / 1024.), qPrintable(torrent->hash()));
|
||||
@@ -476,7 +478,9 @@ void TransferListWidget::setUpLimitSelectedTorrents()
|
||||
int default_limit = -1;
|
||||
if (all_same_limit)
|
||||
default_limit = selected_torrents.first()->uploadLimit();
|
||||
const long new_limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Torrent Upload Speed Limiting"), default_limit, Preferences::instance()->getGlobalUploadLimit() * 1024.);
|
||||
const long new_limit = SpeedLimitDialog::askSpeedLimit(
|
||||
&ok, tr("Torrent Upload Speed Limiting"), default_limit
|
||||
, BitTorrent::Session::instance()->globalUploadSpeedLimit());
|
||||
if (ok) {
|
||||
foreach (BitTorrent::TorrentHandle *const torrent, selected_torrents) {
|
||||
qDebug("Applying upload speed limit of %ld Kb/s to torrent %s", (long)(new_limit / 1024.), qPrintable(torrent->hash()));
|
||||
@@ -522,7 +526,7 @@ void TransferListWidget::displayDLHoSMenu(const QPoint&)
|
||||
hideshowColumn.setTitle(tr("Column visibility"));
|
||||
QList<QAction*> actions;
|
||||
for (int i = 0; i < listModel->columnCount(); ++i) {
|
||||
if (!BitTorrent::Session::instance()->isQueueingEnabled() && i == TorrentModel::TR_PRIORITY) {
|
||||
if (!BitTorrent::Session::instance()->isQueueingSystemEnabled() && i == TorrentModel::TR_PRIORITY) {
|
||||
actions.append(0);
|
||||
continue;
|
||||
}
|
||||
@@ -837,7 +841,7 @@ void TransferListWidget::displayListMenu(const QPoint&)
|
||||
listMenu.addSeparator();
|
||||
}
|
||||
listMenu.addAction(&actionOpen_destination_folder);
|
||||
if (BitTorrent::Session::instance()->isQueueingEnabled() && one_not_seed) {
|
||||
if (BitTorrent::Session::instance()->isQueueingSystemEnabled() && one_not_seed) {
|
||||
listMenu.addSeparator();
|
||||
QMenu *prioMenu = listMenu.addMenu(tr("Priority"));
|
||||
prioMenu->addAction(&actionTopPriority);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt4 and libtorrent.
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2011 Christian Kandeler, Christophe Dumez
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -29,28 +29,32 @@
|
||||
*/
|
||||
|
||||
#include "updownratiodlg.h"
|
||||
|
||||
#include "base/bittorrent/session.h"
|
||||
#include "ui_updownratiodlg.h"
|
||||
|
||||
#include "base/preferences.h"
|
||||
|
||||
UpDownRatioDlg::UpDownRatioDlg(bool useDefault, qreal initialValue,
|
||||
qreal maxValue, QWidget *parent)
|
||||
: QDialog(parent), ui(new Ui::UpDownRatioDlg)
|
||||
qreal maxValue, QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::UpDownRatioDlg)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
if (useDefault) {
|
||||
ui->useDefaultButton->setChecked(true);
|
||||
} else if (initialValue == -1) {
|
||||
}
|
||||
else if (initialValue == -1) {
|
||||
ui->noLimitButton->setChecked(true);
|
||||
initialValue = Preferences::instance()->getGlobalMaxRatio();
|
||||
} else {
|
||||
initialValue = BitTorrent::Session::instance()->globalMaxRatio();
|
||||
}
|
||||
else {
|
||||
ui->torrentLimitButton->setChecked(true);
|
||||
}
|
||||
|
||||
ui->ratioSpinBox->setMinimum(0);
|
||||
ui->ratioSpinBox->setMaximum(maxValue);
|
||||
ui->ratioSpinBox->setValue(initialValue);
|
||||
connect(ui->buttonGroup, SIGNAL(buttonClicked(int)),
|
||||
SLOT(handleRatioTypeChanged()));
|
||||
connect(ui->buttonGroup, SIGNAL(buttonClicked(int)), SLOT(handleRatioTypeChanged()));
|
||||
handleRatioTypeChanged();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user