diff --git a/src/preferences/advancedsettings.h b/src/preferences/advancedsettings.h index d71967e97..b56823c47 100644 --- a/src/preferences/advancedsettings.h +++ b/src/preferences/advancedsettings.h @@ -55,6 +55,8 @@ public: horizontalHeader()->setStretchLastSection(true); verticalHeader()->setVisible(false); setRowCount(ROW_COUNT); + // Signals + connect(&spin_cache, SIGNAL(valueChanged(int)), SLOT(updateCacheSpinSuffix(int))); // Load settings loadAdvancedSettings(); } @@ -151,13 +153,22 @@ private: } private slots: - void loadAdvancedSettings() { + void updateCacheSpinSuffix(int value) + { + if (value <= 0) + spin_cache.setSuffix(tr(" (auto)")); + else + spin_cache.setSuffix(tr(" MiB")); + } + + void loadAdvancedSettings() + { const Preferences pref; // Disk write cache - spin_cache.setMinimum(1); - spin_cache.setMaximum(200); + spin_cache.setMinimum(0); + spin_cache.setMaximum(2048); spin_cache.setValue(pref.diskCacheSize()); - spin_cache.setSuffix(tr(" MiB")); + updateCacheSpinSuffix(spin_cache.value()); setRow(DISK_CACHE, tr("Disk write cache size"), &spin_cache); // Outgoing port Min outgoing_ports_min.setMinimum(0); diff --git a/src/preferences/preferences.h b/src/preferences/preferences.h index 4dc61e765..c46e7f8f7 100755 --- a/src/preferences/preferences.h +++ b/src/preferences/preferences.h @@ -927,11 +927,11 @@ public: } uint diskCacheSize() const { - return value(QString::fromUtf8("Preferences/Downloads/DiskCache"), 16).toUInt(); + return value(QString::fromUtf8("Preferences/Downloads/DiskWriteCacheSize"), 0).toUInt(); } void setDiskCacheSize(uint size) { - setValue(QString::fromUtf8("Preferences/Downloads/DiskCache"), size); + setValue(QString::fromUtf8("Preferences/Downloads/DiskWriteCacheSize"), size); } uint outgoingPortsMin() const { diff --git a/src/qtlibtorrent/qbtsession.cpp b/src/qtlibtorrent/qbtsession.cpp index 4551cb192..2d8c8fba1 100755 --- a/src/qtlibtorrent/qbtsession.cpp +++ b/src/qtlibtorrent/qbtsession.cpp @@ -402,7 +402,8 @@ void QBtSession::configureSession() { sessionSettings.announce_to_all_trackers = announce_to_all; sessionSettings.announce_to_all_tiers = announce_to_all; sessionSettings.auto_scrape_min_interval = 900; // 15 minutes - sessionSettings.cache_size = pref.diskCacheSize()*64; + int cache_size = pref.diskCacheSize(); + sessionSettings.cache_size = cache_size ? pref.diskCacheSize() * 64 : -1; qDebug() << "Using a disk cache size of" << pref.diskCacheSize() << "MiB"; // Disable OS cache to avoid memory problems (uTorrent behavior) #ifdef Q_WS_WIN