Browse Source

Merge pull request #254 from sledgehammer999/fix_default_path

Fix behaviour of the torrent addition dialog. The 'set as default path' ...
adaptive-webui-19844
Christophe Dumez 12 years ago
parent
commit
177e6738e4
  1. 6
      src/addnewtorrentdialog.cpp
  2. 18
      src/qtlibtorrent/qbtsession.cpp
  3. 3
      src/qtlibtorrent/qbtsession.h

6
src/addnewtorrentdialog.cpp

@ -65,7 +65,7 @@ AddNewTorrentDialog::AddNewTorrentDialog(QWidget *parent) :
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent")); QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
Preferences pref; Preferences pref;
ui->start_torrent_cb->setChecked(!pref.addTorrentsInPause()); ui->start_torrent_cb->setChecked(!pref.addTorrentsInPause());
ui->save_path_combo->addItem(fsutils::toDisplayPath(pref.getSavePath())); ui->save_path_combo->addItem(fsutils::toDisplayPath(pref.getSavePath()), pref.getSavePath());
loadSavePathHistory(); loadSavePathHistory();
ui->save_path_combo->insertSeparator(ui->save_path_combo->count()); ui->save_path_combo->insertSeparator(ui->save_path_combo->count());
ui->save_path_combo->addItem(tr("Other...", "Other save path...")); ui->save_path_combo->addItem(tr("Other...", "Other save path..."));
@ -594,6 +594,8 @@ void AddNewTorrentDialog::on_buttonBox_accepted()
saveSavePathHistory(); saveSavePathHistory();
// Save settings // Save settings
pref.useAdditionDialog(!ui->never_show_cb->isChecked()); pref.useAdditionDialog(!ui->never_show_cb->isChecked());
if (ui->default_save_path_cb->isChecked()) if (ui->default_save_path_cb->isChecked()) {
pref.setSavePath(ui->save_path_combo->itemData(ui->save_path_combo->currentIndex()).toString()); pref.setSavePath(ui->save_path_combo->itemData(ui->save_path_combo->currentIndex()).toString());
QBtSession::instance()->setDefaultSavePath(pref.getSavePath());
}
} }

18
src/qtlibtorrent/qbtsession.cpp

@ -1773,9 +1773,17 @@ void QBtSession::addTorrentsFromScanFolder(QStringList &pathList) {
} }
} }
void QBtSession::setDefaultTempPath(QString temppath) { void QBtSession::setDefaultSavePath(const QString &savepath) {
if (defaultTempPath == temppath) if (savepath.isEmpty())
return; return;
defaultSavePath = QDir::fromNativeSeparators(savepath);
}
void QBtSession::setDefaultTempPath(const QString &temppath) {
if (QDir(defaultTempPath) == QDir(temppath))
return;
if (temppath.isEmpty()) { if (temppath.isEmpty()) {
// Disabling temp dir // Disabling temp dir
// Moving all torrents to their destination folder // Moving all torrents to their destination folder
@ -1799,13 +1807,13 @@ void QBtSession::setDefaultTempPath(QString temppath) {
QTorrentHandle h = QTorrentHandle(*torrentIT); QTorrentHandle h = QTorrentHandle(*torrentIT);
if (!h.is_valid()) continue; if (!h.is_valid()) continue;
if (!h.is_seed()) { if (!h.is_seed()) {
QString torrent_tmp_path = temppath.replace("\\", "/"); QString torrent_tmp_path = QDir::fromNativeSeparators(temppath);
qDebug("Moving torrent to its temp save path: %s", qPrintable(torrent_tmp_path)); qDebug("Moving torrent to its temp save path: %s", qPrintable(fsutils::toDisplayPath(torrent_tmp_path)));
h.move_storage(torrent_tmp_path); h.move_storage(torrent_tmp_path);
} }
} }
} }
defaultTempPath = temppath; defaultTempPath = QDir::fromNativeSeparators(temppath);
} }
void QBtSession::appendqBextensionToTorrent(const QTorrentHandle &h, bool append) { void QBtSession::appendqBextensionToTorrent(const QTorrentHandle &h, bool append) {

3
src/qtlibtorrent/qbtsession.h

@ -147,7 +147,8 @@ public slots:
void setDHTPort(int dht_port); void setDHTPort(int dht_port);
void setProxySettings(libtorrent::proxy_settings proxySettings); void setProxySettings(libtorrent::proxy_settings proxySettings);
void setSessionSettings(const libtorrent::session_settings &sessionSettings); void setSessionSettings(const libtorrent::session_settings &sessionSettings);
void setDefaultTempPath(QString temppath); void setDefaultSavePath(const QString &savepath);
void setDefaultTempPath(const QString &temppath);
void setAppendLabelToSavePath(bool append); void setAppendLabelToSavePath(bool append);
void appendLabelToTorrentSavePath(const QTorrentHandle &h); void appendLabelToTorrentSavePath(const QTorrentHandle &h);
void changeLabelInTorrentSavePath(const QTorrentHandle &h, QString old_label, QString new_label); void changeLabelInTorrentSavePath(const QTorrentHandle &h, QString old_label, QString new_label);

Loading…
Cancel
Save