diff --git a/Changelog b/Changelog index 86aee3cd2..a291d542f 100644 --- a/Changelog +++ b/Changelog @@ -11,6 +11,7 @@ - FEATURE: Improved eMule DAT ip filter parser - FEATURE: Added support for PeerGuardian p2p filters (text) - FEATURE: Added support for PeerGuardian p2b filters (binary) + - FEATURE: Allow to customize folder scan interval - BUGFIX: Do not display seeds number in seeding list (always 0) - BUGFIX: Threadified IP filter file parser to avoid GUI freeze - COSMETIC: Do not display progress bar in seeding list (always 100%) diff --git a/src/GUI.cpp b/src/GUI.cpp index d71bf5553..c4367d6ad 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -849,6 +849,8 @@ void GUI::configureSession(bool deleteOptions) { if(options->getScanDir().isNull()) { BTSession->disableDirectoryScanning(); }else{ + //Interval first + BTSession->setTimerScanInterval(options->getFolderScanInterval()); BTSession->enableDirectoryScanning(options->getScanDir()); } // Connection diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index 9814d9ceb..de4960956 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -42,7 +42,7 @@ #define MAX_TRACKER_ERRORS 2 // Main constructor -bittorrent::bittorrent() : timerScan(0), DHTEnabled(false), preAllocateAll(false), addInPause(false), maxConnecsPerTorrent(500), maxUploadsPerTorrent(4), max_ratio(-1), UPnPEnabled(false), NATPMPEnabled(false), LSDEnabled(false) { +bittorrent::bittorrent() : timerScan(0), DHTEnabled(false), preAllocateAll(false), addInPause(false), maxConnecsPerTorrent(500), maxUploadsPerTorrent(4), max_ratio(-1), UPnPEnabled(false), NATPMPEnabled(false), LSDEnabled(false), folderScanInterval(5) { // To avoid some exceptions fs::path::default_name_check(fs::no_check); // Creating bittorrent session @@ -977,13 +977,22 @@ void bittorrent::setDefaultSavePath(QString savepath) { defaultSavePath = savepath; } +void bittorrent::setTimerScanInterval(int secs) { + if(folderScanInterval != secs) { + folderScanInterval = secs; + if(!scan_dir.isNull()) { + timerScan->start(folderScanInterval*1000); + } + } +} + // Enable directory scanning void bittorrent::enableDirectoryScanning(QString _scan_dir) { if(!_scan_dir.isEmpty()) { scan_dir = _scan_dir; timerScan = new QTimer(this); connect(timerScan, SIGNAL(timeout()), this, SLOT(scanDirectory())); - timerScan->start(5000); + timerScan->start(folderScanInterval*1000); } } diff --git a/src/bittorrent.h b/src/bittorrent.h index e3a7830c8..64da67efe 100644 --- a/src/bittorrent.h +++ b/src/bittorrent.h @@ -69,6 +69,7 @@ class bittorrent : public QObject{ bool LSDEnabled; FilterParserThread *filterParser; QString filterPath; + int folderScanInterval; // in seconds protected: QString getSavePath(QString hash); @@ -145,6 +146,7 @@ class bittorrent : public QObject{ void enableLSD(bool b); bool enableDHT(bool b); void reloadTorrent(const QTorrentHandle &h, bool full_alloc); + void setTimerScanInterval(int secs); protected slots: void scanDirectory(); diff --git a/src/options.ui b/src/options.ui index c8ce7fafd..e7bc085f9 100644 --- a/src/options.ui +++ b/src/options.ui @@ -54,7 +54,7 @@ - + QTabWidget::North @@ -344,7 +344,7 @@ :/Icons/download.png:/Icons/download.png - + @@ -419,23 +419,40 @@ When adding a torrent - + - - - Display torrent content and some options - - - true - - - - - - - Do not start download automatically - - + + + + + Display torrent content and some options + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Do not start download automatically + + + + @@ -451,7 +468,7 @@ Folder watching - + @@ -468,31 +485,52 @@ 0 - - - 6 + + + false - - 0 + + + + + + false - - - - false - - - - - - - false - - - ... - - - - + + ... + + + + + + + + + + + Folder scan interval: + + + + + + + 1 + + + 9999 + + + 5 + + + + + + + seconds + + @@ -1913,7 +1951,7 @@ - tabOptions + tabOption comboI18n comboStyle checkConfirmExit @@ -1930,7 +1968,6 @@ checkAdditionDialog checkStartPaused checkScanDir - textScanDir browseScanDirButton actionTorrentDlOnDblClBox actionTorrentFnOnDblClBox diff --git a/src/options_imp.cpp b/src/options_imp.cpp index 85d943052..343b00d4b 100644 --- a/src/options_imp.cpp +++ b/src/options_imp.cpp @@ -164,6 +164,7 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){ connect(checkStartPaused, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton())); connect(checkScanDir, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton())); connect(textScanDir, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton())); + connect(FolderScanSpin, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton())); // Connection tab connect(spinPortMin, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton())); connect(spinPortMax, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton())); @@ -279,6 +280,7 @@ void options_imp::saveOptions(){ settings.setValue(QString::fromUtf8("AdditionDialog"), useAdditionDialog()); settings.setValue(QString::fromUtf8("StartInPause"), addTorrentsInPause()); settings.setValue(QString::fromUtf8("ScanDir"), getScanDir()); + settings.setValue(QString::fromUtf8("ScanDirInterval"), getFolderScanInterval()); settings.setValue(QString::fromUtf8("DblClOnTorDl"), getActionOnDblClOnTorrentDl()); settings.setValue(QString::fromUtf8("DblClOnTorFn"), getActionOnDblClOnTorrentFn()); // End Downloads preferences @@ -448,6 +450,7 @@ void options_imp::loadOptions(){ // enable checkScanDir->setChecked(true); textScanDir->setText(strValue); + FolderScanSpin->setValue(settings.value(QString::fromUtf8("ScanDirInterval"), 5).toInt()); enableDirScan(2); } actionTorrentDlOnDblClBox->setCurrentIndex(settings.value(QString::fromUtf8("DblClOnTorDl"), 0).toInt()); @@ -931,10 +934,16 @@ void options_imp::enableDirScan(int checkBoxValue){ //enable textScanDir->setEnabled(true); browseScanDirButton->setEnabled(true); + FolderScanSpin->setEnabled(true); + FolderScanLbl->setEnabled(true); + FolderScanLbl2->setEnabled(true); }else{ //disable textScanDir->setEnabled(false); browseScanDirButton->setEnabled(false); + FolderScanSpin->setEnabled(false); + FolderScanLbl->setEnabled(false); + FolderScanLbl2->setEnabled(false); } } @@ -969,6 +978,10 @@ unsigned short options_imp::getProxyPort() const{ return spinProxyPort->value(); } +int options_imp::getFolderScanInterval() const { + return FolderScanSpin->value(); +} + QString options_imp::getProxyUsername() const{ QString username = textProxyUsername->text(); username = username.trimmed(); diff --git a/src/options_imp.h b/src/options_imp.h index 6a36283e8..9cc15c8d9 100644 --- a/src/options_imp.h +++ b/src/options_imp.h @@ -73,6 +73,7 @@ class options_imp : public QDialog, private Ui::Dialog { bool addTorrentsInPause() const; bool isDirScanEnabled() const; QString getScanDir() const; + int getFolderScanInterval() const; int getActionOnDblClOnTorrentDl() const; int getActionOnDblClOnTorrentFn() const; // Connection options