mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-09 00:52:30 -06:00
Add setting to copy .torrent files for finished downloads (closes issue #22)
Patch edited by Christophe Dumez.
This commit is contained in:
60
src/preferences/options.ui
Normal file → Executable file
60
src/preferences/options.ui
Normal file → Executable file
@@ -508,9 +508,9 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<y>-373</y>
|
||||
<width>486</width>
|
||||
<height>952</height>
|
||||
<height>1025</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
@@ -561,9 +561,6 @@
|
||||
<string>Hard Disk</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_25">
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
@@ -818,6 +815,55 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="checkExportDirFin">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Copy .torrent files for finished downloads to:</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_13">
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLineEdit" name="textExportDirFin"/>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QToolButton" name="browseExportDirFinButton">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>22</width>
|
||||
<height>22</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>25</width>
|
||||
<height>27</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -969,7 +1015,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>486</width>
|
||||
<width>474</width>
|
||||
<height>577</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -1413,7 +1459,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>486</width>
|
||||
<width>395</width>
|
||||
<height>480</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
||||
61
src/preferences/options_imp.cpp
Normal file → Executable file
61
src/preferences/options_imp.cpp
Normal file → Executable file
@@ -161,7 +161,9 @@ options_imp::options_imp(QWidget *parent):
|
||||
connect(checkAdditionDialog, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
|
||||
connect(checkStartPaused, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
|
||||
connect(checkExportDir, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
|
||||
connect(checkExportDirFin, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
|
||||
connect(textExportDir, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton()));
|
||||
connect(textExportDirFin, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton()));
|
||||
connect(actionTorrentDlOnDblClBox, SIGNAL(currentIndexChanged(int)), this, SLOT(enableApplyButton()));
|
||||
connect(actionTorrentFnOnDblClBox, SIGNAL(currentIndexChanged(int)), this, SLOT(enableApplyButton()));
|
||||
connect(checkTempFolder, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
|
||||
@@ -395,11 +397,14 @@ void options_imp::saveOptions() {
|
||||
pref.addTorrentsInPause(addTorrentsInPause());
|
||||
ScanFoldersModel::instance()->makePersistent();
|
||||
addedScanDirs.clear();
|
||||
QString export_dir = getExportDir();
|
||||
QString export_dir = getTorrentExportDir();
|
||||
QString export_dir_fin = getFinishedTorrentExportDir();
|
||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
||||
export_dir_fin.replace("\\", "/");
|
||||
export_dir.replace("\\", "/");
|
||||
#endif
|
||||
pref.setExportDir(export_dir);
|
||||
pref.setTorrentExportDir(export_dir);
|
||||
pref.setFinishedTorrentExportDir(export_dir_fin);
|
||||
pref.setMailNotificationEnabled(groupMailNotification->isChecked());
|
||||
pref.setMailNotificationEmail(dest_email_txt->text());
|
||||
pref.setMailNotificationSMTP(smtp_server_txt->text());
|
||||
@@ -569,7 +574,7 @@ void options_imp::loadOptions() {
|
||||
checkAdditionDialog->setChecked(pref.useAdditionDialog());
|
||||
checkStartPaused->setChecked(pref.addTorrentsInPause());
|
||||
|
||||
strValue = pref.getExportDir();
|
||||
strValue = pref.getTorrentExportDir();
|
||||
if (strValue.isEmpty()) {
|
||||
// Disable
|
||||
checkExportDir->setChecked(false);
|
||||
@@ -581,6 +586,19 @@ void options_imp::loadOptions() {
|
||||
#endif
|
||||
textExportDir->setText(strValue);
|
||||
}
|
||||
|
||||
strValue = pref.getFinishedTorrentExportDir();
|
||||
if (strValue.isEmpty()) {
|
||||
// Disable
|
||||
checkExportDirFin->setChecked(false);
|
||||
} else {
|
||||
// enable
|
||||
checkExportDirFin->setChecked(true);
|
||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
||||
strValue.replace("/", "\\");
|
||||
#endif
|
||||
textExportDirFin->setText(strValue);
|
||||
}
|
||||
groupMailNotification->setChecked(pref.isMailNotificationEnabled());
|
||||
dest_email_txt->setText(pref.getMailNotificationEmail());
|
||||
smtp_server_txt->setText(pref.getMailNotificationSMTP());
|
||||
@@ -1016,12 +1034,18 @@ void options_imp::setLocale(const QString &localeStr) {
|
||||
comboI18n->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
QString options_imp::getExportDir() const {
|
||||
QString options_imp::getTorrentExportDir() const {
|
||||
if (checkExportDir->isChecked())
|
||||
return fsutils::expandPath(textExportDir->text());
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString options_imp::getFinishedTorrentExportDir() const {
|
||||
if (checkExportDirFin->isChecked())
|
||||
return fsutils::expandPath(textExportDirFin->text());
|
||||
return QString();
|
||||
}
|
||||
|
||||
// Return action on double-click on a downloading torrent set in options
|
||||
int options_imp::getActionOnDblClOnTorrentDl() const {
|
||||
if (actionTorrentDlOnDblClBox->currentIndex() < 1)
|
||||
@@ -1075,21 +1099,28 @@ void options_imp::handleScanFolderViewSelectionChanged() {
|
||||
removeScanFolderButton->setEnabled(!scanFoldersView->selectionModel()->selectedIndexes().isEmpty());
|
||||
}
|
||||
|
||||
void options_imp::on_browseExportDirButton_clicked() {
|
||||
const QString export_path = fsutils::expandPath(textExportDir->text());
|
||||
QDir exportDir(export_path);
|
||||
QString options_imp::askForExportDir(const QString& currentExportPath)
|
||||
{
|
||||
QDir currentExportDir(fsutils::expandPath(currentExportPath));
|
||||
QString dir;
|
||||
if (!export_path.isEmpty() && exportDir.exists()) {
|
||||
dir = QFileDialog::getExistingDirectory(this, tr("Choose export directory"), exportDir.absolutePath());
|
||||
if (!currentExportPath.isEmpty() && currentExportDir.exists()) {
|
||||
dir = QFileDialog::getExistingDirectory(this, tr("Choose export directory"), currentExportDir.absolutePath());
|
||||
} else {
|
||||
dir = QFileDialog::getExistingDirectory(this, tr("Choose export directory"), QDir::homePath());
|
||||
}
|
||||
if (!dir.isNull()) {
|
||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
||||
dir.replace("/", "\\");
|
||||
#endif
|
||||
textExportDir->setText(dir);
|
||||
}
|
||||
return dir;
|
||||
}
|
||||
|
||||
void options_imp::on_browseExportDirButton_clicked() {
|
||||
const QString newExportDir = askForExportDir(textExportDir->text());
|
||||
if (!newExportDir.isNull())
|
||||
textExportDir->setText(fsutils::toDisplayPath(newExportDir));
|
||||
}
|
||||
|
||||
void options_imp::on_browseExportDirFinButton_clicked() {
|
||||
const QString newExportDir = askForExportDir(textExportDirFin->text());
|
||||
if (!newExportDir.isNull())
|
||||
textExportDirFin->setText(fsutils::toDisplayPath(newExportDir));
|
||||
}
|
||||
|
||||
void options_imp::on_browseFilterButton_clicked() {
|
||||
|
||||
5
src/preferences/options_imp.h
Normal file → Executable file
5
src/preferences/options_imp.h
Normal file → Executable file
@@ -74,6 +74,7 @@ private slots:
|
||||
void on_IpFilterRefreshBtn_clicked();
|
||||
void handleIPFilterParsed(bool error, int ruleCount);
|
||||
void on_browseExportDirButton_clicked();
|
||||
void on_browseExportDirFinButton_clicked();
|
||||
void on_browseFilterButton_clicked();
|
||||
void on_browseSaveDirButton_clicked();
|
||||
void on_browseTempDirButton_clicked();
|
||||
@@ -107,7 +108,9 @@ private:
|
||||
bool preAllocateAllFiles() const;
|
||||
bool useAdditionDialog() const;
|
||||
bool addTorrentsInPause() const;
|
||||
QString getExportDir() const;
|
||||
QString getTorrentExportDir() const;
|
||||
QString getFinishedTorrentExportDir() const;
|
||||
QString askForExportDir(const QString& currentExportPath);
|
||||
int getActionOnDblClOnTorrentDl() const;
|
||||
int getActionOnDblClOnTorrentFn() const;
|
||||
// Connection options
|
||||
|
||||
25
src/preferences/preferences.h
Normal file → Executable file
25
src/preferences/preferences.h
Normal file → Executable file
@@ -276,18 +276,33 @@ public:
|
||||
}
|
||||
|
||||
bool isTorrentExportEnabled() const {
|
||||
return !value(QString::fromUtf8("Preferences/Downloads/TorrentExport"), QString()).toString().isEmpty();
|
||||
return !value(QString::fromUtf8("Preferences/Downloads/TorrentExportDir"), QString()).toString().isEmpty();
|
||||
}
|
||||
|
||||
QString getExportDir() const {
|
||||
return value(QString::fromUtf8("Preferences/Downloads/TorrentExport"), QString()).toString();
|
||||
QString getTorrentExportDir() const {
|
||||
return value(QString::fromUtf8("Preferences/Downloads/TorrentExportDir"), QString()).toString();
|
||||
}
|
||||
|
||||
void setExportDir(QString path) {
|
||||
void setTorrentExportDir(QString path) {
|
||||
path = path.trimmed();
|
||||
if (path.isEmpty())
|
||||
path = QString();
|
||||
setValue(QString::fromUtf8("Preferences/Downloads/TorrentExport"), path);
|
||||
setValue(QString::fromUtf8("Preferences/Downloads/TorrentExportDir"), path);
|
||||
}
|
||||
|
||||
bool isFinishedTorrentExportEnabled() const {
|
||||
return !value(QString::fromUtf8("Preferences/Downloads/FinishedTorrentExportDir"), QString()).toString().isEmpty();
|
||||
}
|
||||
|
||||
QString getFinishedTorrentExportDir() const {
|
||||
return value(QString::fromUtf8("Preferences/Downloads/FinishedTorrentExportDir"), QString()).toString();
|
||||
}
|
||||
|
||||
void setFinishedTorrentExportDir(QString path) {
|
||||
path = path.trimmed();
|
||||
if (path.isEmpty())
|
||||
path = QString();
|
||||
setValue(QString::fromUtf8("Preferences/Downloads/FinishedTorrentExportDir"), path);
|
||||
}
|
||||
|
||||
bool isMailNotificationEnabled() const {
|
||||
|
||||
Reference in New Issue
Block a user