Browse Source

- FEATURE: Allow to customize folder scan interval

adaptive-webui-19844
Christophe Dumez 17 years ago
parent
commit
fc931d8c88
  1. 1
      Changelog
  2. 2
      src/GUI.cpp
  3. 13
      src/bittorrent.cpp
  4. 2
      src/bittorrent.h
  5. 65
      src/options.ui
  6. 13
      src/options_imp.cpp
  7. 1
      src/options_imp.h

1
Changelog

@ -11,6 +11,7 @@ @@ -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%)

2
src/GUI.cpp

@ -849,6 +849,8 @@ void GUI::configureSession(bool deleteOptions) { @@ -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

13
src/bittorrent.cpp

@ -42,7 +42,7 @@ @@ -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) { @@ -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);
}
}

2
src/bittorrent.h

@ -69,6 +69,7 @@ class bittorrent : public QObject{ @@ -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{ @@ -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();

65
src/options.ui

@ -54,7 +54,7 @@ @@ -54,7 +54,7 @@
</widget>
</item>
<item>
<widget class="QTabWidget" name="tabOptions" >
<widget class="QTabWidget" name="tabOption" >
<property name="tabPosition" >
<enum>QTabWidget::North</enum>
</property>
@ -344,7 +344,7 @@ @@ -344,7 +344,7 @@
<iconset resource="icons.qrc" >
<normaloff>:/Icons/download.png</normaloff>:/Icons/download.png</iconset>
</attribute>
<layout class="QVBoxLayout" >
<layout class="QVBoxLayout" name="verticalLayout_4" >
<item>
<widget class="QGroupBox" name="fileSystemBox" >
<property name="sizePolicy" >
@ -419,7 +419,9 @@ @@ -419,7 +419,9 @@
<property name="title" >
<string>When adding a torrent</string>
</property>
<layout class="QVBoxLayout" >
<layout class="QVBoxLayout" name="verticalLayout_3" >
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3" >
<item>
<widget class="QCheckBox" name="checkAdditionDialog" >
<property name="text" >
@ -430,6 +432,19 @@ @@ -430,6 +432,19 @@
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="checkStartPaused" >
<property name="text" >
@ -438,6 +453,8 @@ @@ -438,6 +453,8 @@
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
@ -451,7 +468,7 @@ @@ -451,7 +468,7 @@
<property name="title" >
<string comment="qBittorrent will watch a directory and automatically download torrents present in it" >Folder watching</string>
</property>
<layout class="QVBoxLayout" >
<layout class="QVBoxLayout" name="verticalLayout_2" >
<item>
<widget class="QCheckBox" name="checkScanDir" >
<property name="text" >
@ -459,14 +476,6 @@ @@ -459,14 +476,6 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="spacing" >
<number>6</number>
</property>
<property name="margin" >
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" >
<property name="spacing" >
@ -494,6 +503,35 @@ @@ -494,6 +503,35 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2" >
<item>
<widget class="QLabel" name="FolderScanLbl" >
<property name="text" >
<string>Folder scan interval:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="FolderScanSpin" >
<property name="minimum" >
<number>1</number>
</property>
<property name="maximum" >
<number>9999</number>
</property>
<property name="value" >
<number>5</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="FolderScanLbl2" >
<property name="text" >
<string>seconds</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
@ -1913,7 +1951,7 @@ @@ -1913,7 +1951,7 @@
</layout>
</widget>
<tabstops>
<tabstop>tabOptions</tabstop>
<tabstop>tabOption</tabstop>
<tabstop>comboI18n</tabstop>
<tabstop>comboStyle</tabstop>
<tabstop>checkConfirmExit</tabstop>
@ -1930,7 +1968,6 @@ @@ -1930,7 +1968,6 @@
<tabstop>checkAdditionDialog</tabstop>
<tabstop>checkStartPaused</tabstop>
<tabstop>checkScanDir</tabstop>
<tabstop>textScanDir</tabstop>
<tabstop>browseScanDirButton</tabstop>
<tabstop>actionTorrentDlOnDblClBox</tabstop>
<tabstop>actionTorrentFnOnDblClBox</tabstop>

13
src/options_imp.cpp

@ -164,6 +164,7 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){ @@ -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(){ @@ -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(){ @@ -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){ @@ -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{ @@ -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();

1
src/options_imp.h

@ -73,6 +73,7 @@ class options_imp : public QDialog, private Ui::Dialog { @@ -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

Loading…
Cancel
Save