diff --git a/src/preferences/options.ui b/src/preferences/options.ui
old mode 100644
new mode 100755
index b9af2dfc9..7d934b5e9
--- a/src/preferences/options.ui
+++ b/src/preferences/options.ui
@@ -508,9 +508,9 @@
0
- 0
+ -373
486
- 952
+ 1025
@@ -561,9 +561,6 @@
Hard Disk
-
- 9
-
-
@@ -818,6 +815,55 @@
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Qt::StrongFocus
+
+
+ Copy .torrent files for finished downloads to:
+
+
+ true
+
+
+ false
+
+
+
+ 9
+
+
-
+
+
+ -
+
+
+
+ 22
+ 22
+
+
+
+
+ 25
+ 27
+
+
+
+ ...
+
+
+
+
+
+
@@ -969,7 +1015,7 @@
0
0
- 486
+ 474
577
@@ -1413,7 +1459,7 @@
0
0
- 486
+ 395
480
diff --git a/src/preferences/options_imp.cpp b/src/preferences/options_imp.cpp
old mode 100644
new mode 100755
index e53151122..07113a019
--- a/src/preferences/options_imp.cpp
+++ b/src/preferences/options_imp.cpp
@@ -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() {
diff --git a/src/preferences/options_imp.h b/src/preferences/options_imp.h
old mode 100644
new mode 100755
index 112bf1b97..3ee3dfbfb
--- a/src/preferences/options_imp.h
+++ b/src/preferences/options_imp.h
@@ -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
diff --git a/src/preferences/preferences.h b/src/preferences/preferences.h
old mode 100644
new mode 100755
index 4f6d0935f..4dc61e765
--- a/src/preferences/preferences.h
+++ b/src/preferences/preferences.h
@@ -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 {
diff --git a/src/qtlibtorrent/qbtsession.cpp b/src/qtlibtorrent/qbtsession.cpp
old mode 100644
new mode 100755
index b811e1f75..39dd76e76
--- a/src/qtlibtorrent/qbtsession.cpp
+++ b/src/qtlibtorrent/qbtsession.cpp
@@ -104,7 +104,8 @@ QBtSession::QBtSession()
preAllocateAll(false), global_ratio_limit(-1),
LSDEnabled(false),
DHTEnabled(false), current_dht_port(0), queueingEnabled(false),
- torrentExport(false)
+ m_torrentExportEnabled(false),
+ m_finishedTorrentExportEnabled(false)
#ifndef DISABLE_GUI
, geoipDBLoaded(false), resolve_countries(false)
#endif
@@ -301,15 +302,19 @@ void QBtSession::configureSession() {
setAppendLabelToSavePath(pref.appendTorrentLabel());
setAppendqBExtension(pref.useIncompleteFilesExtension());
preAllocateAllFiles(pref.preAllocateAllFiles());
- // * Export Dir
- const bool newTorrentExport = pref.isTorrentExportEnabled();
- if (torrentExport != newTorrentExport) {
- torrentExport = newTorrentExport;
- if (torrentExport) {
+ // * Torrent export directory
+ const bool torrentExportEnabled = pref.isTorrentExportEnabled();
+ if (m_torrentExportEnabled != torrentExportEnabled) {
+ m_torrentExportEnabled = torrentExportEnabled;
+ if (m_torrentExportEnabled) {
qDebug("Torrent export is enabled, exporting the current torrents");
- exportTorrentFiles(pref.getExportDir());
+ exportTorrentFiles(pref.getTorrentExportDir());
}
}
+ // * Finished Torrent export directory
+ const bool finishedTorrentExportEnabled = pref.isFinishedTorrentExportEnabled();
+ if (m_finishedTorrentExportEnabled != finishedTorrentExportEnabled)
+ m_finishedTorrentExportEnabled = finishedTorrentExportEnabled;
// Connection
// * Global download limit
const bool alternative_speeds = pref.isAltBandwidthEnabled();
@@ -884,7 +889,10 @@ void QBtSession::loadTorrentSettings(QTorrentHandle& h) {
#endif
}
-QTorrentHandle QBtSession::addMagnetUri(QString magnet_uri, bool resumed, bool fromScanDir, const QString &filePath) {
+QTorrentHandle QBtSession::addMagnetUri(QString magnet_uri, bool resumed, bool fromScanDir, const QString &filePath)
+{
+ Q_UNUSED(fromScanDir);
+ Q_UNUSED(filePath);
Preferences pref;
QTorrentHandle h;
const QString hash(misc::magnetUriToHash(magnet_uri));
@@ -1168,7 +1176,7 @@ QTorrentHandle QBtSession::addTorrent(QString path, bool fromScanDir, QString fr
if (path != newFile)
QFile::copy(path, newFile);
// Copy the torrent file to the export folder
- if (torrentExport)
+ if (m_torrentExportEnabled)
exportTorrentFile(h);
}
@@ -1199,10 +1207,11 @@ QTorrentHandle QBtSession::addTorrent(QString path, bool fromScanDir, QString fr
return h;
}
-void QBtSession::exportTorrentFile(const QTorrentHandle &h) {
- Q_ASSERT(torrentExport);
+void QBtSession::exportTorrentFile(const QTorrentHandle& h, TorrentExportFolder folder) {
+ Q_ASSERT((folder == RegularTorrentExportFolder && m_torrentExportEnabled) ||
+ (folder == FinishedTorrentExportFolder && m_finishedTorrentExportEnabled));
QString torrent_path = QDir(fsutils::BTBackupLocation()).absoluteFilePath(h.hash()+".torrent");
- QDir exportPath(Preferences().getExportDir());
+ QDir exportPath(folder == RegularTorrentExportFolder ? Preferences().getTorrentExportDir() : Preferences().getFinishedTorrentExportDir());
if (exportPath.exists() || exportPath.mkpath(exportPath.absolutePath())) {
QString new_torrent_path = exportPath.absoluteFilePath(h.name()+".torrent");
if (QFile::exists(new_torrent_path) && fsutils::sameFiles(torrent_path, new_torrent_path)) {
@@ -1210,7 +1219,6 @@ void QBtSession::exportTorrentFile(const QTorrentHandle &h) {
new_torrent_path = exportPath.absoluteFilePath(h.name()+"-"+h.hash()+".torrent");
}
QFile::copy(torrent_path, new_torrent_path);
- //h.save_torrent_file(torrent_path);
}
}
@@ -1364,7 +1372,7 @@ void QBtSession::mergeTorrents(QTorrentHandle &h_ex, boost::intrusive_ptr t);
- void exportTorrentFile(const QTorrentHandle &h);
+ void exportTorrentFile(const QTorrentHandle &h, TorrentExportFolder folder = RegularTorrentExportFolder);
void initWebUi();
void handleIPFilterParsed(int ruleCount);
void handleIPFilterError();
@@ -245,7 +250,8 @@ private:
bool PeXEnabled;
bool queueingEnabled;
bool appendLabelToSavePath;
- bool torrentExport;
+ bool m_torrentExportEnabled;
+ bool m_finishedTorrentExportEnabled;
bool appendqBExtension;
QString defaultSavePath;
QString defaultTempPath;
diff --git a/src/webui/prefjson.cpp b/src/webui/prefjson.cpp
index b7280573c..30317dbda 100644
--- a/src/webui/prefjson.cpp
+++ b/src/webui/prefjson.cpp
@@ -63,7 +63,7 @@ QString prefjson::getPreferences()
}
data.add("download_in_scan_dirs", var_list);
data.add("export_dir_enabled", pref.isTorrentExportEnabled());
- data.add("export_dir", pref.getExportDir());
+ data.add("export_dir", pref.getTorrentExportDir());
data.add("mail_notification_enabled", pref.isMailNotificationEnabled());
data.add("mail_notification_email", pref.getMailNotificationEmail());
data.add("mail_notification_smtp", pref.getMailNotificationSMTP());
@@ -198,7 +198,7 @@ void prefjson::setPreferences(const QString& json)
}
}
if (m.contains("export_dir"))
- pref.setExportDir(m["export_dir"].toString());
+ pref.setTorrentExportDir(m["export_dir"].toString());
if (m.contains("mail_notification_enabled"))
pref.setMailNotificationEnabled(m["mail_notification_enabled"].toBool());
if (m.contains("mail_notification_email"))